Subversion Repositories OpenInventory

Rev

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