Subversion Repositories OpenInventory

Rev

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

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