Subversion Repositories OpenInventory

Rev

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