Added license information
[emufront] / src / dialogs / dbobjectdialog.h
1 // EmuFront
2 // Copyright Mikko Keinänen 2010
3 //
4 // This file is part of EmuFront.
5 //
6 //
7 // EmuFront is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Foobar is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
19
20 #ifndef DBOBJECTDIALOG_H
21 #define DBOBJECTDIALOG_H
22
23 #include "emufrontdialog.h"
24 #include "namedialog.h"
25 #include "../db/databasemanager.h"
26 #include "../dataobjects/emufrontobject.h"
27
28 class QPushButton;
29 class QModelIndex;
30 class QDialogButtonBox;
31 class QTableView;
32
33 class DbObjectDialog : public EmuFrontDialog
34 {
35     Q_OBJECT
36
37     public:
38     DbObjectDialog(QWidget *parent = 0);
39     ~DbObjectDialog();
40
41     protected slots:
42         void editButtonClicked();
43         void addButtonClicked();
44         void deleteButtonClicked();
45         //void enableEditButton();
46         //void enableDeleteButton();
47         void listObjectClicked(const QModelIndex &);
48     virtual void updateData();
49     void updateList() const;
50
51     protected:
52         virtual int deleteObject() =0;
53         virtual void addObject() =0;
54         virtual void editObject() =0;
55     virtual bool deleteItem() = 0;
56     NameDialog *nameDialog;
57     DatabaseManager *dbManager;
58     QTableView *objectList;
59     EmuFrontObject *dbObject;
60     void connectSignals();
61     void activateNameDialog() const;
62     virtual void updateDb(const EmuFrontObject*) const = 0;
63     virtual void insertDb(const EmuFrontObject*) const = 0;
64     //virtual QSqlTableModel* getDataObjects() = 0;
65
66     private:
67         QDialogButtonBox *buttonBox;
68         QPushButton *editButton;
69     QPushButton *addButton;
70         QPushButton *deleteButton;
71
72         void setButtonsEnabled(bool);
73     void layout();
74     void disableSelection();
75 };
76
77 #endif