Added new button for scanning file (media image) paths.
[emufront] / src / dialogs / dbobjectdialog.h
1 // EmuFront
2 // Copyright 2010 Mikko Keinänen
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 "dataobjecteditdialog.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 private slots:
42         void editButtonClicked();
43         void addButtonClicked();
44         void deleteButtonClicked();
45         void listObjectClicked(const QModelIndex &);
46     void updateData();
47     void updateReject();
48     void updateList() const;
49
50 protected:
51     // implementation specific, deletes current data object from memory
52     virtual void deleteCurrentObject();
53     virtual EmuFrontObject* createObject() = 0;
54     void initDataTable();
55     virtual void connectSignals();
56     DataObjectEditDialog *nameDialog;
57     EmuFrontObject *dbObject;
58     DatabaseManager *dbManager;
59     QDialogButtonBox *buttonBox;
60
61 private:
62     bool deleteItem();
63     void addObject();
64     void insertDb(const EmuFrontObject*) const;
65     void updateDb(const EmuFrontObject*) const;
66     void editObject();
67     void activateNameDialog();
68     bool confirmDelete(QString name, int numRefs);
69     QTableView *objectList;
70         void setButtonsEnabled(bool);
71     void layout();
72     void disableSelection();
73     QPushButton *editButton;
74     QPushButton *addButton;
75     QPushButton *deleteButton;
76 };
77
78 #endif