Subversion Repositories OpenInventory

Rev

Rev 219 | Rev 222 | 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"
200 pingvin 10
// #include "fileform.h"
209 pingvin 11
#include "treedelegateform.h"
124 pingvin 12
 
88 pingvin 13
#include <QMainWindow>
14
#include <QStandardItemModel>
15
#include <QStandardItem>
16
#include <QTreeWidgetItem>
17
#include <QTextCodec>
89 pingvin 18
#include <QSqlDatabase>
88 pingvin 19
 
89 pingvin 20
#include <QtGui>
93 pingvin 21
#include <QString>
22
#include <QtSql>
113 pingvin 23
#include <QFont>
114 pingvin 24
#include <QColor>
130 pingvin 25
#include <QItemDelegate>
147 pingvin 26
#include <QList>
89 pingvin 27
 
93 pingvin 28
 
29
/*
30
#include <QSqlField>
31
#include <QSqlRecord>
32
#include <QSqlTableModel>
33
#include <QSqlQueryModel>
34
#include <QTableView>
35
#include <QSqlDriverPlugin>
36
#include <QIcon>
37
#include <QVariant>
38
#include <QProcess>
39
#include <QByteArray>
40
*/
41
 
99 pingvin 42
typedef struct Class {
43
        QString name;
44
        QString ID;
93 pingvin 45
 
99 pingvin 46
} TClass;
93 pingvin 47
 
48
 
49
 
50
 
88 pingvin 51
namespace Ui {
52
    class MainWindow;
53
}
54
 
55
class MainWindow : public QMainWindow {
56
    Q_OBJECT
57
public:
58
    MainWindow(QWidget *parent = 0);
59
    ~MainWindow();
60
 
61
protected:
62
    void changeEvent(QEvent *e);
63
 
64
private:
65
    Ui::MainWindow *ui;
200 pingvin 66
    //FileForm fileForm;
209 pingvin 67
    TreeDelegateForm treeForm;
88 pingvin 68
 
132 pingvin 69
        settingForm setFrm;
70
//    
71
        QString baseName;
72
        QString hostName;
73
        QString userName;
74
        QString password;
75
        QString tableName;
76
 
77
        void readSettings();
78
        void writeSettings();
79
 
80
 
81
 
106 pingvin 82
    QList<QTreeWidgetItem *> root_items_list;
88 pingvin 83
    QStandardItemModel *model;
84
    QStandardItem *item;
85
    QTreeWidgetItem *rootItem1, *rootItem2;
89 pingvin 86
    void openBase();
87
    bool readModel();
215 pingvin 88
    void setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row, QString model_id); // row -     ,   
146 pingvin 89
    QString creatModelString(QTreeWidgetItem* model);
91 pingvin 90
    QString modelString; // ,   
91
    void addChildsString(QTreeWidgetItem *parentItem, int level);
93 pingvin 92
 
93
    QSqlDatabase sql;
118 pingvin 94
    bool model_is_build; //  ,    (true)    (false)
93 pingvin 95
 
96
    bool openDataBase();
97 pingvin 97
    bool buildPreviewModel(QString modelName, QString rootClassID);
107 pingvin 98
 
147 pingvin 99
    bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row);
107 pingvin 100
 
95 pingvin 101
    QString ClassName(QString class_id); //     ID
147 pingvin 102
    void addChildsItems(QTreeWidgetItem *perent_class_item, int row); //          ,      
99 pingvin 103
    QStringList classChields(QString class_id);
102 pingvin 104
    QMap <QString, QString> getClassList(); //   
125 pingvin 105
    QMap <QString, QString> getFieldsList(QString class_id); //    
104 pingvin 106
    void initComboBox();
107
    QList<QTreeWidgetItem *> rootItems; //     ()
127 pingvin 108
 
109
    /////// QSqlTableModel * sql_mogel;
110
 
111
    MyModel  * sql_mogel;
219 pingvin 112
//  MyModel * filtr_model;
113
 
221 pingvin 114
    QSqlTableModel * filter_model;
219 pingvin 115
 
142 pingvin 116
    QSqlTableModel * model_for_ListModelsTable;
127 pingvin 117
 
142 pingvin 118
    void initListModelsTablle();
144 pingvin 119
    void readModels(); //          
142 pingvin 120
 
118 pingvin 121
    int pointer_index; // -   
122
    QString parentObject_id;
109 pingvin 123
 
115 pingvin 124
 
106 pingvin 125
    QMap <QString, QString> class_list_map;
147 pingvin 126
    QMap <int, QTreeWidgetItem*> models_items; //   ( )       
109 pingvin 127
    void getDatabaseData();
128
    void buildTree(QTreeWidgetItem * model_item);
129
    QString getClassInctance(QString class_id); //    -   
110 pingvin 130
    void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); //   
131
    void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); //   
112 pingvin 132
    void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// //   
133
    QString getPointerFieldName(QString parent_class_id, QString chield_class_id); //   ,        
93 pingvin 134
 
128 pingvin 135
    QMap <QString, QString> getPointersList(QString class_id); //    -,      -
136
                                                                //      -   
147 pingvin 137
 
138
 
174 pingvin 139
    QMap <QString, QPixmap> getClassesIcons(); //     
140
                                                //     ID ,     -  
141
 
195 pingvin 142
 
143
    QMap <QString, QPixmap> getObjectsIcon(QString inctance); //     
144
    //     ID ,     -  
145
 
146
 
158 pingvin 147
    QStringList getDataFieldList(QString class_id); //     c  ""
147 pingvin 148
 
158 pingvin 149
 
150
 
151
    QStringList getBoolFieldList(QString class_id); //     c  "bool"
152
 
153
 
200 pingvin 154
    QStringList getFileFieldList(QString class_id); //    ,    "
188 pingvin 155
 
200 pingvin 156
 
157
 
188 pingvin 158
    int getIconFieldIndex(QString inctance); //     
159
 
126 pingvin 160
    SpinBoxDelegate spinDelegate;
130 pingvin 161
    QItemDelegate standart_delegate;
138 pingvin 162
    CPictureDelegate * picture_delegate;
189 pingvin 163
    IconDelegate * iconDelegate;
219 pingvin 164
    FileDelegate * fileDelegate; //     ,     
165
    FilterSpinBoxDelegate filterSpinDelegate;
166
    FilterConditionDelegate filterConditionDelegate, filterConditionDelegate_1, filterConditionDelegate_2;
152 pingvin 167
    bool comboBox_slot_enable; //   ,   item_index  ,   
159 pingvin 168
    QList <int> boolFieldsIndexes_global; //      "BOOL"
115 pingvin 169
 
174 pingvin 170
    QMap <QString, QPixmap> classesIcons;
132 pingvin 171
 
172
 
173
 
174
 
175
 
106 pingvin 176
private slots:
177
    void on_comboBox_currentIndexChanged( int index );
178
    void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
179
    void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
115 pingvin 180
    void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
119 pingvin 181
    void on_pushButton_clicked(); //   " "
182
    void on_pushButton_2_clicked();//   "  "
183
    void on_pushButton_3_clicked();//   ""
184
    void on_pushButton_4_clicked();//   " "
144 pingvin 185
    void on_pushButton_5_clicked();//   "  "
186
    void on_pushButton_6_clicked();//   "  "
146 pingvin 187
    void on_pushButton_7_clicked();//   "" (  )
188
    void on_pushButton_8_clicked();//   "" (  )
217 pingvin 189
    void on_pushButton_9_clicked();//   " " (  )
190
    void on_pushButton_10_clicked();//   " " (  )
191
    void on_pushButton_11_clicked();//   "" (  )
192
    void on_pushButton_12_clicked();//   " " (  )
193
 
119 pingvin 194
    void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
146 pingvin 195
    void on_model_for_ListModelsTable_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
221 pingvin 196
    void on_filter_model_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
132 pingvin 197
    void applySetting();
198
    void getSetting(); //   
88 pingvin 199
};
200
 
105 pingvin 201
 
202
 
203
 
88 pingvin 204
#endif // MAINWINDOW_H