Rev 158 | Rev 174 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 158 | Rev 159 | ||
---|---|---|---|
1 | #ifndef MAINWINDOW_H
|
1 | #ifndef MAINWINDOW_H
|
2 | #define MAINWINDOW_H
|
2 | #define MAINWINDOW_H
|
3 | 3 | ||
4 | 4 | ||
5 | //#include "mysql.h"
|
5 | //#include "mysql.h"
|
6 | 6 | ||
7 | #include "mymodel.h"
|
7 | #include "mymodel.h"
|
8 | #include "settingform.h"
|
8 | #include "settingform.h"
|
9 | #include "delegate.h"
|
9 | #include "delegate.h"
|
10 | 10 | ||
11 | #include <QMainWindow>
|
11 | #include <QMainWindow>
|
12 | #include <QStandardItemModel>
|
12 | #include <QStandardItemModel>
|
13 | #include <QStandardItem>
|
13 | #include <QStandardItem>
|
14 | #include <QTreeWidgetItem>
|
14 | #include <QTreeWidgetItem>
|
15 | #include <QTextCodec>
|
15 | #include <QTextCodec>
|
16 | #include <QSqlDatabase>
|
16 | #include <QSqlDatabase>
|
17 | 17 | ||
18 | #include <QtGui>
|
18 | #include <QtGui>
|
19 | #include <QString>
|
19 | #include <QString>
|
20 | #include <QtSql>
|
20 | #include <QtSql>
|
21 | #include <QFont>
|
21 | #include <QFont>
|
22 | #include <QColor>
|
22 | #include <QColor>
|
23 | #include <QItemDelegate>
|
23 | #include <QItemDelegate>
|
24 | #include <QList>
|
24 | #include <QList>
|
25 | 25 | ||
26 | 26 | ||
27 | /*
|
27 | /*
|
28 | #include <QSqlField>
|
28 | #include <QSqlField>
|
29 | #include <QSqlRecord>
|
29 | #include <QSqlRecord>
|
30 | #include <QSqlTableModel>
|
30 | #include <QSqlTableModel>
|
31 | #include <QSqlQueryModel>
|
31 | #include <QSqlQueryModel>
|
32 | #include <QTableView>
|
32 | #include <QTableView>
|
33 | #include <QSqlDriverPlugin>
|
33 | #include <QSqlDriverPlugin>
|
34 | #include <QIcon>
|
34 | #include <QIcon>
|
35 | #include <QVariant>
|
35 | #include <QVariant>
|
36 | #include <QProcess>
|
36 | #include <QProcess>
|
37 | #include <QByteArray>
|
37 | #include <QByteArray>
|
38 | */
|
38 | */
|
39 | 39 | ||
40 | typedef struct Class { |
40 | typedef struct Class { |
41 | QString name;
|
41 | QString name;
|
42 | QString ID;
|
42 | QString ID;
|
43 | 43 | ||
44 | } TClass; |
44 | } TClass; |
45 | 45 | ||
46 | 46 | ||
47 | 47 | ||
48 | 48 | ||
49 | namespace Ui { |
49 | namespace Ui { |
50 | class MainWindow; |
50 | class MainWindow; |
51 | }
|
51 | }
|
52 | 52 | ||
53 | class MainWindow : public QMainWindow { |
53 | class MainWindow : public QMainWindow { |
54 | Q_OBJECT |
54 | Q_OBJECT |
55 | public: |
55 | public: |
56 | MainWindow(QWidget *parent = 0); |
56 | MainWindow(QWidget *parent = 0); |
57 | ~MainWindow(); |
57 | ~MainWindow(); |
58 | 58 | ||
59 | protected: |
59 | protected: |
60 | void changeEvent(QEvent *e); |
60 | void changeEvent(QEvent *e); |
61 | 61 | ||
62 | private: |
62 | private: |
63 | Ui::MainWindow *ui; |
63 | Ui::MainWindow *ui; |
64 | 64 | ||
65 | settingForm setFrm;
|
65 | settingForm setFrm;
|
66 | //ïåðåìåííûå äëÿ ñîåäèíåíèÿ ñ áàçîé
|
66 | //ïåðåìåííûå äëÿ ñîåäèíåíèÿ ñ áàçîé
|
67 | QString baseName;
|
67 | QString baseName;
|
68 | QString hostName;
|
68 | QString hostName;
|
69 | QString userName;
|
69 | QString userName;
|
70 | QString password;
|
70 | QString password;
|
71 | QString tableName;
|
71 | QString tableName;
|
72 | 72 | ||
73 | void readSettings(); |
73 | void readSettings(); |
74 | void writeSettings(); |
74 | void writeSettings(); |
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | QList<QTreeWidgetItem *> root_items_list; |
78 | QList<QTreeWidgetItem *> root_items_list; |
79 | QStandardItemModel *model; |
79 | QStandardItemModel *model; |
80 | QStandardItem *item; |
80 | QStandardItem *item; |
81 | QTreeWidgetItem *rootItem1, *rootItem2; |
81 | QTreeWidgetItem *rootItem1, *rootItem2; |
82 | void openBase(); |
82 | void openBase(); |
83 | bool readModel(); |
83 | bool readModel(); |
84 | void setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row); // row - íîìåð ñòðîêè â òàáëèöå ìîäåëåé, ñîîòâåòñòâóþùèé äàííîé ìîäåëè |
84 | void setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row); // row - íîìåð ñòðîêè â òàáëèöå ìîäåëåé, ñîîòâåòñòâóþùèé äàííîé ìîäåëè |
85 | QString creatModelString(QTreeWidgetItem* model); |
85 | QString creatModelString(QTreeWidgetItem* model); |
86 | QString modelString; // ñòðîêà, îïèñûâàþùàÿ ìîäåëü ïðåäñòàâëåíèÿ |
86 | QString modelString; // ñòðîêà, îïèñûâàþùàÿ ìîäåëü ïðåäñòàâëåíèÿ |
87 | void addChildsString(QTreeWidgetItem *parentItem, int level); |
87 | void addChildsString(QTreeWidgetItem *parentItem, int level); |
88 | 88 | ||
89 | QSqlDatabase sql;
|
89 | QSqlDatabase sql;
|
90 | bool model_is_build; // ôëàã ãîâîðèò, ïîñòðîåíà ëè ìîäêëü (true) èëè íåò (false) |
90 | bool model_is_build; // ôëàã ãîâîðèò, ïîñòðîåíà ëè ìîäêëü (true) èëè íåò (false) |
91 | 91 | ||
92 | bool openDataBase(); |
92 | bool openDataBase(); |
93 | bool buildPreviewModel(QString modelName, QString rootClassID); |
93 | bool buildPreviewModel(QString modelName, QString rootClassID); |
94 | 94 | ||
95 | bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row); |
95 | bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row); |
96 | 96 | ||
97 | QString ClassName(QString class_id); //âîçâðàùàåò èìÿ êëàññà ïî åãî ID |
97 | QString ClassName(QString class_id); //âîçâðàùàåò èìÿ êëàññà ïî åãî ID |
98 | void addChildsItems(QTreeWidgetItem *perent_class_item, int row); // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì |
98 | void addChildsItems(QTreeWidgetItem *perent_class_item, int row); // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì |
99 | QStringList classChields(QString class_id); |
99 | QStringList classChields(QString class_id); |
100 | QMap <QString, QString> getClassList(); // ïîëó÷àåì ñïèñîê êëàññîâ |
100 | QMap <QString, QString> getClassList(); // ïîëó÷àåì ñïèñîê êëàññîâ |
101 | QMap <QString, QString> getFieldsList(QString class_id); // ïîëó÷àåì ñïèñîê ïîëåé êëàññà |
101 | QMap <QString, QString> getFieldsList(QString class_id); // ïîëó÷àåì ñïèñîê ïîëåé êëàññà |
102 | void initComboBox(); |
102 | void initComboBox(); |
103 | QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé) |
103 | QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé) |
104 | 104 | ||
105 | /////// QSqlTableModel * sql_mogel;
|
105 | /////// QSqlTableModel * sql_mogel;
|
106 | 106 | ||
107 | MyModel * sql_mogel; |
107 | MyModel * sql_mogel; |
108 | QSqlTableModel * model_for_ListModelsTable; |
108 | QSqlTableModel * model_for_ListModelsTable; |
109 | 109 | ||
110 | void initListModelsTablle(); |
110 | void initListModelsTablle(); |
111 | void readModels(); // ñ÷èòûâàåì ñïèñîê ìîäåëåé èç áàçû äàííûõ è ñòðîèì äåðåâî ìîäåëåé |
111 | void readModels(); // ñ÷èòûâàåì ñïèñîê ìîäåëåé èç áàçû äàííûõ è ñòðîèì äåðåâî ìîäåëåé |
112 | 112 | ||
113 | int pointer_index; //èíäåêñ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ |
113 | int pointer_index; //èíäåêñ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ |
114 | QString parentObject_id;
|
114 | QString parentObject_id;
|
115 | 115 | ||
116 | 116 | ||
117 | QMap <QString, QString> class_list_map; |
117 | QMap <QString, QString> class_list_map; |
118 | QMap <int, QTreeWidgetItem*> models_items; // ñïèñîê èòåìîâ (êîðíåâûõ )ìîäåëåé è ñîîòâåòñòâóþùèõ èì ñòðîê â òàáëèöå ìîäåëåé |
118 | QMap <int, QTreeWidgetItem*> models_items; // ñïèñîê èòåìîâ (êîðíåâûõ )ìîäåëåé è ñîîòâåòñòâóþùèõ èì ñòðîê â òàáëèöå ìîäåëåé |
119 | void getDatabaseData(); |
119 | void getDatabaseData(); |
120 | void buildTree(QTreeWidgetItem * model_item); |
120 | void buildTree(QTreeWidgetItem * model_item); |
121 | QString getClassInctance(QString class_id); // ïîëó÷àåì èìÿ òàáëèöû - õðàíèëèùà îáúåêòîâ êëàññà |
121 | QString getClassInctance(QString class_id); // ïîëó÷àåì èìÿ òàáëèöû - õðàíèëèùà îáúåêòîâ êëàññà |
122 | void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà |
122 | void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà |
123 | void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà |
123 | void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà |
124 | void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// // îòîáðàçèì îáúåêòû êëàññîâà |
124 | void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// // îòîáðàçèì îáúåêòû êëàññîâà |
125 | QString getPointerFieldName(QString parent_class_id, QString chield_class_id); // îïðåäåëÿåì èìÿ ïîëÿ, â êîòîðîì õðÿíÿòñÿ óêàçàòåëè íà îáúåêòû ðîäèòåëüñêîãî êëàññà |
125 | QString getPointerFieldName(QString parent_class_id, QString chield_class_id); // îïðåäåëÿåì èìÿ ïîëÿ, â êîòîðîì õðÿíÿòñÿ óêàçàòåëè íà îáúåêòû ðîäèòåëüñêîãî êëàññà |
126 | 126 | ||
127 | QMap <QString, QString> getPointersList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé-óêàçàòåëåé, â êà÷åñòâå êëþ÷åé ïîëó÷èì èìåíà ïîëåé-óêàçàòåëåé |
127 | QMap <QString, QString> getPointersList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé-óêàçàòåëåé, â êà÷åñòâå êëþ÷åé ïîëó÷èì èìåíà ïîëåé-óêàçàòåëåé |
128 | // â êà÷åñòâå çíà÷åíèé ïîëó÷èì ñïèñîê òàáëèö-õðàíèëèù îáúåêòîâ ðîäèòåëüñêèõ êëàññîâ
|
128 | // â êà÷åñòâå çíà÷åíèé ïîëó÷èì ñïèñîê òàáëèö-õðàíèëèù îáúåêòîâ ðîäèòåëüñêèõ êëàññîâ
|
129 | 129 | ||
130 | 130 | ||
131 | QStringList getDataFieldList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé c òèïîì "Äàòà" |
131 | QStringList getDataFieldList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé c òèïîì "Äàòà" |
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | QStringList getBoolFieldList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé c òèïîì "bool" |
135 | QStringList getBoolFieldList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé c òèïîì "bool" |
136 | 136 | ||
137 | 137 | ||
138 | SpinBoxDelegate spinDelegate;
|
138 | SpinBoxDelegate spinDelegate;
|
139 | QItemDelegate standart_delegate;
|
139 | QItemDelegate standart_delegate;
|
140 | CPictureDelegate * picture_delegate; |
140 | CPictureDelegate * picture_delegate; |
141 | bool comboBox_slot_enable; // äëÿ áëîêèðîâêè ñëîòà, êîãäà ìåíÿåì item_index èç ïðîãðàììû, à íå âðó÷íóþ |
141 | bool comboBox_slot_enable; // äëÿ áëîêèðîâêè ñëîòà, êîãäà ìåíÿåì item_index èç ïðîãðàììû, à íå âðó÷íóþ |
142 | - | ||
- | 142 | QList <int> boolFieldsIndexes_global; // ñïèñîê íîìåðîâ ñòîëáöîâ ñ òèïîì "BOOL" |
|
143 | 143 | ||
144 | 144 | ||
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | 148 | ||
149 | 149 | ||
150 | private slots: |
150 | private slots: |
151 | void on_comboBox_currentIndexChanged( int index ); |
151 | void on_comboBox_currentIndexChanged( int index ); |
152 | void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column ); |
152 | void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column ); |
153 | void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column ); |
153 | void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column ); |
154 | void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column ); |
154 | void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column ); |
155 | void on_pushButton_clicked(); // íàæàòèå êíîïêè "Äîáàâèòü îáúåêò" |
155 | void on_pushButton_clicked(); // íàæàòèå êíîïêè "Äîáàâèòü îáúåêò" |
156 | void on_pushButton_2_clicked();// íàæàòèå êíîïêè "Óäàëèòü âûäåëåííûå îáúåêòû" |
156 | void on_pushButton_2_clicked();// íàæàòèå êíîïêè "Óäàëèòü âûäåëåííûå îáúåêòû" |
157 | void on_pushButton_3_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü" |
157 | void on_pushButton_3_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü" |
158 | void on_pushButton_4_clicked();// íàæàòèå êíîïêè "Ñáðîñèòü èçìåíåíèÿ" |
158 | void on_pushButton_4_clicked();// íàæàòèå êíîïêè "Ñáðîñèòü èçìåíåíèÿ" |
159 | void on_pushButton_5_clicked();// íàæàòèå êíîïêè "Äîáàâèòü ìîäåëü " |
159 | void on_pushButton_5_clicked();// íàæàòèå êíîïêè "Äîáàâèòü ìîäåëü " |
160 | void on_pushButton_6_clicked();// íàæàòèå êíîïêè "Óäàëèòü ìîäåëü " |
160 | void on_pushButton_6_clicked();// íàæàòèå êíîïêè "Óäàëèòü ìîäåëü " |
161 | void on_pushButton_7_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü" (íà âêëàäêå ìîäåëåé) |
161 | void on_pushButton_7_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü" (íà âêëàäêå ìîäåëåé) |
162 | void on_pushButton_8_clicked();// íàæàòèå êíîïêè "Îòìåíèòü" (íà âêëàäêå ìîäåëåé) |
162 | void on_pushButton_8_clicked();// íàæàòèå êíîïêè "Îòìåíèòü" (íà âêëàäêå ìîäåëåé) |
163 | void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò |
163 | void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò |
164 | void on_model_for_ListModelsTable_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò |
164 | void on_model_for_ListModelsTable_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò |
165 | void applySetting(); |
165 | void applySetting(); |
166 | void getSetting(); // îòêðîåì îêíî íàñòðîåê |
166 | void getSetting(); // îòêðîåì îêíî íàñòðîåê |
167 | }; |
167 | }; |
168 | 168 | ||
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | #endif // MAINWINDOW_H
|
172 | #endif // MAINWINDOW_H
|
173 | 173 |