Subversion Repositories OpenInventory

Rev

Rev 126 | Rev 128 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 126 Rev 127
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"
-
 
8
7
#include "delegate.h"
9
#include "delegate.h"
8
10
9
#include <QMainWindow>
11
#include <QMainWindow>
10
#include <QStandardItemModel>
12
#include <QStandardItemModel>
11
#include <QStandardItem>
13
#include <QStandardItem>
12
#include <QTreeWidgetItem>
14
#include <QTreeWidgetItem>
13
#include <QTextCodec>
15
#include <QTextCodec>
14
#include <QSqlDatabase>
16
#include <QSqlDatabase>
15
17
16
#include <QtGui>
18
#include <QtGui>
17
#include <QString>
19
#include <QString>
18
#include <QtSql>
20
#include <QtSql>
19
#include <QFont>
21
#include <QFont>
20
#include <QColor>
22
#include <QColor>
21
23
22
24
23
/*
25
/*
24
#include <QSqlField>
26
#include <QSqlField>
25
#include <QSqlRecord>
27
#include <QSqlRecord>
26
#include <QSqlTableModel>
28
#include <QSqlTableModel>
27
#include <QSqlQueryModel>
29
#include <QSqlQueryModel>
28
#include <QTableView>
30
#include <QTableView>
29
#include <QSqlDriverPlugin>
31
#include <QSqlDriverPlugin>
30
#include <QIcon>
32
#include <QIcon>
31
#include <QVariant>
33
#include <QVariant>
32
#include <QProcess>
34
#include <QProcess>
33
#include <QByteArray>
35
#include <QByteArray>
34
*/
36
*/
35
37
36
typedef struct Class {
38
typedef struct Class {
37
        QString name;
39
        QString name;
38
        QString ID;
40
        QString ID;
39
41
40
} TClass;
42
} TClass;
41
43
42
44
43
45
44
46
45
namespace Ui {
47
namespace Ui {
46
    class MainWindow;
48
    class MainWindow;
47
}
49
}
48
50
49
class MainWindow : public QMainWindow {
51
class MainWindow : public QMainWindow {
50
    Q_OBJECT
52
    Q_OBJECT
51
public:
53
public:
52
    MainWindow(QWidget *parent = 0);
54
    MainWindow(QWidget *parent = 0);
53
    ~MainWindow();
55
    ~MainWindow();
54
56
55
protected:
57
protected:
56
    void changeEvent(QEvent *e);
58
    void changeEvent(QEvent *e);
57
59
58
private:
60
private:
59
    Ui::MainWindow *ui;
61
    Ui::MainWindow *ui;
60
62
61
    QList<QTreeWidgetItem *> root_items_list;
63
    QList<QTreeWidgetItem *> root_items_list;
62
    QStandardItemModel *model;
64
    QStandardItemModel *model;
63
    QStandardItem *item;
65
    QStandardItem *item;
64
    QTreeWidgetItem *rootItem1, *rootItem2;
66
    QTreeWidgetItem *rootItem1, *rootItem2;
65
    void openBase();
67
    void openBase();
66
    bool readModel();
68
    bool readModel();
67
    void setupModelData(const QStringList &lines, QTreeWidgetItem *parent);
69
    void setupModelData(const QStringList &lines, QTreeWidgetItem *parent);
68
    void creatModelString();
70
    void creatModelString();
69
    QString modelString; // ñòðîêà, îïèñûâàþùàÿ ìîäåëü ïðåäñòàâëåíèÿ
71
    QString modelString; // ñòðîêà, îïèñûâàþùàÿ ìîäåëü ïðåäñòàâëåíèÿ
70
    void addChildsString(QTreeWidgetItem *parentItem, int level);
72
    void addChildsString(QTreeWidgetItem *parentItem, int level);
71
73
72
    QSqlDatabase sql;
74
    QSqlDatabase sql;
73
    bool model_is_build; // ôëàã ãîâîðèò, ïîñòðîåíà ëè ìîäêëü (true) èëè íåò  (false)
75
    bool model_is_build; // ôëàã ãîâîðèò, ïîñòðîåíà ëè ìîäêëü (true) èëè íåò  (false)
74
76
75
    bool openDataBase();
77
    bool openDataBase();
76
    bool buildPreviewModel(QString modelName, QString rootClassID);
78
    bool buildPreviewModel(QString modelName, QString rootClassID);
77
79
78
    bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID);
80
    bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID);
79
81
80
    QString ClassName(QString class_id); //âîçâðàùàåò èìÿ êëàññà ïî åãî ID
82
    QString ClassName(QString class_id); //âîçâðàùàåò èìÿ êëàññà ïî åãî ID
81
    void addChildsItems(QTreeWidgetItem *perent_class_item); // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì
83
    void addChildsItems(QTreeWidgetItem *perent_class_item); // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì
82
    QStringList classChields(QString class_id);
84
    QStringList classChields(QString class_id);
83
    QMap <QString, QString> getClassList(); // ïîëó÷àåì ñïèñîê êëàññîâ
85
    QMap <QString, QString> getClassList(); // ïîëó÷àåì ñïèñîê êëàññîâ
84
    QMap <QString, QString> getFieldsList(QString class_id); // ïîëó÷àåì ñïèñîê ïîëåé êëàññà
86
    QMap <QString, QString> getFieldsList(QString class_id); // ïîëó÷àåì ñïèñîê ïîëåé êëàññà
85
    void initComboBox();
87
    void initComboBox();
86
    QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé)
88
    QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé)
-
 
89
87
    QSqlTableModel * sql_mogel;
90
    /////// QSqlTableModel * sql_mogel;
-
 
91
-
 
92
    MyModel  * sql_mogel;
-
 
93
88
    int pointer_index; //èíäåêñ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ
94
    int pointer_index; //èíäåêñ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ
89
    QString parentObject_id;
95
    QString parentObject_id;
90
96
91
97
92
    QMap <QString, QString> class_list_map;
98
    QMap <QString, QString> class_list_map;
93
    void getDatabaseData();
99
    void getDatabaseData();
94
    void buildTree(QTreeWidgetItem * model_item);
100
    void buildTree(QTreeWidgetItem * model_item);
95
    QString getClassInctance(QString class_id); // ïîëó÷àåì èìÿ òàáëèöû - õðàíèëèùà îáúåêòîâ êëàññà
101
    QString getClassInctance(QString class_id); // ïîëó÷àåì èìÿ òàáëèöû - õðàíèëèùà îáúåêòîâ êëàññà
96
    void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà
102
    void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà
97
    void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà
103
    void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà
98
    void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// // îòîáðàçèì îáúåêòû êëàññîâà
104
    void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// // îòîáðàçèì îáúåêòû êëàññîâà
99
    QString getPointerFieldName(QString parent_class_id, QString chield_class_id); // îïðåäåëÿåì èìÿ ïîëÿ, â êîòîðîì õðÿíÿòñÿ óêàçàòåëè íà îáúåêòû ðîäèòåëüñêîãî êëàññà
105
    QString getPointerFieldName(QString parent_class_id, QString chield_class_id); // îïðåäåëÿåì èìÿ ïîëÿ, â êîòîðîì õðÿíÿòñÿ óêàçàòåëè íà îáúåêòû ðîäèòåëüñêîãî êëàññà
100
106
101
    SpinBoxDelegate spinDelegate;
107
    SpinBoxDelegate spinDelegate;
102
108
103
109
104
private slots:
110
private slots:
105
    void on_comboBox_currentIndexChanged( int index );
111
    void on_comboBox_currentIndexChanged( int index );
106
    void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
112
    void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
107
    void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
113
    void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
108
    void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
114
    void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
109
    void on_pushButton_clicked(); // íàæàòèå êíîïêè "Äîáàâèòü îáúåêò"
115
    void on_pushButton_clicked(); // íàæàòèå êíîïêè "Äîáàâèòü îáúåêò"
110
    void on_pushButton_2_clicked();// íàæàòèå êíîïêè "Óäàëèòü âûäåëåííûå îáúåêòû"
116
    void on_pushButton_2_clicked();// íàæàòèå êíîïêè "Óäàëèòü âûäåëåííûå îáúåêòû"
111
    void on_pushButton_3_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü"
117
    void on_pushButton_3_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü"
112
    void on_pushButton_4_clicked();// íàæàòèå êíîïêè "Ñáðîñèòü èçìåíåíèÿ"
118
    void on_pushButton_4_clicked();// íàæàòèå êíîïêè "Ñáðîñèòü èçìåíåíèÿ"
113
    void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò
119
    void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò
114
120
115
};
121
};
116
122
117
123
118
124
119
125
120
#endif // MAINWINDOW_H
126
#endif // MAINWINDOW_H
121
 
127