Subversion Repositories OpenInventory

Rev

Rev 212 | Rev 217 | 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;
212 pingvin 112
    MyModel * filtr_model;
142 pingvin 113
    QSqlTableModel * model_for_ListModelsTable;
127 pingvin 114
 
142 pingvin 115
    void initListModelsTablle();
144 pingvin 116
    void readModels(); //          
142 pingvin 117
 
118 pingvin 118
    int pointer_index; // -   
119
    QString parentObject_id;
109 pingvin 120
 
115 pingvin 121
 
106 pingvin 122
    QMap <QString, QString> class_list_map;
147 pingvin 123
    QMap <int, QTreeWidgetItem*> models_items; //   ( )       
109 pingvin 124
    void getDatabaseData();
125
    void buildTree(QTreeWidgetItem * model_item);
126
    QString getClassInctance(QString class_id); //    -   
110 pingvin 127
    void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); //   
128
    void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); //   
112 pingvin 129
    void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// //   
130
    QString getPointerFieldName(QString parent_class_id, QString chield_class_id); //   ,        
93 pingvin 131
 
128 pingvin 132
    QMap <QString, QString> getPointersList(QString class_id); //    -,      -
133
                                                                //      -   
147 pingvin 134
 
135
 
174 pingvin 136
    QMap <QString, QPixmap> getClassesIcons(); //     
137
                                                //     ID ,     -  
138
 
195 pingvin 139
 
140
    QMap <QString, QPixmap> getObjectsIcon(QString inctance); //     
141
    //     ID ,     -  
142
 
143
 
158 pingvin 144
    QStringList getDataFieldList(QString class_id); //     c  ""
147 pingvin 145
 
158 pingvin 146
 
147
 
148
    QStringList getBoolFieldList(QString class_id); //     c  "bool"
149
 
150
 
200 pingvin 151
    QStringList getFileFieldList(QString class_id); //    ,    "
188 pingvin 152
 
200 pingvin 153
 
154
 
188 pingvin 155
    int getIconFieldIndex(QString inctance); //     
156
 
126 pingvin 157
    SpinBoxDelegate spinDelegate;
130 pingvin 158
    QItemDelegate standart_delegate;
138 pingvin 159
    CPictureDelegate * picture_delegate;
189 pingvin 160
    IconDelegate * iconDelegate;
201 pingvin 161
    FileDelegate * fileDelegate;
152 pingvin 162
    bool comboBox_slot_enable; //   ,   item_index  ,   
159 pingvin 163
    QList <int> boolFieldsIndexes_global; //      "BOOL"
115 pingvin 164
 
174 pingvin 165
    QMap <QString, QPixmap> classesIcons;
132 pingvin 166
 
167
 
168
 
169
 
170
 
106 pingvin 171
private slots:
172
    void on_comboBox_currentIndexChanged( int index );
173
    void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
174
    void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
115 pingvin 175
    void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
119 pingvin 176
    void on_pushButton_clicked(); //   " "
177
    void on_pushButton_2_clicked();//   "  "
178
    void on_pushButton_3_clicked();//   ""
179
    void on_pushButton_4_clicked();//   " "
144 pingvin 180
    void on_pushButton_5_clicked();//   "  "
181
    void on_pushButton_6_clicked();//   "  "
146 pingvin 182
    void on_pushButton_7_clicked();//   "" (  )
183
    void on_pushButton_8_clicked();//   "" (  )
215 pingvin 184
    void on_pushButton_9_clicked();//   " " (  )
119 pingvin 185
    void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
146 pingvin 186
    void on_model_for_ListModelsTable_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
132 pingvin 187
    void applySetting();
188
    void getSetting(); //   
88 pingvin 189
};
190
 
105 pingvin 191
 
192
 
193
 
88 pingvin 194
#endif // MAINWINDOW_H