Subversion Repositories OpenInventory

Rev

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

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