Subversion Repositories OpenInventory

Rev

Rev 250 | Rev 255 | 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"
241 pingvin 12
#include "wmithread.h"
124 pingvin 13
 
243 pingvin 14
 
88 pingvin 15
#include <QMainWindow>
16
#include <QStandardItemModel>
17
#include <QStandardItem>
18
#include <QTreeWidgetItem>
19
#include <QTextCodec>
89 pingvin 20
#include <QSqlDatabase>
88 pingvin 21
 
89 pingvin 22
#include <QtGui>
93 pingvin 23
#include <QString>
24
#include <QtSql>
113 pingvin 25
#include <QFont>
114 pingvin 26
#include <QColor>
130 pingvin 27
#include <QItemDelegate>
147 pingvin 28
#include <QList>
222 pingvin 29
#include <QPalette>
89 pingvin 30
 
93 pingvin 31
 
222 pingvin 32
 
93 pingvin 33
/*
34
#include <QSqlField>
35
#include <QSqlRecord>
36
#include <QSqlTableModel>
37
#include <QSqlQueryModel>
38
#include <QTableView>
39
#include <QSqlDriverPlugin>
40
#include <QIcon>
41
#include <QVariant>
42
#include <QProcess>
43
#include <QByteArray>
44
*/
45
 
99 pingvin 46
typedef struct Class {
47
        QString name;
48
        QString ID;
93 pingvin 49
 
99 pingvin 50
} TClass;
93 pingvin 51
 
52
 
53
 
241 pingvin 54
typedef struct wmiVideoCard {
55
    QString name; //  
56
    QString manufacturer; // 
57
    QString model;
248 pingvin 58
    int video_ram;
93 pingvin 59
 
241 pingvin 60
} TWmiVideoCard;
61
 
62
 
63
 
64
 
251 pingvin 65
typedef struct wmiMatherBoard {
66
   // QString name; //  
67
    QString manufacturer; // 
68
    QString model;
69
    //int video_ram;
241 pingvin 70
 
251 pingvin 71
} TWmiMatherBoard;
241 pingvin 72
 
251 pingvin 73
 
74
typedef struct wmiProcessor {
75
    QString name; //  
76
    QString manufacturer; // 
77
    int clockSpeed;
78
    QString socket;
79
 
80
    //int video_ram;
81
 
82
} TWmiProcessor;
83
 
84
 
85
 
86
 
88 pingvin 87
namespace Ui {
88
    class MainWindow;
89
}
90
 
91
class MainWindow : public QMainWindow {
92
    Q_OBJECT
93
public:
94
    MainWindow(QWidget *parent = 0);
95
    ~MainWindow();
96
 
97
protected:
98
    void changeEvent(QEvent *e);
99
 
100
private:
101
    Ui::MainWindow *ui;
200 pingvin 102
    //FileForm fileForm;
241 pingvin 103
 
104
volatile bool all_reading;
105
 
209 pingvin 106
    TreeDelegateForm treeForm;
88 pingvin 107
 
132 pingvin 108
        settingForm setFrm;
109
//    
110
        QString baseName;
111
        QString hostName;
112
        QString userName;
113
        QString password;
114
        QString tableName;
115
 
116
        void readSettings();
117
        void writeSettings();
118
 
119
 
237 pingvin 120
    QProcess wmiProcess;
106 pingvin 121
    QList<QTreeWidgetItem *> root_items_list;
88 pingvin 122
    QStandardItemModel *model;
123
    QStandardItem *item;
124
    QTreeWidgetItem *rootItem1, *rootItem2;
89 pingvin 125
    void openBase();
126
    bool readModel();
250 pingvin 127
 
128
    void initWmiTree();
129
 
215 pingvin 130
    void setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row, QString model_id); // row -     ,   
146 pingvin 131
    QString creatModelString(QTreeWidgetItem* model);
91 pingvin 132
    QString modelString; // ,   
133
    void addChildsString(QTreeWidgetItem *parentItem, int level);
93 pingvin 134
 
135
    QSqlDatabase sql;
118 pingvin 136
    bool model_is_build; //  ,    (true)    (false)
93 pingvin 137
 
138
    bool openDataBase();
97 pingvin 139
    bool buildPreviewModel(QString modelName, QString rootClassID);
107 pingvin 140
 
147 pingvin 141
    bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row);
107 pingvin 142
 
95 pingvin 143
    QString ClassName(QString class_id); //     ID
147 pingvin 144
    void addChildsItems(QTreeWidgetItem *perent_class_item, int row); //          ,      
99 pingvin 145
    QStringList classChields(QString class_id);
102 pingvin 146
    QMap <QString, QString> getClassList(); //   
125 pingvin 147
    QMap <QString, QString> getFieldsList(QString class_id); //    
104 pingvin 148
    void initComboBox();
149
    QList<QTreeWidgetItem *> rootItems; //     ()
241 pingvin 150
    TWmiVideoCard getWmiVideoGard(QString host, QString user_name, QString password);
251 pingvin 151
    TWmiMatherBoard getWmiMatherBoard(QString host, QString user_name, QString password);
152
    TWmiProcessor getWmiProcessor(QString host, QString user_name, QString password);
127 pingvin 153
 
241 pingvin 154
 
155
 
242 pingvin 156
    WmiThread wmiThread;
127 pingvin 157
    /////// QSqlTableModel * sql_mogel;
158
 
159
    MyModel  * sql_mogel;
223 pingvin 160
 ////   MyModel * filter_model;
219 pingvin 161
 
221 pingvin 162
    QSqlTableModel * filter_model;
219 pingvin 163
 
142 pingvin 164
    QSqlTableModel * model_for_ListModelsTable;
127 pingvin 165
 
142 pingvin 166
    void initListModelsTablle();
144 pingvin 167
    void readModels(); //          
142 pingvin 168
 
118 pingvin 169
    int pointer_index; // -   
170
    QString parentObject_id;
109 pingvin 171
 
115 pingvin 172
 
106 pingvin 173
    QMap <QString, QString> class_list_map;
147 pingvin 174
    QMap <int, QTreeWidgetItem*> models_items; //   ( )       
109 pingvin 175
    void getDatabaseData();
176
    void buildTree(QTreeWidgetItem * model_item);
177
    QString getClassInctance(QString class_id); //    -   
110 pingvin 178
    void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); //   
179
    void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); //   
112 pingvin 180
    void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// //   
181
    QString getPointerFieldName(QString parent_class_id, QString chield_class_id); //   ,        
93 pingvin 182
 
128 pingvin 183
    QMap <QString, QString> getPointersList(QString class_id); //    -,      -
184
                                                                //      -   
147 pingvin 185
 
186
 
174 pingvin 187
    QMap <QString, QPixmap> getClassesIcons(); //     
188
                                                //     ID ,     -  
189
 
195 pingvin 190
 
191
    QMap <QString, QPixmap> getObjectsIcon(QString inctance); //     
192
    //     ID ,     -  
193
 
194
 
158 pingvin 195
    QStringList getDataFieldList(QString class_id); //     c  ""
147 pingvin 196
 
158 pingvin 197
 
198
 
199
    QStringList getBoolFieldList(QString class_id); //     c  "bool"
200
 
201
 
200 pingvin 202
    QStringList getFileFieldList(QString class_id); //    ,    "
188 pingvin 203
 
200 pingvin 204
 
222 pingvin 205
    QString getFiltrString(QString model_id, QString class_id); //  -     
200 pingvin 206
 
222 pingvin 207
 
230 pingvin 208
    QList<TField> getFieldList(QString class_id);//    
209
 
210
 
188 pingvin 211
    int getIconFieldIndex(QString inctance); //     
212
 
228 pingvin 213
 
214
    void buildReport(bool advanced); //      OpenOffice,  advanced     
215
    // QTreeWidgetItem * model_item
216
 
217
    void getReport(QTreeWidgetItem * model_item, bool advanced); //       advanced     
218
 
219
    void printChild(QTreeWidgetItem * model_item, QString filtr, bool advanced, int pos);//    
220
 
229 pingvin 221
    void newPage(int page_number);//    
222
    void newPage();//    
228 pingvin 223
 
126 pingvin 224
    SpinBoxDelegate spinDelegate;
130 pingvin 225
    QItemDelegate standart_delegate;
138 pingvin 226
    CPictureDelegate * picture_delegate;
189 pingvin 227
    IconDelegate * iconDelegate;
224 pingvin 228
    FileDelegate * fileDelegate; //     ,     
219 pingvin 229
    FilterSpinBoxDelegate filterSpinDelegate;
230
    FilterConditionDelegate filterConditionDelegate, filterConditionDelegate_1, filterConditionDelegate_2;
224 pingvin 231
    FilterValueDelegate filterValueDelegate; //     ,      
232
 
152 pingvin 233
    bool comboBox_slot_enable; //   ,   item_index  ,   
159 pingvin 234
    QList <int> boolFieldsIndexes_global; //      "BOOL"
115 pingvin 235
 
174 pingvin 236
    QMap <QString, QPixmap> classesIcons;
132 pingvin 237
 
233 pingvin 238
    QTextDocument * doc;
228 pingvin 239
    QTextCursor * cursor;
132 pingvin 240
 
241
 
242
 
106 pingvin 243
private slots:
244
    void on_comboBox_currentIndexChanged( int index );
245
    void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
246
    void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
115 pingvin 247
    void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
119 pingvin 248
    void on_pushButton_clicked(); //   " "
249
    void on_pushButton_2_clicked();//   "  "
250
    void on_pushButton_3_clicked();//   ""
251
    void on_pushButton_4_clicked();//   " "
144 pingvin 252
    void on_pushButton_5_clicked();//   "  "
253
    void on_pushButton_6_clicked();//   "  "
146 pingvin 254
    void on_pushButton_7_clicked();//   "" (  )
255
    void on_pushButton_8_clicked();//   "" (  )
217 pingvin 256
    void on_pushButton_9_clicked();//   " " (  )
257
    void on_pushButton_10_clicked();//   " " (  )
258
    void on_pushButton_11_clicked();//   "" (  )
259
    void on_pushButton_12_clicked();//   " " (  )
233 pingvin 260
    void on_pushButton_13_clicked();//   "  " (  )
261
    void on_pushButton_14_clicked();//   "  " (  )
262
    void on_pushButton_15_clicked();//   "" (  )
263
    void on_pushButton_16_clicked();//   "  PDF" (  )
264
    void on_pushButton_17_clicked();//   "  OpenOffice" (  )
238 pingvin 265
    void on_pushButton_18_clicked();//   "  OpenOffice" (  )
217 pingvin 266
 
238 pingvin 267
 
119 pingvin 268
    void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
146 pingvin 269
    void on_model_for_ListModelsTable_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
221 pingvin 270
    void on_filter_model_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); //       
132 pingvin 271
    void applySetting();
272
    void getSetting(); //   
238 pingvin 273
    void readStandartProcessOutput();
274
    void readStandartProcessError();
275
 
276
 
277
 
278
 
88 pingvin 279
};
280
 
105 pingvin 281
 
282
 
283
 
88 pingvin 284
#endif // MAINWINDOW_H