Редакция 137 | Редакция 161 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
24 | pingvin | 1 | #include "classeditor.h" |
2 | #include "ui_classeditor.h" |
||
3 | |||
45 | pingvin | 4 | |
24 | pingvin | 5 | ClassEditor::ClassEditor(QWidget *parent) : |
6 | QMainWindow(parent), |
||
7 | ui(new Ui::ClassEditor) |
||
8 | { |
||
9 | ui->setupUi(this); |
||
60 | pingvin | 10 | |
11 | |||
12 | |||
56 | pingvin | 13 | |
137 | pingvin | 14 | |
135 | pingvin | 15 | readSettings(); |
16 | |||
17 | |||
137 | pingvin | 18 | initDataBase(); // |
19 | createMainTables(); // - DescriptionOfClasses ListOfClasses |
||
135 | pingvin | 20 | |
21 | |||
22 | |||
60 | pingvin | 23 | /* |
35 | pingvin | 24 | field = new TableField(tr(""), this); |
38 | pingvin | 25 | field->setNotNull(true); |
35 | pingvin | 26 | field->setDefaultValue(tr("")); |
33 | pingvin | 27 | |
38 | pingvin | 28 | table = new SqlTable (tr("NewTable"), this); |
29 | table->setName(tr("NewTable")); |
||
39 | pingvin | 30 | table->fields().at(0)->setNotNull(true); |
31 | if (!(table->setPrimaryKey(tr("ID")))) { |
||
32 | ui->label_3->setText(table->lastError()); |
||
33 | } |
||
34 | else ui->label_3->setText(table->primaryKey()); |
||
35 | table->append(field); |
||
36 | |||
37 | field = new TableField(tr(""), this); |
||
38 | field->setNotNull(true); |
||
39 | field->setDefaultValue(tr("")); |
||
40 | table->append(field); |
||
41 | |||
40 | pingvin | 42 | field = new TableField(tr(""), this); |
43 | field->setNotNull(true); |
||
44 | field->setDefaultValue(tr("")); |
||
45 | table->append(field); |
||
46 | |||
47 | field = new TableField(tr(" ()"), this); |
||
48 | field->setNotNull(true); |
||
49 | field->setType(tr("INTEGER")); |
||
50 | field->setDefaultValue(tr("1")); |
||
51 | table->append(field); |
||
52 | |||
53 | field = new TableField(tr(" "), this); |
||
54 | field->setNotNull(false); |
||
55 | field->setType(tr("DATE")); |
||
56 | field->setDefaultValue(tr("NULL")); |
||
57 | table->append(field); |
||
58 | |||
38 | pingvin | 59 | ui->label_2->setText(table->name()); |
60 | ui->label->setText(table->fields().at(0)->sqlString()); |
||
39 | pingvin | 61 | ui->label_4->setText(table->sqlString()); |
40 | pingvin | 62 | ////// ui->lineEdit->insert(table->sqlString()); |
38 | pingvin | 63 | |
60 | pingvin | 64 | */ |
45 | pingvin | 65 | /********************************************** |
66 | |||
40 | pingvin | 67 | QTextDocument *document; |
68 | // = ui->textEdit->document(); |
||
69 | QTextCursor *cursor; |
||
45 | pingvin | 70 | |
40 | pingvin | 71 | document = ui->textEdit->document(); |
72 | cursor = new QTextCursor(document); |
||
73 | cursor->movePosition(QTextCursor::Start); |
||
74 | QTextCharFormat format(cursor->charFormat()); |
||
75 | //format.setFontFamily("Courier"); |
||
76 | format.setFontFamily("Arial"); |
||
77 | //format.setFontItalic(false); |
||
78 | |||
79 | format.setFontWeight(QFont::Normal); |
||
80 | QTextCharFormat boldFormat = format; |
||
81 | boldFormat.setFontWeight(QFont::Bold); |
||
82 | |||
83 | QTextCharFormat italicFormat = format; |
||
84 | //format.setFontFamily("Courier"); |
||
85 | // format.setFontFamily("Arial"); |
||
86 | italicFormat.setFontItalic(true); |
||
87 | |||
88 | cursor->insertText(table->sqlString(), format); |
||
41 | pingvin | 89 | |
45 | pingvin | 90 | ****************************************************/ |
91 | |||
41 | pingvin | 92 | QString errorString; |
93 | |||
135 | pingvin | 94 | |
41 | pingvin | 95 | |
135 | pingvin | 96 | |
60 | pingvin | 97 | /* |
44 | pingvin | 98 | ok = sql.createTable(table); |
42 | pingvin | 99 | if (!ok) { |
100 | QMessageBox::critical( // . |
||
101 | this, // . |
||
102 | QObject::tr("Database Error"), // . |
||
45 | pingvin | 103 | sql.lasError()); // . |
104 | } |
||
42 | pingvin | 105 | else { |
106 | |||
107 | QMessageBox::information( // . |
||
108 | this, // . |
||
109 | QObject::tr("Database Connect"), // . |
||
110 | QObject::tr(" .")); // . |
||
45 | pingvin | 111 | } |
42 | pingvin | 112 | |
113 | |||
114 | |||
60 | pingvin | 115 | */ |
42 | pingvin | 116 | |
41 | pingvin | 117 | |
45 | pingvin | 118 | |
119 | |||
72 | pingvin | 120 | model = new QSqlTableModel(); // |
121 | tableForInstance = new QTableView(); |
||
50 | pingvin | 122 | mymodel = new MyModel(this); |
82 | pingvin | 123 | modelForPointers = new ModelForPointers(this); // // |
124 | |||
61 | pingvin | 125 | //modelForDescription = new QSqlTableModel(this); |
126 | modelForDescription = new ModelForDescriptionTable(this); |
||
50 | pingvin | 127 | |
61 | pingvin | 128 | |
137 | pingvin | 129 | |
130 | initClassListTable(); |
||
131 | |||
132 | initFieldsTable(); |
||
133 | |||
134 | initPointersTable(); |
||
135 | |||
56 | pingvin | 136 | /////////////////model->setTable(tr("ListOfClasses")); |
50 | pingvin | 137 | |
137 | pingvin | 138 | |
139 | |||
45 | pingvin | 140 | /////model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
50 | pingvin | 141 | |
87 | pingvin | 142 | // modelForPointers->setEditStrategy(QSqlTableModel::OnManualSubmit); |
143 | |||
144 | |||
50 | pingvin | 145 | |
146 | |||
82 | pingvin | 147 | |
148 | |||
71 | pingvin | 149 | //mymodel->setEditStrategy(QSqlTableModel::OnFieldChange); |
150 | |||
151 | |||
152 | |||
56 | pingvin | 153 | //////////////////model->setSort(0, Qt::AscendingOrder); |
50 | pingvin | 154 | |
155 | |||
56 | pingvin | 156 | |
68 | pingvin | 157 | |
137 | pingvin | 158 | // model->setFilter(tr("__ = '7' and _ = 'i09090909'")); |
159 | ////////////////////model->select(); |
||
68 | pingvin | 160 | |
137 | pingvin | 161 | //tableForDescription = new QTableView(); |
50 | pingvin | 162 | |
56 | pingvin | 163 | //tableForDescription->show(); |
50 | pingvin | 164 | |
165 | |||
65 | pingvin | 166 | |
45 | pingvin | 167 | |
65 | pingvin | 168 | /* |
62 | pingvin | 169 | ui->tableView_2->hideColumn(0); |
170 | ui->tableView_2->hideColumn(5); |
||
171 | ui->tableView_2->hideColumn(2); |
||
65 | pingvin | 172 | */ |
45 | pingvin | 173 | |
134 | pingvin | 174 | |
175 | |||
176 | |||
135 | pingvin | 177 | |
178 | |||
137 | pingvin | 179 | //if (mymodel->rowCount() > 0) { |
135 | pingvin | 180 | |
137 | pingvin | 181 | |
182 | |||
183 | /* |
||
184 | |||
185 | currIndexOfClassesTable = mymodel->index(0, 1); |
||
186 | |||
187 | |||
62 | pingvin | 188 | QModelIndex index_temp; |
189 | |||
75 | pingvin | 190 | |
191 | |||
62 | pingvin | 192 | currClassID = mymodel->data(mymodel->index(0,0)).toString(); |
193 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
||
194 | |||
195 | QModelIndex topLeft; |
||
196 | QModelIndex bottomRight; |
||
197 | |||
198 | topLeft = mymodel->index(0, 0, QModelIndex()); |
||
199 | bottomRight = mymodel->index(0, 1, QModelIndex()); |
||
200 | |||
201 | QItemSelection selection(topLeft, bottomRight); |
||
202 | selectionModel->select(selection, QItemSelectionModel::Select); |
||
203 | |||
204 | |||
71 | pingvin | 205 | QString class_indx, class_instance; |
68 | pingvin | 206 | QString str_fltr = tr("ClassIdentifer = "); |
207 | class_indx = mymodel->data(mymodel->index(0,0)).toString(); |
||
71 | pingvin | 208 | class_instance = mymodel->data(mymodel->index(0,3)).toString(); |
75 | pingvin | 209 | |
210 | currInctanceTable = class_instance; // |
||
137 | pingvin | 211 | |
212 | |||
213 | |||
75 | pingvin | 214 | modelForDescription->setInctance(class_instance); // - |
71 | pingvin | 215 | //class_instance.append(tr("_inctance")); |
68 | pingvin | 216 | str_fltr.append(class_indx); |
83 | pingvin | 217 | str_fltr.append(tr(" AND FieldType <> \"pointer\"")); |
62 | pingvin | 218 | |
71 | pingvin | 219 | model->setTable(class_instance); |
220 | //model->setTable(tr("memory")); |
||
72 | pingvin | 221 | model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
71 | pingvin | 222 | model->select(); |
72 | pingvin | 223 | tableForInstance->setModel(model); |
224 | tableForInstance->resizeColumnsToContents(); |
||
225 | tableForInstance->setWindowTitle(class_instance); |
||
226 | tableForInstance->show(); |
||
71 | pingvin | 227 | |
68 | pingvin | 228 | modelForDescription->setFilter(str_fltr); |
229 | modelForDescription->select(); |
||
69 | pingvin | 230 | ui->tableView_2->resizeColumnsToContents(); |
68 | pingvin | 231 | |
83 | pingvin | 232 | |
233 | str_fltr = tr("ClassIdentifer = "); |
||
234 | modelForPointers->setInctance(class_instance); // - |
||
235 | str_fltr.append(class_indx); |
||
236 | str_fltr.append(tr(" AND FieldType = \"pointer\"")); |
||
82 | pingvin | 237 | // str_fltr.append( tr(" FieldType = pointer ")); |
83 | pingvin | 238 | |
239 | |||
240 | |||
241 | modelForPointers->setFilter(str_fltr); |
||
82 | pingvin | 242 | modelForPointers->select(); |
68 | pingvin | 243 | |
135 | pingvin | 244 | |
137 | pingvin | 245 | */ |
246 | |||
55 | pingvin | 247 | //connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex))); |
62 | pingvin | 248 | connect(mymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_myModel_dataChanged(QModelIndex,QModelIndex))); |
249 | connect(modelForDescription, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_modelForDescription_dataChanged(QModelIndex,QModelIndex))); |
||
72 | pingvin | 250 | //connect(ui->newClassAction, SIGNAL(triggered(bool)), this, SLOT(on_pushButton_clicked(bool))); |
65 | pingvin | 251 | connect(ui->action_ID, SIGNAL(triggered(bool)), this, SLOT(on_action_ID_triggered(bool))); |
68 | pingvin | 252 | connect(ui->action_showAlias, SIGNAL(triggered(bool)), this, SLOT(on_action_showAlias_triggered(bool))); // |
253 | connect(ui->action_showInstance, SIGNAL(triggered(bool)), this, SLOT(on_action_showInstance_triggered(bool))); // |
||
254 | connect(ui->action_removeSelectedFields, SIGNAL(triggered()), this, SLOT(on_pushButton_4_clicked())); // |
||
255 | connect(ui->action_removeAllFields, SIGNAL(triggered()), this, SLOT(on_pushButton_5_clicked())); // |
||
256 | connect(ui->action_removeSelectedClasses, SIGNAL(triggered()), this, SLOT(on_pushButton_2_clicked())); // |
||
73 | pingvin | 257 | connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // |
258 | connect(ui->action_newClass, SIGNAL(triggered()), this, SLOT(on_pushButton_clicked())); // |
||
259 | connect(ui->action_newField, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // |
||
86 | pingvin | 260 | connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_action_newPointer())); // - |
261 | // connect(ui->action_newPointer, SIGNAL(triggered()), this, SLOT(on_pushButton_3_clicked())); // - |
||
87 | pingvin | 262 | |
263 | connect(ui->action_removeSelectedPointers, SIGNAL(triggered()), this, SLOT(on_action_removeSelectedPointers())); // |
||
86 | pingvin | 264 | connect(modelForDescription, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // |
265 | connect(ClassEditor::modelForPointers, SIGNAL(field_changed()), this, SLOT(on_field_changed())); // |
||
266 | |||
267 | |||
135 | pingvin | 268 | connect(ui->getsettingAct, SIGNAL(triggered()), this, SLOT(getSetting())); // " " " " |
269 | connect(setFrm.pushButton, SIGNAL(clicked()), this, SLOT(applySetting())); |
||
87 | pingvin | 270 | |
135 | pingvin | 271 | |
272 | |||
273 | |||
42 | pingvin | 274 | } |
275 | |||
45 | pingvin | 276 | |
277 | |||
278 | |||
279 | |||
280 | |||
281 | |||
282 | |||
283 | |||
284 | |||
285 | |||
24 | pingvin | 286 | ClassEditor::~ClassEditor() |
287 | { |
||
288 | delete ui; |
||
72 | pingvin | 289 | delete model; |
290 | delete tableForInstance; |
||
38 | pingvin | 291 | // delete field; |
24 | pingvin | 292 | // delete settdialog; |
293 | } |
||
294 | |||
295 | void ClassEditor::changeEvent(QEvent *e) |
||
296 | { |
||
297 | QMainWindow::changeEvent(e); |
||
298 | switch (e->type()) { |
||
299 | case QEvent::LanguageChange: |
||
300 | ui->retranslateUi(this); |
||
301 | break; |
||
302 | default: |
||
303 | break; |
||
304 | } |
||
305 | } |
||
51 | pingvin | 306 | |
307 | |||
71 | pingvin | 308 | /* |
51 | pingvin | 309 | void ClassEditor::addNewClass(){ |
310 | |||
311 | int row = model->rowCount(); |
||
312 | |||
313 | model->insertRows(row, 1); |
||
54 | pingvin | 314 | model->setData(model->index(row, 1), tr("New class")); // " " |
51 | pingvin | 315 | |
316 | |||
317 | // model->setData(model->index(row, 1), tr(" ")); |
||
318 | // model->setData(model->index(row, 2) , tr(" , 1")); |
||
319 | |||
320 | |||
321 | model->submitAll(); |
||
322 | |||
323 | row = model->rowCount(); |
||
324 | QString tmp_str; |
||
325 | int i_tmp; |
||
326 | i_tmp = model->data(model->index(row-1, 0)).toInt(); |
||
327 | tmp_str = model->data(model->index(row-1, 0)).toString(); // - |
||
328 | |||
329 | tmp_str.append(tr("_Inctance")); |
||
330 | model->setData(model->index(row-1, 3), tmp_str ); // |
||
331 | |||
332 | model->submitAll(); |
||
333 | mymodel->select(); |
||
334 | |||
335 | |||
336 | } |
||
71 | pingvin | 337 | */ |
51 | pingvin | 338 | |
54 | pingvin | 339 | void ClassEditor::addNewClass_new(){ |
340 | |||
341 | int row = mymodel->rowCount(); |
||
342 | |||
343 | mymodel->insertRows(row, 1); |
||
70 | pingvin | 344 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New class")), Qt::EditRole); // " " |
54 | pingvin | 345 | |
70 | pingvin | 346 | |
54 | pingvin | 347 | mymodel->submitAll(); |
348 | row = mymodel->rowCount(); |
||
70 | pingvin | 349 | QString tmp_str1, sql_str; |
54 | pingvin | 350 | int i_tmp1; |
351 | i_tmp1 = mymodel->data(mymodel->index(row-1, 0)).toInt(); |
||
352 | tmp_str1 = mymodel->data(mymodel->index(row-1, 0)).toString(); // - |
||
353 | |||
354 | tmp_str1.append(tr("_Inctance")); |
||
70 | pingvin | 355 | SqlTable* tbl; |
356 | tbl = new SqlTable(tmp_str1); // |
||
357 | sql_str = tbl->sqlString(); |
||
358 | bool ok; |
||
359 | |||
360 | ok = sql.createTable(tbl); |
||
361 | |||
362 | if (!ok) { |
||
363 | QMessageBox::critical( // . |
||
364 | this, // . |
||
365 | QObject::tr("Database Error"), // . |
||
366 | sql.lasError()); // . |
||
367 | delete tbl; |
||
368 | mymodel->removeRow(row-1); |
||
369 | mymodel->submitAll(); |
||
370 | mymodel->select(); |
||
371 | ui->tableView_2->resizeRowsToContents(); |
||
372 | return; // |
||
373 | |||
374 | } |
||
375 | |||
376 | delete tbl; |
||
54 | pingvin | 377 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // |
378 | |||
70 | pingvin | 379 | |
380 | |||
54 | pingvin | 381 | // model->setData(model->index(row, 1), tr(" ")); |
382 | // model->setData(model->index(row, 2) , tr(" , 1")); |
||
383 | |||
384 | |||
56 | pingvin | 385 | //mymodel->submitAll(); |
54 | pingvin | 386 | |
387 | //row = mymodel->rowCount(); |
||
388 | |||
389 | |||
56 | pingvin | 390 | //mymodel->select(); |
54 | pingvin | 391 | |
392 | |||
393 | } |
||
394 | |||
395 | |||
62 | pingvin | 396 | void ClassEditor::addNewField(){ |
397 | // QSqlRecord rec = mymodel->record(1); |
||
398 | //bool ok; |
||
399 | //ok = rec.isEmpty(); |
||
400 | //QString currientClassID; |
||
401 | //currientClassID = rec.value(1).toString(); |
||
73 | pingvin | 402 | QString Inctance_str; // - |
403 | QString query_str = tr("ALTER TABLE "); |
||
404 | QString db_error; |
||
405 | QSqlQuery q; |
||
72 | pingvin | 406 | int currRow = ClassEditor::currIndexOfClassesTable.row(); // |
407 | Inctance_str = mymodel->data(mymodel->index(currRow, 3)).toString(); |
||
73 | pingvin | 408 | query_str.append( Inctance_str); |
82 | pingvin | 409 | query_str.append(tr(" ADD COLUMN `New field` CHAR(30)")); |
73 | pingvin | 410 | bool ok = q.prepare(query_str); |
72 | pingvin | 411 | |
73 | pingvin | 412 | ok = q.exec(); |
413 | if (!ok) { |
||
414 | QMessageBox::critical( // . |
||
415 | this, // . |
||
416 | QObject::tr("Database Error"), // . |
||
417 | q.lastError().text()); // . |
||
418 | |||
419 | return; // |
||
420 | |||
421 | } |
||
422 | |||
62 | pingvin | 423 | int row = modelForDescription->rowCount(); |
424 | modelForDescription->insertRows(row, 1); |
||
81 | pingvin | 425 | modelForDescription->onlySetData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole); |
426 | modelForDescription->onlySetData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole); |
||
62 | pingvin | 427 | |
428 | modelForDescription->submitAll(); |
||
73 | pingvin | 429 | |
430 | delete model; |
||
431 | delete tableForInstance; |
||
432 | model = new QSqlTableModel(); |
||
433 | tableForInstance = new QTableView(); |
||
434 | model->setTable(Inctance_str); |
||
435 | model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
||
436 | tableForInstance->setModel(model); |
||
437 | tableForInstance->setWindowTitle(Inctance_str); |
||
438 | tableForInstance->show(); |
||
62 | pingvin | 439 | } |
440 | |||
441 | |||
442 | |||
86 | pingvin | 443 | void ClassEditor::addNewPointer(){ // , - |
444 | QString Inctance_str; // - |
||
445 | QString query_str = tr("ALTER TABLE "); |
||
446 | QString db_error; |
||
447 | QSqlQuery q; |
||
448 | int currRow = ClassEditor::currIndexOfClassesTable.row(); // |
||
449 | Inctance_str = mymodel->data(mymodel->index(currRow, 3)).toString(); |
||
450 | query_str.append( Inctance_str); |
||
451 | query_str.append(tr(" ADD COLUMN `lass-container ID` CHAR(30)")); |
||
452 | bool ok = q.prepare(query_str); |
||
62 | pingvin | 453 | |
86 | pingvin | 454 | ok = q.exec(); |
455 | if (!ok) { |
||
456 | QMessageBox::critical( // . |
||
457 | this, // . |
||
458 | QObject::tr("Database Error"), // . |
||
459 | q.lastError().text()); // . |
||
62 | pingvin | 460 | |
86 | pingvin | 461 | return; // |
62 | pingvin | 462 | |
86 | pingvin | 463 | } |
62 | pingvin | 464 | |
465 | |||
86 | pingvin | 466 | int row = ClassEditor::modelForPointers->rowCount(); |
467 | modelForPointers->insertRows(row, 1); |
||
62 | pingvin | 468 | |
86 | pingvin | 469 | modelForPointers->onlySetData(modelForPointers->index(row, 1), QVariant(tr("lass-container ID")), Qt::EditRole); |
470 | modelForPointers->onlySetData(modelForPointers->index(row, 3), QVariant(tr("pointer")), Qt::EditRole); |
||
471 | modelForPointers->onlySetData(modelForPointers->index(row, 5), QVariant(currClassID), Qt::EditRole); |
||
472 | modelForPointers->onlySetData(modelForPointers->index(row, 4), QVariant(tr("NULL")), Qt::EditRole); |
||
62 | pingvin | 473 | |
86 | pingvin | 474 | |
475 | modelForPointers->submitAll(); |
||
476 | |||
135 | pingvin | 477 | |
478 | |||
479 | |||
480 | |||
481 | |||
482 | |||
483 | |||
484 | /* |
||
485 | |||
486 | str_fltr = tr("ClassIdentifer = "); |
||
487 | modelForPointers->setInctance(Inctance_str); // - |
||
488 | str_fltr.append(class_indx); |
||
489 | str_fltr.append(tr(" AND FieldType = \"pointer\"")); |
||
490 | // str_fltr.append( tr(" FieldType = pointer ")); |
||
491 | |||
492 | |||
493 | |||
494 | modelForPointers->setFilter(str_fltr); |
||
495 | modelForPointers->select(); |
||
496 | ui->tableView_3->setModel(modelForPointers); |
||
497 | ui->tableView_3->resizeColumnsToContents(); |
||
498 | */ |
||
499 | |||
500 | |||
501 | |||
502 | |||
503 | // modelForPointers->select(); |
||
504 | |||
505 | |||
506 | |||
507 | |||
508 | |||
86 | pingvin | 509 | ClassEditor::refreshInctance(); |
510 | |||
511 | |||
512 | |||
513 | |||
514 | |||
515 | |||
516 | |||
517 | |||
518 | |||
519 | } |
||
520 | |||
521 | |||
522 | |||
523 | |||
524 | |||
68 | pingvin | 525 | // |
51 | pingvin | 526 | void ClassEditor::on_pushButton_clicked(){ |
54 | pingvin | 527 | //int i; |
528 | //i++; |
||
529 | /////ClassEditor::addNewClass(); |
||
530 | ClassEditor::addNewClass_new(); |
||
531 | mymodel->select(); |
||
532 | //ui->tableView->setModel(mymodel); |
||
533 | |||
51 | pingvin | 534 | } |
54 | pingvin | 535 | |
55 | pingvin | 536 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
137 | pingvin | 537 | bool indexIsValid; |
55 | pingvin | 538 | int i, row, column; |
539 | i++; |
||
137 | pingvin | 540 | indexIsValid = index.isValid(); |
55 | pingvin | 541 | row = index.row(); |
542 | column = index.column(); |
||
62 | pingvin | 543 | currIndexOfClassesTable = index; |
71 | pingvin | 544 | QModelIndex index_tmp, index_instance; |
545 | QString tmp_str, filter_str, instance_str; |
||
56 | pingvin | 546 | index_tmp = ui->tableView->model()->index(row, 0); |
71 | pingvin | 547 | index_instance = ui->tableView->model()->index(row, 3); |
56 | pingvin | 548 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
71 | pingvin | 549 | instance_str = ui->tableView->model()->data(index_instance).toString(); |
75 | pingvin | 550 | modelForDescription->setInctance(instance_str); // - |
83 | pingvin | 551 | modelForPointers->setInctance(instance_str); |
75 | pingvin | 552 | |
134 | pingvin | 553 | delegateForDefaultValueColomn.getItems(); // |
75 | pingvin | 554 | |
71 | pingvin | 555 | // instance_str.append(tr("_inctance")); |
72 | pingvin | 556 | /* |
557 | Inctance_model.clear(); |
||
558 | Inctance_model.setTable(instance_str); |
||
559 | Inctance_model.select(); |
||
560 | tableForInstance_new.setModel(&Inctance_model); |
||
561 | tableForInstance_new.show(); |
||
562 | */ |
||
563 | // model->clear(); |
||
564 | tableForInstance->close(); |
||
565 | delete model; |
||
566 | delete tableForInstance; |
||
567 | model = new QSqlTableModel(); |
||
568 | tableForInstance = new QTableView(); |
||
569 | model->setTable(instance_str); |
||
570 | model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
||
571 | tableForInstance->setModel(model); |
||
71 | pingvin | 572 | |
573 | model->select(); |
||
72 | pingvin | 574 | tableForInstance->setWindowTitle(instance_str); |
575 | tableForInstance->show(); |
||
576 | |||
71 | pingvin | 577 | // tableForInstance.setModel(model); |
72 | pingvin | 578 | tableForInstance->resizeColumnsToContents(); |
71 | pingvin | 579 | |
62 | pingvin | 580 | currClassID = tmp_str; |
581 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
56 | pingvin | 582 | filter_str = tr("ClassIdentifer = "); |
583 | filter_str.append(tmp_str); |
||
83 | pingvin | 584 | filter_str.append(tr(" AND FieldType <> \"pointer\"")); |
56 | pingvin | 585 | modelForDescription->setFilter(filter_str); |
68 | pingvin | 586 | modelForDescription->select(); |
62 | pingvin | 587 | ui->tableView_2->resizeColumnsToContents(); |
83 | pingvin | 588 | |
589 | filter_str = tr("ClassIdentifer = "); |
||
590 | filter_str.append(tmp_str); |
||
591 | filter_str.append(tr(" AND FieldType = \"pointer\"")); |
||
592 | modelForPointers->setFilter(filter_str); |
||
593 | modelForPointers->select(); |
||
594 | ui->tableView_3->resizeColumnsToContents(); |
||
595 | |||
596 | |||
597 | |||
598 | |||
56 | pingvin | 599 | i++; |
55 | pingvin | 600 | } |
54 | pingvin | 601 | |
59 | pingvin | 602 | |
603 | |||
68 | pingvin | 604 | void ClassEditor::on_pushButton_2_clicked(){ // " " |
605 | QModelIndex model_index; |
||
606 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
||
607 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
||
608 | QList<int> selectedRows; |
||
609 | selectedRows.clear(); |
||
610 | foreach (model_index, indexes){ // |
||
611 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // |
||
59 | pingvin | 612 | |
68 | pingvin | 613 | } |
614 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
615 | |||
616 | |||
617 | for (int m =0; m < selectedRows.size(); ++m){ |
||
618 | |||
619 | ClassEditor::removeClass(selectedRows.at(m)); |
||
620 | |||
621 | |||
622 | |||
623 | } |
||
624 | mymodel->submitAll(); |
||
625 | ClassEditor::modelForDescription->select(); |
||
626 | |||
59 | pingvin | 627 | } |
628 | |||
629 | void ClassEditor::on_pushButton_3_clicked(){ // " " |
||
630 | int i; |
||
631 | i++; |
||
62 | pingvin | 632 | ClassEditor::addNewField(); |
633 | ClassEditor::modelForDescription->select(); |
||
64 | pingvin | 634 | ui->tableView_2->resizeColumnsToContents(); |
59 | pingvin | 635 | } |
68 | pingvin | 636 | |
637 | |||
59 | pingvin | 638 | void ClassEditor::on_pushButton_4_clicked(){ // " " |
69 | pingvin | 639 | // int i; |
62 | pingvin | 640 | QModelIndex model_index; |
63 | pingvin | 641 | QItemSelectionModel *selectionModel = ui->tableView_2->selectionModel(); |
62 | pingvin | 642 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
69 | pingvin | 643 | //QModelIndexList indexes_fo_first_col; // ( ) |
62 | pingvin | 644 | //model_index = mymodel->selec; |
645 | //modelList = ui->tableView->SelectItems; |
||
69 | pingvin | 646 | //i = indexes.size(); |
63 | pingvin | 647 | QList<int> selectedRows; |
69 | pingvin | 648 | //indexes_fo_first_col.clear(); |
649 | /* |
||
67 | pingvin | 650 | foreach (model_index, indexes){ // |
651 | if (!indexes_fo_first_col.contains(model_index) && (model_index.column()==1)) indexes_fo_first_col.append(model_index); // |
||
652 | |||
653 | } |
||
69 | pingvin | 654 | */ |
63 | pingvin | 655 | selectedRows.clear(); |
656 | foreach (model_index, indexes){ // |
||
73 | pingvin | 657 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) { |
658 | selectedRows.append(model_index.row()); // |
||
659 | } |
||
63 | pingvin | 660 | } |
67 | pingvin | 661 | |
662 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
663 | |||
74 | pingvin | 664 | QString Inctance_str; // - |
665 | Inctance_str = mymodel->data(mymodel->index(ClassEditor::currIndexOfClassesTable.row(), 3)).toString(); |
||
67 | pingvin | 666 | for (int m =0; m < selectedRows.size(); ++m){ |
667 | |||
74 | pingvin | 668 | |
669 | QString query_str; |
||
670 | QString field_name_str; // |
||
671 | QSqlQuery q; |
||
672 | |||
673 | query_str.clear(); |
||
674 | |||
675 | |||
676 | field_name_str = modelForDescription->data(modelForDescription->index(selectedRows.at(m), 1)).toString(); |
||
677 | |||
678 | query_str.append(tr("ALTER TABLE ")); |
||
679 | query_str.append(Inctance_str); |
||
680 | query_str.append(tr(" DROP COLUMN `")); |
||
681 | query_str.append(field_name_str); |
||
682 | query_str.append(tr("`")); |
||
683 | q.prepare(query_str); |
||
684 | bool ok = q.exec(); |
||
685 | if (!ok) { |
||
686 | QMessageBox::critical( // . |
||
687 | this, // . |
||
688 | QObject::tr("Database Error"), // . |
||
689 | q.lastError().text()); // . |
||
690 | |||
691 | return; // |
||
692 | |||
693 | } |
||
694 | |||
695 | |||
696 | |||
697 | modelForDescription->removeRow(selectedRows.at(m)); |
||
698 | |||
67 | pingvin | 699 | } |
74 | pingvin | 700 | delete model; |
701 | delete tableForInstance; |
||
702 | model = new QSqlTableModel(); |
||
703 | tableForInstance = new QTableView(); |
||
704 | model->setTable(Inctance_str); |
||
705 | model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
||
706 | tableForInstance->setModel(model); |
||
707 | tableForInstance->setWindowTitle(Inctance_str); |
||
708 | tableForInstance->show(); |
||
69 | pingvin | 709 | //i = selectedRows.size(); |
63 | pingvin | 710 | |
69 | pingvin | 711 | //if (i > 0) model_index = indexes.at(0); |
59 | pingvin | 712 | } |
62 | pingvin | 713 | |
714 | |||
87 | pingvin | 715 | void ClassEditor::on_action_removeSelectedPointers(){ // |
716 | QModelIndex model_index; |
||
717 | QItemSelectionModel *selectionModel = ui->tableView_3->selectionModel(); |
||
718 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
||
719 | QList<int> selectedRows; |
||
720 | |||
721 | selectedRows.clear(); |
||
722 | |||
723 | foreach (model_index, indexes){ // |
||
724 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) { |
||
725 | selectedRows.append(model_index.row()); // |
||
726 | } |
||
727 | } |
||
728 | |||
729 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
730 | |||
731 | QString Inctance_str; // - |
||
732 | Inctance_str = mymodel->data(mymodel->index(ClassEditor::currIndexOfClassesTable.row(), 3)).toString(); |
||
733 | for (int m =0; m < selectedRows.size(); ++m){ |
||
734 | |||
735 | |||
736 | QString query_str; |
||
737 | QString field_name_str; // |
||
738 | QSqlQuery q; |
||
739 | |||
740 | query_str.clear(); |
||
741 | |||
742 | |||
743 | field_name_str = modelForPointers->data(modelForPointers->index(selectedRows.at(m), 1)).toString(); |
||
744 | |||
745 | query_str.append(tr("ALTER TABLE ")); |
||
746 | query_str.append(Inctance_str); |
||
747 | query_str.append(tr(" DROP COLUMN `")); |
||
748 | query_str.append(field_name_str); |
||
749 | query_str.append(tr("`")); |
||
750 | q.prepare(query_str); |
||
751 | bool ok = q.exec(); |
||
752 | if (!ok) { |
||
753 | QMessageBox::critical( // . |
||
754 | this, // . |
||
755 | QObject::tr("Database Error"), // . |
||
756 | q.lastError().text()); // . |
||
757 | |||
758 | return; // |
||
759 | |||
760 | } |
||
761 | |||
762 | |||
763 | |||
764 | modelForPointers->removeRow(selectedRows.at(m)); |
||
765 | |||
766 | } |
||
767 | |||
768 | |||
769 | refreshInctance(); |
||
770 | |||
771 | |||
772 | |||
773 | } |
||
774 | |||
775 | |||
776 | |||
777 | |||
778 | |||
63 | pingvin | 779 | void ClassEditor::on_pushButton_5_clicked(){ // " " |
780 | int row; |
||
781 | row = ClassEditor::modelForDescription->rowCount(); |
||
782 | ClassEditor::modelForDescription->removeRows(0, row); |
||
783 | ClassEditor::modelForDescription->submitAll(); |
||
784 | } |
||
785 | |||
62 | pingvin | 786 | void ClassEditor::on_myModel_dataChanged( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
75 | pingvin | 787 | |
62 | pingvin | 788 | int i; |
789 | i++; |
||
790 | ui->tableView->resizeColumnsToContents(); |
||
75 | pingvin | 791 | |
792 | |||
793 | |||
794 | |||
795 | |||
62 | pingvin | 796 | } |
797 | |||
798 | void ClassEditor::on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
||
799 | ui->tableView_2->resizeColumnsToContents(); |
||
75 | pingvin | 800 | |
801 | /* |
||
802 | QString instance_str; |
||
803 | instance_str = mymodel->data(mymodel->index(ClassEditor::currIndexOfClassesTable.row(), 3)).toString(); |
||
804 | tableForInstance->close(); |
||
805 | delete model; |
||
806 | delete tableForInstance; |
||
807 | model = new QSqlTableModel(); |
||
808 | tableForInstance = new QTableView(); |
||
809 | model->setTable(instance_str); |
||
810 | model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
||
811 | tableForInstance->setModel(model); |
||
812 | |||
813 | model->select(); |
||
814 | tableForInstance->setWindowTitle(instance_str); |
||
815 | tableForInstance->show(); |
||
816 | */ |
||
62 | pingvin | 817 | } |
65 | pingvin | 818 | |
819 | void ClassEditor::on_action_ID_triggered(bool is_checked){ // " ID" |
||
820 | if (is_checked) ui->tableView->showColumn(0); |
||
821 | else ui->tableView->hideColumn(0); |
||
822 | ui->tableView->resizeColumnsToContents(); |
||
823 | } |
||
824 | |||
825 | void ClassEditor::on_action_showAlias_triggered(bool is_checked){ // " " |
||
826 | if (is_checked) ui->tableView->showColumn(2); |
||
827 | else ui->tableView->hideColumn(2); |
||
828 | ui->tableView->resizeColumnsToContents(); |
||
829 | } |
||
830 | |||
68 | pingvin | 831 | void ClassEditor::on_action_showInstance_triggered(bool is_checked){ // " " |
65 | pingvin | 832 | if (is_checked) ui->tableView->showColumn(3); |
833 | else ui->tableView->hideColumn(3); |
||
834 | ui->tableView->resizeColumnsToContents(); |
||
835 | } |
||
68 | pingvin | 836 | |
837 | |||
838 | |||
839 | void ClassEditor::on_action_removeAllClasses(){ // " " |
||
840 | int row; |
||
841 | row = ClassEditor::mymodel->rowCount(); |
||
842 | for (int m=0; m < row; ++m){ |
||
843 | ClassEditor::removeClass(0); |
||
844 | //ClassEditor::mymodel->removeRows(0, row); |
||
845 | } |
||
846 | ClassEditor::mymodel->submitAll(); |
||
847 | ClassEditor::modelForDescription->select(); |
||
848 | } |
||
849 | |||
850 | void ClassEditor::removeClass(int class_row){ // , class_row |
||
851 | QModelIndex index_tmp; |
||
852 | QString tmp_str, filter_str; |
||
853 | index_tmp = ui->tableView->model()->index(class_row, 0); |
||
854 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
||
855 | currClassID = tmp_str; |
||
856 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
857 | filter_str = tr("ClassIdentifer = "); |
||
858 | filter_str.append(tmp_str); |
||
859 | modelForDescription->setFilter(filter_str); // |
||
860 | ClassEditor::on_pushButton_5_clicked(); // |
||
861 | mymodel->removeRow(class_row); // |
||
862 | mymodel->submitAll(); // |
||
863 | ui->tableView->resizeColumnsToContents(); |
||
864 | ui->tableView_2->resizeColumnsToContents(); |
||
865 | |||
866 | } |
||
76 | pingvin | 867 | |
868 | |||
77 | pingvin | 869 | void ClassEditor::on_field_changed(){ // |
76 | pingvin | 870 | ClassEditor::refreshInctance(); |
871 | } |
||
872 | |||
873 | |||
874 | |||
875 | |||
876 | void ClassEditor::refreshInctance(){ // - |
||
877 | |||
878 | QString Inctance_str; // - |
||
879 | Inctance_str = mymodel->data(mymodel->index(ClassEditor::currIndexOfClassesTable.row(), 3)).toString(); |
||
880 | delete model; |
||
881 | delete tableForInstance; |
||
882 | model = new QSqlTableModel(); |
||
883 | tableForInstance = new QTableView(); |
||
884 | model->setTable(Inctance_str); |
||
885 | model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
||
78 | pingvin | 886 | model->select(); |
76 | pingvin | 887 | tableForInstance->setModel(model); |
888 | tableForInstance->setWindowTitle(Inctance_str); |
||
889 | tableForInstance->resizeRowsToContents(); |
||
890 | tableForInstance->show(); |
||
891 | |||
892 | } |
||
86 | pingvin | 893 | |
894 | |||
895 | |||
896 | |||
87 | pingvin | 897 | void ClassEditor::on_action_newPointer(){ // - |
86 | pingvin | 898 | ClassEditor::addNewPointer(); |
899 | ClassEditor::modelForPointers->select(); |
||
900 | ui->tableView_3->resizeColumnsToContents(); |
||
901 | |||
902 | } |
||
903 | |||
135 | pingvin | 904 | |
905 | // |
||
906 | |||
907 | void ClassEditor::readSettings() |
||
908 | { |
||
909 | QSettings settings("Trolltech", "Application Example"); |
||
910 | baseName = settings.value("baseName", "an_db").toString(); |
||
911 | userName = settings.value("userName", "an").toString(); |
||
912 | password = settings.value("password", "393939").toString(); |
||
913 | tableName = settings.value("tableName", "inventar").toString(); |
||
914 | hostName = settings.value("hostName", "server").toString(); |
||
915 | // resize(size); |
||
916 | // move(pos);tableName |
||
917 | } |
||
918 | |||
919 | |||
920 | void ClassEditor::writeSettings() |
||
921 | { |
||
922 | QSettings settings("Trolltech", "Application Example"); |
||
923 | settings.setValue("baseName", baseName); |
||
924 | settings.setValue("userName", userName); |
||
925 | settings.setValue("password", password); |
||
926 | settings.setValue("tableName", tableName); |
||
927 | settings.setValue("hostName", hostName); |
||
928 | } |
||
929 | |||
930 | |||
931 | void ClassEditor::applySetting() |
||
932 | { |
||
933 | bool ok; |
||
934 | baseName = setFrm.lineEdit->text(); |
||
935 | userName = setFrm.lineEdit_2->text(); |
||
936 | password = setFrm.lineEdit_3->text(); |
||
937 | // tableName = setFrm->lineEdit_4->text(); |
||
938 | hostName = setFrm.lineEdit_5->text(); |
||
939 | writeSettings(); |
||
940 | |||
941 | sql.close(); // |
||
942 | |||
943 | sql.setDatabaseName(baseName); |
||
944 | // sql.setDatabaseName(tr("inventory")); |
||
945 | |||
946 | // sql.setHostName(tr("localhost")); |
||
947 | sql.setHostName(hostName); |
||
948 | |||
949 | // sql.setUserName(tr("an")); |
||
950 | |||
951 | sql.setUserName(userName); |
||
952 | |||
953 | // sql.setPassword(tr("393939")); |
||
954 | |||
955 | sql.setPassword(password); |
||
956 | |||
957 | ok = sql.connect(); |
||
958 | if (!ok) { |
||
959 | QMessageBox::critical( // . |
||
960 | this, // . |
||
961 | QObject::tr("Database Error"), // . |
||
962 | sql.lasError()); // . |
||
963 | |||
964 | } |
||
965 | else { |
||
966 | |||
967 | QMessageBox::information( // . |
||
968 | this, // . |
||
969 | QObject::tr("Database Connect"), // . |
||
970 | QObject::tr(" .")); // . |
||
971 | |||
972 | |||
973 | |||
974 | |||
975 | |||
976 | } |
||
977 | |||
978 | |||
979 | mymodel->select(); |
||
980 | model->select(); |
||
981 | modelForDescription->select(); |
||
982 | |||
983 | //////////// ok=openDataBase(); |
||
984 | //////////// if (!ok) return; |
||
985 | // // // ui->treeWidget->clear(); // |
||
986 | |||
987 | // // // buildPreviewModel(tr(" "), tr("1")); |
||
988 | //////////// class_list_map.clear(); // |
||
989 | //////////// initComboBox(); |
||
990 | // // // getDatabaseData(); |
||
991 | // delete setFrm; |
||
992 | setFrm.close(); |
||
993 | } |
||
994 | |||
995 | void ClassEditor::getSetting() |
||
996 | { |
||
997 | // setFrm = new settingForm; |
||
998 | // // // connect(setFrm.pushButton, SIGNAL(clicked()), this, SLOT(applySetting())); |
||
999 | setFrm.lineEdit->setText(baseName); |
||
1000 | setFrm.lineEdit_2->setText(userName); |
||
1001 | setFrm.lineEdit_3->setText(password); |
||
1002 | // setFrm->lineEdit_4->setText(tableName); |
||
1003 | setFrm.lineEdit_5->setText(hostName); |
||
1004 | setFrm.show(); |
||
1005 | |||
1006 | |||
1007 | |||
1008 | } |
||
1009 | |||
1010 | |||
1011 | void ClassEditor::initDataBase(){ // |
||
1012 | |||
137 | pingvin | 1013 | sql.setDatabaseName(baseName); |
1014 | sql.setHostName(hostName); |
||
1015 | sql.setUserName(userName); |
||
1016 | sql.setPassword(password); |
||
135 | pingvin | 1017 | |
137 | pingvin | 1018 | bool ok; |
1019 | ok = sql.connect(); |
||
1020 | if (!ok) { |
||
1021 | QMessageBox::critical( // . |
||
1022 | this, // . |
||
1023 | QObject::tr("Database Error"), // . |
||
1024 | sql.lasError()); // . |
||
1025 | |||
1026 | } |
||
1027 | else { |
||
1028 | |||
1029 | QMessageBox::information( // . |
||
1030 | this, // . |
||
1031 | QObject::tr("Database Connect"), // . |
||
1032 | QObject::tr(" .")); // . |
||
1033 | |||
1034 | |||
1035 | |||
1036 | |||
1037 | |||
1038 | } |
||
1039 | |||
135 | pingvin | 1040 | } |
137 | pingvin | 1041 | |
1042 | |||
1043 | void ClassEditor::createMainTables(){// - DescriptionOfClasses ListOfClasses |
||
1044 | |||
1045 | bool ok; |
||
1046 | ok = sql.createListOfClassesTable(); |
||
1047 | |||
1048 | if (!ok) { |
||
1049 | QMessageBox::critical( // . |
||
1050 | this, // . |
||
1051 | QObject::tr("Database Error"), // . |
||
1052 | sql.lasError()); // . |
||
1053 | |||
1054 | } |
||
1055 | else { |
||
1056 | |||
1057 | QMessageBox::information( // . |
||
1058 | this, // . |
||
1059 | QObject::tr("Database Create"), // . |
||
1060 | QObject::tr(" .")); // . |
||
1061 | } |
||
1062 | |||
1063 | |||
1064 | |||
1065 | |||
1066 | ok = sql.createDescriptionOfClassesTable(); |
||
1067 | |||
1068 | if (!ok) { |
||
1069 | QMessageBox::critical( // . |
||
1070 | this, // . |
||
1071 | QObject::tr("Database Error"), // . |
||
1072 | sql.lasError()); // . |
||
1073 | |||
1074 | } |
||
1075 | else { |
||
1076 | |||
1077 | QMessageBox::information( // . |
||
1078 | this, // . |
||
1079 | QObject::tr("Database Create"), // . |
||
1080 | QObject::tr(" .")); // . |
||
1081 | } |
||
1082 | |||
1083 | |||
143 | pingvin | 1084 | ok = sql.createListModelsTable(); |
137 | pingvin | 1085 | |
143 | pingvin | 1086 | if (!ok) { |
1087 | QMessageBox::critical( // . |
||
1088 | this, // . |
||
1089 | QObject::tr("Database Error"), // . |
||
1090 | sql.lasError()); // . |
||
137 | pingvin | 1091 | |
143 | pingvin | 1092 | } |
1093 | else { |
||
137 | pingvin | 1094 | |
143 | pingvin | 1095 | QMessageBox::information( // . |
1096 | this, // . |
||
1097 | QObject::tr("Database Create"), // . |
||
1098 | QObject::tr(" .")); // . |
||
1099 | } |
||
137 | pingvin | 1100 | |
1101 | |||
143 | pingvin | 1102 | |
1103 | |||
137 | pingvin | 1104 | } |
1105 | |||
1106 | void ClassEditor::initClassListTable(){ // |
||
1107 | |||
1108 | mymodel->setTable(tr("ListOfClasses")); |
||
1109 | mymodel->setSort(0, Qt::AscendingOrder); |
||
1110 | mymodel->select(); |
||
1111 | mymodel->setHeaderData(1, Qt::Horizontal, tr(" ")); |
||
1112 | mymodel->setHeaderData(2, Qt::Horizontal, tr(" ")); |
||
1113 | mymodel->setHeaderData(4, Qt::Horizontal, tr("")); |
||
1114 | ui->tableView->setModel(mymodel); |
||
1115 | ui->tableView->setAlternatingRowColors(true); |
||
1116 | ui->tableView->resizeColumnsToContents(); |
||
1117 | |||
1118 | ui->tableView->hideColumn(0); |
||
1119 | ui->tableView->hideColumn(3); |
||
1120 | ui->tableView->hideColumn(2); |
||
1121 | } |
||
1122 | |||
1123 | |||
1124 | void ClassEditor::initFieldsTable(){ // |
||
1125 | |||
1126 | modelForDescription->setTable(tr("DescriptionOfClasses")); |
||
1127 | modelForDescription->setSort(0, Qt::AscendingOrder); |
||
1128 | modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange); |
||
1129 | ui->tableView_2->setModel(modelForDescription); |
||
1130 | ui->tableView_2->setAlternatingRowColors(true); |
||
1131 | ui->tableView_2->resizeColumnsToContents(); |
||
1132 | ui->tableView_2->setItemDelegateForColumn(3, &classTableDelegate); |
||
1133 | } |
||
1134 | |||
1135 | void ClassEditor::initPointersTable(){ // - |
||
1136 | |||
1137 | modelForPointers->setTable(tr("DescriptionOfClasses")); |
||
1138 | modelForPointers->setSort(0, Qt::AscendingOrder); |
||
1139 | modelForPointers->setEditStrategy(QSqlTableModel::OnFieldChange); |
||
1140 | ui->tableView_3->setModel(modelForPointers); |
||
1141 | delegateForDefaultValueColomn.getItems(); |
||
1142 | ui->tableView_3->setItemDelegateForColumn(4, &delegateForDefaultValueColomn); |
||
1143 | |||
1144 | // ui->tableView_3->resizeColumnsToContents(); |
||
1145 | |||
1146 | } |