Subversion Repositories OpenInventory

Rev

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