Редакция 249 | Редакция 251 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 249 | Редакция 250 | ||
---|---|---|---|
1 | #include "mainwindow.h"
|
1 | #include "mainwindow.h"
|
2 | #include "ui_mainwindow.h"
|
2 | #include "ui_mainwindow.h"
|
3 | 3 | ||
4 | MainWindow::MainWindow(QWidget *parent) : |
4 | MainWindow::MainWindow(QWidget *parent) : |
5 | QMainWindow(parent), |
5 | QMainWindow(parent), |
6 | ui(new Ui::MainWindow) |
6 | ui(new Ui::MainWindow) |
7 | {
|
7 | {
|
8 | ui->setupUi(this); |
8 | ui->setupUi(this); |
9 | /*
|
9 | /*
|
10 | QPalette p = this->palette();
|
10 | QPalette p = this->palette();
|
11 | p.setBrush(this->backgroundRole(), QBrush(QColor(255,255,255,128)));
|
11 | p.setBrush(this->backgroundRole(), QBrush(QColor(255,255,255,128)));
|
12 | this->setAutoFillBackground(true);
|
12 | this->setAutoFillBackground(true);
|
13 | this->setPalette(p);
|
13 | this->setPalette(p);
|
14 | */
|
14 | */
|
15 | 15 | ||
16 | ui->centralWidget->setLayout(ui->verticalLayout); |
16 | ui->centralWidget->setLayout(ui->verticalLayout); |
17 | ui->tab->setLayout(ui->horizontalLayout); |
17 | ui->tab->setLayout(ui->horizontalLayout); |
18 | ui->tab_2->setLayout(ui->horizontalLayout_3); |
18 | ui->tab_2->setLayout(ui->horizontalLayout_3); |
19 | ui->tab_3->setLayout(ui->horizontalLayout_7); |
19 | ui->tab_3->setLayout(ui->horizontalLayout_7); |
20 | ui->tab_4->setLayout(ui->horizontalLayout_8); |
20 | ui->tab_4->setLayout(ui->horizontalLayout_8); |
21 | // connect( ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int)));
|
21 | // connect( ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int)));
|
22 | model_is_build = false; |
22 | model_is_build = false; |
23 | // MainWindow::readModel();
|
23 | // MainWindow::readModel();
|
24 | 24 | ||
25 | //QString model_str;
|
25 | //QString model_str;
|
26 | 26 | ||
27 | 27 | ||
28 | /*
|
28 | /*
|
29 | MainWindow::creatModelString();
|
29 | MainWindow::creatModelString();
|
30 | int i;
|
30 | int i;
|
31 | i++;
|
31 | i++;
|
32 | QFile file_tmp("./temp.txt");
|
32 | QFile file_tmp("./temp.txt");
|
33 | bool ok;
|
33 | bool ok;
|
34 | ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
|
34 | ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
|
35 | QTextStream out(&file_tmp);
|
35 | QTextStream out(&file_tmp);
|
36 | out << MainWindow::modelString;
|
36 | out << MainWindow::modelString;
|
37 | file_tmp.close();
|
37 | file_tmp.close();
|
38 | */
|
38 | */
|
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | 42 | ||
43 | ui->treeWidget->setAlternatingRowColors(true); |
43 | ui->treeWidget->setAlternatingRowColors(true); |
44 | ui->treeWidget_2->setAlternatingRowColors(true); |
44 | ui->treeWidget_2->setAlternatingRowColors(true); |
45 | 45 | ||
46 | ui->treeWidget->setIconSize(QSize(30,30)); |
46 | ui->treeWidget->setIconSize(QSize(30,30)); |
47 | ui->treeWidget->setColumnWidth(0, 400); |
47 | ui->treeWidget->setColumnWidth(0, 400); |
48 | ui->treeWidget_2->setIconSize(QSize(128,128)); |
48 | ui->treeWidget_2->setIconSize(QSize(128,128)); |
49 | 49 | ||
50 | MainWindow::readSettings(); |
50 | MainWindow::readSettings(); |
51 | 51 | ||
52 | MainWindow::openDataBase(); |
52 | MainWindow::openDataBase(); |
53 | 53 | ||
54 | classesIcons = MainWindow::getClassesIcons(); // ïîëó÷èì èêîíêè äëÿ êëàññîâ |
54 | classesIcons = MainWindow::getClassesIcons(); // ïîëó÷èì èêîíêè äëÿ êëàññîâ |
55 | 55 | ||
56 | MainWindow::initComboBox(); |
56 | MainWindow::initComboBox(); |
57 | 57 | ||
58 | // MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("11"));
|
58 | // MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("11"));
|
59 | 59 | ||
60 | MainWindow::initListModelsTablle(); |
60 | MainWindow::initListModelsTablle(); |
61 | 61 | ||
62 | MainWindow::readModels(); |
62 | MainWindow::readModels(); |
63 | 63 | ||
- | 64 | initWmiTree(); |
|
- | 65 | ||
- | 66 | ||
64 | // MainWindow::creatModelString();
|
67 | // MainWindow::creatModelString();
|
65 | //int i;
|
68 | //int i;
|
66 | //i++;
|
69 | //i++;
|
67 | 70 | ||
68 | /*
|
71 | /*
|
69 | QFile file_tmp("./modelstring.txt");
|
72 | QFile file_tmp("./modelstring.txt");
|
70 | bool ok;
|
73 | bool ok;
|
71 | file_tmp.remove();
|
74 | file_tmp.remove();
|
72 | ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
|
75 | ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
|
73 | QTextStream out(&file_tmp);
|
76 | QTextStream out(&file_tmp);
|
74 | out.setCodec("cp1251");
|
77 | out.setCodec("cp1251");
|
75 | out << MainWindow::modelString;
|
78 | out << MainWindow::modelString;
|
76 | file_tmp.close();
|
79 | file_tmp.close();
|
77 | */
|
80 | */
|
78 | 81 | ||
79 | 82 | ||
80 | ui->treeWidget_2->hideColumn(1); |
83 | ui->treeWidget_2->hideColumn(1); |
81 | ui->treeWidget_2->hideColumn(2); |
84 | ui->treeWidget_2->hideColumn(2); |
82 | ui->treeWidget_2->hideColumn(3); |
85 | ui->treeWidget_2->hideColumn(3); |
83 | ui->treeWidget_2->hideColumn(4); |
86 | ui->treeWidget_2->hideColumn(4); |
84 | ui->treeWidget_2->hideColumn(5); |
87 | ui->treeWidget_2->hideColumn(5); |
85 | 88 | ||
86 | 89 | ||
87 | getDatabaseData(); |
90 | getDatabaseData(); |
88 | //// sql_mogel = new QSqlTableModel();
|
91 | //// sql_mogel = new QSqlTableModel();
|
89 | sql_mogel = new MyModel(); |
92 | sql_mogel = new MyModel(); |
90 | 93 | ||
91 | /// filter_model = new MyModel();
|
94 | /// filter_model = new MyModel();
|
92 | filter_model = new QSqlTableModel(); |
95 | filter_model = new QSqlTableModel(); |
93 | filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
96 | filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
94 | 97 | ||
95 | model_is_build = true; |
98 | model_is_build = true; |
96 | connect(sql_mogel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_sql_mogel_dataChanged(QModelIndex,QModelIndex))); |
99 | connect(sql_mogel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_sql_mogel_dataChanged(QModelIndex,QModelIndex))); |
97 | connect(model_for_ListModelsTable, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_model_for_ListModelsTable_dataChanged(QModelIndex,QModelIndex))); |
100 | connect(model_for_ListModelsTable, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_model_for_ListModelsTable_dataChanged(QModelIndex,QModelIndex))); |
98 | connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
101 | connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
99 | connect(&wmiProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput())); |
102 | connect(&wmiProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput())); |
100 | connect(&wmiProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError())); |
103 | connect(&wmiProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError())); |
101 | 104 | ||
102 | 105 | ||
103 | ui->pushButton_3->setEnabled(false); |
106 | ui->pushButton_3->setEnabled(false); |
104 | ui->pushButton_4->setEnabled(false); |
107 | ui->pushButton_4->setEnabled(false); |
105 | 108 | ||
106 | 109 | ||
107 | ui->pushButton_9->setEnabled(false); |
110 | ui->pushButton_9->setEnabled(false); |
108 | ui->pushButton_10->setEnabled(false); |
111 | ui->pushButton_10->setEnabled(false); |
109 | ui->pushButton_11->setEnabled(false); |
112 | ui->pushButton_11->setEnabled(false); |
110 | ui->pushButton_12->setEnabled(false); |
113 | ui->pushButton_12->setEnabled(false); |
111 | 114 | ||
112 | // setFrm.show();
|
115 | // setFrm.show();
|
113 | 116 | ||
114 | // treeForm.show();
|
117 | // treeForm.show();
|
115 | 118 | ||
116 | connect(ui->getsettingAct, SIGNAL(triggered()), this, SLOT(getSetting())); // âûáîð â ãëàâíîé ôîðìå â ìåíþ "Áàçà äàííûõ" ïóíêòà "Ïàðàìåòðû ñîåäèíåíèÿ" |
119 | connect(ui->getsettingAct, SIGNAL(triggered()), this, SLOT(getSetting())); // âûáîð â ãëàâíîé ôîðìå â ìåíþ "Áàçà äàííûõ" ïóíêòà "Ïàðàìåòðû ñîåäèíåíèÿ" |
117 | connect(setFrm.pushButton, SIGNAL(clicked()), this, SLOT(applySetting())); |
120 | connect(setFrm.pushButton, SIGNAL(clicked()), this, SLOT(applySetting())); |
118 | 121 | ||
119 | // connect(ui->tableView_2,SIGNAL(activated(QModelIndex)),ui->tableView_2,SLOT(edit(QModelIndex)));
|
122 | // connect(ui->tableView_2,SIGNAL(activated(QModelIndex)),ui->tableView_2,SLOT(edit(QModelIndex)));
|
120 | 123 | ||
121 | picture_delegate = new CPictureDelegate(this); |
124 | picture_delegate = new CPictureDelegate(this); |
122 | iconDelegate = new IconDelegate(this); |
125 | iconDelegate = new IconDelegate(this); |
123 | fileDelegate = new FileDelegate(this); |
126 | fileDelegate = new FileDelegate(this); |
124 | 127 | ||
125 | // fileForm.show();
|
128 | // fileForm.show();
|
126 | 129 | ||
127 | doc = ui->textEdit->document(); |
130 | doc = ui->textEdit->document(); |
128 | cursor = new QTextCursor(doc); |
131 | cursor = new QTextCursor(doc); |
129 | // buildReport(true);
|
132 | // buildReport(true);
|
130 | 133 | ||
131 | all_reading = false; // íåò ïðî÷èòàííûõ äàííûõ èç ïðîöåññà |
134 | all_reading = false; // íåò ïðî÷èòàííûõ äàííûõ èç ïðîöåññà |
132 | // wmiThread = new WmiThread(this);
|
135 | // wmiThread = new WmiThread(this);
|
133 | 136 | ||
134 | }
|
137 | }
|
135 | 138 | ||
136 | MainWindow::~MainWindow() |
139 | MainWindow::~MainWindow() |
137 | {
|
140 | {
|
138 | delete sql_mogel; |
141 | delete sql_mogel; |
139 | delete filter_model; |
142 | delete filter_model; |
140 | delete ui; |
143 | delete ui; |
141 | delete model_for_ListModelsTable; |
144 | delete model_for_ListModelsTable; |
142 | }
|
145 | }
|
143 | 146 | ||
144 | void MainWindow::changeEvent(QEvent *e) |
147 | void MainWindow::changeEvent(QEvent *e) |
145 | {
|
148 | {
|
146 | QMainWindow::changeEvent(e); |
149 | QMainWindow::changeEvent(e); |
147 | switch (e->type()) { |
150 | switch (e->type()) { |
148 | case QEvent::LanguageChange: |
151 | case QEvent::LanguageChange: |
149 | ui->retranslateUi(this); |
152 | ui->retranslateUi(this); |
150 | break; |
153 | break; |
151 | default: |
154 | default: |
152 | break; |
155 | break; |
153 | }
|
156 | }
|
154 | }
|
157 | }
|
155 | 158 | ||
156 | 159 | ||
157 | bool MainWindow::readModel(){ |
160 | bool MainWindow::readModel(){ |
158 | bool result; |
161 | bool result; |
159 | QString model_str;
|
162 | QString model_str;
|
160 | QFile file("modelstring.txt"); |
163 | QFile file("modelstring.txt"); |
161 | // QFile file("model.txt");
|
164 | // QFile file("model.txt");
|
162 | rootItem1 = new QTreeWidgetItem(ui->treeWidget); |
165 | rootItem1 = new QTreeWidgetItem(ui->treeWidget); |
163 | rootItem1->setText(0, tr("Óðîâåíü 1")); |
166 | rootItem1->setText(0, tr("Óðîâåíü 1")); |
164 | // rootItem2 = new QTreeWidgetItem(rootItem1);
|
167 | // rootItem2 = new QTreeWidgetItem(rootItem1);
|
165 | // rootItem2->setText(0, tr("óðîâåíü 2"));
|
168 | // rootItem2->setText(0, tr("óðîâåíü 2"));
|
166 | rootItem1->setCheckState(0,Qt::Checked); |
169 | rootItem1->setCheckState(0,Qt::Checked); |
167 | // rootItem2->setCheckState(0,Qt::Checked);
|
170 | // rootItem2->setCheckState(0,Qt::Checked);
|
168 | 171 | ||
169 | 172 | ||
170 | 173 | ||
171 | result = file.open(QIODevice::ReadOnly); |
174 | result = file.open(QIODevice::ReadOnly); |
172 | if (result) { |
175 | if (result) { |
173 | model_str = QString(tr(file.readAll())); |
176 | model_str = QString(tr(file.readAll())); |
174 | }
|
177 | }
|
175 | 178 | ||
176 | setupModelData(model_str.split(QString("\n")), rootItem1, -1, tr("1")); |
179 | setupModelData(model_str.split(QString("\n")), rootItem1, -1, tr("1")); |
177 | 180 | ||
178 | 181 | ||
179 | return result; |
182 | return result; |
180 | 183 | ||
181 | }
|
184 | }
|
182 | 185 | ||
183 | 186 | ||
184 | void MainWindow::setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row, QString model_id) |
187 | void MainWindow::setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row, QString model_id) |
185 | {
|
188 | {
|
186 | QList<QTreeWidgetItem*> parents; |
189 | QList<QTreeWidgetItem*> parents; |
187 | QList<int> indentations; |
190 | QList<int> indentations; |
188 | parents << parent; |
191 | parents << parent; |
189 | indentations << 0; |
192 | indentations << 0; |
190 | 193 | ||
191 | int number = 0; |
194 | int number = 0; |
192 | 195 | ||
193 | while (number < lines.count()) { |
196 | while (number < lines.count()) { |
194 | int position = 0; |
197 | int position = 0; |
195 | while (position < lines[number].length()) { |
198 | while (position < lines[number].length()) { |
196 | if (lines[number].mid(position, 1) != " ") |
199 | if (lines[number].mid(position, 1) != " ") |
197 | break; |
200 | break; |
198 | position++; |
201 | position++; |
199 | }
|
202 | }
|
200 | 203 | ||
201 | QString lineData = lines[number].mid(position).trimmed(); |
204 | QString lineData = lines[number].mid(position).trimmed(); |
202 | 205 | ||
203 | if (!lineData.isEmpty()) { |
206 | if (!lineData.isEmpty()) { |
204 | // Read the column data from the rest of the line.
|
207 | // Read the column data from the rest of the line.
|
205 | QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts); |
208 | QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts); |
206 | QList<QVariant> columnData; |
209 | QList<QVariant> columnData; |
207 | for (int column = 0; column < columnStrings.count(); ++column) |
210 | for (int column = 0; column < columnStrings.count(); ++column) |
208 | columnData << columnStrings[column]; |
211 | columnData << columnStrings[column]; |
209 | 212 | ||
210 | if (position > indentations.last()) { |
213 | if (position > indentations.last()) { |
211 | // The last child of the current parent is now the new parent
|
214 | // The last child of the current parent is now the new parent
|
212 | // unless the current parent has no children.
|
215 | // unless the current parent has no children.
|
213 | 216 | ||
214 | if (parents.last()->childCount() > 0) { |
217 | if (parents.last()->childCount() > 0) { |
215 | parents << parents.last()->child(parents.last()->childCount()-1); |
218 | parents << parents.last()->child(parents.last()->childCount()-1); |
216 | indentations << position; |
219 | indentations << position; |
217 | }
|
220 | }
|
218 | } else { |
221 | } else { |
219 | while (position < indentations.last() && parents.count() > 0) { |
222 | while (position < indentations.last() && parents.count() > 0) { |
220 | parents.pop_back(); |
223 | parents.pop_back(); |
221 | indentations.pop_back(); |
224 | indentations.pop_back(); |
222 | }
|
225 | }
|
223 | }
|
226 | }
|
224 | 227 | ||
225 | // Append a new item to the current parent's list of children.
|
228 | // Append a new item to the current parent's list of children.
|
226 | // // // parents.last()->appendChild(new QTreeWidgetItem(columnData, parents.last()));
|
229 | // // // parents.last()->appendChild(new QTreeWidgetItem(columnData, parents.last()));
|
227 | QTreeWidgetItem* itm_tmp; |
230 | QTreeWidgetItem* itm_tmp; |
228 | itm_tmp = new QTreeWidgetItem( parents.last()); |
231 | itm_tmp = new QTreeWidgetItem( parents.last()); |
229 | // itm_tmp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
232 | // itm_tmp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
230 | 233 | ||
231 | /*
|
234 | /*
|
232 | QLineEdit * edit_line;
|
235 | QLineEdit * edit_line;
|
233 | edit_line = new QLineEdit(this);
|
236 | edit_line = new QLineEdit(this);
|
234 | ui->treeWidget->setItemWidget(itm_tmp, 5, edit_line);
|
237 | ui->treeWidget->setItemWidget(itm_tmp, 5, edit_line);
|
235 | */
|
238 | */
|
236 | //static QStandartDelegate delegate;
|
239 | //static QStandartDelegate delegate;
|
237 | ui->treeWidget->setItemDelegateForColumn(5, &standart_delegate); |
240 | ui->treeWidget->setItemDelegateForColumn(5, &standart_delegate); |
238 | 241 | ||
239 | 242 | ||
240 | itm_tmp->setText(0, QString(columnData.at(0).toString())); |
243 | itm_tmp->setText(0, QString(columnData.at(0).toString())); |
241 | if (columnData.at(1).toString() == "true") { |
244 | if (columnData.at(1).toString() == "true") { |
242 | itm_tmp->setCheckState(0,Qt::Checked); |
245 | itm_tmp->setCheckState(0,Qt::Checked); |
243 | }
|
246 | }
|
244 | else itm_tmp->setCheckState(0,Qt::Unchecked); |
247 | else itm_tmp->setCheckState(0,Qt::Unchecked); |
245 | if (columnData.count()>2) |
248 | if (columnData.count()>2) |
246 | {
|
249 | {
|
247 | QString class_id;
|
250 | QString class_id;
|
248 | QString filtr_str;
|
251 | QString filtr_str;
|
249 | QPixmap pxmp;
|
252 | QPixmap pxmp;
|
250 | QIcon icon;
|
253 | QIcon icon;
|
251 | class_id = QString(columnData.at(2).toString()); |
254 | class_id = QString(columnData.at(2).toString()); |
252 | pxmp = MainWindow::classesIcons.value(class_id); |
255 | pxmp = MainWindow::classesIcons.value(class_id); |
253 | 256 | ||
254 | // itm_tmp->setText(1, QString(columnData.at(2).toString())); // id êëàññà
|
257 | // itm_tmp->setText(1, QString(columnData.at(2).toString())); // id êëàññà
|
255 | itm_tmp->setText(1, class_id); // id êëàññà |
258 | itm_tmp->setText(1, class_id); // id êëàññà |
256 | itm_tmp->setText(6, model_id); // id ìîäåëè |
259 | itm_tmp->setText(6, model_id); // id ìîäåëè |
257 | itm_tmp->setText(2, QVariant(number).toString()); // íîìåð ñòðîêè â ôàéëå-ìîäåëè îòîáðàæåíèÿ |
260 | itm_tmp->setText(2, QVariant(number).toString()); // íîìåð ñòðîêè â ôàéëå-ìîäåëè îòîáðàæåíèÿ |
258 | itm_tmp->setText(3, QVariant(indentations.size()).toString()); // óðîâåíü âëîæåíèÿ |
261 | itm_tmp->setText(3, QVariant(indentations.size()).toString()); // óðîâåíü âëîæåíèÿ |
259 | itm_tmp->setText(4, QVariant(row).toString()); // íîìåð ñòðîêè â ôàéëå |
262 | itm_tmp->setText(4, QVariant(row).toString()); // íîìåð ñòðîêè â ôàéëå |
260 | filtr_str = getFiltrString(model_id,class_id); |
263 | filtr_str = getFiltrString(model_id,class_id); |
261 | itm_tmp->setText(5,filtr_str); |
264 | itm_tmp->setText(5,filtr_str); |
262 | 265 | ||
263 | if (!pxmp.isNull()) |
266 | if (!pxmp.isNull()) |
264 | {
|
267 | {
|
265 | icon.addPixmap(pxmp); |
268 | icon.addPixmap(pxmp); |
266 | itm_tmp->setIcon(0, icon); |
269 | itm_tmp->setIcon(0, icon); |
267 | }
|
270 | }
|
268 | }
|
271 | }
|
269 | }
|
272 | }
|
270 | 273 | ||
271 | number++; |
274 | number++; |
272 | }
|
275 | }
|
273 | }
|
276 | }
|
274 | 277 | ||
275 | 278 | ||
276 | /*
|
279 | /*
|
277 | void MainWindow::openBase()
|
280 | void MainWindow::openBase()
|
278 | {
|
281 | {
|
279 | 282 | ||
280 | db = QSqlDatabase::addDatabase("QMYSQL");
|
283 | db = QSqlDatabase::addDatabase("QMYSQL");
|
281 | pdb = &db;
|
284 | pdb = &db;
|
282 | raportFrm.pdb = &db;
|
285 | raportFrm.pdb = &db;
|
283 | 286 | ||
284 | pdb->setHostName(hostName);
|
287 | pdb->setHostName(hostName);
|
285 | pdb->setDatabaseName(baseName);
|
288 | pdb->setDatabaseName(baseName);
|
286 | pdb->setUserName(userName);
|
289 | pdb->setUserName(userName);
|
287 | pdb->setPassword(password);
|
290 | pdb->setPassword(password);
|
288 | bool ok = pdb->open();
|
291 | bool ok = pdb->open();
|
289 | if (!ok) {
|
292 | if (!ok) {
|
290 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
293 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
291 | this, // Ðîäèòåëüñêèé âèäæåò.
|
294 | this, // Ðîäèòåëüñêèé âèäæåò.
|
292 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
295 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
293 | pdb->lastError().text()); // Òåêñò ñîîáùåíèÿ.
|
296 | pdb->lastError().text()); // Òåêñò ñîîáùåíèÿ.
|
294 | }
|
297 | }
|
295 | if (ok)
|
298 | if (ok)
|
296 | {lineEdit-> insert(tr("Áàçà óñïåøíî îòêðûòà"));
|
299 | {lineEdit-> insert(tr("Áàçà óñïåøíî îòêðûòà"));
|
297 | }
|
300 | }
|
298 | else {lineEdit-> insert(tr("Áàçà íåäîñòóïíà. Êîä îøèáêè: "));
|
301 | else {lineEdit-> insert(tr("Áàçà íåäîñòóïíà. Êîä îøèáêè: "));
|
299 | lineEdit-> insert(pdb->lastError().text());
|
302 | lineEdit-> insert(pdb->lastError().text());
|
300 | }
|
303 | }
|
301 | 304 | ||
302 | 305 | ||
303 | 306 | ||
304 | model = new QSqlTableModel(this);
|
307 | model = new QSqlTableModel(this);
|
305 | model->setTable(tableName);
|
308 | model->setTable(tableName);
|
306 | 309 | ||
307 | model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
310 | model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
308 | model->setSort(0, Qt::AscendingOrder);
|
311 | model->setSort(0, Qt::AscendingOrder);
|
309 | 312 | ||
310 | model->select();
|
313 | model->select();
|
311 | 314 | ||
312 | 315 | ||
313 | QSqlField field(tr("age"), QVariant::Int);
|
316 | QSqlField field(tr("age"), QVariant::Int);
|
314 | field.setValue(QString(tr("123")));
|
317 | field.setValue(QString(tr("123")));
|
315 | 318 | ||
316 | bool okey;
|
319 | bool okey;
|
317 | int index;
|
320 | int index;
|
318 | QSqlRecord record;
|
321 | QSqlRecord record;
|
319 | 322 | ||
320 | 323 | ||
321 | tableView->setModel(model);
|
324 | tableView->setModel(model);
|
322 | view.setModel(model);
|
325 | view.setModel(model);
|
323 | 326 | ||
324 | 327 | ||
325 | tableView->setAlternatingRowColors(true);
|
328 | tableView->setAlternatingRowColors(true);
|
326 | view.setAlternatingRowColors(true);
|
329 | view.setAlternatingRowColors(true);
|
327 | 330 | ||
328 | tableView->resizeColumnsToContents();
|
331 | tableView->resizeColumnsToContents();
|
329 | 332 | ||
330 | 333 | ||
331 | view.resizeColumnsToContents();
|
334 | view.resizeColumnsToContents();
|
332 | 335 | ||
333 | tableView->show();
|
336 | tableView->show();
|
334 | 337 | ||
335 | 338 | ||
336 | 339 | ||
337 | initTreeWidget();
|
340 | initTreeWidget();
|
338 | }
|
341 | }
|
339 | */
|
342 | */
|
340 | 343 | ||
341 | 344 | ||
342 | QString MainWindow::creatModelString(QTreeWidgetItem* model){ |
345 | QString MainWindow::creatModelString(QTreeWidgetItem* model){ |
343 | 346 | ||
344 | MainWindow::modelString.clear(); // î÷èùàåì ñòðîêó ìîäåëè |
347 | MainWindow::modelString.clear(); // î÷èùàåì ñòðîêó ìîäåëè |
345 | // for (int i =0; i < rootItem1->childCount(); ++i )
|
348 | // for (int i =0; i < rootItem1->childCount(); ++i )
|
346 | 349 | ||
347 | {MainWindow::addChildsString(model, 0);} |
350 | {MainWindow::addChildsString(model, 0);} |
348 | 351 | ||
349 | return MainWindow::modelString; |
352 | return MainWindow::modelString; |
350 | // {MainWindow::addChildsString(ui->treeWidget, 0);}
|
353 | // {MainWindow::addChildsString(ui->treeWidget, 0);}
|
351 | /*
|
354 | /*
|
352 | int root_item_child_count;
|
355 | int root_item_child_count;
|
353 | int i;
|
356 | int i;
|
354 | root_item_child_count = rootItem1->childCount();
|
357 | root_item_child_count = rootItem1->childCount();
|
355 | i++;
|
358 | i++;
|
356 | */
|
359 | */
|
357 | }
|
360 | }
|
358 | 361 | ||
359 | 362 | ||
360 | void MainWindow::addChildsString(QTreeWidgetItem *parentItem, int level){ |
363 | void MainWindow::addChildsString(QTreeWidgetItem *parentItem, int level){ |
361 | int child_count; |
364 | int child_count; |
362 | child_count = parentItem->childCount(); |
365 | child_count = parentItem->childCount(); |
363 | for (int i=0; i < child_count; ++i){ |
366 | for (int i=0; i < child_count; ++i){ |
364 | for (int m=0; m < level; ++m){ |
367 | for (int m=0; m < level; ++m){ |
365 | modelString.append(tr(" ")); // ÷åòûðå ïðîáåëà - ïðèçíàê òîãî, ÷òî ýòî íîâûé óðîâåíü âëîæåíèÿ |
368 | modelString.append(tr(" ")); // ÷åòûðå ïðîáåëà - ïðèçíàê òîãî, ÷òî ýòî íîâûé óðîâåíü âëîæåíèÿ |
366 | }
|
369 | }
|
367 | modelString.append(parentItem->child(i)->text(0)); // â ïåðâîé êîëîíêå - èìÿ êëàññà |
370 | modelString.append(parentItem->child(i)->text(0)); // â ïåðâîé êîëîíêå - èìÿ êëàññà |
368 | modelString.append(tr("\t\t\t\t")); // ÷åòûðå òàáóëÿöèè - ïðèçíàê íîâîãî ñòîëáöà |
371 | modelString.append(tr("\t\t\t\t")); // ÷åòûðå òàáóëÿöèè - ïðèçíàê íîâîãî ñòîëáöà |
369 | if (parentItem->child(i)->checkState(0) == Qt::Checked) {modelString.append(tr("true"));} // åñëè ãàëî÷êà ñòîèò, çàíîñèì "true", ýëåìåíòû êëàññà â ïðåäñòàâëåíèè îòîáðàæàòüñÿ áóäóò |
372 | if (parentItem->child(i)->checkState(0) == Qt::Checked) {modelString.append(tr("true"));} // åñëè ãàëî÷êà ñòîèò, çàíîñèì "true", ýëåìåíòû êëàññà â ïðåäñòàâëåíèè îòîáðàæàòüñÿ áóäóò |
370 | else {modelString.append(tr("false"));} // åñëè êëàññ íå âûáðàí - çàíîñèì "false", ýëåìåíòû êëàññà â ïðåäñòàâëåíèè îòîáðàæàòüñÿ íå áóäóò |
373 | else {modelString.append(tr("false"));} // åñëè êëàññ íå âûáðàí - çàíîñèì "false", ýëåìåíòû êëàññà â ïðåäñòàâëåíèè îòîáðàæàòüñÿ íå áóäóò |
371 | modelString.append(tr("\t\t\t\t")); // ÷åòûðå òàáóëÿöèè - ïðèçíàê íîâîãî ñòîëáöà |
374 | modelString.append(tr("\t\t\t\t")); // ÷åòûðå òàáóëÿöèè - ïðèçíàê íîâîãî ñòîëáöà |
372 | modelString.append(parentItem->child(i)->text(1)); // âî âòîðîé êîëîíêå - ID êëàññà |
375 | modelString.append(parentItem->child(i)->text(1)); // âî âòîðîé êîëîíêå - ID êëàññà |
373 | modelString.append(tr("\n")); // êîíåö ñòðîêè |
376 | modelString.append(tr("\n")); // êîíåö ñòðîêè |
374 | if (parentItem->child(i)->childCount() > 0) { MainWindow::addChildsString(parentItem->child(i), level+1);} |
377 | if (parentItem->child(i)->childCount() > 0) { MainWindow::addChildsString(parentItem->child(i), level+1);} |
375 | 378 | ||
376 | }
|
379 | }
|
377 | int i; |
380 | int i; |
378 | i++; |
381 | i++; |
379 | }
|
382 | }
|
380 | 383 | ||
381 | 384 | ||
382 | bool MainWindow::openDataBase(){ |
385 | bool MainWindow::openDataBase(){ |
383 | QString errorString;
|
386 | QString errorString;
|
384 | sql = QSqlDatabase::addDatabase("QMYSQL"); |
387 | sql = QSqlDatabase::addDatabase("QMYSQL"); |
385 | // sql.setDatabaseName(tr("an_db"));
|
388 | // sql.setDatabaseName(tr("an_db"));
|
386 | 389 | ||
387 | // // // sql.setDatabaseName(tr("inventory"));
|
390 | // // // sql.setDatabaseName(tr("inventory"));
|
388 | 391 | ||
389 | sql.setDatabaseName(baseName); |
392 | sql.setDatabaseName(baseName); |
390 | 393 | ||
391 | 394 | ||
392 | 395 | ||
393 | // // // sql.setHostName(tr("localhost"));
|
396 | // // // sql.setHostName(tr("localhost"));
|
394 | 397 | ||
395 | sql.setHostName(hostName); |
398 | sql.setHostName(hostName); |
396 | 399 | ||
397 | 400 | ||
398 | // // // sql.setUserName(tr("an"));
|
401 | // // // sql.setUserName(tr("an"));
|
399 | 402 | ||
400 | sql.setUserName(userName); |
403 | sql.setUserName(userName); |
401 | 404 | ||
402 | 405 | ||
403 | 406 | ||
404 | // // // sql.setPassword(tr("393939"));
|
407 | // // // sql.setPassword(tr("393939"));
|
405 | 408 | ||
406 | 409 | ||
407 | sql.setPassword(password); |
410 | sql.setPassword(password); |
408 | 411 | ||
409 | 412 | ||
410 | 413 | ||
411 | bool ok; |
414 | bool ok; |
412 | ok = sql.open(); |
415 | ok = sql.open(); |
413 | 416 | ||
414 | /*
|
417 | /*
|
415 | if (!ok) {
|
418 | if (!ok) {
|
416 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
419 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
417 | this, // Ðîäèòåëüñêèé âèäæåò.
|
420 | this, // Ðîäèòåëüñêèé âèäæåò.
|
418 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
421 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
419 | sql.lastError().text() ); // Òåêñò ñîîáùåíèÿ.
|
422 | sql.lastError().text() ); // Òåêñò ñîîáùåíèÿ.
|
420 | 423 | ||
421 | 424 | ||
422 | }
|
425 | }
|
423 | 426 | ||
424 | */
|
427 | */
|
425 | if (!ok) { |
428 | if (!ok) { |
426 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
429 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
427 | this, // Ðîäèòåëüñêèé âèäæåò. |
430 | this, // Ðîäèòåëüñêèé âèäæåò. |
428 | QObject::tr("Database Error"), // Çàãîëîâîê. |
431 | QObject::tr("Database Error"), // Çàãîëîâîê. |
429 | sql.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
432 | sql.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
430 | }
|
433 | }
|
431 | else { |
434 | else { |
432 | 435 | ||
433 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
436 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
434 | this, // Ðîäèòåëüñêèé âèäæåò. |
437 | this, // Ðîäèòåëüñêèé âèäæåò. |
435 | QObject::tr("Database Connect"), // Çàãîëîâîê. |
438 | QObject::tr("Database Connect"), // Çàãîëîâîê. |
436 | QObject::tr("Ñîåäèíåíèå ñ áàçîé äàííûõ óñïåøíî óñòàíîâëåíî.")); // Òåêñò ñîîáùåíèÿ. |
439 | QObject::tr("Ñîåäèíåíèå ñ áàçîé äàííûõ óñïåøíî óñòàíîâëåíî.")); // Òåêñò ñîîáùåíèÿ. |
437 | 440 | ||
438 | 441 | ||
439 | 442 | ||
440 | 443 | ||
441 | 444 | ||
442 | }
|
445 | }
|
443 | 446 | ||
444 | return ok; |
447 | return ok; |
445 | }
|
448 | }
|
446 | 449 | ||
447 | 450 | ||
448 | bool MainWindow::buildPreviewModel(QString modelName, QString rootClassID){ |
451 | bool MainWindow::buildPreviewModel(QString modelName, QString rootClassID){ |
449 | QSqlQuery q;
|
452 | QSqlQuery q;
|
450 | QString sql_str;
|
453 | QString sql_str;
|
451 | QString field_name_str;
|
454 | QString field_name_str;
|
452 | QString root_class_name;
|
455 | QString root_class_name;
|
453 | //bool ok;
|
456 | //bool ok;
|
454 | //int field_name;
|
457 | //int field_name;
|
455 | 458 | ||
456 | //ui->treeWidget->clear();
|
459 | //ui->treeWidget->clear();
|
457 | 460 | ||
458 | root_class_name = MainWindow::ClassName(rootClassID); // îïðåäåëÿåì èìÿ êëàññà |
461 | root_class_name = MainWindow::ClassName(rootClassID); // îïðåäåëÿåì èìÿ êëàññà |
459 | 462 | ||
460 | 463 | ||
461 | rootItem1 = new QTreeWidgetItem(ui->treeWidget); |
464 | rootItem1 = new QTreeWidgetItem(ui->treeWidget); |
462 | root_items_list << rootItem1; |
465 | root_items_list << rootItem1; |
463 | rootItem1->setText(0, modelName); |
466 | rootItem1->setText(0, modelName); |
464 | 467 | ||
465 | rootItem1->setCheckState(0,Qt::Checked); |
468 | rootItem1->setCheckState(0,Qt::Checked); |
466 | rootItems.append(rootItem1); |
469 | rootItems.append(rootItem1); |
467 | 470 | ||
468 | 471 | ||
469 | 472 | ||
470 | rootItem2 = new QTreeWidgetItem(rootItem1); |
473 | rootItem2 = new QTreeWidgetItem(rootItem1); |
471 | rootItem2->setText(0, root_class_name); |
474 | rootItem2->setText(0, root_class_name); |
472 | rootItem2->setText(1, rootClassID); |
475 | rootItem2->setText(1, rootClassID); |
473 | rootItem2->setCheckState(0,Qt::Checked); |
476 | rootItem2->setCheckState(0,Qt::Checked); |
474 | 477 | ||
475 | addChildsItems(rootItem2, -1); |
478 | addChildsItems(rootItem2, -1); |
476 | 479 | ||
477 | 480 | ||
478 | /*
|
481 | /*
|
479 | 482 | ||
480 | sql_str = tr("select * "
|
483 | sql_str = tr("select * "
|
481 | " from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
|
484 | " from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
|
482 | );
|
485 | );
|
483 | sql_str.append(rootClassID);
|
486 | sql_str.append(rootClassID);
|
484 | 487 | ||
485 | sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
|
488 | sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
|
486 | 489 | ||
487 | q.prepare(sql_str);
|
490 | q.prepare(sql_str);
|
488 | 491 | ||
489 | ok = q.exec();
|
492 | ok = q.exec();
|
490 | if (!ok) {
|
493 | if (!ok) {
|
491 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
494 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
492 | this, // Ðîäèòåëüñêèé âèäæåò.
|
495 | this, // Ðîäèòåëüñêèé âèäæåò.
|
493 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
496 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
494 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
|
497 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
|
495 | }
|
498 | }
|
496 | field_name = q.record().indexOf(tr("FieldName"));
|
499 | field_name = q.record().indexOf(tr("FieldName"));
|
497 | while(q.next()){
|
500 | while(q.next()){
|
498 | 501 | ||
499 | field_name_str = q.value(field_name).toString();
|
502 | field_name_str = q.value(field_name).toString();
|
500 | 503 | ||
501 | }
|
504 | }
|
502 | 505 | ||
503 | 506 | ||
504 | 507 | ||
505 | 508 | ||
506 | */
|
509 | */
|
507 | 510 | ||
508 | 511 | ||
509 | }
|
512 | }
|
510 | 513 | ||
511 | 514 | ||
512 | bool MainWindow::rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row){ |
515 | bool MainWindow::rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row){ |
513 | QSqlQuery q;
|
516 | QSqlQuery q;
|
514 | QString sql_str;
|
517 | QString sql_str;
|
515 | QString field_name_str;
|
518 | QString field_name_str;
|
516 | QString root_class_name;
|
519 | QString root_class_name;
|
517 | //bool ok;
|
520 | //bool ok;
|
518 | //int field_name;
|
521 | //int field_name;
|
519 | 522 | ||
520 | //ui->treeWidget->clear();
|
523 | //ui->treeWidget->clear();
|
521 | 524 | ||
522 | root_class_name = MainWindow::ClassName(rootClassID); // îïðåäåëÿåì èìÿ êëàññà |
525 | root_class_name = MainWindow::ClassName(rootClassID); // îïðåäåëÿåì èìÿ êëàññà |
523 | 526 | ||
524 | 527 | ||
525 | // rootItem1 = new QTreeWidgetItem(ui->treeWidget);
|
528 | // rootItem1 = new QTreeWidgetItem(ui->treeWidget);
|
526 | // root_items_list << rootItem1;
|
529 | // root_items_list << rootItem1;
|
527 | // rootItem1->setText(0, modelName);
|
530 | // rootItem1->setText(0, modelName);
|
528 | 531 | ||
529 | // rootItem1->setCheckState(0,Qt::Checked);
|
532 | // rootItem1->setCheckState(0,Qt::Checked);
|
530 | // rootItems.append(rootItem1);
|
533 | // rootItems.append(rootItem1);
|
531 | 534 | ||
532 | // root_item->removeChild(root_item->child(0)); // î÷èùàåì ñïèñîê äî÷åðíèõ êëàññîâ
|
535 | // root_item->removeChild(root_item->child(0)); // î÷èùàåì ñïèñîê äî÷åðíèõ êëàññîâ
|
533 | if (root_item->childCount()==0){ // íåò êîðíåâîãî êëàññà, ñîçäàäèì åãî |
536 | if (root_item->childCount()==0){ // íåò êîðíåâîãî êëàññà, ñîçäàäèì åãî |
534 | QTreeWidgetItem* item_tmp; |
537 | QTreeWidgetItem* item_tmp; |
535 | item_tmp = new QTreeWidgetItem (root_item); |
538 | item_tmp = new QTreeWidgetItem (root_item); |
536 | item_tmp->setText(4, QVariant(row).toString()); |
539 | item_tmp->setText(4, QVariant(row).toString()); |
537 | 540 | ||
538 | }
|
541 | }
|
539 | 542 | ||
540 | if (root_item->childCount()==1){ // êîðíåâîé êëàññ åñòü è îí ïóñòîé, î÷èùàòü åãî íå íàäî |
543 | if (root_item->childCount()==1){ // êîðíåâîé êëàññ åñòü è îí ïóñòîé, î÷èùàòü åãî íå íàäî |
541 | root_item->child(0)->setText(0, root_class_name); |
544 | root_item->child(0)->setText(0, root_class_name); |
542 | root_item->child(0)->setText(1, rootClassID); |
545 | root_item->child(0)->setText(1, rootClassID); |
543 | root_item->child(0)->setCheckState(0,Qt::Checked); |
546 | root_item->child(0)->setCheckState(0,Qt::Checked); |
544 | root_item->setText(4, QVariant(row).toString()); |
547 | root_item->setText(4, QVariant(row).toString()); |
545 | 548 | ||
546 | }
|
549 | }
|
547 | 550 | ||
548 | 551 | ||
549 | 552 | ||
550 | //delete rootItem2;
|
553 | //delete rootItem2;
|
551 | 554 | ||
552 | 555 | ||
553 | // rootItem2 = new QTreeWidgetItem(rootItem1);
|
556 | // rootItem2 = new QTreeWidgetItem(rootItem1);
|
554 | 557 | ||
555 | 558 | ||
556 | 559 | ||
557 | // rootItem2->setText(0, root_class_name);
|
560 | // rootItem2->setText(0, root_class_name);
|
558 | // rootItem2->setText(1, rootClassID);
|
561 | // rootItem2->setText(1, rootClassID);
|
559 | // rootItem2->setCheckState(0,Qt::Checked);
|
562 | // rootItem2->setCheckState(0,Qt::Checked);
|
560 | 563 | ||
561 | int child_count = root_item->child(0)->childCount(); |
564 | int child_count = root_item->child(0)->childCount(); |
562 | 565 | ||
563 | 566 | ||
564 | for (int i=0; i < child_count; i++){ // åñëè êîðíåâîé êëàññ åñòü è íå ïóñòîé, î÷èùàåì åãî |
567 | for (int i=0; i < child_count; i++){ // åñëè êîðíåâîé êëàññ åñòü è íå ïóñòîé, î÷èùàåì åãî |
565 | root_item->child(0)->removeChild(root_item->child(0)->child(0)); |
568 | root_item->child(0)->removeChild(root_item->child(0)->child(0)); |
566 | }
|
569 | }
|
567 | 570 | ||
568 | child_count = root_item->child(0)->childCount(); |
571 | child_count = root_item->child(0)->childCount(); |
569 | addChildsItems(root_item->child(0), row); |
572 | addChildsItems(root_item->child(0), row); |
570 | /*
|
573 | /*
|
571 | sql_str = tr("select * "
|
574 | sql_str = tr("select * "
|
572 | " from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
|
575 | " from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
|
573 | );
|
576 | );
|
574 | sql_str.append(rootClassID);
|
577 | sql_str.append(rootClassID);
|
575 | 578 | ||
576 | sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
|
579 | sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
|
577 | 580 | ||
578 | q.prepare(sql_str);
|
581 | q.prepare(sql_str);
|
579 | 582 | ||
580 | ok = q.exec();
|
583 | ok = q.exec();
|
581 | if (!ok) {
|
584 | if (!ok) {
|
582 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
585 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
583 | this, // Ðîäèòåëüñêèé âèäæåò.
|
586 | this, // Ðîäèòåëüñêèé âèäæåò.
|
584 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
587 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
585 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
|
588 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
|
586 | }
|
589 | }
|
587 | field_name = q.record().indexOf(tr("FieldName"));
|
590 | field_name = q.record().indexOf(tr("FieldName"));
|
588 | while(q.next()){
|
591 | while(q.next()){
|
589 | 592 | ||
590 | field_name_str = q.value(field_name).toString();
|
593 | field_name_str = q.value(field_name).toString();
|
591 | 594 | ||
592 | }
|
595 | }
|
593 | 596 | ||
594 | */
|
597 | */
|
595 | 598 | ||
596 | 599 | ||
597 | }
|
600 | }
|
598 | 601 | ||
599 | 602 | ||
600 | 603 | ||
601 | 604 | ||
602 | QString MainWindow::ClassName(QString class_id){ //âîçâðàùàåò èìÿ êëàññà ïî åãî ID |
605 | QString MainWindow::ClassName(QString class_id){ //âîçâðàùàåò èìÿ êëàññà ïî åãî ID |
603 | QSqlQuery q;
|
606 | QSqlQuery q;
|
604 | QString sql_str;
|
607 | QString sql_str;
|
605 | QString class_name_str;
|
608 | QString class_name_str;
|
606 | bool ok; |
609 | bool ok; |
607 | int field_class_name; |
610 | int field_class_name; |
608 | 611 | ||
609 | sql_str = tr("select * " |
612 | sql_str = tr("select * " |
610 | " from ListOfClasses where ListOfClasses.ID = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì |
613 | " from ListOfClasses where ListOfClasses.ID = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì |
611 | ); |
614 | ); |
612 | 615 | ||
613 | sql_str.append(class_id); |
616 | sql_str.append(class_id); |
614 | sql_str.append(tr("' ")); |
617 | sql_str.append(tr("' ")); |
615 | 618 | ||
616 | q.prepare(sql_str); |
619 | q.prepare(sql_str); |
617 | 620 | ||
618 | ok = q.exec(); |
621 | ok = q.exec(); |
619 | 622 | ||
620 | 623 | ||
621 | if (!ok) { |
624 | if (!ok) { |
622 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
625 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
623 | this, // Ðîäèòåëüñêèé âèäæåò. |
626 | this, // Ðîäèòåëüñêèé âèäæåò. |
624 | QObject::tr("Database Error"), // Çàãîëîâîê. |
627 | QObject::tr("Database Error"), // Çàãîëîâîê. |
625 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
628 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
626 | }
|
629 | }
|
627 | 630 | ||
628 | field_class_name = q.record().indexOf(tr("ClassName")); |
631 | field_class_name = q.record().indexOf(tr("ClassName")); |
629 | while(q.next()){ |
632 | while(q.next()){ |
630 | 633 | ||
631 | class_name_str = q.value(field_class_name).toString(); |
634 | class_name_str = q.value(field_class_name).toString(); |
632 | 635 | ||
633 | }
|
636 | }
|
634 | 637 | ||
635 | return class_name_str; |
638 | return class_name_str; |
636 | 639 | ||
637 | }
|
640 | }
|
638 | 641 | ||
639 | void MainWindow::addChildsItems(QTreeWidgetItem *perent_class_item, int row){ // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì |
642 | void MainWindow::addChildsItems(QTreeWidgetItem *perent_class_item, int row){ // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì |
640 | QStringList chields_list;
|
643 | QStringList chields_list;
|
641 | QString parent_ID;
|
644 | QString parent_ID;
|
642 | QTreeWidgetItem *Item_tmp; |
645 | QTreeWidgetItem *Item_tmp; |
643 | parent_ID = perent_class_item->text(1); |
646 | parent_ID = perent_class_item->text(1); |
644 | int chields_count, i; |
647 | int chields_count, i; |
645 | 648 | ||
646 | chields_list = MainWindow::classChields(parent_ID); |
649 | chields_list = MainWindow::classChields(parent_ID); |
647 | if(chields_list.isEmpty()) return; |
650 | if(chields_list.isEmpty()) return; |
648 | chields_count = chields_list.size(); |
651 | chields_count = chields_list.size(); |
649 | for (int l = 0; l < chields_count; ++l){ |
652 | for (int l = 0; l < chields_count; ++l){ |
650 | QString chield_class_name, chield_id;
|
653 | QString chield_class_name, chield_id;
|
651 | chield_id = chields_list.at(l); |
654 | chield_id = chields_list.at(l); |
652 | chield_class_name = MainWindow::ClassName(chield_id); |
655 | chield_class_name = MainWindow::ClassName(chield_id); |
653 | Item_tmp = new QTreeWidgetItem(perent_class_item); |
656 | Item_tmp = new QTreeWidgetItem(perent_class_item); |
654 | Item_tmp->setText(0, chield_class_name); |
657 | Item_tmp->setText(0, chield_class_name); |
655 | Item_tmp->setText(1, chield_id); |
658 | Item_tmp->setText(1, chield_id); |
656 | Item_tmp->setCheckState(0, Qt::Checked); |
659 | Item_tmp->setCheckState(0, Qt::Checked); |
657 | Item_tmp->setText(4, QVariant(row).toString()); |
660 | Item_tmp->setText(4, QVariant(row).toString()); |
658 | MainWindow::addChildsItems(Item_tmp, row); |
661 | MainWindow::addChildsItems(Item_tmp, row); |
659 | }
|
662 | }
|
660 | 663 | ||
661 | i++; |
664 | i++; |
662 | 665 | ||
663 | }
|
666 | }
|
664 | 667 | ||
665 | 668 | ||
666 | /********************************************************
|
669 | /********************************************************
|
667 | * Ôóíêöèÿ âîçâðàùàåò ñïèñîê "äî÷åðíèõ" êëàññîâ
|
670 | * Ôóíêöèÿ âîçâðàùàåò ñïèñîê "äî÷åðíèõ" êëàññîâ
|
668 | *
|
671 | *
|
669 | *
|
672 | *
|
670 | *
|
673 | *
|
671 | ********************************************************/
|
674 | ********************************************************/
|
672 | 675 | ||
673 | QStringList MainWindow::classChields(QString class_id){ |
676 | QStringList MainWindow::classChields(QString class_id){ |
674 | // QMap<QString, QString> map;
|
677 | // QMap<QString, QString> map;
|
675 | // TClass class_tmp;
|
678 | // TClass class_tmp;
|
676 | // QList <TClass> chields_class_list; // ñïèñîê äî÷åðíèõ êëàññîâ
|
679 | // QList <TClass> chields_class_list; // ñïèñîê äî÷åðíèõ êëàññîâ
|
677 | QStringList result;
|
680 | QStringList result;
|
678 | QSqlQuery q;
|
681 | QSqlQuery q;
|
679 | QString sql_str;
|
682 | QString sql_str;
|
680 | QString classIdentifer_str; // â ýòîì ïîëå ëåæèò èäåíòèôèêàòîð êëàññà-êîíòåéíåðà |
683 | QString classIdentifer_str; // â ýòîì ïîëå ëåæèò èäåíòèôèêàòîð êëàññà-êîíòåéíåðà |
681 | QString field_id_str;
|
684 | QString field_id_str;
|
682 | bool ok; |
685 | bool ok; |
683 | int field_classIdentifer; |
686 | int field_classIdentifer; |
684 | sql_str = tr("select * " |
687 | sql_str = tr("select * " |
685 | " from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì |
688 | " from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì |
686 | ); |
689 | ); |
687 | sql_str.append(class_id); |
690 | sql_str.append(class_id); |
688 | 691 | ||
689 | sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' ")); |
692 | sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' ")); |
690 | 693 | ||
691 | q.prepare(sql_str); |
694 | q.prepare(sql_str); |
692 | 695 | ||
693 | ok = q.exec(); |
696 | ok = q.exec(); |
694 | if (!ok) { |
697 | if (!ok) { |
695 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
698 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
696 | this, // Ðîäèòåëüñêèé âèäæåò. |
699 | this, // Ðîäèòåëüñêèé âèäæåò. |
697 | QObject::tr("Database Error"), // Çàãîëîâîê. |
700 | QObject::tr("Database Error"), // Çàãîëîâîê. |
698 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
701 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
699 | }
|
702 | }
|
700 | field_classIdentifer = q.record().indexOf(tr("ClassIdentifer")); |
703 | field_classIdentifer = q.record().indexOf(tr("ClassIdentifer")); |
701 | while(q.next()){ |
704 | while(q.next()){ |
702 | 705 | ||
703 | classIdentifer_str = q.value(field_classIdentifer).toString(); |
706 | classIdentifer_str = q.value(field_classIdentifer).toString(); |
704 | result.append(classIdentifer_str); |
707 | result.append(classIdentifer_str); |
705 | }
|
708 | }
|
706 | 709 | ||
707 | return result; |
710 | return result; |
708 | 711 | ||
709 | }
|
712 | }
|
710 | 713 | ||
711 | 714 | ||
712 | QMap <QString, QString> MainWindow::getClassList(){ // ïîëó÷àåì ñïèñîê êëàññîâ |
715 | QMap <QString, QString> MainWindow::getClassList(){ // ïîëó÷àåì ñïèñîê êëàññîâ |
713 | QMap <QString, QString> result_map; |
716 | QMap <QString, QString> result_map; |
714 | QSqlQuery q;
|
717 | QSqlQuery q;
|
715 | QString sql_str;
|
718 | QString sql_str;
|
716 | QString class_name_str, class_id_str;
|
719 | QString class_name_str, class_id_str;
|
717 | 720 | ||
718 | int field_class_id, field_class_name; |
721 | int field_class_id, field_class_name; |
719 | bool ok; |
722 | bool ok; |
720 | sql_str = tr("select * " |
723 | sql_str = tr("select * " |
721 | " from ListOfClasses " //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì |
724 | " from ListOfClasses " //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì |
722 | ); |
725 | ); |
723 | q.prepare(sql_str); |
726 | q.prepare(sql_str); |
724 | ok = q.exec(); |
727 | ok = q.exec(); |
725 | if (!ok) { |
728 | if (!ok) { |
726 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
729 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
727 | this, // Ðîäèòåëüñêèé âèäæåò. |
730 | this, // Ðîäèòåëüñêèé âèäæåò. |
728 | QObject::tr("Database Error"), // Çàãîëîâîê. |
731 | QObject::tr("Database Error"), // Çàãîëîâîê. |
729 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
732 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
730 | return result_map; // åñëè îøèáêà - âîçâðàùàåì ïóñòîé ñïèñîê |
733 | return result_map; // åñëè îøèáêà - âîçâðàùàåì ïóñòîé ñïèñîê |
731 | }
|
734 | }
|
732 | field_class_id = q.record().indexOf(tr("ID")); |
735 | field_class_id = q.record().indexOf(tr("ID")); |
733 | field_class_name = q.record().indexOf(tr("ClassName")); |
736 | field_class_name = q.record().indexOf(tr("ClassName")); |
734 | 737 | ||
735 | while(q.next()){ |
738 | while(q.next()){ |
736 | 739 | ||
737 | class_name_str = q.value(field_class_name).toString(); |
740 | class_name_str = q.value(field_class_name).toString(); |
738 | class_id_str = q.value(field_class_id).toString(); |
741 | class_id_str = q.value(field_class_id).toString(); |
739 | result_map[class_id_str] = class_name_str; |
742 | result_map[class_id_str] = class_name_str; |
740 | }
|
743 | }
|
741 | return result_map; |
744 | return result_map; |
742 | }
|
745 | }
|
743 | 746 | ||
744 | 747 | ||
745 | 748 | ||
746 | 749 | ||
747 | 750 | ||
748 | void MainWindow::initComboBox(){ |
751 | void MainWindow::initComboBox(){ |
749 | 752 | ||
750 | 753 | ||
751 | QStringList classesNameList;
|
754 | QStringList classesNameList;
|
752 | QStringList classesID_list;
|
755 | QStringList classesID_list;
|
753 | QStringList tmp_stringList;
|
756 | QStringList tmp_stringList;
|
754 | 757 | ||
755 | 758 | ||
756 | 759 | ||
757 | QString tmp_str;
|
760 | QString tmp_str;
|
758 | 761 | ||
759 | class_list_map = MainWindow::getClassList(); |
762 | class_list_map = MainWindow::getClassList(); |
760 | classesID_list = class_list_map.keys(); |
763 | classesID_list = class_list_map.keys(); |
761 | classesNameList = class_list_map.values(); |
764 | classesNameList = class_list_map.values(); |
762 | QMapIterator<QString, QString> interator(class_list_map); |
765 | QMapIterator<QString, QString> interator(class_list_map); |
763 | // ui->comboBox->addItems(classesID_list);
|
766 | // ui->comboBox->addItems(classesID_list);
|
764 | // ui->comboBox->addItems(classesNameList);
|
767 | // ui->comboBox->addItems(classesNameList);
|
765 | 768 | ||
766 | while (interator.hasNext()) { |
769 | while (interator.hasNext()) { |
767 | interator.next(); |
770 | interator.next(); |
768 | tmp_str = interator.value(); |
771 | tmp_str = interator.value(); |
769 | tmp_str.append(tr(" \t(ID=")); |
772 | tmp_str.append(tr(" \t(ID=")); |
770 | tmp_str.append(interator.key()); |
773 | tmp_str.append(interator.key()); |
771 | tmp_str.append(tr(")")); |
774 | tmp_str.append(tr(")")); |
772 | tmp_stringList << tmp_str; |
775 | tmp_stringList << tmp_str; |
773 | 776 | ||
774 | }
|
777 | }
|
775 | tmp_stringList << tr("íå çàäàíî"); |
778 | tmp_stringList << tr("íå çàäàíî"); |
776 | // int count = ui->comboBox->count();
|
779 | // int count = ui->comboBox->count();
|
777 | 780 | ||
778 | ui->comboBox->clear(); |
781 | ui->comboBox->clear(); |
779 | ui->comboBox->addItems(tmp_stringList); |
782 | ui->comboBox->addItems(tmp_stringList); |
780 | 783 | ||
781 | 784 | ||
782 | }
|
785 | }
|
783 | 786 | ||
784 | 787 | ||
785 | void MainWindow::on_comboBox_currentIndexChanged( int index ){ |
788 | void MainWindow::on_comboBox_currentIndexChanged( int index ){ |
786 | QStringList classesNameList;
|
789 | QStringList classesNameList;
|
787 | QStringList classesID_list;
|
790 | QStringList classesID_list;
|
788 | QString ID_str;
|
791 | QString ID_str;
|
789 | if (index == -1) return;// èíäåêñ íå âåðíûé èëè èíäåêñ ñòðîêè "íå îïðåäåëåíî" |
792 | if (index == -1) return;// èíäåêñ íå âåðíûé èëè èíäåêñ ñòðîêè "íå îïðåäåëåíî" |
790 | if (ui->comboBox->itemText(index) == tr("íå çàäàíî")) return; |
793 | if (ui->comboBox->itemText(index) == tr("íå çàäàíî")) return; |
791 | if (!comboBox_slot_enable) return; // èíäåêñ ïîìåíÿëà ïðîãðàììà, îí íå áûë èçìåíåí âðó÷íóþ, âûõîäèì |
794 | if (!comboBox_slot_enable) return; // èíäåêñ ïîìåíÿëà ïðîãðàììà, îí íå áûë èçìåíåí âðó÷íóþ, âûõîäèì |
792 | int row; |
795 | int row; |
793 | 796 | ||
794 | classesID_list = class_list_map.keys(); |
797 | classesID_list = class_list_map.keys(); |
795 | classesNameList = class_list_map.values(); |
798 | classesNameList = class_list_map.values(); |
796 | ID_str = classesID_list[index]; |
799 | ID_str = classesID_list[index]; |
797 | ui->label->setText(ID_str); |
800 | ui->label->setText(ID_str); |
798 | if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1) |
801 | if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1) |
799 | {
|
802 | {
|
800 | row = QVariant(ui->treeWidget->currentItem()->text(4)).toInt(); |
803 | row = QVariant(ui->treeWidget->currentItem()->text(4)).toInt(); |
801 | model_is_build = false; // ÷òîáû íå âûçûâàëîñü ñîáûòèå on_treeWidget_itemChanged |
804 | model_is_build = false; // ÷òîáû íå âûçûâàëîñü ñîáûòèå on_treeWidget_itemChanged |
802 | rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str, row); |
805 | rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str, row); |
803 | model_is_build = true; // òåïåðü ïóñòü âûçûâàåòñÿ |
806 | model_is_build = true; // òåïåðü ïóñòü âûçûâàåòñÿ |
804 | QString mdl_str = MainWindow::creatModelString(ui->treeWidget->currentItem()); // |
807 | QString mdl_str = MainWindow::creatModelString(ui->treeWidget->currentItem()); // |
805 | model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row, 2), QVariant(mdl_str)); |
808 | model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row, 2), QVariant(mdl_str)); |
806 | }
|
809 | }
|
807 | getDatabaseData(); |
810 | getDatabaseData(); |
808 | 811 | ||
809 | 812 | ||
810 | }
|
813 | }
|
811 | 814 | ||
812 | void MainWindow::on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column ){ |
815 | void MainWindow::on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column ){ |
813 | int i; |
816 | int i; |
814 | i++; |
817 | i++; |
815 | QTreeWidgetItem * item_tmp; |
818 | QTreeWidgetItem * item_tmp; |
816 | QString mdl_str;
|
819 | QString mdl_str;
|
817 | QString row; // íîìåð ñòðîêè â òàáëèöå ìîäåëåé, ñîîòâåòñòâóþùèé èçìåíåííîé ìîäåëå |
820 | QString row; // íîìåð ñòðîêè â òàáëèöå ìîäåëåé, ñîîòâåòñòâóþùèé èçìåíåííîé ìîäåëå |
818 | QList <QTreeWidgetItem *> mdl_itm_list; |
821 | QList <QTreeWidgetItem *> mdl_itm_list; |
819 | QList <int> rows_list; |
822 | QList <int> rows_list; |
820 | 823 | ||
821 | 824 | ||
822 | if ((column) == 0 && (model_is_build)) { |
825 | if ((column) == 0 && (model_is_build)) { |
823 | // if (!model_is_build) return; // ìîäåëü åù¸ íå ïîñòðîåíà
|
826 | // if (!model_is_build) return; // ìîäåëü åù¸ íå ïîñòðîåíà
|
824 | 827 | ||
825 | mdl_itm_list = models_items.values(); |
828 | mdl_itm_list = models_items.values(); |
826 | rows_list = models_items.keys(); |
829 | rows_list = models_items.keys(); |
827 | row= item->text(4); |
830 | row= item->text(4); |
828 | 831 | ||
829 | 832 | ||
830 | if ( mdl_itm_list.indexOf(item) != -1){ // èçìåí¸í êîðíåâîé èòåì (ñàìà ìîäåëü) |
833 | if ( mdl_itm_list.indexOf(item) != -1){ // èçìåí¸í êîðíåâîé èòåì (ñàìà ìîäåëü) |
831 | if (item->checkState(0)) model_for_ListModelsTable->setData(model_for_ListModelsTable->index(QVariant(row).toInt(), 3), QVariant(1)); |
834 | if (item->checkState(0)) model_for_ListModelsTable->setData(model_for_ListModelsTable->index(QVariant(row).toInt(), 3), QVariant(1)); |
832 | else model_for_ListModelsTable->setData(model_for_ListModelsTable->index(QVariant(row).toInt(), 3), QVariant(0)); |
835 | else model_for_ListModelsTable->setData(model_for_ListModelsTable->index(QVariant(row).toInt(), 3), QVariant(0)); |
833 | }
|
836 | }
|
834 | 837 | ||
835 | 838 | ||
836 | 839 | ||
837 | 840 | ||
838 | if (!row.isEmpty()){ |
841 | if (!row.isEmpty()){ |
839 | 842 | ||
840 | 843 | ||
841 | int row_int; |
844 | int row_int; |
842 | row_int = QVariant(row).toInt(); |
845 | row_int = QVariant(row).toInt(); |
843 | if (rows_list.indexOf(row_int) != -1) |
846 | if (rows_list.indexOf(row_int) != -1) |
844 | {
|
847 | {
|
845 | item_tmp = models_items[row_int]; |
848 | item_tmp = models_items[row_int]; |
846 | mdl_str = MainWindow::creatModelString(item_tmp); |
849 | mdl_str = MainWindow::creatModelString(item_tmp); |
847 | model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row_int, 2), QVariant(mdl_str)); |
850 | model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row_int, 2), QVariant(mdl_str)); |
848 | }
|
851 | }
|
849 | 852 | ||
850 | 853 | ||
851 | }
|
854 | }
|
852 | 855 | ||
853 | 856 | ||
854 | }
|
857 | }
|
855 | 858 | ||
856 | /*
|
859 | /*
|
857 | QTreeWidgetItem * item_tmp;
|
860 | QTreeWidgetItem * item_tmp;
|
858 | item_tmp = item;
|
861 | item_tmp = item;
|
859 | while (item_tmp ){
|
862 | while (item_tmp ){
|
860 | item_tmp = item_tmp->parent();
|
863 | item_tmp = item_tmp->parent();
|
861 | }
|
864 | }
|
862 | */
|
865 | */
|
863 | if ((column) == 0 && (model_is_build)) getDatabaseData(); |
866 | if ((column) == 0 && (model_is_build)) getDatabaseData(); |
864 | 867 | ||
865 | 868 | ||
866 | }
|
869 | }
|
867 | 870 | ||
868 | 871 | ||
869 | void MainWindow::on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column ){ |
872 | void MainWindow::on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column ){ |
870 | int i; |
873 | int i; |
871 | i++; |
874 | i++; |
872 | if (root_items_list.indexOf(item) != -1) { // Åñëè âûáðàííûé èòåì ñîäåðæèò íàçâàíèå ìîäåëè |
875 | if (root_items_list.indexOf(item) != -1) { // Åñëè âûáðàííûé èòåì ñîäåðæèò íàçâàíèå ìîäåëè |
873 | QStringList classesNameList;
|
876 | QStringList classesNameList;
|
874 | QStringList classesID_list;
|
877 | QStringList classesID_list;
|
875 | 878 | ||
876 | ui->pushButton_9->setEnabled(false); |
879 | ui->pushButton_9->setEnabled(false); |
877 | ui->pushButton_10->setEnabled(false); |
880 | ui->pushButton_10->setEnabled(false); |
878 | ui->pushButton_11->setEnabled(false); |
881 | ui->pushButton_11->setEnabled(false); |
879 | ui->pushButton_12->setEnabled(false); |
882 | ui->pushButton_12->setEnabled(false); |
880 | // ui->tableView->reset();
|
883 | // ui->tableView->reset();
|
881 | // MainWindow::filtr_model->clear();
|
884 | // MainWindow::filtr_model->clear();
|
882 | disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
885 | disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
883 | delete filter_model; |
886 | delete filter_model; |
884 | 887 | ||
885 | filter_model = new QSqlTableModel(); |
888 | filter_model = new QSqlTableModel(); |
886 | /// filter_model = new MyModel();
|
889 | /// filter_model = new MyModel();
|
887 | filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
890 | filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
888 | 891 | ||
889 | connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
892 | connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
890 | int index; |
893 | int index; |
891 | classesID_list = class_list_map.keys(); |
894 | classesID_list = class_list_map.keys(); |
892 | classesNameList = class_list_map.values(); |
895 | classesNameList = class_list_map.values(); |
893 | if (item->childCount()>0) index = classesID_list.indexOf(item->child(0)->text(1)); // åñëè ìîäåëü íå ïóñòàÿ, óçíàåì êîðíåâîé êëàññ |
896 | if (item->childCount()>0) index = classesID_list.indexOf(item->child(0)->text(1)); // åñëè ìîäåëü íå ïóñòàÿ, óçíàåì êîðíåâîé êëàññ |
894 | else { // åñëè ïóñòàÿ |
897 | else { // åñëè ïóñòàÿ |
895 | index = classesID_list.count(); |
898 | index = classesID_list.count(); |
896 | comboBox_slot_enable = false; // ÷òîáû ñëîò comboBox íå ìåíÿë ñòðîêó ìîäåëè |
899 | comboBox_slot_enable = false; // ÷òîáû ñëîò comboBox íå ìåíÿë ñòðîêó ìîäåëè |
897 | ui->comboBox->setCurrentIndex(index); |
900 | ui->comboBox->setCurrentIndex(index); |
898 | ui->comboBox->setEnabled(true); |
901 | ui->comboBox->setEnabled(true); |
899 | comboBox_slot_enable = true; |
902 | comboBox_slot_enable = true; |
900 | return; |
903 | return; |
901 | 904 | ||
902 | }
|
905 | }
|
903 | comboBox_slot_enable = false; // ÷òîáû ñëîò comboBox íå ìåíÿë ñòðîêó ìîäåëè |
906 | comboBox_slot_enable = false; // ÷òîáû ñëîò comboBox íå ìåíÿë ñòðîêó ìîäåëè |
904 | if (index != -1) ui->comboBox->setCurrentIndex(index); |
907 | if (index != -1) ui->comboBox->setCurrentIndex(index); |
905 | comboBox_slot_enable = true; |
908 | comboBox_slot_enable = true; |
906 | ui->comboBox->setEnabled(true); |
909 | ui->comboBox->setEnabled(true); |
907 | 910 | ||
908 | 911 | ||
909 | }
|
912 | }
|
910 | // if ((rootItem1) == (item) ) ui->comboBox->setEnabled(true);
|
913 | // if ((rootItem1) == (item) ) ui->comboBox->setEnabled(true);
|
911 | else // âûáðàííûé èòåì ñîäåðæèò íàçâàíèå êëàññà |
914 | else // âûáðàííûé èòåì ñîäåðæèò íàçâàíèå êëàññà |
912 | {
|
915 | {
|
913 | QString class_id;
|
916 | QString class_id;
|
914 | QString model_id;
|
917 | QString model_id;
|
915 | QString filtr_str;
|
918 | QString filtr_str;
|
916 | QString inctance;
|
919 | QString inctance;
|
917 | QStringList conditionList;
|
920 | QStringList conditionList;
|
918 | class_id = item->text(1); |
921 | class_id = item->text(1); |
919 | model_id = item->text(6); |
922 | model_id = item->text(6); |
920 | inctance = MainWindow::getClassInctance(class_id); |
923 | inctance = MainWindow::getClassInctance(class_id); |
921 | 924 | ||
922 | filtr_str = tr("`Model_ID` = "); |
925 | filtr_str = tr("`Model_ID` = "); |
923 | filtr_str.append(model_id); |
926 | filtr_str.append(model_id); |
924 | filtr_str.append(tr(" AND `Class_ID` = ")); |
927 | filtr_str.append(tr(" AND `Class_ID` = ")); |
925 | filtr_str.append(class_id); |
928 | filtr_str.append(class_id); |
926 | // filtr_str.append(tr("`"));
|
929 | // filtr_str.append(tr("`"));
|
927 | 930 | ||
928 | disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
931 | disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
929 | delete filter_model; |
932 | delete filter_model; |
930 | /// filter_model = new MyModel();
|
933 | /// filter_model = new MyModel();
|
931 | 934 | ||
932 | filter_model = new QSqlTableModel(); |
935 | filter_model = new QSqlTableModel(); |
933 | filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
936 | filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
934 | 937 | ||
935 | connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
938 | connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex))); |
936 | filter_model->setTable(tr("Filters")); |
939 | filter_model->setTable(tr("Filters")); |
937 | filter_model->setFilter(filtr_str); |
940 | filter_model->setFilter(filtr_str); |
938 | 941 | ||
939 | 942 | ||
940 | 943 | ||
941 | filter_model->select(); |
944 | filter_model->select(); |
942 | 945 | ||
943 | filter_model->sort(0,Qt::AscendingOrder); |
946 | filter_model->sort(0,Qt::AscendingOrder); |
944 | 947 | ||
945 | ui->tableView_3->setModel(filter_model); |
948 | ui->tableView_3->setModel(filter_model); |
946 | 949 | ||
947 | 950 | ||
948 | ui->tableView_3->hideColumn(0); |
951 | ui->tableView_3->hideColumn(0); |
949 | ui->tableView_3->hideColumn(1); |
952 | ui->tableView_3->hideColumn(1); |
950 | ui->tableView_3->hideColumn(2); |
953 | ui->tableView_3->hideColumn(2); |
951 | 954 | ||
952 | 955 | ||
953 | filterSpinDelegate.setClassID(class_id); |
956 | filterSpinDelegate.setClassID(class_id); |
954 | filterSpinDelegate.getItems(); |
957 | filterSpinDelegate.getItems(); |
955 | ui->tableView_3->setItemDelegateForColumn(4, &filterSpinDelegate); |
958 | ui->tableView_3->setItemDelegateForColumn(4, &filterSpinDelegate); |
956 | 959 | ||
957 | // ui->tableView_3->setItemDelegate();
|
960 | // ui->tableView_3->setItemDelegate();
|
958 | conditionList <<"" << "and" << "or" << "(" << "and (" << "or ("; |
961 | conditionList <<"" << "and" << "or" << "(" << "and (" << "or ("; |
959 | filterConditionDelegate.setItems(conditionList); |
962 | filterConditionDelegate.setItems(conditionList); |
960 | ui->tableView_3->setItemDelegateForColumn(3, &filterConditionDelegate); |
963 | ui->tableView_3->setItemDelegateForColumn(3, &filterConditionDelegate); |
961 | 964 | ||
962 | conditionList.clear(); |
965 | conditionList.clear(); |
963 | conditionList <<"" << "=" << "<" << ">" << "IS NULL" << "IS NOT NULL"; |
966 | conditionList <<"" << "=" << "<" << ">" << "IS NULL" << "IS NOT NULL"; |
964 | filterConditionDelegate_1.setItems(conditionList); |
967 | filterConditionDelegate_1.setItems(conditionList); |
965 | ui->tableView_3->setItemDelegateForColumn(5, &filterConditionDelegate_1); |
968 | ui->tableView_3->setItemDelegateForColumn(5, &filterConditionDelegate_1); |
966 | 969 | ||
967 | 970 | ||
968 | 971 | ||
969 | 972 | ||
970 | conditionList.clear(); |
973 | conditionList.clear(); |
971 | conditionList <<"" << ")"; |
974 | conditionList <<"" << ")"; |
972 | filterConditionDelegate_2.setItems(conditionList); |
975 | filterConditionDelegate_2.setItems(conditionList); |
973 | ui->tableView_3->setItemDelegateForColumn(7, &filterConditionDelegate_2); |
976 | ui->tableView_3->setItemDelegateForColumn(7, &filterConditionDelegate_2); |
974 | 977 | ||
975 | ui->tableView_3->setItemDelegateForColumn(6, &filterValueDelegate); |
978 | ui->tableView_3->setItemDelegateForColumn(6, &filterValueDelegate); |
976 | 979 | ||
977 | 980 | ||
978 | 981 | ||
979 | 982 | ||
980 | ui->pushButton_9->setEnabled(true); |
983 | ui->pushButton_9->setEnabled(true); |
981 | ui->pushButton_10->setEnabled(true); |
984 | ui->pushButton_10->setEnabled(true); |
982 | 985 | ||
983 | ui->comboBox->setEnabled(false); |
986 | ui->comboBox->setEnabled(false); |
984 | 987 | ||
985 | 988 | ||
986 | }
|
989 | }
|
987 | }
|
990 | }
|
988 | 991 | ||
989 | QMap <QString, QString> MainWindow::getFieldsList(QString class_id){ // ïîëó÷àåì ñïèñîê ïîëåé êëàññà |
992 | QMap <QString, QString> MainWindow::getFieldsList(QString class_id){ // ïîëó÷àåì ñïèñîê ïîëåé êëàññà |
990 | 993 | ||
991 | }
|
994 | }
|
992 | 995 | ||
993 | 996 | ||
994 | void MainWindow::initListModelsTablle(){ |
997 | void MainWindow::initListModelsTablle(){ |
995 | model_for_ListModelsTable = new QSqlTableModel(); |
998 | model_for_ListModelsTable = new QSqlTableModel(); |
996 | 999 | ||
997 | model_for_ListModelsTable->setTable(tr("ListOfModels")); |
1000 | model_for_ListModelsTable->setTable(tr("ListOfModels")); |
998 | // model_for_ListModelsTable->setEditStrategy(QSqlTableModel::OnFieldChange);
|
1001 | // model_for_ListModelsTable->setEditStrategy(QSqlTableModel::OnFieldChange);
|
999 | model_for_ListModelsTable->setEditStrategy(QSqlTableModel::OnManualSubmit); |
1002 | model_for_ListModelsTable->setEditStrategy(QSqlTableModel::OnManualSubmit); |
1000 | ui->tableView_2->setModel(model_for_ListModelsTable); |
1003 | ui->tableView_2->setModel(model_for_ListModelsTable); |
1001 | 1004 | ||
1002 | model_for_ListModelsTable->select(); |
1005 | model_for_ListModelsTable->select(); |
1003 | 1006 | ||
1004 | 1007 | ||
1005 | ui->treeWidget->hideColumn(1); |
1008 | ui->treeWidget->hideColumn(1); |
1006 | ui->treeWidget->hideColumn(2); |
1009 | ui->treeWidget->hideColumn(2); |
1007 | ui->treeWidget->hideColumn(3); |
1010 | ui->treeWidget->hideColumn(3); |
1008 | ui->treeWidget->hideColumn(4); |
1011 | ui->treeWidget->hideColumn(4); |
1009 | // ui->treeWidget->hideColumn(5);
|
1012 | // ui->treeWidget->hideColumn(5);
|
1010 | ui->treeWidget->hideColumn(6); |
1013 | ui->treeWidget->hideColumn(6); |
1011 | 1014 | ||
1012 | ui->tableView_2->hideColumn(0); |
1015 | ui->tableView_2->hideColumn(0); |
1013 | ui->tableView_2->hideColumn(2); |
1016 | ui->tableView_2->hideColumn(2); |
1014 | ui->tableView_2->hideColumn(3); |
1017 | ui->tableView_2->hideColumn(3); |
1015 | ui->tableView_2->hideColumn(4); |
1018 | ui->tableView_2->hideColumn(4); |
1016 | 1019 | ||
1017 | ui->tableView_2->resizeColumnsToContents(); |
1020 | ui->tableView_2->resizeColumnsToContents(); |
1018 | ui->tableView_2->setAlternatingRowColors(true); |
1021 | ui->tableView_2->setAlternatingRowColors(true); |
1019 | 1022 | ||
1020 | ui->pushButton_7->setEnabled(false); |
1023 | ui->pushButton_7->setEnabled(false); |
1021 | ui->pushButton_8->setEnabled(false); |
1024 | ui->pushButton_8->setEnabled(false); |
1022 | 1025 | ||
1023 | 1026 | ||
1024 | }
|
1027 | }
|
1025 | 1028 | ||
1026 | void MainWindow::buildReport(bool advanced){ |
1029 | void MainWindow::buildReport(bool advanced){ |
1027 | 1030 | ||
1028 | // QTreeWidgetItem * hitm;
|
1031 | // QTreeWidgetItem * hitm;
|
1029 | 1032 | ||
1030 | // hitm = ui->treeWidget_2->headerItem();
|
1033 | // hitm = ui->treeWidget_2->headerItem();
|
1031 | 1034 | ||
1032 | // int count = root_items_list.count();
|
1035 | // int count = root_items_list.count();
|
1033 | 1036 | ||
1034 | //int count = ui->treeWidget_2->rootIndex();
|
1037 | //int count = ui->treeWidget_2->rootIndex();
|
1035 | 1038 | ||
1036 | 1039 | ||
1037 | doc->clear();//î÷èùàåì äîêóìåíò |
1040 | doc->clear();//î÷èùàåì äîêóìåíò |
1038 | 1041 | ||
1039 | int list_count; |
1042 | int list_count; |
1040 | if (rootItems.isEmpty()) return; |
1043 | if (rootItems.isEmpty()) return; |
1041 | 1044 | ||
1042 | 1045 | ||
1043 | 1046 | ||
1044 | list_count = rootItems.count(); |
1047 | list_count = rootItems.count(); |
1045 | 1048 | ||
1046 | for (int i=0; i < list_count; i++){ |
1049 | for (int i=0; i < list_count; i++){ |
1047 | 1050 | ||
1048 | getReport(rootItems.at(i), advanced); |
1051 | getReport(rootItems.at(i), advanced); |
1049 | 1052 | ||
1050 | 1053 | ||
1051 | 1054 | ||
1052 | }
|
1055 | }
|
1053 | // (bool)QTextDocumentWriter("raport.odt").write(doc);
|
1056 | // (bool)QTextDocumentWriter("raport.odt").write(doc);
|
1054 | }
|
1057 | }
|
1055 | 1058 | ||
1056 | 1059 | ||
1057 | void MainWindow::getReport(QTreeWidgetItem * model_item, bool advanced){ // ñîçäàåò îò÷åò äëÿ êîíêðåòíîé ìîäåëè |
1060 | void MainWindow::getReport(QTreeWidgetItem * model_item, bool advanced){ // ñîçäàåò îò÷åò äëÿ êîíêðåòíîé ìîäåëè |
1058 | 1061 | ||
1059 | 1062 | ||
1060 | // QTextDocument doc;
|
1063 | // QTextDocument doc;
|
1061 | // QTextCursor cursor(&doc);
|
1064 | // QTextCursor cursor(&doc);
|
1062 | QTextCharFormat char_fmt;
|
1065 | QTextCharFormat char_fmt;
|
1063 | bool ok; |
1066 | bool ok; |
1064 | 1067 | ||
1065 | /**************
|
1068 | /**************
|
1066 | 1069 | ||
1067 | // char_fmt.setBackground(Qt::red);
|
1070 | // char_fmt.setBackground(Qt::red);
|
1068 | cursor.insertText(tr("Ì1\n"),char_fmt);
|
1071 | cursor.insertText(tr("Ì1\n"),char_fmt);
|
1069 | QImage img;
|
1072 | QImage img;
|
1070 | ok = img.load("./hdd5.png");
|
1073 | ok = img.load("./hdd5.png");
|
1071 | doc.addResource(QTextDocument::ImageResource, QUrl("myimage"), img);
|
1074 | doc.addResource(QTextDocument::ImageResource, QUrl("myimage"), img);
|
1072 | cursor.insertImage("myimage");
|
1075 | cursor.insertImage("myimage");
|
1073 | cursor.insertText(tr("Æåñòêèé äèñê\n"),char_fmt);
|
1076 | cursor.insertText(tr("Æåñòêèé äèñê\n"),char_fmt);
|
1074 | 1077 | ||
1075 | (bool)QTextDocumentWriter("test.odt").write(&doc);
|
1078 | (bool)QTextDocumentWriter("test.odt").write(&doc);
|
1076 | ***************/
|
1079 | ***************/
|
1077 | 1080 | ||
1078 | QString model_name;
|
1081 | QString model_name;
|
1079 | QString rootClassID;
|
1082 | QString rootClassID;
|
1080 | QString rootClassInctance;
|
1083 | QString rootClassInctance;
|
1081 | QFont font;
|
1084 | QFont font;
|
1082 | QBrush brush;
|
1085 | QBrush brush;
|
1083 | 1086 | ||
1084 | brush.setColor(Qt::darkRed); |
1087 | brush.setColor(Qt::darkRed); |
1085 | char_fmt.setForeground(brush); |
1088 | char_fmt.setForeground(brush); |
1086 | font.setBold(true); |
1089 | font.setBold(true); |
1087 | char_fmt.setFont(font); |
1090 | char_fmt.setFont(font); |
1088 | 1091 | ||
1089 | model_name = model_item->text(0); |
1092 | model_name = model_item->text(0); |
1090 | if (model_item->checkState(0) == false) return; // ìîäåëü íå âûäåëåíà äëÿ îòîáðàæåíèÿ |
1093 | if (model_item->checkState(0) == false) return; // ìîäåëü íå âûäåëåíà äëÿ îòîáðàæåíèÿ |
1091 | 1094 | ||
1092 | 1095 | ||
1093 | newPage(); |
1096 | newPage(); |
1094 | /*******************
|
1097 | /*******************
|
1095 | QTextBlockFormat textFormat;
|
1098 | QTextBlockFormat textFormat;
|
1096 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
|
1099 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
|
1097 | cursor->setBlockFormat(textFormat);
|
1100 | cursor->setBlockFormat(textFormat);
|
1098 | 1101 | ||
1099 | cursor->insertText(tr("Íîâàÿ ñòðàíèöà"));
|
1102 | cursor->insertText(tr("Íîâàÿ ñòðàíèöà"));
|
1100 | cursor->insertBlock();
|
1103 | cursor->insertBlock();
|
1101 | 1104 | ||
1102 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
|
1105 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
|
1103 | cursor->setBlockFormat(textFormat);
|
1106 | cursor->setBlockFormat(textFormat);
|
1104 | ********************/
|
1107 | ********************/
|
1105 | 1108 | ||
1106 | 1109 | ||
1107 | 1110 | ||
1108 | if (!(model_item->childCount() > 0)) return; // ìîäåëü ïóñòà (íå ñîäåðæèò êëàññîâ) |
1111 | if (!(model_item->childCount() > 0)) return; // ìîäåëü ïóñòà (íå ñîäåðæèò êëàññîâ) |
1109 | 1112 | ||
1110 | rootClassID = model_item->child(0)->text(1); |
1113 | rootClassID = model_item->child(0)->text(1); |
1111 | rootClassInctance = getClassInctance(rootClassID); |
1114 | rootClassInctance = getClassInctance(rootClassID); |
1112 | 1115 | ||
1113 | cursor->insertText(model_name, char_fmt); |
1116 | cursor->insertText(model_name, char_fmt); |
1114 | cursor->insertText(tr("\n")); |
1117 | cursor->insertText(tr("\n")); |
1115 | 1118 | ||
1116 | if (model_item->child(0)->checkState(0)) // åñëè â ìîäåëè êîðíåâîé êëàññ âûáðàí äëÿ îòîáðàæåíèÿ (ñòîèò ãàëî÷êà), òî |
1119 | if (model_item->child(0)->checkState(0)) // åñëè â ìîäåëè êîðíåâîé êëàññ âûáðàí äëÿ îòîáðàæåíèÿ (ñòîèò ãàëî÷êà), òî |
1117 | {
|
1120 | {
|
1118 | ///// QTreeWidgetItem * item_tmp;
|
1121 | ///// QTreeWidgetItem * item_tmp;
|
1119 | ///// item_tmp = new QTreeWidgetItem(item); // â äåðåâå, îòîáðàæàþùåì îáúåêòû êëàññîâ, ñîçäàåì íîâûé óçåë
|
1122 | ///// item_tmp = new QTreeWidgetItem(item); // â äåðåâå, îòîáðàæàþùåì îáúåêòû êëàññîâ, ñîçäàåì íîâûé óçåë
|
1120 | ///// item_tmp->setText(0, model_item->child(0)->text(0)); // ñ íàçâàíèåì êëàññà
|
1123 | ///// item_tmp->setText(0, model_item->child(0)->text(0)); // ñ íàçâàíèåì êëàññà
|
1121 | 1124 | ||
1122 | //showClassObjects(item_tmp, model_item->child(0)); // è âûâîäèì âñå îáúåêòû äàííîãî êëàññà
|
1125 | //showClassObjects(item_tmp, model_item->child(0)); // è âûâîäèì âñå îáúåêòû äàííîãî êëàññà
|
1123 | 1126 | ||
1124 | ///// showObjects(item_tmp, model_item->child(0), tr(""));
|
1127 | ///// showObjects(item_tmp, model_item->child(0), tr(""));
|
1125 | printChild(model_item->child(0), tr(""), advanced, 1); |
1128 | printChild(model_item->child(0), tr(""), advanced, 1); |
1126 | 1129 | ||
1127 | }
|
1130 | }
|
1128 | 1131 | ||
1129 | 1132 | ||
1130 | 1133 | ||
1131 | 1134 | ||
1132 | }
|
1135 | }
|
1133 | 1136 | ||
1134 | void MainWindow::printChild(QTreeWidgetItem * model_item, QString filtr, bool advanced, int pos){//â ðàïîðò äîáàâëÿåì äî÷åðíèå êëàññû |
1137 | void MainWindow::printChild(QTreeWidgetItem * model_item, QString filtr, bool advanced, int pos){//â ðàïîðò äîáàâëÿåì äî÷åðíèå êëàññû |
1135 | QString classID; // èäåíòèôèêàòîð êëàññà |
1138 | QString classID; // èäåíòèôèêàòîð êëàññà |
1136 | QString parentClassID; // èäåíòèôèêàòîð ðîäèòåëüñêîãî êëàññà |
1139 | QString parentClassID; // èäåíòèôèêàòîð ðîäèòåëüñêîãî êëàññà |
1137 | QString pointerField; // èìÿ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ |
1140 | QString pointerField; // èìÿ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ |
1138 | QString inctance; // èìÿ òàáëèöû, õðàíèëèùà |
1141 | QString inctance; // èìÿ òàáëèöû, õðàíèëèùà |
1139 | QString className; // èìÿ êëàññà |
1142 | QString className; // èìÿ êëàññà |
1140 | QString modelID; // èäåíòèôèêàòîð ìîäåëè |
1143 | QString modelID; // èäåíòèôèêàòîð ìîäåëè |
1141 | QString add_filtr; // äîïîëíèòåëüíûé ôèëüòð |
1144 | QString add_filtr; // äîïîëíèòåëüíûé ôèëüòð |
1142 | int field_ID; |
1145 | int field_ID; |
1143 | int icon_field_index; |
1146 | int icon_field_index; |
1144 | bool filtr_empty; |
1147 | bool filtr_empty; |
1145 | bool ok; |
1148 | bool ok; |
1146 | QSqlQuery q;
|
1149 | QSqlQuery q;
|
1147 | QString sql_str;
|
1150 | QString sql_str;
|
1148 | QString str_tmp;
|
1151 | QString str_tmp;
|
1149 | QTreeWidgetItem * title_item; |
1152 | QTreeWidgetItem * title_item; |
1150 | 1153 | ||
1151 | QIcon icon;
|
1154 | QIcon icon;
|
1152 | QMap<QString, QString> fieldsTypesList;//çäåñü â êà÷åñòâå êëþ÷å áóäåì õðàíèòü èìåíà ïîëåé, çíà÷åíèÿìè áóäóò èõ òèïû |
1155 | QMap<QString, QString> fieldsTypesList;//çäåñü â êà÷åñòâå êëþ÷å áóäåì õðàíèòü èìåíà ïîëåé, çíà÷åíèÿìè áóäóò èõ òèïû |
1153 | //QList<TField> FieldsList; //ñïèñîê ïîëåé êëàññà
|
1156 | //QList<TField> FieldsList; //ñïèñîê ïîëåé êëàññà
|
1154 | 1157 | ||
1155 | 1158 | ||
1156 | 1159 | ||
1157 | 1160 | ||
1158 | // // // font.setBold(true);
|
1161 | // // // font.setBold(true);
|
1159 | filtr_empty = filtr.isEmpty(); |
1162 | filtr_empty = filtr.isEmpty(); |
1160 | 1163 | ||
1161 | classID = model_item->text(1); |
1164 | classID = model_item->text(1); |
1162 | modelID = model_item->text(6); |
1165 | modelID = model_item->text(6); |
1163 | add_filtr = MainWindow::getFiltrString(modelID, classID); |
1166 | add_filtr = MainWindow::getFiltrString(modelID, classID); |
1164 | 1167 | ||
1165 | 1168 | ||
1166 | icon = model_item->icon(0); |
1169 | icon = model_item->icon(0); |
1167 | 1170 | ||
1168 | parentClassID = model_item->parent()->text(1); |
1171 | parentClassID = model_item->parent()->text(1); |
1169 | 1172 | ||
1170 | pointerField = getPointerFieldName(parentClassID, classID); |
1173 | pointerField = getPointerFieldName(parentClassID, classID); |
1171 | 1174 | ||
1172 | className = model_item->text(0); |
1175 | className = model_item->text(0); |
1173 | inctance = getClassInctance(classID); |
1176 | inctance = getClassInctance(classID); |
1174 | 1177 | ||
1175 | if (!model_item->checkState(0)) return; |
1178 | if (!model_item->checkState(0)) return; |
1176 | 1179 | ||
1177 | 1180 | ||
1178 | 1181 | ||
1179 | 1182 | ||
1180 | QTextCharFormat charFormatItalic, charFormatBase, charFormatItalicBold, charFormatItalicOnly;
|
1183 | QTextCharFormat charFormatItalic, charFormatBase, charFormatItalicBold, charFormatItalicOnly;
|
1181 | QTextTableFormat tableFormat;
|
1184 | QTextTableFormat tableFormat;
|
1182 | 1185 | ||
1183 | 1186 | ||
1184 | // QPen pen;
|
1187 | // QPen pen;
|
1185 | QBrush brush;
|
1188 | QBrush brush;
|
1186 | QFont font;
|
1189 | QFont font;
|
1187 | // pen.setColor(Qt::red);
|
1190 | // pen.setColor(Qt::red);
|
1188 | // charFormatItalic.setTextOutline(pen);
|
1191 | // charFormatItalic.setTextOutline(pen);
|
1189 | 1192 | ||
1190 | //QFont font;
|
1193 | //QFont font;
|
1191 | 1194 | ||
1192 | brush.setColor(Qt::blue); |
1195 | brush.setColor(Qt::blue); |
1193 | 1196 | ||
1194 | font.setItalic(true); |
1197 | font.setItalic(true); |
1195 | 1198 | ||
1196 | charFormatItalicOnly.setFont(font); |
1199 | charFormatItalicOnly.setFont(font); |
1197 | //charFormatItalic.setFontItalic(true);
|
1200 | //charFormatItalic.setFontItalic(true);
|
1198 | 1201 | ||
1199 | font.setBold(true);///////////////// |
1202 | font.setBold(true);///////////////// |
1200 | charFormatItalic.setFont(font); |
1203 | charFormatItalic.setFont(font); |
1201 | 1204 | ||
1202 | 1205 | ||
1203 | charFormatItalic.setForeground(brush); |
1206 | charFormatItalic.setForeground(brush); |
1204 | 1207 | ||
1205 | 1208 | ||
1206 | 1209 | ||
1207 | charFormatItalicBold.setFont(font); |
1210 | charFormatItalicBold.setFont(font); |
1208 | charFormatItalicBold.setForeground(brush); |
1211 | charFormatItalicBold.setForeground(brush); |
1209 | 1212 | ||
1210 | 1213 | ||
1211 | 1214 | ||
1212 | //charFormatItalic.setFontWeight(16);
|
1215 | //charFormatItalic.setFontWeight(16);
|
1213 | pos++; |
1216 | pos++; |
1214 | for(int i=0; i<pos; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1217 | for(int i=0; i<pos; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1215 | cursor->insertText(className, charFormatItalic); |
1218 | cursor->insertText(className, charFormatItalic); |
1216 | cursor->setCharFormat(charFormatBase); |
1219 | cursor->setCharFormat(charFormatBase); |
1217 | cursor->insertText(tr("\n")); |
1220 | cursor->insertText(tr("\n")); |
1218 | 1221 | ||
1219 | 1222 | ||
1220 | 1223 | ||
1221 | sql_str = tr("select * " |
1224 | sql_str = tr("select * " |
1222 | " from " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà |
1225 | " from " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà |
1223 | ); |
1226 | ); |
1224 | sql_str.append(inctance); |
1227 | sql_str.append(inctance); |
1225 | 1228 | ||
1226 | 1229 | ||
1227 | if (filtr.isEmpty() && (!add_filtr.isEmpty())) // ôèëüòð ïóñòîé, äîïîëíèòåëüíûé ôèëüòð íå ïóñòîé |
1230 | if (filtr.isEmpty() && (!add_filtr.isEmpty())) // ôèëüòð ïóñòîé, äîïîëíèòåëüíûé ôèëüòð íå ïóñòîé |
1228 | {
|
1231 | {
|
1229 | filtr.append(tr ("where ")); |
1232 | filtr.append(tr ("where ")); |
1230 | filtr.append(add_filtr); |
1233 | filtr.append(add_filtr); |
1231 | }
|
1234 | }
|
1232 | 1235 | ||
1233 | 1236 | ||
1234 | if (!filtr.isEmpty()) { // åñëè ôèëüòð íå ïóñòîé |
1237 | if (!filtr.isEmpty()) { // åñëè ôèëüòð íå ïóñòîé |
1235 | sql_str.append(tr(" ")); |
1238 | sql_str.append(tr(" ")); |
1236 | sql_str.append(filtr); // äîáàâëÿåì â çàïðîñ ôèëüòð |
1239 | sql_str.append(filtr); // äîáàâëÿåì â çàïðîñ ôèëüòð |
1237 | }
|
1240 | }
|
1238 | 1241 | ||
1239 | q.prepare(sql_str); |
1242 | q.prepare(sql_str); |
1240 | 1243 | ||
1241 | ok = q.exec(); |
1244 | ok = q.exec(); |
1242 | 1245 | ||
1243 | if (!ok) { |
1246 | if (!ok) { |
1244 | QString debug_str;
|
1247 | QString debug_str;
|
1245 | debug_str.append(tr("ôóí showObjects(): Database Error ")); |
1248 | debug_str.append(tr("ôóí showObjects(): Database Error ")); |
1246 | debug_str.append(tr(" õð: ")); |
1249 | debug_str.append(tr(" õð: ")); |
1247 | debug_str.append(inctance); |
1250 | debug_str.append(inctance); |
1248 | debug_str.append(tr(" ô: ")); |
1251 | debug_str.append(tr(" ô: ")); |
1249 | debug_str.append(filtr); |
1252 | debug_str.append(filtr); |
1250 | debug_str.append(q.lastError().text()); |
1253 | debug_str.append(q.lastError().text()); |
1251 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
1254 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
1252 | this, // Ðîäèòåëüñêèé âèäæåò. |
1255 | this, // Ðîäèòåëüñêèé âèäæåò. |
1253 | QObject::tr("ôóíêöèÿ showObjects(): Database Error"), // Çàãîëîâîê. |
1256 | QObject::tr("ôóíêöèÿ showObjects(): Database Error"), // Çàãîëîâîê. |
1254 | debug_str |
1257 | debug_str |
1255 | // q.lastError().text()
|
1258 | // q.lastError().text()
|
1256 | ); // Òåêñò ñîîáùåíèÿ. |
1259 | ); // Òåêñò ñîîáùåíèÿ. |
1257 | return; |
1260 | return; |
1258 | }
|
1261 | }
|
1259 | 1262 | ||
1260 | field_ID = q.record().indexOf(tr("ID")); |
1263 | field_ID = q.record().indexOf(tr("ID")); |
1261 | 1264 | ||
1262 | icon_field_index = q.record().indexOf(tr("Icon")); |
1265 | icon_field_index = q.record().indexOf(tr("Icon")); |
1263 | 1266 | ||
1264 | int k=0; |
1267 | int k=0; |
1265 | QStringList fieldsNamesList;// ñïèñîê èì¸í ïîëåé òàáëèöû |
1268 | QStringList fieldsNamesList;// ñïèñîê èì¸í ïîëåé òàáëèöû |
1266 | QList<TField> FieldsList; //ñïèñîê ïîëåé êëàññà |
1269 | QList<TField> FieldsList; //ñïèñîê ïîëåé êëàññà |
1267 | QMap<QString, TField> fieldsMap;// çäåñü áóäåì â êà÷åñòâå êëþ÷åé õðàíèòü èìåíà ïîëåé, à â êà÷åñòâå çíà÷åíèé - íåïîñðåäñòâåííî ñîîòâåòñòâóþùèå ïîëÿ |
1270 | QMap<QString, TField> fieldsMap;// çäåñü áóäåì â êà÷åñòâå êëþ÷åé õðàíèòü èìåíà ïîëåé, à â êà÷åñòâå çíà÷åíèé - íåïîñðåäñòâåííî ñîîòâåòñòâóþùèå ïîëÿ |
1268 | QMap <QString, QString> fieldsValues;// çäåñü áóäåì õðàíèòü çíà÷åíèÿ ïîëåé, êëþ÷àìè áóäóò ñëóæèòü èìåíà ïîëåé |
1271 | QMap <QString, QString> fieldsValues;// çäåñü áóäåì õðàíèòü çíà÷åíèÿ ïîëåé, êëþ÷àìè áóäóò ñëóæèòü èìåíà ïîëåé |
1269 | FieldsList = getFieldList(classID); // ïîëó÷àåì ñïèñîê ïîëåé |
1272 | FieldsList = getFieldList(classID); // ïîëó÷àåì ñïèñîê ïîëåé |
1270 | 1273 | ||
1271 | 1274 | ||
1272 | 1275 | ||
1273 | 1276 | ||
1274 | 1277 | ||
1275 | if(FieldsList.count()>0){ |
1278 | if(FieldsList.count()>0){ |
1276 | for(int i=0; i < FieldsList.count(); i++){ //ñîñòàâèì ïàðû (èìÿ ïîëÿ-òèï ïîëÿ) |
1279 | for(int i=0; i < FieldsList.count(); i++){ //ñîñòàâèì ïàðû (èìÿ ïîëÿ-òèï ïîëÿ) |
1277 | fieldsTypesList.insert(FieldsList.at(i).FieldName, FieldsList.at(i).FieldType); |
1280 | fieldsTypesList.insert(FieldsList.at(i).FieldName, FieldsList.at(i).FieldType); |
1278 | fieldsMap.insert(FieldsList.at(i).FieldName, FieldsList.at(i)); |
1281 | fieldsMap.insert(FieldsList.at(i).FieldName, FieldsList.at(i)); |
1279 | }
|
1282 | }
|
1280 | 1283 | ||
1281 | // fieldsNamesList = fieldsTypesList.keys(); // ïîëó÷èì ñïèñîê èìåí ïîëåé
|
1284 | // fieldsNamesList = fieldsTypesList.keys(); // ïîëó÷èì ñïèñîê èìåí ïîëåé
|
1282 | }
|
1285 | }
|
1283 | 1286 | ||
1284 | // icon_field_index = fieldsNamesList.indexOf(tr("Icon"));//îïðåäåëèì èíäåêñ ïîëÿ ñ èêîíêîé
|
1287 | // icon_field_index = fieldsNamesList.indexOf(tr("Icon"));//îïðåäåëèì èíäåêñ ïîëÿ ñ èêîíêîé
|
1285 | 1288 | ||
1286 | 1289 | ||
1287 | 1290 | ||
1288 | while(!q.record().fieldName(k).isEmpty()){// ïîêà íå ïåðåáåð¸ì âñå ïîëÿ |
1291 | while(!q.record().fieldName(k).isEmpty()){// ïîêà íå ïåðåáåð¸ì âñå ïîëÿ |
1289 | fieldsNamesList.append(q.record().fieldName(k++)); |
1292 | fieldsNamesList.append(q.record().fieldName(k++)); |
1290 | }
|
1293 | }
|
1291 | 1294 | ||
1292 | 1295 | ||
1293 | //icon_field_index = fieldsNamesList.indexOf(tr("Icon"));//îïðåäåëèì èíäåêñ ïîëÿ ñ èêîíêîé
|
1296 | //icon_field_index = fieldsNamesList.indexOf(tr("Icon"));//îïðåäåëèì èíäåêñ ïîëÿ ñ èêîíêîé
|
1294 | 1297 | ||
1295 | 1298 | ||
1296 | while(q.next()){ |
1299 | while(q.next()){ |
1297 | if (q.record().count() > 1) |
1300 | if (q.record().count() > 1) |
1298 | {
|
1301 | {
|
1299 | QString value_tmp;
|
1302 | QString value_tmp;
|
1300 | QString ID_tmp;
|
1303 | QString ID_tmp;
|
1301 | QString space;
|
1304 | QString space;
|
1302 | 1305 | ||
1303 | // // // // QTreeWidgetItem * itm;
|
1306 | // // // // QTreeWidgetItem * itm;
|
1304 | ID_tmp = q.value(field_ID).toString(); // îïðåäåëÿåì èäåíòèôèêàòîð îáúåêòà |
1307 | ID_tmp = q.value(field_ID).toString(); // îïðåäåëÿåì èäåíòèôèêàòîð îáúåêòà |
1305 | value_tmp = q.value(1).toString(); // îïðåäåëÿåì èìÿ îáúåêòà (äîëæíî õðàíèòüñÿ â ïåðâîì ïîëå) |
1308 | value_tmp = q.value(1).toString(); // îïðåäåëÿåì èìÿ îáúåêòà (äîëæíî õðàíèòüñÿ â ïåðâîì ïîëå) |
1306 | // itm = new QTreeWidgetItem(parent_object_item); // äîáàâëÿåì â äåðåâî óçåë, ñîîòâåòñòâóþùèé îáúåêòó
|
1309 | // itm = new QTreeWidgetItem(parent_object_item); // äîáàâëÿåì â äåðåâî óçåë, ñîîòâåòñòâóþùèé îáúåêòó
|
1307 | 1310 | ||
1308 | 1311 | ||
1309 | 1312 | ||
1310 | 1313 | ||
1311 | /***************************
|
1314 | /***************************
|
1312 | itm = new QTreeWidgetItem(title_item); // äîáàâëÿåì â äåðåâî óçåë, ñîîòâåòñòâóþùèé îáúåêòó
|
1315 | itm = new QTreeWidgetItem(title_item); // äîáàâëÿåì â äåðåâî óçåë, ñîîòâåòñòâóþùèé îáúåêòó
|
1313 | itm->setText(0, value_tmp);
|
1316 | itm->setText(0, value_tmp);
|
1314 | itm->setText(1, tr("object"));
|
1317 | itm->setText(1, tr("object"));
|
1315 | itm->setText(2, ID_tmp);
|
1318 | itm->setText(2, ID_tmp);
|
1316 | ******************************/
|
1319 | ******************************/
|
1317 | 1320 | ||
1318 | if (icon_field_index != -1){ // åñëè èìååòñÿ ïîëå ñ èêîíêàìè |
1321 | if (icon_field_index != -1){ // åñëè èìååòñÿ ïîëå ñ èêîíêàìè |
1319 | 1322 | ||
1320 | QVariant data;
|
1323 | QVariant data;
|
1321 | QByteArray bytes;
|
1324 | QByteArray bytes;
|
1322 | QPixmap pix;
|
1325 | QPixmap pix;
|
1323 | QIcon icn;
|
1326 | QIcon icn;
|
1324 | QMap <QString, QPixmap> pixmap_map; |
1327 | QMap <QString, QPixmap> pixmap_map; |
1325 | QList <QString> id_list; |
1328 | QList <QString> id_list; |
1326 | QList <QPixmap> pixmap_list; |
1329 | QList <QPixmap> pixmap_list; |
1327 | pixmap_map = MainWindow::getObjectsIcon(inctance); |
1330 | pixmap_map = MainWindow::getObjectsIcon(inctance); |
1328 | if (!pixmap_map.isEmpty()) { |
1331 | if (!pixmap_map.isEmpty()) { |
1329 | id_list = pixmap_map.keys(); |
1332 | id_list = pixmap_map.keys(); |
1330 | pixmap_list = pixmap_map.values(); |
1333 | pixmap_list = pixmap_map.values(); |
1331 | }
|
1334 | }
|
1332 | if (id_list.indexOf(ID_tmp) != -1) { |
1335 | if (id_list.indexOf(ID_tmp) != -1) { |
1333 | pix = pixmap_list.at(id_list.indexOf(ID_tmp)); |
1336 | pix = pixmap_list.at(id_list.indexOf(ID_tmp)); |
1334 | }
|
1337 | }
|
1335 | // data = q.record().value(icon_field_index);
|
1338 | // data = q.record().value(icon_field_index);
|
1336 | // bytes = q.record().value(icon_field_index).toByteArray();
|
1339 | // bytes = q.record().value(icon_field_index).toByteArray();
|
1337 | // if (data.isValid() && (!data.isNull())) {
|
1340 | // if (data.isValid() && (!data.isNull())) {
|
1338 | // if (!bytes.isEmpty()){
|
1341 | // if (!bytes.isEmpty()){
|
1339 | // pix.loadFromData(data.toByteArray());
|
1342 | // pix.loadFromData(data.toByteArray());
|
1340 | // pix.loadFromData(bytes);
|
1343 | // pix.loadFromData(bytes);
|
1341 | 1344 | ||
1342 | 1345 | ||
1343 | if(!pix.isNull()) { |
1346 | if(!pix.isNull()) { |
1344 | if (pix.height() > 128) pix = pix.scaledToHeight(128); |
1347 | if (pix.height() > 128) pix = pix.scaledToHeight(128); |
1345 | QString fname = value_tmp; |
1348 | QString fname = value_tmp; |
1346 | fname.append(tr(".png")); |
1349 | fname.append(tr(".png")); |
1347 | 1350 | ||
1348 | 1351 | ||
1349 | pix.toImage().save(fname); |
1352 | pix.toImage().save(fname); |
1350 | doc->addResource(QTextDocument::ImageResource, QUrl(fname), pix.toImage()); |
1353 | doc->addResource(QTextDocument::ImageResource, QUrl(fname), pix.toImage()); |
1351 | 1354 | ||
1352 | // for(int i=0; i<pos; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû
|
1355 | // for(int i=0; i<pos; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû
|
1353 | 1356 | ||
1354 | 1357 | ||
1355 | for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1358 | for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1356 | cursor->insertImage(fname); |
1359 | cursor->insertImage(fname); |
1357 | // cursor->insertText(tr("\n"));
|
1360 | // cursor->insertText(tr("\n"));
|
1358 | 1361 | ||
1359 | }
|
1362 | }
|
1360 | else for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1363 | else for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1361 | 1364 | ||
1362 | 1365 | ||
1363 | 1366 | ||
1364 | 1367 | ||
1365 | // // // icn.addPixmap(pix);
|
1368 | // // // icn.addPixmap(pix);
|
1366 | // // // itm->setIcon(0, icn);
|
1369 | // // // itm->setIcon(0, icn);
|
1367 | // }
|
1370 | // }
|
1368 | 1371 | ||
1369 | 1372 | ||
1370 | }
|
1373 | }
|
1371 | 1374 | ||
1372 | else for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1375 | else for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
1373 | cursor->insertText( value_tmp); |
1376 | cursor->insertText( value_tmp); |
1374 | cursor->insertText( tr("\n")); |
1377 | cursor->insertText( tr("\n")); |
1375 | 1378 | ||
1376 | 1379 | ||
1377 | 1380 | ||
1378 | // q.first();
|
1381 | // q.first();
|
1379 | 1382 | ||
1380 | 1383 | ||
1381 | if(advanced && (fieldsNamesList.count()>0)){ // åñëè îò÷åò ðàñøèðåííûé |
1384 | if(advanced && (fieldsNamesList.count()>0)){ // åñëè îò÷åò ðàñøèðåííûé |
1382 | 1385 | ||
1383 | QString tmp_string;
|
1386 | QString tmp_string;
|
1384 | sql_str.clear(); |
1387 | sql_str.clear(); |
1385 | 1388 | ||
1386 | // // // QTextTable *table = cursor->insertTable(fieldsNamesList.count()-2, 2);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà)
|
1389 | // // // QTextTable *table = cursor->insertTable(fieldsNamesList.count()-2, 2);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà)
|
1387 | 1390 | ||
1388 | 1391 | ||
1389 | 1392 | ||
1390 | /************************
|
1393 | /************************
|
1391 | QTextTable *table = cursor->insertTable(fieldsNamesList.count(), 2);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà)
|
1394 | QTextTable *table = cursor->insertTable(fieldsNamesList.count(), 2);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà)
|
1392 | 1395 | ||
1393 | ************************/
|
1396 | ************************/
|
1394 | 1397 | ||
1395 | 1398 | ||
1396 | 1399 | ||
1397 | 1400 | ||
1398 | 1401 | ||
1399 | 1402 | ||
1400 | 1403 | ||
1401 | 1404 | ||
1402 | 1405 | ||
1403 | 1406 | ||
1404 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû"));
|
1407 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû"));
|
1405 | 1408 | ||
1406 | 1409 | ||
1407 | // *cursor = table->cellAt(0,1).firstCursorPosition();
|
1410 | // *cursor = table->cellAt(0,1).firstCursorPosition();
|
1408 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû 2"));
|
1411 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû 2"));
|
1409 | // *cursor = table->cellAt(1,1).lastCursorPosition();
|
1412 | // *cursor = table->cellAt(1,1).lastCursorPosition();
|
1410 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû 4"));
|
1413 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû 4"));
|
1411 | 1414 | ||
1412 | 1415 | ||
1413 | // cursor->movePosition(QTextCursor::End);
|
1416 | // cursor->movePosition(QTextCursor::End);
|
1414 | 1417 | ||
1415 | 1418 | ||
1416 | 1419 | ||
1417 | //table->cellAt(1,1).firstCursorPosition().insertText(tr("1"));
|
1420 | //table->cellAt(1,1).firstCursorPosition().insertText(tr("1"));
|
1418 | //table->cellAt(1,2).firstCursorPosition().insertText(tr("2"));
|
1421 | //table->cellAt(1,2).firstCursorPosition().insertText(tr("2"));
|
1419 | //table->cellAt(2,1).firstCursorPosition().insertText(tr("3"));
|
1422 | //table->cellAt(2,1).firstCursorPosition().insertText(tr("3"));
|
1420 | 1423 | ||
1421 | //table->cellAt(2,2).firstCursorPosition().insertText(tr("4"));
|
1424 | //table->cellAt(2,2).firstCursorPosition().insertText(tr("4"));
|
1422 | // cursor->insertText(tr("1 \t 2"));
|
1425 | // cursor->insertText(tr("1 \t 2"));
|
1423 | // cursor->insertText(tr("3 \t 4"));
|
1426 | // cursor->insertText(tr("3 \t 4"));
|
1424 | 1427 | ||
1425 | for(int i=0; i < fieldsNamesList.count(); i++) |
1428 | for(int i=0; i < fieldsNamesList.count(); i++) |
1426 | {
|
1429 | {
|
1427 | 1430 | ||
1428 | 1431 | ||
1429 | if (fieldsNamesList.at(i)== tr("Icon") || fieldsNamesList.at(i)== tr("ID")) { tmp_string = tr("íå âîçìîæíî îòîáðàçèòü"); |
1432 | if (fieldsNamesList.at(i)== tr("Icon") || fieldsNamesList.at(i)== tr("ID")) { tmp_string = tr("íå âîçìîæíî îòîáðàçèòü"); |
1430 | continue; |
1433 | continue; |
1431 | }
|
1434 | }
|
1432 | 1435 | ||
1433 | QString fieldType;
|
1436 | QString fieldType;
|
1434 | fieldType = fieldsTypesList.value(fieldsNamesList.at(i)); //îïðåäåëÿåì òèï ïîëÿ |
1437 | fieldType = fieldsTypesList.value(fieldsNamesList.at(i)); //îïðåäåëÿåì òèï ïîëÿ |
1435 | if(fieldType == tr("pointer")) // åñëè òèï ïîëÿ - óêàçàòåëü |
1438 | if(fieldType == tr("pointer")) // åñëè òèï ïîëÿ - óêàçàòåëü |
1436 | {
|
1439 | {
|
1437 | QSqlQuery q_tmp;
|
1440 | QSqlQuery q_tmp;
|
1438 | QString sql_str;
|
1441 | QString sql_str;
|
1439 | // QString val_str;
|
1442 | // QString val_str;
|
1440 | QString parent_class_id;// èäåíòèôèêàòîð êëàññà, íà îáúåêòû êîòîðîãî ññûëàåòñÿ ïîëå |
1443 | QString parent_class_id;// èäåíòèôèêàòîð êëàññà, íà îáúåêòû êîòîðîãî ññûëàåòñÿ ïîëå |
1441 | QString parent_class_inctance; // õðàíèëèùå îáúåêòîâ ðîäèòåëüñêîãî êëàññà |
1444 | QString parent_class_inctance; // õðàíèëèùå îáúåêòîâ ðîäèòåëüñêîãî êëàññà |
1442 | bool ok; |
1445 | bool ok; |
1443 | TField field_tmp;
|
1446 | TField field_tmp;
|
1444 | field_tmp = fieldsMap.value(fieldsNamesList.at(i)); |
1447 | field_tmp = fieldsMap.value(fieldsNamesList.at(i)); |
1445 | parent_class_id = field_tmp.DefaultValue; |
1448 | parent_class_id = field_tmp.DefaultValue; |
1446 | if (parent_class_id.isEmpty()) continue; // íå ñìîãëè îïðåäåëèòü id ðîäèòåëüñêîãî êëàññà |
1449 | if (parent_class_id.isEmpty()) continue; // íå ñìîãëè îïðåäåëèòü id ðîäèòåëüñêîãî êëàññà |
1447 | else parent_class_inctance = getClassInctance(parent_class_id); |
1450 | else parent_class_inctance = getClassInctance(parent_class_id); |
1448 | if (parent_class_inctance.isEmpty()) continue; // íå ñìîãëè îïðåäåëèòü id ðîäèòåëüñêîãî êëàññà |
1451 | if (parent_class_inctance.isEmpty()) continue; // íå ñìîãëè îïðåäåëèòü id ðîäèòåëüñêîãî êëàññà |
1449 | sql_str = tr("select * from `"); |
1452 | sql_str = tr("select * from `"); |
1450 | sql_str.append(parent_class_inctance); |
1453 | sql_str.append(parent_class_inctance); |
1451 | sql_str.append(tr("` where `ID` = '")); |
1454 | sql_str.append(tr("` where `ID` = '")); |
1452 | sql_str.append(q.record().value(i).asString()); |
1455 | sql_str.append(q.record().value(i).asString()); |
1453 | sql_str.append(tr("'")); |
1456 | sql_str.append(tr("'")); |
1454 | ok = q_tmp.prepare(sql_str); |
1457 | ok = q_tmp.prepare(sql_str); |
1455 | ok = q_tmp.exec(); |
1458 | ok = q_tmp.exec(); |
1456 | 1459 | ||
1457 | if (!ok) { |
1460 | if (!ok) { |
1458 | QString debug_str;
|
1461 | QString debug_str;
|
1459 | debug_str.append(tr("ôóí showObjects(): Database Error ")); |
1462 | debug_str.append(tr("ôóí showObjects(): Database Error ")); |
1460 | debug_str.append(tr(" õð: ")); |
1463 | debug_str.append(tr(" õð: ")); |
1461 | debug_str.append(inctance); |
1464 | debug_str.append(inctance); |
1462 | debug_str.append(tr(" ô: ")); |
1465 | debug_str.append(tr(" ô: ")); |
1463 | debug_str.append(filtr); |
1466 | debug_str.append(filtr); |
1464 | debug_str.append(q.lastError().text()); |
1467 | debug_str.append(q.lastError().text()); |
1465 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
1468 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
1466 | this, // Ðîäèòåëüñêèé âèäæåò. |
1469 | this, // Ðîäèòåëüñêèé âèäæåò. |
1467 | QObject::tr("ôóíêöèÿ showObjects(): Database Error"), // Çàãîëîâîê. |
1470 | QObject::tr("ôóíêöèÿ showObjects(): Database Error"), // Çàãîëîâîê. |
1468 | debug_str |
1471 | debug_str |
1469 | // q.lastError().text()
|
1472 | // q.lastError().text()
|
1470 | ); // Òåêñò ñîîáùåíèÿ. |
1473 | ); // Òåêñò ñîîáùåíèÿ. |
1471 | return; |
1474 | return; |
1472 | }
|
1475 | }
|
1473 | 1476 | ||
1474 | tmp_string.clear(); |
1477 | tmp_string.clear(); |
1475 | while (q_tmp.next()){ |
1478 | while (q_tmp.next()){ |
1476 | tmp_string = q_tmp.record().value(1).asString(); |
1479 | tmp_string = q_tmp.record().value(1).asString(); |
1477 | 1480 | ||
1478 | }
|
1481 | }
|
1479 | 1482 | ||
1480 | fieldsValues.insert(fieldsNamesList.at(i), tmp_string);// äîáàâëÿåì çíà÷åíèå â ñïèñîê çíà÷åíèé |
1483 | fieldsValues.insert(fieldsNamesList.at(i), tmp_string);// äîáàâëÿåì çíà÷åíèå â ñïèñîê çíà÷åíèé |
1481 | 1484 | ||
1482 | continue;// ïåðåõîäèì ê ñëåäóþùåé èíòåðàöèè |
1485 | continue;// ïåðåõîäèì ê ñëåäóþùåé èíòåðàöèè |
1483 | 1486 | ||
1484 | } // äàëüøå åñëè òèï ïîëÿ íå pointer |
1487 | } // äàëüøå åñëè òèï ïîëÿ íå pointer |
1485 | 1488 | ||
1486 | if(fieldType == tr("file")){ // åñëè òèï ïîëÿ - ôàéë, íå áóäåì îòîáðàæàòü |
1489 | if(fieldType == tr("file")){ // åñëè òèï ïîëÿ - ôàéë, íå áóäåì îòîáðàæàòü |
1487 | 1490 | ||
1488 | tmp_string = tr("íå âîçìîæíî îòîáðàçèòü"); |
1491 | tmp_string = tr("íå âîçìîæíî îòîáðàçèòü"); |
1489 | continue; |
1492 | continue; |
1490 | 1493 | ||
1491 | }
|
1494 | }
|
1492 | 1495 | ||
1493 | tmp_string = q.record().value(i).asString(); // ýòî íå èêîíêà, íå ôàéë è íå ïîëå-óêàçàòåëü, ïðîñòî îòîáðàæàåì çíà÷åíèå |
1496 | tmp_string = q.record().value(i).asString(); // ýòî íå èêîíêà, íå ôàéë è íå ïîëå-óêàçàòåëü, ïðîñòî îòîáðàæàåì çíà÷åíèå |
1494 | fieldsValues.insert(fieldsNamesList.at(i), tmp_string);// äîáàâëÿåì çíà÷åíèå â ñïèñîê çíà÷åíèé |
1497 | fieldsValues.insert(fieldsNamesList.at(i), tmp_string);// äîáàâëÿåì çíà÷åíèå â ñïèñîê çíà÷åíèé |
1495 | 1498 | ||
1496 | 1499 | ||
1497 | }
|
1500 | }
|
1498 | 1501 | ||
1499 | 1502 | ||
1500 | 1503 | ||
1501 | 1504 | ||
1502 | 1505 | ||
1503 | // for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû
|
1506 | // for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû
|
1504 | tableFormat.setAlignment(Qt::AlignLeft); |
1507 | tableFormat.setAlignment(Qt::AlignLeft); |
1505 | tableFormat.setBackground(QColor("#e0e0e0")); |
1508 | tableFormat.setBackground(QColor("#e0e0e0")); |
1506 | // tableFormat.setCellPadding(2);
|
1509 | // tableFormat.setCellPadding(2);
|
1507 | // tableFormat.setCellSpacing(4);
|
1510 | // tableFormat.setCellSpacing(4);
|
1508 | tableFormat.setLeftMargin(pos*7); |
1511 | tableFormat.setLeftMargin(pos*7); |
1509 | tableFormat.setBorder(1); |
1512 | tableFormat.setBorder(1); |
1510 | tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid); |
1513 | tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid); |
1511 | 1514 | ||
1512 | QTextTable *table = cursor->insertTable(fieldsValues.count(), 2, tableFormat);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà) |
1515 | QTextTable *table = cursor->insertTable(fieldsValues.count(), 2, tableFormat);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà) |
1513 | // table->setFormat(tableFormat);
|
1516 | // table->setFormat(tableFormat);
|
1514 | 1517 | ||
1515 | 1518 | ||
1516 | for(int i=0; i < fieldsValues.count(); i++){ // ïðîïóñòèì ïîëÿ: ID è ïîëå, ñîäåðæàùåå èìÿ îáúåêòà (îíî è òàê óæå îòîáðàæåíî) |
1519 | for(int i=0; i < fieldsValues.count(); i++){ // ïðîïóñòèì ïîëÿ: ID è ïîëå, ñîäåðæàùåå èìÿ îáúåêòà (îíî è òàê óæå îòîáðàæåíî) |
1517 | QStringList keys_list = fieldsValues.keys(); |
1520 | QStringList keys_list = fieldsValues.keys(); |
1518 | QStringList values_list = fieldsValues.values(); |
1521 | QStringList values_list = fieldsValues.values(); |
1519 | *cursor = table->cellAt(i,0).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö ïåðâûé |
1522 | *cursor = table->cellAt(i,0).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö ïåðâûé |
1520 | cursor->insertText(keys_list.at(i), charFormatItalicOnly);//ñþäà çàíîñèì èìÿ ïîëÿ |
1523 | cursor->insertText(keys_list.at(i), charFormatItalicOnly);//ñþäà çàíîñèì èìÿ ïîëÿ |
1521 | *cursor = table->cellAt(i,1).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö âòîðîé |
1524 | *cursor = table->cellAt(i,1).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö âòîðîé |
1522 | cursor->insertText(values_list.at(i));//ñþäà çàíîñèì èìÿ ïîëÿ |
1525 | cursor->insertText(values_list.at(i));//ñþäà çàíîñèì èìÿ ïîëÿ |
1523 | }
|
1526 | }
|
1524 | 1527 | ||
1525 | // table->setFormat(tableFormat);
|
1528 | // table->setFormat(tableFormat);
|
1526 | cursor->movePosition(QTextCursor::End);//âûõîäèì èç òàáëèöû |
1529 | cursor->movePosition(QTextCursor::End);//âûõîäèì èç òàáëèöû |
1527 | cursor->insertText( tr("\n")); |
1530 | cursor->insertText( tr("\n")); |
1528 | 1531 | ||
1529 | 1532 | ||
1530 | 1533 | ||
1531 | /******************************
|
1534 | /******************************
|
1532 | 1535 | ||
1533 | table = cursor->insertTable(fieldsNamesList.count(), 2);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà)
|
1536 | table = cursor->insertTable(fieldsNamesList.count(), 2);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà)
|
1534 | 1537 | ||
1535 | for(int i=2; i < fieldsNamesList.count(); i++){ // ïðîïóñòèì ïîëÿ: ID è ïîëå, ñîäåðæàùåå èìÿ îáúåêòà (îíî è òàê óæå îòîáðàæåíî)
|
1538 | for(int i=2; i < fieldsNamesList.count(); i++){ // ïðîïóñòèì ïîëÿ: ID è ïîëå, ñîäåðæàùåå èìÿ îáúåêòà (îíî è òàê óæå îòîáðàæåíî)
|
1536 | // if (i !=icon_field_index) tmp_string = q.record().value(i).asString(); // åñëè ýòî íå èêîíêà, òî ñ÷èòûâàåì çíà÷åíèå êàê ñòðîêó
|
1539 | // if (i !=icon_field_index) tmp_string = q.record().value(i).asString(); // åñëè ýòî íå èêîíêà, òî ñ÷èòûâàåì çíà÷åíèå êàê ñòðîêó
|
1537 | if (i !=icon_field_index) tmp_string = q.record().value(i).asString(); // åñëè ýòî íå èêîíêà, òî ñ÷èòûâàåì çíà÷åíèå êàê ñòðîêó
|
1540 | if (i !=icon_field_index) tmp_string = q.record().value(i).asString(); // åñëè ýòî íå èêîíêà, òî ñ÷èòûâàåì çíà÷åíèå êàê ñòðîêó
|
1538 | 1541 | ||
1539 | 1542 | ||
1540 | else tmp_string = tr("íåâîçìîæíî îòîáðàçèòü");
|
1543 | else tmp_string = tr("íåâîçìîæíî îòîáðàçèòü");
|
1541 | //// if (i !=icon_field_index) {
|
1544 | //// if (i !=icon_field_index) {
|
1542 | for(int i=0; i<pos+2; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû
|
1545 | for(int i=0; i<pos+2; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû
|
1543 | *cursor = table->cellAt(i-2,0).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö ïåðâûé
|
1546 | *cursor = table->cellAt(i-2,0).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö ïåðâûé
|
1544 | cursor->insertText( fieldsNamesList.at(i));//ñþäà çàíîñèì èìÿ ïîëÿ
|
1547 | cursor->insertText( fieldsNamesList.at(i));//ñþäà çàíîñèì èìÿ ïîëÿ
|
1545 | *cursor = table->cellAt(i-2,1).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö âòîðîé
|
1548 | *cursor = table->cellAt(i-2,1).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö âòîðîé
|
1546 | //cursor->insertText( tr(":\t"));
|
1549 | //cursor->insertText( tr(":\t"));
|
1547 | 1550 | ||
1548 | cursor->insertText(tmp_string);//ñþäà çíà÷åíèå ïîëÿ
|
1551 | cursor->insertText(tmp_string);//ñþäà çíà÷åíèå ïîëÿ
|
1549 | // cursor->insertText( tr("\n"));
|
1552 | // cursor->insertText( tr("\n"));
|
1550 | }
|
1553 | }
|
1551 | 1554 | ||
1552 | //// }
|
1555 | //// }
|
1553 | 1556 | ||
1554 | 1557 | ||
1555 | 1558 | ||
1556 | 1559 | ||
1557 | 1560 | ||
1558 | 1561 | ||
1559 | 1562 | ||
1560 | 1563 | ||
1561 | 1564 | ||
1562 | 1565 | ||
1563 | cursor->movePosition(QTextCursor::End);//âûõîäèì èç òàáëèöû
|
1566 | cursor->movePosition(QTextCursor::End);//âûõîäèì èç òàáëèöû
|
1564 | cursor->insertText( tr("\n"));
|
1567 | cursor->insertText( tr("\n"));
|
1565 | 1568 | ||
1566 | *********************************/
|
1569 | *********************************/
|
1567 | 1570 | ||
1568 | }
|
1571 | }
|
1569 | 1572 | ||
1570 | 1573 | ||
1571 | 1574 | ||
1572 | /********************************************************
|
1575 | /********************************************************
|
1573 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
|
1576 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
|
1574 | cursor->setBlockFormat(textFormat);
|
1577 | cursor->setBlockFormat(textFormat);
|
1575 | 1578 | ||
1576 | cursor->insertText(tr("Íîâàÿ ñòðàíèöà "));
|
1579 | cursor->insertText(tr("Íîâàÿ ñòðàíèöà "));
|
1577 | cursor->insertBlock();
|
1580 | cursor->insertBlock();
|
1578 | 1581 | ||
1579 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
|
1582 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
|
1580 | cursor->setBlockFormat(textFormat);
|
1583 | cursor->setBlockFormat(textFormat);
|
1581 | **********************************************************/
|
1584 | **********************************************************/
|
1582 | 1585 | ||
1583 | 1586 | ||
1584 | // itm->setIcon(0, icon);
|
1587 | // itm->setIcon(0, icon);
|
1585 | 1588 | ||
1586 | 1589 | ||
1587 | for (int i=0; i < model_item->childCount(); i++) // ïðîâåðÿåì, åñòü ëè ó êëàññà äî÷åðíèå êëàññû |
1590 | for (int i=0; i < model_item->childCount(); i++) // ïðîâåðÿåì, åñòü ëè ó êëàññà äî÷åðíèå êëàññû |
1588 | {
|
1591 | {
|
1589 | QTreeWidgetItem * model_item_tmp; // åñëè åñòü |
1592 | QTreeWidgetItem * model_item_tmp; // åñëè åñòü |
1590 | QString pointer_name;
|
1593 | QString pointer_name;
|
1591 | QString filtr_tmp;
|
1594 | QString filtr_tmp;
|
1592 | bool pointer_isEmpty; |
1595 | bool pointer_isEmpty; |
1593 | model_item_tmp = model_item->child(i); // îòîáðàæàåì îáúåêòû äî÷åðíèõ êëàññîâ |
1596 | model_item_tmp = model_item->child(i); // îòîáðàæàåì îáúåêòû äî÷åðíèõ êëàññîâ |
1594 | pointer_name = getPointerFieldName(classID, model_item->child(i)->text(1)); |
1597 | pointer_name = getPointerFieldName(classID, model_item->child(i)->text(1)); |
1595 | // // // // itm->setText(4, pointer_name);
|
1598 | // // // // itm->setText(4, pointer_name);
|
1596 | 1599 | ||
1597 | // title_item->setText(4, pointer_name);
|
1600 | // title_item->setText(4, pointer_name);
|
1598 | 1601 | ||
1599 | 1602 | ||
1600 | pointer_isEmpty = pointer_name.isEmpty(); |
1603 | pointer_isEmpty = pointer_name.isEmpty(); |
1601 | filtr_tmp = tr("where "); |
1604 | filtr_tmp = tr("where "); |
1602 | filtr_tmp.append(tr("`")); |
1605 | filtr_tmp.append(tr("`")); |
1603 | filtr_tmp.append(pointer_name); |
1606 | filtr_tmp.append(pointer_name); |
1604 | filtr_tmp.append(tr("` = '")); |
1607 | filtr_tmp.append(tr("` = '")); |
1605 | filtr_tmp.append(ID_tmp); |
1608 | filtr_tmp.append(ID_tmp); |
1606 | filtr_tmp.append(tr("'")); |
1609 | filtr_tmp.append(tr("'")); |
1607 | 1610 | ||
1608 | printChild(model_item_tmp, filtr_tmp, advanced, pos+1); |
1611 | printChild(model_item_tmp, filtr_tmp, advanced, pos+1); |
1609 | 1612 | ||
1610 | // // // // showObjects(itm, model_item_tmp, filtr_tmp);
|
1613 | // // // // showObjects(itm, model_item_tmp, filtr_tmp);
|
1611 | //MainWindow::showObjectChildrens(ID_tmp, itm, model_item_tmp);
|
1614 | //MainWindow::showObjectChildrens(ID_tmp, itm, model_item_tmp);
|
1612 | 1615 | ||
1613 | }
|
1616 | }
|
1614 | // if(pos==2) newPage(); // åñëè ýòî êîðíåâîé êëàññ, âñòàâèì ðàçäåë ñòðàíèöû
|
1617 | // if(pos==2) newPage(); // åñëè ýòî êîðíåâîé êëàññ, âñòàâèì ðàçäåë ñòðàíèöû
|
1615 | 1618 | ||
1616 | }
|
1619 | }
|
1617 | 1620 | ||
1618 | }
|
1621 | }
|
1619 | 1622 | ||
1620 | 1623 | ||
1621 | 1624 | ||
1622 | 1625 | ||
1623 | 1626 | ||
1624 | 1627 | ||
1625 | 1628 | ||
1626 | 1629 | ||
1627 | 1630 | ||
1628 | 1631 | ||
1629 | }
|
1632 | }
|
1630 | 1633 | ||
1631 | 1634 | ||
1632 | void MainWindow::newPage(int page_number){ //âñòàâëÿåì â äîêóìåíò íîâóþ ñòðàíèöó |
1635 | void MainWindow::newPage(int page_number){ //âñòàâëÿåì â äîêóìåíò íîâóþ ñòðàíèöó |
1633 | 1636 | ||
1634 | QTextBlockFormat textFormat;
|
1637 | QTextBlockFormat textFormat;
|
1635 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore); |
1638 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore); |
1636 | cursor->setBlockFormat(textFormat); |
1639 | cursor->setBlockFormat(textFormat); |
1637 | 1640 | ||
1638 | cursor->insertText(tr("Íîâàÿ ñòðàíèöà %1").arg(page_number)); |
1641 | cursor->insertText(tr("Íîâàÿ ñòðàíèöà %1").arg(page_number)); |
1639 | cursor->insertBlock(); |
1642 | cursor->insertBlock(); |
1640 | 1643 | ||
1641 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto); |
1644 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto); |
1642 | cursor->setBlockFormat(textFormat); |
1645 | cursor->setBlockFormat(textFormat); |
1643 | 1646 | ||
1644 | 1647 | ||
1645 | }
|
1648 | }
|
1646 | void MainWindow::newPage(){ //âñòàâëÿåì â äîêóìåíò íîâóþ ñòðàíèöó |
1649 | void MainWindow::newPage(){ //âñòàâëÿåì â äîêóìåíò íîâóþ ñòðàíèöó |
1647 | 1650 | ||
1648 | QTextBlockFormat textFormat;
|
1651 | QTextBlockFormat textFormat;
|
1649 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore); |
1652 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore); |
1650 | cursor->setBlockFormat(textFormat); |
1653 | cursor->setBlockFormat(textFormat); |
1651 | 1654 | ||
1652 | //cursor->insertText(tr("Íîâàÿ ñòðàíèöà %1").arg(page_number));
|
1655 | //cursor->insertText(tr("Íîâàÿ ñòðàíèöà %1").arg(page_number));
|
1653 | cursor->insertBlock(); |
1656 | cursor->insertBlock(); |
1654 | 1657 | ||
1655 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto); |
1658 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto); |
1656 | cursor->setBlockFormat(textFormat); |
1659 | cursor->setBlockFormat(textFormat); |
1657 | 1660 | ||
1658 | 1661 | ||
1659 | }
|
1662 | }
|
1660 | 1663 | ||
1661 | QList<TField> MainWindow::getFieldList(QString class_id){// ïîëó÷àåì ñïèñîê ïîëåé êëàññà |
1664 | QList<TField> MainWindow::getFieldList(QString class_id){// ïîëó÷àåì ñïèñîê ïîëåé êëàññà |
1662 | 1665 | ||
1663 | QSqlQuery q;
|
1666 | QSqlQuery q;
|
1664 | QString sql_str;
|
1667 | QString sql_str;
|
1665 | QList<TField> result_list; |
1668 | QList<TField> result_list; |
1666 | 1669 | ||
1667 | int field_id, field_name, field_alias, field_type, field_default_value, field_classIdentifer, field_comment; |
1670 | int field_id, field_name, field_alias, field_type, field_default_value, field_classIdentifer, field_comment; |
1668 | 1671 | ||
1669 | bool ok; |
1672 | bool ok; |
1670 | sql_str = tr("select * " |
1673 | sql_str = tr("select * " |
1671 | " from `DescriptionOfClasses` where `DescriptionOfClasses`.`ClassIdentifer` = " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà |
1674 | " from `DescriptionOfClasses` where `DescriptionOfClasses`.`ClassIdentifer` = " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà |
1672 | ); |
1675 | ); |
1673 | 1676 | ||
1674 | sql_str.append(tr("'")); |
1677 | sql_str.append(tr("'")); |
1675 | sql_str.append(class_id); |
1678 | sql_str.append(class_id); |
1676 | sql_str.append(tr("' ")); |
1679 | sql_str.append(tr("' ")); |
1677 | ok = q.prepare(sql_str); |
1680 | ok = q.prepare(sql_str); |
1678 | 1681 | ||
1679 | ok = q.exec(); |
1682 | ok = q.exec(); |
1680 | if (!ok) { |
1683 | if (!ok) { |
1681 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
1684 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
1682 | this, // Ðîäèòåëüñêèé âèäæåò. |
1685 | this, // Ðîäèòåëüñêèé âèäæåò. |
1683 | QObject::tr("Database Error"), // Çàãîëîâîê. |
1686 | QObject::tr("Database Error"), // Çàãîëîâîê. |
1684 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
1687 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
1685 | return result_list; |
1688 | return result_list; |
1686 | }
|
1689 | }
|
1687 | 1690 | ||
1688 | 1691 | ||
1689 | field_id = q.record().indexOf(tr("ID")); |
1692 | field_id = q.record().indexOf(tr("ID")); |
1690 | field_name = q.record().indexOf(tr("FieldName")); |
1693 | field_name = q.record().indexOf(tr("FieldName")); |
1691 | field_alias = q.record().indexOf(tr("FieldAlias")); |
1694 | field_alias = q.record().indexOf(tr("FieldAlias")); |
1692 | field_type = q.record().indexOf(tr("FieldType")); |
1695 | field_type = q.record().indexOf(tr("FieldType")); |
1693 | field_default_value = q.record().indexOf(tr("DefaultValue")); |
1696 | field_default_value = q.record().indexOf(tr("DefaultValue")); |
1694 | field_classIdentifer = q.record().indexOf(tr("ClassIdentifer")); |
1697 | field_classIdentifer = q.record().indexOf(tr("ClassIdentifer")); |
1695 | field_comment = q.record().indexOf(tr("Comment")); |
1698 | field_comment = q.record().indexOf(tr("Comment")); |
1696 | 1699 | ||
1697 | while(q.next()){ |
1700 | while(q.next()){ |
1698 | 1701 | ||
1699 | TField field_tmp;
|
1702 | TField field_tmp;
|
1700 | field_tmp.ID = q.value(field_id).toString(); |
1703 | field_tmp.ID = q.value(field_id).toString(); |
1701 | field_tmp.FieldName = q.value(field_name).toString(); |
1704 | field_tmp.FieldName = q.value(field_name).toString(); |
1702 | field_tmp.FieldAlias = q.value(field_alias).toString(); |
1705 | field_tmp.FieldAlias = q.value(field_alias).toString(); |
1703 | field_tmp.FieldType = q.value(field_type).toString(); |
1706 | field_tmp.FieldType = q.value(field_type).toString(); |
1704 | field_tmp.DefaultValue = q.value(field_default_value).toString(); |
1707 | field_tmp.DefaultValue = q.value(field_default_value).toString(); |
1705 | field_tmp.ClassIdentifer = q.value(field_classIdentifer).toString(); |
1708 | field_tmp.ClassIdentifer = q.value(field_classIdentifer).toString(); |
1706 | field_tmp.Comment = q.value(field_comment).toString(); |
1709 | field_tmp.Comment = q.value(field_comment).toString(); |
1707 | result_list << field_tmp; |
1710 | result_list << field_tmp; |
1708 | 1711 | ||
1709 | 1712 | ||
1710 | 1713 | ||
1711 | 1714 | ||
1712 | // parentClassID = q.value(field_default_value).toString();
|
1715 | // parentClassID = q.value(field_default_value).toString();
|
1713 | // parentClassInctance = getClassInctance(parentClassID);
|
1716 | // parentClassInctance = getClassInctance(parentClassID);
|
1714 | // result_map.insert(pointerFieldName, parentClassInctance);
|
1717 | // result_map.insert(pointerFieldName, parentClassInctance);
|
1715 | 1718 | ||
1716 | 1719 | ||
1717 | 1720 | ||
1718 | }
|
1721 | }
|
1719 | 1722 | ||
1720 | return result_list; |
1723 | return result_list; |
1721 | 1724 | ||
1722 | }
|
1725 | }
|
1723 | 1726 | ||
1724 | 1727 | ||
1725 | 1728 | ||
1726 | void MainWindow::readStandartProcessOutput(){ |
1729 | void MainWindow::readStandartProcessOutput(){ |
1727 | 1730 | ||
1728 | QTextDocument * wmiDoc = ui->textEdit_2->document(); |
1731 | QTextDocument * wmiDoc = ui->textEdit_2->document(); |
1729 | QTextCursor * wmiCursor; |
1732 | QTextCursor * wmiCursor; |
1730 | wmiCursor = new QTextCursor(wmiDoc); |
1733 | wmiCursor = new QTextCursor(wmiDoc); |
1731 | 1734 | ||
1732 | QByteArray arr;
|
1735 | QByteArray arr;
|
1733 | QStringList result, fields, values;
|
1736 | QStringList result, fields, values;
|
1734 | QString str1, str2;
|
1737 | QString str1, str2;
|
1735 | int i; |
1738 | int i; |
1736 | arr = wmiProcess.readAllStandardOutput(); |
1739 | arr = wmiProcess.readAllStandardOutput(); |
1737 | QTextCodec *codecUTF = QTextCodec::codecForName("utf8"); |
1740 | QTextCodec *codecUTF = QTextCodec::codecForName("utf8"); |
1738 | QTextCodec *codec = QTextCodec::codecForName("cp1251"); |
1741 | QTextCodec *codec = QTextCodec::codecForName("cp1251"); |
1739 | QTextCodec::setCodecForTr(codecUTF); |
1742 | QTextCodec::setCodecForTr(codecUTF); |
1740 | str1 = QString(tr(arr)); |
1743 | str1 = QString(tr(arr)); |
1741 | result = str1.split("\n", QString::SkipEmptyParts); |
1744 | result = str1.split("\n", QString::SkipEmptyParts); |
1742 | if (result.count()>2){ |
1745 | if (result.count()>2){ |
1743 | 1746 | ||
1744 | 1747 | ||
1745 | 1748 | ||
1746 | 1749 | ||
1747 | QString tmp_str;
|
1750 | QString tmp_str;
|
1748 | QTextTable * wmi_table; |
1751 | QTextTable * wmi_table; |
1749 | int fields_count, row_count; |
1752 | int fields_count, row_count; |
1750 | tmp_str = result.at(1); |
1753 | tmp_str = result.at(1); |
1751 | fields = tmp_str.split("|"); |
1754 | fields = tmp_str.split("|"); |
1752 | fields_count = fields.count(); |
1755 | fields_count = fields.count(); |
1753 | row_count = result.count()-1; // ïåðâóþ ñòðîêó (íàçâàíèå êëàññà) îòîáðàæàòü íå áóäåì |
1756 | row_count = result.count()-1; // ïåðâóþ ñòðîêó (íàçâàíèå êëàññà) îòîáðàæàòü íå áóäåì |
1754 | wmi_table = wmiCursor->insertTable(row_count, fields_count); |
1757 | wmi_table = wmiCursor->insertTable(row_count, fields_count); |
1755 | for(int n = 0; n < fields.count(); n++) { // çàïîëíÿåì "øàïêó" òàáëèöû |
1758 | for(int n = 0; n < fields.count(); n++) { // çàïîëíÿåì "øàïêó" òàáëèöû |
1756 | *wmiCursor = wmi_table->cellAt(0, n).firstCursorPosition(); |
1759 | *wmiCursor = wmi_table->cellAt(0, n).firstCursorPosition(); |
1757 | wmiCursor->insertText(fields.at(n)); |
1760 | wmiCursor->insertText(fields.at(n)); |
1758 | }
|
1761 | }
|
1759 | // tmp_str = result.at(2);
|
1762 | // tmp_str = result.at(2);
|
1760 | // values = tmp_str.split("|");
|
1763 | // values = tmp_str.split("|");
|
1761 | 1764 | ||
1762 | 1765 | ||
1763 | for (int m=2; m< result.count(); m++){ |
1766 | for (int m=2; m< result.count(); m++){ |
1764 | 1767 | ||
1765 | tmp_str = result.at(m); |
1768 | tmp_str = result.at(m); |
1766 | values = tmp_str.split("|"); |
1769 | values = tmp_str.split("|"); |
1767 | 1770 | ||
1768 | for(int n = 0; n < values.count(); n++){ |
1771 | for(int n = 0; n < values.count(); n++){ |
1769 | *wmiCursor = wmi_table->cellAt(m-1, n).firstCursorPosition(); |
1772 | *wmiCursor = wmi_table->cellAt(m-1, n).firstCursorPosition(); |
1770 | 1773 | ||
1771 | // wmiCursor->insertText(fields.at(n));
|
1774 | // wmiCursor->insertText(fields.at(n));
|
1772 | // wmiCursor->insertText(tr(": "));
|
1775 | // wmiCursor->insertText(tr(": "));
|
1773 | wmiCursor->insertText(values.at(n)); |
1776 | wmiCursor->insertText(values.at(n)); |
1774 | // wmiCursor->insertText(tr("\n"));
|
1777 | // wmiCursor->insertText(tr("\n"));
|
1775 | 1778 | ||
1776 | }
|
1779 | }
|
1777 | 1780 | ||
1778 | 1781 | ||
1779 | 1782 | ||
1780 | }
|
1783 | }
|
1781 | 1784 | ||
1782 | 1785 | ||
1783 | 1786 | ||
1784 | }
|
1787 | }
|
1785 | QTextCodec::setCodecForTr(codec); |
1788 | QTextCodec::setCodecForTr(codec); |
1786 | 1789 | ||
1787 | 1790 | ||
1788 | 1791 | ||
1789 | 1792 | ||
1790 | 1793 | ||
1791 | 1794 | ||
1792 | 1795 | ||
1793 | 1796 | ||
1794 | 1797 | ||
1795 | // result = QStringList(arr);
|
1798 | // result = QStringList(arr);
|
1796 | // str2 << arr;
|
1799 | // str2 << arr;
|
1797 | //i = result.size();
|
1800 | //i = result.size();
|
1798 | // str1 = result.at(0);
|
1801 | // str1 = result.at(0);
|
1799 | i++; |
1802 | i++; |
1800 | //lineEdit->insert(str1);
|
1803 | //lineEdit->insert(str1);
|
1801 | all_reading = true; |
1804 | all_reading = true; |
1802 | 1805 | ||
1803 | }
|
1806 | }
|
1804 | 1807 | ||
1805 | void MainWindow::readStandartProcessError(){ |
1808 | void MainWindow::readStandartProcessError(){ |
1806 | QTextDocument * wmiDoc = ui->textEdit_2->document(); |
1809 | QTextDocument * wmiDoc = ui->textEdit_2->document(); |
1807 | QTextCursor * wmiCursor; |
1810 | QTextCursor * wmiCursor; |
1808 | wmiCursor = new QTextCursor(wmiDoc); |
1811 | wmiCursor = new QTextCursor(wmiDoc); |
1809 | QString str;
|
1812 | QString str;
|
1810 | 1813 | ||
1811 | QByteArray arr;
|
1814 | QByteArray arr;
|
1812 | arr = wmiProcess.readAllStandardError(); |
1815 | arr = wmiProcess.readAllStandardError(); |
1813 | str = QString(tr(arr)); |
1816 | str = QString(tr(arr)); |
1814 | wmiCursor->insertText(str); |
1817 | wmiCursor->insertText(str); |
1815 | wmiCursor->insertText(tr("\n")); |
1818 | wmiCursor->insertText(tr("\n")); |
1816 | 1819 | ||
1817 | }
|
1820 | }
|
1818 | 1821 | ||
1819 | 1822 | ||
1820 | 1823 | ||
1821 | TWmiVideoCard MainWindow::getWmiVideoGard(QString host, QString user_name, QString password){ |
1824 | TWmiVideoCard MainWindow::getWmiVideoGard(QString host, QString user_name, QString password){ |
1822 | TWmiVideoCard result;
|
1825 | TWmiVideoCard result;
|
1823 | bool ok; |
1826 | bool ok; |
1824 | QString ansver_string;
|
1827 | QString ansver_string;
|
1825 | // wmiThread.moveToThread(&wmiThread);
|
1828 | // wmiThread.moveToThread(&wmiThread);
|
1826 | wmiThread.setHost(host); // çàäàåì õîñò |
1829 | wmiThread.setHost(host); // çàäàåì õîñò |
1827 | wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ |
1830 | wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ |
1828 | wmiThread.setPassword( password); |
1831 | wmiThread.setPassword( password); |
1829 | wmiThread.setWmiString(tr("select Name, AdapterCompatibility, AdapterRAM, VideoProcessor from Win32_VideoController")); |
1832 | wmiThread.setWmiString(tr("select Name, AdapterCompatibility, AdapterRAM, VideoProcessor from Win32_VideoController")); |
1830 | wmiThread.start(QThread::NormalPriority); |
1833 | wmiThread.start(QThread::NormalPriority); |
1831 | //for (;;) {if (wmiThread.isStopped()) break;}
|
1834 | //for (;;) {if (wmiThread.isStopped()) break;}
|
1832 | int t; |
1835 | int t; |
1833 | t++; |
1836 | t++; |
1834 | 1837 | ||
1835 | 1838 | ||
1836 | ok = wmiThread.wait(10000); |
1839 | ok = wmiThread.wait(10000); |
1837 | if (ok){ |
1840 | if (ok){ |
1838 | QTextDocument * wmiDoc = ui->textEdit_2->document(); |
1841 | QTextDocument * wmiDoc = ui->textEdit_2->document(); |
1839 | QTextCursor * wmiCursor; |
1842 | QTextCursor * wmiCursor; |
1840 | QStringList split_new_line; // |
1843 | QStringList split_new_line; // |
1841 | QStringList fields_list; //â ýòîì ñïèñêå ñîõðàíèì ïîëÿ |
1844 | QStringList fields_list; //â ýòîì ñïèñêå ñîõðàíèì ïîëÿ |
1842 | QStringList values_list; //à â ýòîì ñïèñêå - çíà÷åíèÿ |
1845 | QStringList values_list; //à â ýòîì ñïèñêå - çíà÷åíèÿ |
1843 | wmiCursor = new QTextCursor(wmiDoc); |
1846 | wmiCursor = new QTextCursor(wmiDoc); |
1844 | ansver_string = wmiThread.resultString(); |
1847 | ansver_string = wmiThread.resultString(); |
1845 | wmiCursor->insertText(ansver_string); |
1848 | wmiCursor->insertText(ansver_string); |
1846 | split_new_line = ansver_string.split("\n", QString::SkipEmptyParts); // ðàçáèâàåíì îòâåò íà ñòðîêè |
1849 | split_new_line = ansver_string.split("\n", QString::SkipEmptyParts); // ðàçáèâàåíì îòâåò íà ñòðîêè |
1847 | if(split_new_line.count()>2) { |
1850 | if(split_new_line.count()>2) { |
1848 | QString tmp_str;
|
1851 | QString tmp_str;
|
1849 | tmp_str = split_new_line.at(1); |
1852 | tmp_str = split_new_line.at(1); |
1850 | fields_list = tmp_str.split("|"); |
1853 | fields_list = tmp_str.split("|"); |
1851 | tmp_str = split_new_line.at(2); |
1854 | tmp_str = split_new_line.at(2); |
1852 | values_list = tmp_str.split("|"); |
1855 | values_list = tmp_str.split("|"); |
1853 | int index_tmp; |
1856 | int index_tmp; |
1854 | index_tmp = fields_list.indexOf(tr("AdapterCompatibility")); // ïðîèçâîäèòåëü |
1857 | index_tmp = fields_list.indexOf(tr("AdapterCompatibility")); // ïðîèçâîäèòåëü |
1855 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.manufacturer = values_list.at(index_tmp); |
1858 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.manufacturer = values_list.at(index_tmp); |
1856 | index_tmp = fields_list.indexOf(tr("Name")); // íàçâàíèå âèäåîêàðòû |
1859 | index_tmp = fields_list.indexOf(tr("Name")); // íàçâàíèå âèäåîêàðòû |
1857 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.name = values_list.at(index_tmp); |
1860 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.name = values_list.at(index_tmp); |
1858 | index_tmp = fields_list.indexOf(tr("VideoProcessor")); // ìîäåëü |
1861 | index_tmp = fields_list.indexOf(tr("VideoProcessor")); // ìîäåëü |
1859 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.model = values_list.at(index_tmp); |
1862 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.model = values_list.at(index_tmp); |
1860 | index_tmp = fields_list.indexOf(tr("AdapterRAM")); // ìîäåëü |
1863 | index_tmp = fields_list.indexOf(tr("AdapterRAM")); // ìîäåëü |
1861 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.video_ram = QVariant(values_list.at(index_tmp)).asInt(); |
1864 | if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.video_ram = QVariant(values_list.at(index_tmp)).asInt(); |
1862 | return result; |
1865 | return result; |
1863 | }
|
1866 | }
|
1864 | else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò |
1867 | else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò |
1865 | int m; |
1868 | int m; |
1866 | m++; |
1869 | m++; |
1867 | }
|
1870 | }
|
1868 | else { |
1871 | else { |
1869 | wmiThread.stop(); |
1872 | wmiThread.stop(); |
1870 | ok = wmiThread.wait(10000); |
1873 | ok = wmiThread.wait(10000); |
1871 | int k; |
1874 | int k; |
1872 | k++; |
1875 | k++; |
1873 | }
|
1876 | }
|
1874 | 1877 | ||
1875 | /*
|
1878 | /*
|
1876 | 1879 | ||
1877 | QString program = tr("wmic");
|
1880 | QString program = tr("wmic");
|
1878 | QStringList arguments;
|
1881 | QStringList arguments;
|
1879 | 1882 | ||
1880 | // arguments << tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\"");
|
1883 | // arguments << tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\"");
|
1881 | // program.append(tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\""));
|
1884 | // program.append(tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\""));
|
1882 | program.append(tr(" -U admin --password=samba //192.168.0.101 \"select * from ")); //Win32_Product\""));
|
1885 | program.append(tr(" -U admin --password=samba //192.168.0.101 \"select * from ")); //Win32_Product\""));
|
1883 | program.append(ui->comboBox_2->currentText());
|
1886 | program.append(ui->comboBox_2->currentText());
|
1884 | program.append(tr("\""));
|
1887 | program.append(tr("\""));
|
1885 | all_reading = false;
|
1888 | all_reading = false;
|
1886 | int i;
|
1889 | int i;
|
1887 | i++;
|
1890 | i++;
|
1888 | wmiProcess.start(program);
|
1891 | wmiProcess.start(program);
|
1889 | 1892 | ||
1890 | 1893 | ||
1891 | 1894 | ||
1892 | while (!all_reading){}; //æäåì, ïîêà íå ñ÷èòàåòñÿ ðåçóëüòàò çàïðîñà
|
1895 | while (!all_reading){}; //æäåì, ïîêà íå ñ÷èòàåòñÿ ðåçóëüòàò çàïðîñà
|
1893 | 1896 | ||
1894 | */
|
1897 | */
|
1895 | return result; |
1898 | return result; |
1896 | 1899 | ||
1897 | }
|
1900 | }
|
1898 | 1901 |