Редакция 70 | Редакция 72 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | 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 | |||
13 | // settdialog = new SettingsDialog(this); |
||
14 | ///////////////////////////////////////////////////// settdialog.show(); |
||
24 | pingvin | 15 | sql.setDatabaseName(tr("an_db")); |
56 | pingvin | 16 | |
60 | pingvin | 17 | /* |
35 | pingvin | 18 | field = new TableField(tr(""), this); |
38 | pingvin | 19 | field->setNotNull(true); |
35 | pingvin | 20 | field->setDefaultValue(tr("")); |
33 | pingvin | 21 | |
38 | pingvin | 22 | table = new SqlTable (tr("NewTable"), this); |
23 | table->setName(tr("NewTable")); |
||
39 | pingvin | 24 | table->fields().at(0)->setNotNull(true); |
25 | if (!(table->setPrimaryKey(tr("ID")))) { |
||
26 | ui->label_3->setText(table->lastError()); |
||
27 | } |
||
28 | else ui->label_3->setText(table->primaryKey()); |
||
29 | table->append(field); |
||
30 | |||
31 | field = new TableField(tr(""), this); |
||
32 | field->setNotNull(true); |
||
33 | field->setDefaultValue(tr("")); |
||
34 | table->append(field); |
||
35 | |||
40 | pingvin | 36 | field = new TableField(tr(""), this); |
37 | field->setNotNull(true); |
||
38 | field->setDefaultValue(tr("")); |
||
39 | table->append(field); |
||
40 | |||
41 | field = new TableField(tr(" ()"), this); |
||
42 | field->setNotNull(true); |
||
43 | field->setType(tr("INTEGER")); |
||
44 | field->setDefaultValue(tr("1")); |
||
45 | table->append(field); |
||
46 | |||
47 | field = new TableField(tr(" "), this); |
||
48 | field->setNotNull(false); |
||
49 | field->setType(tr("DATE")); |
||
50 | field->setDefaultValue(tr("NULL")); |
||
51 | table->append(field); |
||
52 | |||
38 | pingvin | 53 | ui->label_2->setText(table->name()); |
54 | ui->label->setText(table->fields().at(0)->sqlString()); |
||
39 | pingvin | 55 | ui->label_4->setText(table->sqlString()); |
40 | pingvin | 56 | ////// ui->lineEdit->insert(table->sqlString()); |
38 | pingvin | 57 | |
60 | pingvin | 58 | */ |
45 | pingvin | 59 | /********************************************** |
60 | |||
40 | pingvin | 61 | QTextDocument *document; |
62 | // = ui->textEdit->document(); |
||
63 | QTextCursor *cursor; |
||
45 | pingvin | 64 | |
40 | pingvin | 65 | document = ui->textEdit->document(); |
66 | cursor = new QTextCursor(document); |
||
67 | cursor->movePosition(QTextCursor::Start); |
||
68 | QTextCharFormat format(cursor->charFormat()); |
||
69 | //format.setFontFamily("Courier"); |
||
70 | format.setFontFamily("Arial"); |
||
71 | //format.setFontItalic(false); |
||
72 | |||
73 | format.setFontWeight(QFont::Normal); |
||
74 | QTextCharFormat boldFormat = format; |
||
75 | boldFormat.setFontWeight(QFont::Bold); |
||
76 | |||
77 | QTextCharFormat italicFormat = format; |
||
78 | //format.setFontFamily("Courier"); |
||
79 | // format.setFontFamily("Arial"); |
||
80 | italicFormat.setFontItalic(true); |
||
81 | |||
82 | cursor->insertText(table->sqlString(), format); |
||
41 | pingvin | 83 | |
45 | pingvin | 84 | ****************************************************/ |
85 | |||
41 | pingvin | 86 | QString errorString; |
87 | |||
88 | sql.setDatabaseName(tr("an_db")); |
||
89 | sql.setHostName(tr("localhost")); |
||
90 | sql.setUserName(tr("an")); |
||
91 | sql.setPassword(tr("393939")); |
||
92 | |||
93 | bool ok; |
||
44 | pingvin | 94 | ok = sql.connect(); |
41 | pingvin | 95 | if (!ok) { |
96 | QMessageBox::critical( // . |
||
97 | this, // . |
||
98 | QObject::tr("Database Error"), // . |
||
45 | pingvin | 99 | sql.lasError()); // . |
41 | pingvin | 100 | |
101 | } |
||
102 | else { |
||
103 | |||
104 | QMessageBox::information( // . |
||
105 | this, // . |
||
106 | QObject::tr("Database Connect"), // . |
||
107 | QObject::tr(" .")); // . |
||
108 | |||
109 | |||
110 | |||
111 | |||
112 | |||
24 | pingvin | 113 | } |
114 | |||
60 | pingvin | 115 | /* |
44 | pingvin | 116 | ok = sql.createTable(table); |
42 | pingvin | 117 | if (!ok) { |
118 | QMessageBox::critical( // . |
||
119 | this, // . |
||
120 | QObject::tr("Database Error"), // . |
||
45 | pingvin | 121 | sql.lasError()); // . |
122 | } |
||
42 | pingvin | 123 | else { |
124 | |||
125 | QMessageBox::information( // . |
||
126 | this, // . |
||
127 | QObject::tr("Database Connect"), // . |
||
128 | QObject::tr(" .")); // . |
||
45 | pingvin | 129 | } |
42 | pingvin | 130 | |
131 | |||
132 | |||
60 | pingvin | 133 | */ |
42 | pingvin | 134 | |
56 | pingvin | 135 | ok = sql.createListOfClassesTable(); |
41 | pingvin | 136 | |
45 | pingvin | 137 | if (!ok) { |
138 | QMessageBox::critical( // . |
||
139 | this, // . |
||
140 | QObject::tr("Database Error"), // . |
||
141 | sql.lasError()); // . |
||
142 | |||
143 | } |
||
144 | else { |
||
145 | |||
146 | QMessageBox::information( // . |
||
147 | this, // . |
||
148 | QObject::tr("Database Create"), // . |
||
149 | QObject::tr(" .")); // . |
||
150 | } |
||
151 | |||
152 | |||
56 | pingvin | 153 | |
154 | |||
155 | ok = sql.createDescriptionOfClassesTable(); |
||
156 | |||
157 | if (!ok) { |
||
158 | QMessageBox::critical( // . |
||
159 | this, // . |
||
160 | QObject::tr("Database Error"), // . |
||
161 | sql.lasError()); // . |
||
162 | |||
163 | } |
||
164 | else { |
||
165 | |||
166 | QMessageBox::information( // . |
||
167 | this, // . |
||
168 | QObject::tr("Database Create"), // . |
||
169 | QObject::tr(" .")); // . |
||
170 | } |
||
171 | |||
172 | |||
173 | |||
174 | |||
175 | |||
176 | |||
177 | |||
71 | pingvin | 178 | model = new QSqlTableModel(this); // |
50 | pingvin | 179 | mymodel = new MyModel(this); |
61 | pingvin | 180 | //modelForDescription = new QSqlTableModel(this); |
181 | modelForDescription = new ModelForDescriptionTable(this); |
||
50 | pingvin | 182 | |
61 | pingvin | 183 | |
56 | pingvin | 184 | /////////////////model->setTable(tr("ListOfClasses")); |
50 | pingvin | 185 | mymodel->setTable(tr("ListOfClasses")); |
56 | pingvin | 186 | modelForDescription->setTable(tr("DescriptionOfClasses")); |
187 | modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange); |
||
50 | pingvin | 188 | |
45 | pingvin | 189 | /////model->setEditStrategy(QSqlTableModel::OnManualSubmit); |
50 | pingvin | 190 | |
191 | |||
192 | |||
71 | pingvin | 193 | //mymodel->setEditStrategy(QSqlTableModel::OnFieldChange); |
194 | |||
195 | |||
196 | |||
56 | pingvin | 197 | //////////////////model->setSort(0, Qt::AscendingOrder); |
50 | pingvin | 198 | mymodel->setSort(0, Qt::AscendingOrder); |
56 | pingvin | 199 | modelForDescription->setSort(0, Qt::AscendingOrder); |
50 | pingvin | 200 | |
56 | pingvin | 201 | |
45 | pingvin | 202 | // model->setFilter(tr("__ = '7' and _ = 'i09090909'")); |
56 | pingvin | 203 | ////////////////////model->select(); |
50 | pingvin | 204 | mymodel->select(); |
205 | |||
56 | pingvin | 206 | |
68 | pingvin | 207 | |
208 | |||
56 | pingvin | 209 | /////////////////////////model->setHeaderData(1, Qt::Horizontal, tr(" ")); |
50 | pingvin | 210 | mymodel->setHeaderData(1, Qt::Horizontal, tr(" ")); |
211 | |||
212 | |||
213 | |||
56 | pingvin | 214 | ////////////////////////model->setHeaderData(2, Qt::Horizontal, tr(" ")); |
50 | pingvin | 215 | mymodel->setHeaderData(2, Qt::Horizontal, tr(" ")); |
60 | pingvin | 216 | mymodel->setHeaderData(4, Qt::Horizontal, tr("")); |
50 | pingvin | 217 | |
65 | pingvin | 218 | |
50 | pingvin | 219 | //ui->tableView->setModel(model); |
220 | ui->tableView->setModel(mymodel); |
||
56 | pingvin | 221 | //tableForDescription = new QTableView(); |
222 | ui->tableView_2->setModel(modelForDescription); |
||
223 | ui->tableView_2->setAlternatingRowColors(true); |
||
224 | ui->tableView_2->resizeColumnsToContents(); |
||
225 | //tableForDescription->show(); |
||
50 | pingvin | 226 | |
227 | |||
45 | pingvin | 228 | ui->tableView->setAlternatingRowColors(true); |
229 | ui->tableView->resizeColumnsToContents(); |
||
65 | pingvin | 230 | |
60 | pingvin | 231 | ui->tableView->hideColumn(0); |
55 | pingvin | 232 | ui->tableView->hideColumn(3); |
60 | pingvin | 233 | ui->tableView->hideColumn(2); |
45 | pingvin | 234 | |
65 | pingvin | 235 | /* |
62 | pingvin | 236 | ui->tableView_2->hideColumn(0); |
237 | ui->tableView_2->hideColumn(5); |
||
238 | ui->tableView_2->hideColumn(2); |
||
65 | pingvin | 239 | */ |
240 | ui->tableView_2->setItemDelegateForColumn(3, &classTableDelegate); |
||
45 | pingvin | 241 | |
62 | pingvin | 242 | currIndexOfClassesTable = modelForDescription->index(0, 1); |
243 | QModelIndex index_temp; |
||
244 | |||
245 | currClassID = mymodel->data(mymodel->index(0,0)).toString(); |
||
246 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
||
247 | |||
248 | QModelIndex topLeft; |
||
249 | QModelIndex bottomRight; |
||
250 | |||
251 | topLeft = mymodel->index(0, 0, QModelIndex()); |
||
252 | bottomRight = mymodel->index(0, 1, QModelIndex()); |
||
253 | |||
254 | QItemSelection selection(topLeft, bottomRight); |
||
255 | selectionModel->select(selection, QItemSelectionModel::Select); |
||
256 | |||
257 | |||
71 | pingvin | 258 | QString class_indx, class_instance; |
68 | pingvin | 259 | QString str_fltr = tr("ClassIdentifer = "); |
260 | class_indx = mymodel->data(mymodel->index(0,0)).toString(); |
||
71 | pingvin | 261 | class_instance = mymodel->data(mymodel->index(0,3)).toString(); |
262 | //class_instance.append(tr("_inctance")); |
||
68 | pingvin | 263 | str_fltr.append(class_indx); |
62 | pingvin | 264 | |
71 | pingvin | 265 | model->setTable(class_instance); |
266 | //model->setTable(tr("memory")); |
||
267 | model->setEditStrategy(QSqlTableModel::OnFieldChange); |
||
268 | model->select(); |
||
269 | tableForInstance.setModel(model); |
||
270 | tableForInstance.resizeColumnsToContents(); |
||
271 | tableForInstance.show(); |
||
272 | |||
68 | pingvin | 273 | modelForDescription->setFilter(str_fltr); |
274 | modelForDescription->select(); |
||
69 | pingvin | 275 | ui->tableView_2->resizeColumnsToContents(); |
68 | pingvin | 276 | |
277 | |||
278 | |||
55 | pingvin | 279 | //connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex))); |
62 | pingvin | 280 | connect(mymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_myModel_dataChanged(QModelIndex,QModelIndex))); |
281 | connect(modelForDescription, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_modelForDescription_dataChanged(QModelIndex,QModelIndex))); |
||
65 | pingvin | 282 | connect(ui->newClassAction, SIGNAL(triggered(bool)), this, SLOT(on_pushButton_clicked(bool))); |
283 | connect(ui->action_ID, SIGNAL(triggered(bool)), this, SLOT(on_action_ID_triggered(bool))); |
||
68 | pingvin | 284 | connect(ui->action_showAlias, SIGNAL(triggered(bool)), this, SLOT(on_action_showAlias_triggered(bool))); // |
285 | connect(ui->action_showInstance, SIGNAL(triggered(bool)), this, SLOT(on_action_showInstance_triggered(bool))); // |
||
286 | connect(ui->action_removeSelectedFields, SIGNAL(triggered()), this, SLOT(on_pushButton_4_clicked())); // |
||
287 | connect(ui->action_removeAllFields, SIGNAL(triggered()), this, SLOT(on_pushButton_5_clicked())); // |
||
288 | connect(ui->action_removeSelectedClasses, SIGNAL(triggered()), this, SLOT(on_pushButton_2_clicked())); // |
||
289 | connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // |
||
42 | pingvin | 290 | } |
291 | |||
45 | pingvin | 292 | |
293 | |||
294 | |||
295 | |||
296 | |||
297 | |||
298 | |||
299 | |||
300 | |||
301 | |||
24 | pingvin | 302 | ClassEditor::~ClassEditor() |
303 | { |
||
304 | delete ui; |
||
38 | pingvin | 305 | // delete field; |
24 | pingvin | 306 | // delete settdialog; |
307 | } |
||
308 | |||
309 | void ClassEditor::changeEvent(QEvent *e) |
||
310 | { |
||
311 | QMainWindow::changeEvent(e); |
||
312 | switch (e->type()) { |
||
313 | case QEvent::LanguageChange: |
||
314 | ui->retranslateUi(this); |
||
315 | break; |
||
316 | default: |
||
317 | break; |
||
318 | } |
||
319 | } |
||
51 | pingvin | 320 | |
321 | |||
71 | pingvin | 322 | /* |
51 | pingvin | 323 | void ClassEditor::addNewClass(){ |
324 | |||
325 | int row = model->rowCount(); |
||
326 | |||
327 | model->insertRows(row, 1); |
||
54 | pingvin | 328 | model->setData(model->index(row, 1), tr("New class")); // " " |
51 | pingvin | 329 | |
330 | |||
331 | // model->setData(model->index(row, 1), tr(" ")); |
||
332 | // model->setData(model->index(row, 2) , tr(" , 1")); |
||
333 | |||
334 | |||
335 | model->submitAll(); |
||
336 | |||
337 | row = model->rowCount(); |
||
338 | QString tmp_str; |
||
339 | int i_tmp; |
||
340 | i_tmp = model->data(model->index(row-1, 0)).toInt(); |
||
341 | tmp_str = model->data(model->index(row-1, 0)).toString(); // - |
||
342 | |||
343 | tmp_str.append(tr("_Inctance")); |
||
344 | model->setData(model->index(row-1, 3), tmp_str ); // |
||
345 | |||
346 | model->submitAll(); |
||
347 | mymodel->select(); |
||
348 | |||
349 | |||
350 | } |
||
71 | pingvin | 351 | */ |
51 | pingvin | 352 | |
54 | pingvin | 353 | void ClassEditor::addNewClass_new(){ |
354 | |||
355 | int row = mymodel->rowCount(); |
||
356 | |||
357 | mymodel->insertRows(row, 1); |
||
70 | pingvin | 358 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New class")), Qt::EditRole); // " " |
54 | pingvin | 359 | |
70 | pingvin | 360 | |
54 | pingvin | 361 | mymodel->submitAll(); |
362 | row = mymodel->rowCount(); |
||
70 | pingvin | 363 | QString tmp_str1, sql_str; |
54 | pingvin | 364 | int i_tmp1; |
365 | i_tmp1 = mymodel->data(mymodel->index(row-1, 0)).toInt(); |
||
366 | tmp_str1 = mymodel->data(mymodel->index(row-1, 0)).toString(); // - |
||
367 | |||
368 | tmp_str1.append(tr("_Inctance")); |
||
70 | pingvin | 369 | SqlTable* tbl; |
370 | tbl = new SqlTable(tmp_str1); // |
||
371 | sql_str = tbl->sqlString(); |
||
372 | bool ok; |
||
373 | |||
374 | ok = sql.createTable(tbl); |
||
375 | |||
376 | if (!ok) { |
||
377 | QMessageBox::critical( // . |
||
378 | this, // . |
||
379 | QObject::tr("Database Error"), // . |
||
380 | sql.lasError()); // . |
||
381 | delete tbl; |
||
382 | mymodel->removeRow(row-1); |
||
383 | mymodel->submitAll(); |
||
384 | mymodel->select(); |
||
385 | ui->tableView_2->resizeRowsToContents(); |
||
386 | return; // |
||
387 | |||
388 | } |
||
389 | |||
390 | delete tbl; |
||
54 | pingvin | 391 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // |
392 | |||
70 | pingvin | 393 | |
394 | |||
54 | pingvin | 395 | // model->setData(model->index(row, 1), tr(" ")); |
396 | // model->setData(model->index(row, 2) , tr(" , 1")); |
||
397 | |||
398 | |||
56 | pingvin | 399 | //mymodel->submitAll(); |
54 | pingvin | 400 | |
401 | //row = mymodel->rowCount(); |
||
402 | |||
403 | |||
56 | pingvin | 404 | //mymodel->select(); |
54 | pingvin | 405 | |
406 | |||
407 | } |
||
408 | |||
409 | |||
62 | pingvin | 410 | void ClassEditor::addNewField(){ |
411 | // QSqlRecord rec = mymodel->record(1); |
||
412 | //bool ok; |
||
413 | //ok = rec.isEmpty(); |
||
414 | //QString currientClassID; |
||
415 | //currientClassID = rec.value(1).toString(); |
||
416 | int row = modelForDescription->rowCount(); |
||
417 | modelForDescription->insertRows(row, 1); |
||
418 | modelForDescription->setData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole); |
||
419 | modelForDescription->setData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole); |
||
420 | |||
421 | modelForDescription->submitAll(); |
||
422 | } |
||
423 | |||
424 | |||
425 | |||
426 | |||
427 | |||
428 | |||
429 | |||
430 | |||
431 | |||
432 | |||
68 | pingvin | 433 | // |
51 | pingvin | 434 | void ClassEditor::on_pushButton_clicked(){ |
54 | pingvin | 435 | //int i; |
436 | //i++; |
||
437 | /////ClassEditor::addNewClass(); |
||
438 | ClassEditor::addNewClass_new(); |
||
439 | mymodel->select(); |
||
440 | //ui->tableView->setModel(mymodel); |
||
441 | |||
51 | pingvin | 442 | } |
54 | pingvin | 443 | |
55 | pingvin | 444 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
445 | int i, row, column; |
||
446 | i++; |
||
447 | row = index.row(); |
||
448 | column = index.column(); |
||
62 | pingvin | 449 | currIndexOfClassesTable = index; |
71 | pingvin | 450 | QModelIndex index_tmp, index_instance; |
451 | QString tmp_str, filter_str, instance_str; |
||
56 | pingvin | 452 | index_tmp = ui->tableView->model()->index(row, 0); |
71 | pingvin | 453 | index_instance = ui->tableView->model()->index(row, 3); |
56 | pingvin | 454 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
71 | pingvin | 455 | instance_str = ui->tableView->model()->data(index_instance).toString(); |
456 | // instance_str.append(tr("_inctance")); |
||
457 | |||
458 | model->setTable(instance_str); |
||
459 | model->select(); |
||
460 | tableForInstance.setWindowTitle(instance_str); |
||
461 | // tableForInstance.setModel(model); |
||
462 | tableForInstance.resizeColumnsToContents(); |
||
463 | |||
62 | pingvin | 464 | currClassID = tmp_str; |
465 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
56 | pingvin | 466 | filter_str = tr("ClassIdentifer = "); |
467 | filter_str.append(tmp_str); |
||
468 | modelForDescription->setFilter(filter_str); |
||
68 | pingvin | 469 | modelForDescription->select(); |
62 | pingvin | 470 | ui->tableView_2->resizeColumnsToContents(); |
56 | pingvin | 471 | i++; |
55 | pingvin | 472 | } |
54 | pingvin | 473 | |
59 | pingvin | 474 | |
475 | |||
68 | pingvin | 476 | void ClassEditor::on_pushButton_2_clicked(){ // " " |
477 | QModelIndex model_index; |
||
478 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
||
479 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
||
480 | QList<int> selectedRows; |
||
481 | selectedRows.clear(); |
||
482 | foreach (model_index, indexes){ // |
||
483 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // |
||
59 | pingvin | 484 | |
68 | pingvin | 485 | } |
486 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
487 | |||
488 | |||
489 | for (int m =0; m < selectedRows.size(); ++m){ |
||
490 | |||
491 | ClassEditor::removeClass(selectedRows.at(m)); |
||
492 | |||
493 | |||
494 | |||
495 | } |
||
496 | mymodel->submitAll(); |
||
497 | ClassEditor::modelForDescription->select(); |
||
498 | |||
59 | pingvin | 499 | } |
500 | |||
501 | void ClassEditor::on_pushButton_3_clicked(){ // " " |
||
502 | int i; |
||
503 | i++; |
||
62 | pingvin | 504 | ClassEditor::addNewField(); |
505 | ClassEditor::modelForDescription->select(); |
||
64 | pingvin | 506 | ui->tableView_2->resizeColumnsToContents(); |
59 | pingvin | 507 | } |
68 | pingvin | 508 | |
509 | |||
59 | pingvin | 510 | void ClassEditor::on_pushButton_4_clicked(){ // " " |
69 | pingvin | 511 | // int i; |
62 | pingvin | 512 | QModelIndex model_index; |
63 | pingvin | 513 | QItemSelectionModel *selectionModel = ui->tableView_2->selectionModel(); |
62 | pingvin | 514 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
69 | pingvin | 515 | //QModelIndexList indexes_fo_first_col; // ( ) |
62 | pingvin | 516 | //model_index = mymodel->selec; |
517 | //modelList = ui->tableView->SelectItems; |
||
69 | pingvin | 518 | //i = indexes.size(); |
63 | pingvin | 519 | QList<int> selectedRows; |
69 | pingvin | 520 | //indexes_fo_first_col.clear(); |
521 | /* |
||
67 | pingvin | 522 | foreach (model_index, indexes){ // |
523 | if (!indexes_fo_first_col.contains(model_index) && (model_index.column()==1)) indexes_fo_first_col.append(model_index); // |
||
524 | |||
525 | } |
||
69 | pingvin | 526 | */ |
63 | pingvin | 527 | selectedRows.clear(); |
528 | foreach (model_index, indexes){ // |
||
67 | pingvin | 529 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // |
62 | pingvin | 530 | |
63 | pingvin | 531 | } |
67 | pingvin | 532 | |
533 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
534 | |||
535 | |||
536 | for (int m =0; m < selectedRows.size(); ++m){ |
||
537 | |||
538 | modelForDescription->removeRow(selectedRows.at(m)); |
||
539 | } |
||
540 | |||
69 | pingvin | 541 | //i = selectedRows.size(); |
63 | pingvin | 542 | |
69 | pingvin | 543 | //if (i > 0) model_index = indexes.at(0); |
59 | pingvin | 544 | } |
62 | pingvin | 545 | |
546 | |||
63 | pingvin | 547 | void ClassEditor::on_pushButton_5_clicked(){ // " " |
548 | int row; |
||
549 | row = ClassEditor::modelForDescription->rowCount(); |
||
550 | ClassEditor::modelForDescription->removeRows(0, row); |
||
551 | ClassEditor::modelForDescription->submitAll(); |
||
552 | } |
||
553 | |||
62 | pingvin | 554 | void ClassEditor::on_myModel_dataChanged( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
555 | int i; |
||
556 | i++; |
||
557 | ui->tableView->resizeColumnsToContents(); |
||
558 | } |
||
559 | |||
560 | void ClassEditor::on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
||
561 | ui->tableView_2->resizeColumnsToContents(); |
||
562 | } |
||
65 | pingvin | 563 | |
564 | void ClassEditor::on_action_ID_triggered(bool is_checked){ // " ID" |
||
565 | if (is_checked) ui->tableView->showColumn(0); |
||
566 | else ui->tableView->hideColumn(0); |
||
567 | ui->tableView->resizeColumnsToContents(); |
||
568 | } |
||
569 | |||
570 | void ClassEditor::on_action_showAlias_triggered(bool is_checked){ // " " |
||
571 | if (is_checked) ui->tableView->showColumn(2); |
||
572 | else ui->tableView->hideColumn(2); |
||
573 | ui->tableView->resizeColumnsToContents(); |
||
574 | } |
||
575 | |||
68 | pingvin | 576 | void ClassEditor::on_action_showInstance_triggered(bool is_checked){ // " " |
65 | pingvin | 577 | if (is_checked) ui->tableView->showColumn(3); |
578 | else ui->tableView->hideColumn(3); |
||
579 | ui->tableView->resizeColumnsToContents(); |
||
580 | } |
||
68 | pingvin | 581 | |
582 | |||
583 | |||
584 | void ClassEditor::on_action_removeAllClasses(){ // " " |
||
585 | int row; |
||
586 | row = ClassEditor::mymodel->rowCount(); |
||
587 | for (int m=0; m < row; ++m){ |
||
588 | ClassEditor::removeClass(0); |
||
589 | //ClassEditor::mymodel->removeRows(0, row); |
||
590 | } |
||
591 | ClassEditor::mymodel->submitAll(); |
||
592 | ClassEditor::modelForDescription->select(); |
||
593 | } |
||
594 | |||
595 | void ClassEditor::removeClass(int class_row){ // , class_row |
||
596 | QModelIndex index_tmp; |
||
597 | QString tmp_str, filter_str; |
||
598 | index_tmp = ui->tableView->model()->index(class_row, 0); |
||
599 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
||
600 | currClassID = tmp_str; |
||
601 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
602 | filter_str = tr("ClassIdentifer = "); |
||
603 | filter_str.append(tmp_str); |
||
604 | modelForDescription->setFilter(filter_str); // |
||
605 | ClassEditor::on_pushButton_5_clicked(); // |
||
606 | mymodel->removeRow(class_row); // |
||
607 | mymodel->submitAll(); // |
||
608 | ui->tableView->resizeColumnsToContents(); |
||
609 | ui->tableView_2->resizeColumnsToContents(); |
||
610 | |||
611 | } |