Subversion Repositories OpenInventory

Rev

Rev 130 | Rev 138 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
88 pingvin 1
#ifndef MAINWINDOW_H
2
#define MAINWINDOW_H
3
 
93 pingvin 4
 
5
//#include "mysql.h"
109 pingvin 6
 
127 pingvin 7
#include "mymodel.h"
132 pingvin 8
#include "settingform.h"
124 pingvin 9
#include "delegate.h"
10
 
88 pingvin 11
#include <QMainWindow>
12
#include <QStandardItemModel>
13
#include <QStandardItem>
14
#include <QTreeWidgetItem>
15
#include <QTextCodec>
89 pingvin 16
#include <QSqlDatabase>
88 pingvin 17
 
89 pingvin 18
#include <QtGui>
93 pingvin 19
#include <QString>
20
#include <QtSql>
113 pingvin 21
#include <QFont>
114 pingvin 22
#include <QColor>
130 pingvin 23
#include <QItemDelegate>
89 pingvin 24
 
93 pingvin 25
 
26
/*
27
#include <QSqlField>
28
#include <QSqlRecord>
29
#include <QSqlTableModel>
30
#include <QSqlQueryModel>
31
#include <QTableView>
32
#include <QSqlDriverPlugin>
33
#include <QIcon>
34
#include <QVariant>
35
#include <QProcess>
36
#include <QByteArray>
37
*/
38
 
99 pingvin 39
typedef struct Class {
40
        QString name;
41
        QString ID;
93 pingvin 42
 
99 pingvin 43
} TClass;
93 pingvin 44
 
45
 
46
 
47
 
88 pingvin 48
namespace Ui {
49
    class MainWindow;
50
}
51
 
52
class MainWindow : public QMainWindow {
53
    Q_OBJECT
54
public:
55
    MainWindow(QWidget *parent = 0);
56
    ~MainWindow();
57
 
58
protected:
59
    void changeEvent(QEvent *e);
60
 
61
private:
62
    Ui::MainWindow *ui;
63
 
132 pingvin 64
        settingForm setFrm;
65
//    
66
        QString baseName;
67
        QString hostName;
68
        QString userName;
69
        QString password;
70
        QString tableName;
71
 
72
        void readSettings();
73
        void writeSettings();
74
 
75
 
76
 
106 pingvin 77
    QList<QTreeWidgetItem *> root_items_list;
88 pingvin 78
    QStandardItemModel *model;
79
    QStandardItem *item;
80
    QTreeWidgetItem *rootItem1, *rootItem2;
89 pingvin 81
    void openBase();
82
    bool readModel();
83
    void setupModelData(const QStringList &lines, QTreeWidgetItem *parent);
91 pingvin 84
    void creatModelString();
85
    QString modelString; // ,   
86
    void addChildsString(QTreeWidgetItem *parentItem, int level);
93 pingvin 87
 
88
    QSqlDatabase sql;
118 pingvin 89
    bool model_is_build; //  ,    (true)    (false)
93 pingvin 90
 
91
    bool openDataBase();
97 pingvin 92
    bool buildPreviewModel(QString modelName, QString rootClassID);
107 pingvin 93
 
94
    bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID);
95
 
95 pingvin 96
    QString ClassName(QString class_id); //     ID
98 pingvin 97
    void addChildsItems(QTreeWidgetItem *perent_class_item); //          ,      
99 pingvin 98
    QStringList classChields(QString class_id);
102 pingvin 99
    QMap <QString, QString> getClassList(); //   
125 pingvin 100
    QMap <QString, QString> getFieldsList(QString class_id); //    
104 pingvin 101
    void initComboBox();
102
    QList<QTreeWidgetItem *> rootItems; //     ()
127 pingvin 103
 
104
    /////// QSqlTableModel * sql_mogel;
105
 
106
    MyModel  * sql_mogel;
107
 
118 pingvin 108
    int pointer_index; // -   
109
    QString parentObject_id;
109 pingvin 110
 
115 pingvin 111
 
106 pingvin 112
    QMap <QString, QString> class_list_map;
109 pingvin 113
    void getDatabaseData();
114
    void buildTree(QTreeWidgetItem * model_item);
115
    QString getClassInctance(QString class_id); //    -   
110 pingvin 116
    void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); //   
117
    void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); //   
112 pingvin 118
    void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// //   
119
    QString getPointerFieldName(QString parent_class_id, QString chield_class_id); //   ,        
93 pingvin 120
 
128 pingvin 121
    QMap <QString, QString> getPointersList(QString class_id); //    -,      -
122
                                                                //      -   
126 pingvin 123
    SpinBoxDelegate spinDelegate;
130 pingvin 124
    QItemDelegate standart_delegate;
115 pingvin 125
 
132 pingvin 126
 
127
 
128
 
129
 
130
 
131
 
132
 
106 pingvin 133
private slots:
134
    void on_comboBox_currentIndexChanged( int index );
135
    void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
136
    void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
115 pingvin 137
    void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
119 pingvin 138
    void on_pushButton_clicked(); //   " "
139
    void on_pushButton_2_clicked();//   "  "
140
    void on_pushButton_3_clicked();//   ""
141
    void on_pushButton_4_clicked();//   " "
142
    void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
132 pingvin 143
    void applySetting();
144
    void getSetting(); //   
88 pingvin 145
};
146
 
105 pingvin 147
 
148
 
149
 
88 pingvin 150
#endif // MAINWINDOW_H