aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.h
blob: 0ecc318ca8b732e5fcc4ee923d6757cab257dcba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef POPULATEDIALOG_H
#define POPULATEDIALOG_H

#include "guiSQLiteStudio_global.h"
#include <QDialog>

namespace Ui {
    class PopulateDialog;
}

class PopulatePlugin;
class PopulateEngine;
class QGridLayout;
class DbListModel;
class DbObjListModel;
class Db;
class QComboBox;
class QCheckBox;
class QToolButton;
class QSignalMapper;
class WidgetCover;

class GUI_API_EXPORT PopulateDialog : public QDialog
{
        Q_OBJECT

    public:
        explicit PopulateDialog(QWidget *parent = 0);
        ~PopulateDialog();
        void setDbAndTable(Db* db, const QString& table);

    private:
        struct GUI_API_EXPORT ColumnEntry
        {
            ColumnEntry(QCheckBox* check, QComboBox* combo, QToolButton* button);
            ~ColumnEntry();

            QCheckBox* check = nullptr;
            QComboBox* combo = nullptr;
            QToolButton* button = nullptr;
            PopulateEngine* engine = nullptr;
        };

        void init();
        PopulateEngine* getEngine(int selectedPluginIndex);
        void deleteEngines(const QList<PopulateEngine*>& engines);
        void rebuildEngines();

        Ui::PopulateDialog *ui = nullptr;
        QGridLayout* columnsGrid = nullptr;
        DbListModel* dbListModel = nullptr;
        DbObjListModel* tablesModel = nullptr;
        Db* db = nullptr;
        QStringList pluginTitles;
        QList<PopulatePlugin*> plugins;
        QList<ColumnEntry> columnEntries;
        QSignalMapper* checkMapper = nullptr;
        QSignalMapper* buttonMapper = nullptr;
        QHash<int,bool> columnsValid;
        WidgetCover* widgetCover = nullptr;

    private slots:
        void refreshTables();
        void refreshColumns();
        void pluginSelected(int index);
        void pluginSelected(QComboBox* combo, int index);
        void configurePlugin(int index);
        void updateColumnState(int index, bool updateGlobalState = true);
        void updateState();
        void finished();

    public:
        void accept();
};

#endif // POPULATEDIALOG_H