Rev 241 |
Rev 243 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
//#include "mysql.h"
#include "mymodel.h"
#include "settingform.h"
#include "delegate.h"
// #include "fileform.h"
#include "treedelegateform.h"
#include "wmithread.h"
#include <QMainWindow>
#include <QStandardItemModel>
#include <QStandardItem>
#include <QTreeWidgetItem>
#include <QTextCodec>
#include <QSqlDatabase>
#include <QtGui>
#include <QString>
#include <QtSql>
#include <QFont>
#include <QColor>
#include <QItemDelegate>
#include <QList>
#include <QPalette>
/*
#include <QSqlField>
#include <QSqlRecord>
#include <QSqlTableModel>
#include <QSqlQueryModel>
#include <QTableView>
#include <QSqlDriverPlugin>
#include <QIcon>
#include <QVariant>
#include <QProcess>
#include <QByteArray>
*/
typedef struct Class {
QString name;
QString ID;
} TClass;
typedef struct wmiVideoCard {
QString name; // íàçâàíèå âèäåîêàðòû
QString manufacturer; // ïðîèçâîäèòåëü
QString model;
} TWmiVideoCard;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
//FileForm fileForm;
volatile bool all_reading;
TreeDelegateForm treeForm;
settingForm setFrm;
//ïåðåìåííûå äëÿ ñîåäèíåíèÿ ñ áàçîé
QString baseName;
QString hostName;
QString userName;
QString password;
QString tableName;
void readSettings();
void writeSettings();
QProcess wmiProcess;
QList<QTreeWidgetItem *> root_items_list;
QStandardItemModel *model;
QStandardItem *item;
QTreeWidgetItem *rootItem1, *rootItem2;
void openBase();
bool readModel();
void setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row, QString model_id); // row - íîìåð ñòðîêè â òàáëèöå ìîäåëåé, ñîîòâåòñòâóþùèé äàííîé ìîäåëè
QString creatModelString(QTreeWidgetItem* model);
QString modelString; // ñòðîêà, îïèñûâàþùàÿ ìîäåëü ïðåäñòàâëåíèÿ
void addChildsString(QTreeWidgetItem *parentItem, int level);
QSqlDatabase sql;
bool model_is_build; // ôëàã ãîâîðèò, ïîñòðîåíà ëè ìîäêëü (true) èëè íåò (false)
bool openDataBase();
bool buildPreviewModel(QString modelName, QString rootClassID);
bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row);
QString ClassName(QString class_id); //âîçâðàùàåò èìÿ êëàññà ïî åãî ID
void addChildsItems(QTreeWidgetItem *perent_class_item, int row); // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì
QStringList classChields(QString class_id);
QMap <QString, QString> getClassList(); // ïîëó÷àåì ñïèñîê êëàññîâ
QMap <QString, QString> getFieldsList(QString class_id); // ïîëó÷àåì ñïèñîê ïîëåé êëàññà
void initComboBox();
QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé)
TWmiVideoCard getWmiVideoGard(QString host, QString user_name, QString password);
WmiThread wmiThread;
/////// QSqlTableModel * sql_mogel;
MyModel * sql_mogel;
//// MyModel * filter_model;
QSqlTableModel * filter_model;
QSqlTableModel * model_for_ListModelsTable;
void initListModelsTablle();
void readModels(); // ñ÷èòûâàåì ñïèñîê ìîäåëåé èç áàçû äàííûõ è ñòðîèì äåðåâî ìîäåëåé
int pointer_index; //èíäåêñ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ
QString parentObject_id;
QMap <QString, QString> class_list_map;
QMap <int, QTreeWidgetItem*> models_items; // ñïèñîê èòåìîâ (êîðíåâûõ )ìîäåëåé è ñîîòâåòñòâóþùèõ èì ñòðîê â òàáëèöå ìîäåëåé
void getDatabaseData();
void buildTree(QTreeWidgetItem * model_item);
QString getClassInctance(QString class_id); // ïîëó÷àåì èìÿ òàáëèöû - õðàíèëèùà îáúåêòîâ êëàññà
void showClassObjects(QTreeWidgetItem * parent_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà
void showObjectChildrens(QString object_ID, QTreeWidgetItem * object_item, QTreeWidgetItem * model_item); // îòîáðàçèì îáúåêòû êëàññîâà
void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// // îòîáðàçèì îáúåêòû êëàññîâà
QString getPointerFieldName(QString parent_class_id, QString chield_class_id); // îïðåäåëÿåì èìÿ ïîëÿ, â êîòîðîì õðÿíÿòñÿ óêàçàòåëè íà îáúåêòû ðîäèòåëüñêîãî êëàññà
QMap <QString, QString> getPointersList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé-óêàçàòåëåé, â êà÷åñòâå êëþ÷åé ïîëó÷èì èìåíà ïîëåé-óêàçàòåëåé
// â êà÷åñòâå çíà÷åíèé ïîëó÷èì ñïèñîê òàáëèö-õðàíèëèù îáúåêòîâ ðîäèòåëüñêèõ êëàññîâ
QMap <QString, QPixmap> getClassesIcons(); // ïîëó÷àåì ñïèñîê èêîíîê äëÿ êëàññîâ
// â êà÷åñòâå êëþ÷à ïîëó÷èì ID êëàññà, à â êà÷åñòâå çíà÷åíèé - èçîáðàæåíèÿ èêîíîê
QMap <QString, QPixmap> getObjectsIcon(QString inctance); // ïîëó÷àåì ñïèñîê èêîíîê äëÿ îáúåêòîâ
// â êà÷åñòâå êëþ÷à ïîëó÷èì ID îáúåêòà, à â êà÷åñòâå çíà÷åíèé - èçîáðàæåíèÿ èêîíîê
QStringList getDataFieldList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé c òèïîì "Äàòà"
QStringList getBoolFieldList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé c òèïîì "bool"
QStringList getFileFieldList(QString class_id); // ïîëó÷àåì ñïèñîê âñåõ ïîëåé, â êîòîðûõ õðàíÿòüñÿ ôàéëû"
QString getFiltrString(QString model_id, QString class_id); // ïîëó÷àåì ñòðîêó-ôèëüòð äëÿ äàííîãî êëàññà äàííîé ìîäåëè
QList<TField> getFieldList(QString class_id);// ïîëó÷àåì ñïèñîê ïîëåé êëàññà
int getIconFieldIndex(QString inctance); // ïîëó÷àåì íîìåð ñòîëáöà ñ èêîíêàìè
void buildReport(bool advanced); // ñîçäàåì îò÷åò è ýêñïîðòèðóåì â OpenOffice, ïåðåìåííàÿ advanced óêàçûâàåò áóäåò ëè îò÷åò ðàñøèðåííûì
// QTreeWidgetItem * model_item
void getReport(QTreeWidgetItem * model_item, bool advanced); // ñîçäàåò îò÷åò äëÿ êîíêðåòíîé ìîäåëè ïåðåìåííàÿ advanced óêàçûâàåò áóäåò ëè îò÷åò ðàñøèðåííûì
void printChild(QTreeWidgetItem * model_item, QString filtr, bool advanced, int pos);//â ðàïîðò äîáàâëÿåì äî÷åðíèå êëàññû
void newPage(int page_number);//â ðàïîðò âñòàâëÿåì íîâóþ ñòðàíèöó
void newPage();//â ðàïîðò âñòàâëÿåì íîâóþ ñòðàíèöó
SpinBoxDelegate spinDelegate;
QItemDelegate standart_delegate;
CPictureDelegate * picture_delegate;
IconDelegate * iconDelegate;
FileDelegate * fileDelegate; // äåëåãàò äëÿ òàáëèöû ñ ôèëüòðàìè, áóäåò îòîáðàæàòü ñïèñîê ïîëåé êëàññà
FilterSpinBoxDelegate filterSpinDelegate;
FilterConditionDelegate filterConditionDelegate, filterConditionDelegate_1, filterConditionDelegate_2;
FilterValueDelegate filterValueDelegate; // äåëåãàò äëÿ òàáëèöû ñ ôèëüòðàìè, áóäåò îòîáðàæàòü ñïèñîê çíà÷åíèé îáúåêòîâ êëàññà
bool comboBox_slot_enable; // äëÿ áëîêèðîâêè ñëîòà, êîãäà ìåíÿåì item_index èç ïðîãðàììû, à íå âðó÷íóþ
QList <int> boolFieldsIndexes_global; // ñïèñîê íîìåðîâ ñòîëáöîâ ñ òèïîì "BOOL"
QMap <QString, QPixmap> classesIcons;
QTextDocument * doc;
QTextCursor * cursor;
private slots:
void on_comboBox_currentIndexChanged( int index );
void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
void on_pushButton_clicked(); // íàæàòèå êíîïêè "Äîáàâèòü îáúåêò"
void on_pushButton_2_clicked();// íàæàòèå êíîïêè "Óäàëèòü âûäåëåííûå îáúåêòû"
void on_pushButton_3_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü"
void on_pushButton_4_clicked();// íàæàòèå êíîïêè "Ñáðîñèòü èçìåíåíèÿ"
void on_pushButton_5_clicked();// íàæàòèå êíîïêè "Äîáàâèòü ìîäåëü "
void on_pushButton_6_clicked();// íàæàòèå êíîïêè "Óäàëèòü ìîäåëü "
void on_pushButton_7_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü" (íà âêëàäêå ìîäåëåé)
void on_pushButton_8_clicked();// íàæàòèå êíîïêè "Îòìåíèòü" (íà âêëàäêå ìîäåëåé)
void on_pushButton_9_clicked();// íàæàòèå êíîïêè "Äîáàâèòü ôèëüòð" (íà âêëàäêå ôèëüòðîâ)
void on_pushButton_10_clicked();// íàæàòèå êíîïêè "Óäàëèòü ôèëüòð" (íà âêëàäêå ôèëüòðîâ)
void on_pushButton_11_clicked();// íàæàòèå êíîïêè "Ïðèìåíèòü" (íà âêëàäêå ôèëüòðîâ)
void on_pushButton_12_clicked();// íàæàòèå êíîïêè "Ñáðîñèòü èçìåíåíèÿ" (íà âêëàäêå ôèëüòðîâ)
void on_pushButton_13_clicked();// íàæàòèå êíîïêè "Ñôîðìèðîâàòü êðàòêèé îò÷åò" (íà âêëàäêå îò÷åòîâ)
void on_pushButton_14_clicked();// íàæàòèå êíîïêè "Ñôîðìèðîâàòü ïîëíûé îò÷åò" (íà âêëàäêå îò÷åòîâ)
void on_pushButton_15_clicked();// íàæàòèå êíîïêè "Ïå÷àòü" (íà âêëàäêå îò÷åòîâ)
void on_pushButton_16_clicked();// íàæàòèå êíîïêè "Ïå÷àòü â PDF" (íà âêëàäêå îò÷åòîâ)
void on_pushButton_17_clicked();// íàæàòèå êíîïêè "Ýêñïîðò â OpenOffice" (íà âêëàäêå îò÷åòîâ)
void on_pushButton_18_clicked();// íàæàòèå êíîïêè "Ýêñïîðò â OpenOffice" (íà âêëàäêå îò÷åòîâ)
void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò
void on_model_for_ListModelsTable_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò
void on_filter_model_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà ôèëüòðà èëè äîáàâèëè íîâûé ôèëüòð
void applySetting();
void getSetting(); // îòêðîåì îêíî íàñòðîåê
void readStandartProcessOutput();
void readStandartProcessError();
};
#endif // MAINWINDOW_H