File: constraintdialog.h

package info (click to toggle)
sqlitestudio 3.4.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 54,880 kB
  • sloc: ansic: 406,208; cpp: 123,872; yacc: 2,692; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (80 lines) | stat: -rw-r--r-- 2,037 bytes parent folder | download
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
77
78
79
80
#ifndef CONSTRAINTDIALOG_H
#define CONSTRAINTDIALOG_H

#include "parser/ast/sqlitecreatetable.h"
#include "db/db.h"
#include "guiSQLiteStudio_global.h"
#include <QDialog>
#include <QPointer>

namespace Ui {
    class ConstraintDialog;
}

class ConstraintPanel;

class GUI_API_EXPORT ConstraintDialog : public QDialog
{
        Q_OBJECT

    public:
        enum Mode
        {
            NEW,
            EDIT
        };

        enum Constraint
        {
            PK,
            FK,
            UNIQUE,
            NOTNULL,
            CHECK,
            COLLATE,
            GENERATED,
            DEFAULT,
            UNKNOWN
        };

        enum Type
        {
            TABLE,
            COLUMN
        };

        explicit ConstraintDialog(Mode mode, SqliteCreateTable::Constraint* constraint, SqliteCreateTable* createTable, Db* db,
                                  QWidget *parent = 0);
        explicit ConstraintDialog(Mode mode, SqliteCreateTable::Column::Constraint* constraint, SqliteCreateTable::Column* column, Db* db,
                                  QWidget *parent = 0);
        ~ConstraintDialog();

        SqliteStatement* getConstraint();

    protected:
        void changeEvent(QEvent *e);

    private:
        void init();
        Constraint getSelectedConstraint();
        Constraint getSelectedConstraint(SqliteCreateTable::Constraint* constraint);
        Constraint getSelectedConstraint(SqliteCreateTable::Column::Constraint* constraint);
        ConstraintPanel* createConstraintPanel();
        void updateDefinitionHeader();

        Ui::ConstraintDialog *ui = nullptr;
        Type type;
        Mode mode;
        Db* db = nullptr;
        SqliteStatement* constrStatement = nullptr;
        QPointer<SqliteCreateTable> createTable;
        QPointer<SqliteCreateTable::Column> columnStmt;
        QHash<int,QWidget> panels;
        ConstraintPanel* currentPanel = nullptr;

    private slots:
        void validate();
        void storeConfiguration();
};

#endif // CONSTRAINTDIALOG_H