1 /**
2  * \file subframeseditor.h
3  * Editor for subframes contained in a frame.
4  *
5  * \b Project: Kid3
6  * \author Urs Fleisch
7  * \date 18 Sep 2015
8  *
9  * Copyright (C) 2015-2018  Urs Fleisch
10  *
11  * This file is part of Kid3.
12  *
13  * Kid3 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * Kid3 is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 #pragma once
28 
29 #include <QWidget>
30 #include "frame.h"
31 
32 class QPushButton;
33 class FrameTableModel;
34 class FrameTable;
35 class EditFrameFieldsDialog;
36 class IPlatformTools;
37 class Kid3Application;
38 class TaggedFile;
39 
40 /**
41  * Editor for subframes contained in a frame.
42  */
43 class SubframesEditor : public QWidget {
44   Q_OBJECT
45 public:
46   /**
47    * Constructor.
48    *
49    * @param platformTools platform tools
50    * @param app application context
51    * @param taggedFile tagged file
52    * @param tagNr tag number
53    * @param parent parent widget
54    */
55   explicit SubframesEditor(IPlatformTools* platformTools, Kid3Application* app,
56                            const TaggedFile* taggedFile, Frame::TagNumber tagNr,
57                            QWidget* parent = nullptr);
58 
59   /**
60    * Destructor.
61    */
62   virtual ~SubframesEditor() override = default;
63 
64   /**
65    * Set subframes.
66    * @param frames subframes, will be cleared
67    */
68   void setFrames(FrameCollection& frames);
69 
70   /**
71    * Get subframes.
72    * @param frames the subframes are returned here
73    */
74   void getFrames(FrameCollection& frames) const;
75 
76 private slots:
77   void onEditFrameDialogFinished(int result);
78   void onEditClicked();
79   void onAddClicked();
80   void onDeleteClicked();
81 
82 private:
83   void editFrame(const Frame& frame, int row);
84 
85   IPlatformTools* m_platformTools;
86   Kid3Application* m_app;
87   const TaggedFile* m_taggedFile;
88   Frame::TagNumber m_tagNr;
89   FrameTableModel* m_frameTableModel;
90   FrameTable* m_frameTable;
91   QPushButton* m_editButton;
92   QPushButton* m_addButton;
93   QPushButton* m_deleteButton;
94   EditFrameFieldsDialog* m_editFrameDialog;
95   Frame m_editFrame;
96   int m_editFrameRow;
97 };
98