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