Редакция 68 | Редакция 70 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | 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 | |||
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 | /* |
||
45 | pingvin | 192 | model->setEditStrategy(QSqlTableModel::OnFieldChange); |
50 | 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 | |||
68 | pingvin | 258 | QString class_indx; |
259 | QString str_fltr = tr("ClassIdentifer = "); |
||
260 | class_indx = mymodel->data(mymodel->index(0,0)).toString(); |
||
261 | str_fltr.append(class_indx); |
||
62 | pingvin | 262 | |
68 | pingvin | 263 | modelForDescription->setFilter(str_fltr); |
264 | modelForDescription->select(); |
||
69 | pingvin | 265 | ui->tableView_2->resizeColumnsToContents(); |
68 | pingvin | 266 | |
267 | |||
268 | |||
55 | pingvin | 269 | //connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex))); |
62 | pingvin | 270 | connect(mymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_myModel_dataChanged(QModelIndex,QModelIndex))); |
271 | connect(modelForDescription, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_modelForDescription_dataChanged(QModelIndex,QModelIndex))); |
||
65 | pingvin | 272 | connect(ui->newClassAction, SIGNAL(triggered(bool)), this, SLOT(on_pushButton_clicked(bool))); |
273 | connect(ui->action_ID, SIGNAL(triggered(bool)), this, SLOT(on_action_ID_triggered(bool))); |
||
68 | pingvin | 274 | connect(ui->action_showAlias, SIGNAL(triggered(bool)), this, SLOT(on_action_showAlias_triggered(bool))); // |
275 | connect(ui->action_showInstance, SIGNAL(triggered(bool)), this, SLOT(on_action_showInstance_triggered(bool))); // |
||
276 | connect(ui->action_removeSelectedFields, SIGNAL(triggered()), this, SLOT(on_pushButton_4_clicked())); // |
||
277 | connect(ui->action_removeAllFields, SIGNAL(triggered()), this, SLOT(on_pushButton_5_clicked())); // |
||
278 | connect(ui->action_removeSelectedClasses, SIGNAL(triggered()), this, SLOT(on_pushButton_2_clicked())); // |
||
279 | connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // |
||
42 | pingvin | 280 | } |
281 | |||
45 | pingvin | 282 | |
283 | |||
284 | |||
285 | |||
286 | |||
287 | |||
288 | |||
289 | |||
290 | |||
291 | |||
24 | pingvin | 292 | ClassEditor::~ClassEditor() |
293 | { |
||
294 | delete ui; |
||
38 | pingvin | 295 | // delete field; |
24 | pingvin | 296 | // delete settdialog; |
297 | } |
||
298 | |||
299 | void ClassEditor::changeEvent(QEvent *e) |
||
300 | { |
||
301 | QMainWindow::changeEvent(e); |
||
302 | switch (e->type()) { |
||
303 | case QEvent::LanguageChange: |
||
304 | ui->retranslateUi(this); |
||
305 | break; |
||
306 | default: |
||
307 | break; |
||
308 | } |
||
309 | } |
||
51 | pingvin | 310 | |
311 | |||
312 | |||
313 | void ClassEditor::addNewClass(){ |
||
314 | |||
315 | int row = model->rowCount(); |
||
316 | |||
317 | model->insertRows(row, 1); |
||
54 | pingvin | 318 | model->setData(model->index(row, 1), tr("New class")); // " " |
51 | pingvin | 319 | |
320 | |||
321 | // model->setData(model->index(row, 1), tr(" ")); |
||
322 | // model->setData(model->index(row, 2) , tr(" , 1")); |
||
323 | |||
324 | |||
325 | model->submitAll(); |
||
326 | |||
327 | row = model->rowCount(); |
||
328 | QString tmp_str; |
||
329 | int i_tmp; |
||
330 | i_tmp = model->data(model->index(row-1, 0)).toInt(); |
||
331 | tmp_str = model->data(model->index(row-1, 0)).toString(); // - |
||
332 | |||
333 | tmp_str.append(tr("_Inctance")); |
||
334 | model->setData(model->index(row-1, 3), tmp_str ); // |
||
335 | |||
336 | model->submitAll(); |
||
337 | mymodel->select(); |
||
338 | |||
339 | |||
340 | } |
||
341 | |||
342 | |||
54 | pingvin | 343 | void ClassEditor::addNewClass_new(){ |
344 | |||
345 | int row = mymodel->rowCount(); |
||
346 | |||
347 | mymodel->insertRows(row, 1); |
||
348 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New classs")), Qt::EditRole); // " " |
||
349 | |||
350 | mymodel->submitAll(); |
||
351 | |||
352 | row = mymodel->rowCount(); |
||
353 | QString tmp_str1; |
||
354 | int i_tmp1; |
||
355 | i_tmp1 = mymodel->data(mymodel->index(row-1, 0)).toInt(); |
||
356 | tmp_str1 = mymodel->data(mymodel->index(row-1, 0)).toString(); // - |
||
357 | |||
358 | tmp_str1.append(tr("_Inctance")); |
||
359 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // |
||
360 | |||
361 | // model->setData(model->index(row, 1), tr(" ")); |
||
362 | // model->setData(model->index(row, 2) , tr(" , 1")); |
||
363 | |||
364 | |||
56 | pingvin | 365 | //mymodel->submitAll(); |
54 | pingvin | 366 | |
367 | //row = mymodel->rowCount(); |
||
368 | |||
369 | |||
56 | pingvin | 370 | //mymodel->select(); |
54 | pingvin | 371 | |
372 | |||
373 | } |
||
374 | |||
375 | |||
62 | pingvin | 376 | void ClassEditor::addNewField(){ |
377 | // QSqlRecord rec = mymodel->record(1); |
||
378 | //bool ok; |
||
379 | //ok = rec.isEmpty(); |
||
380 | //QString currientClassID; |
||
381 | //currientClassID = rec.value(1).toString(); |
||
382 | int row = modelForDescription->rowCount(); |
||
383 | modelForDescription->insertRows(row, 1); |
||
384 | modelForDescription->setData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole); |
||
385 | modelForDescription->setData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole); |
||
386 | |||
387 | modelForDescription->submitAll(); |
||
388 | } |
||
389 | |||
390 | |||
391 | |||
392 | |||
393 | |||
394 | |||
395 | |||
396 | |||
397 | |||
398 | |||
68 | pingvin | 399 | // |
51 | pingvin | 400 | void ClassEditor::on_pushButton_clicked(){ |
54 | pingvin | 401 | //int i; |
402 | //i++; |
||
403 | /////ClassEditor::addNewClass(); |
||
404 | ClassEditor::addNewClass_new(); |
||
405 | mymodel->select(); |
||
406 | //ui->tableView->setModel(mymodel); |
||
407 | |||
51 | pingvin | 408 | } |
54 | pingvin | 409 | |
55 | pingvin | 410 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
411 | int i, row, column; |
||
412 | i++; |
||
413 | row = index.row(); |
||
414 | column = index.column(); |
||
62 | pingvin | 415 | currIndexOfClassesTable = index; |
416 | QModelIndex index_tmp; |
||
56 | pingvin | 417 | QString tmp_str, filter_str; |
418 | index_tmp = ui->tableView->model()->index(row, 0); |
||
419 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
||
62 | pingvin | 420 | currClassID = tmp_str; |
421 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
56 | pingvin | 422 | filter_str = tr("ClassIdentifer = "); |
423 | filter_str.append(tmp_str); |
||
424 | modelForDescription->setFilter(filter_str); |
||
68 | pingvin | 425 | modelForDescription->select(); |
62 | pingvin | 426 | ui->tableView_2->resizeColumnsToContents(); |
56 | pingvin | 427 | i++; |
55 | pingvin | 428 | } |
54 | pingvin | 429 | |
59 | pingvin | 430 | |
431 | |||
68 | pingvin | 432 | void ClassEditor::on_pushButton_2_clicked(){ // " " |
433 | QModelIndex model_index; |
||
434 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
||
435 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
||
436 | QList<int> selectedRows; |
||
437 | selectedRows.clear(); |
||
438 | foreach (model_index, indexes){ // |
||
439 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // |
||
59 | pingvin | 440 | |
68 | pingvin | 441 | } |
442 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
443 | |||
444 | |||
445 | for (int m =0; m < selectedRows.size(); ++m){ |
||
446 | |||
447 | ClassEditor::removeClass(selectedRows.at(m)); |
||
448 | |||
449 | |||
450 | |||
451 | } |
||
452 | mymodel->submitAll(); |
||
453 | ClassEditor::modelForDescription->select(); |
||
454 | |||
59 | pingvin | 455 | } |
456 | |||
457 | void ClassEditor::on_pushButton_3_clicked(){ // " " |
||
458 | int i; |
||
459 | i++; |
||
62 | pingvin | 460 | ClassEditor::addNewField(); |
461 | ClassEditor::modelForDescription->select(); |
||
64 | pingvin | 462 | ui->tableView_2->resizeColumnsToContents(); |
59 | pingvin | 463 | } |
68 | pingvin | 464 | |
465 | |||
59 | pingvin | 466 | void ClassEditor::on_pushButton_4_clicked(){ // " " |
69 | pingvin | 467 | // int i; |
62 | pingvin | 468 | QModelIndex model_index; |
63 | pingvin | 469 | QItemSelectionModel *selectionModel = ui->tableView_2->selectionModel(); |
62 | pingvin | 470 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
69 | pingvin | 471 | //QModelIndexList indexes_fo_first_col; // ( ) |
62 | pingvin | 472 | //model_index = mymodel->selec; |
473 | //modelList = ui->tableView->SelectItems; |
||
69 | pingvin | 474 | //i = indexes.size(); |
63 | pingvin | 475 | QList<int> selectedRows; |
69 | pingvin | 476 | //indexes_fo_first_col.clear(); |
477 | /* |
||
67 | pingvin | 478 | foreach (model_index, indexes){ // |
479 | if (!indexes_fo_first_col.contains(model_index) && (model_index.column()==1)) indexes_fo_first_col.append(model_index); // |
||
480 | |||
481 | } |
||
69 | pingvin | 482 | */ |
63 | pingvin | 483 | selectedRows.clear(); |
484 | foreach (model_index, indexes){ // |
||
67 | pingvin | 485 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // |
62 | pingvin | 486 | |
63 | pingvin | 487 | } |
67 | pingvin | 488 | |
489 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
490 | |||
491 | |||
492 | for (int m =0; m < selectedRows.size(); ++m){ |
||
493 | |||
494 | modelForDescription->removeRow(selectedRows.at(m)); |
||
495 | } |
||
496 | |||
69 | pingvin | 497 | //i = selectedRows.size(); |
63 | pingvin | 498 | |
69 | pingvin | 499 | //if (i > 0) model_index = indexes.at(0); |
59 | pingvin | 500 | } |
62 | pingvin | 501 | |
502 | |||
63 | pingvin | 503 | void ClassEditor::on_pushButton_5_clicked(){ // " " |
504 | int row; |
||
505 | row = ClassEditor::modelForDescription->rowCount(); |
||
506 | ClassEditor::modelForDescription->removeRows(0, row); |
||
507 | ClassEditor::modelForDescription->submitAll(); |
||
508 | } |
||
509 | |||
62 | pingvin | 510 | void ClassEditor::on_myModel_dataChanged( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
511 | int i; |
||
512 | i++; |
||
513 | ui->tableView->resizeColumnsToContents(); |
||
514 | } |
||
515 | |||
516 | void ClassEditor::on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
||
517 | ui->tableView_2->resizeColumnsToContents(); |
||
518 | } |
||
65 | pingvin | 519 | |
520 | void ClassEditor::on_action_ID_triggered(bool is_checked){ // " ID" |
||
521 | if (is_checked) ui->tableView->showColumn(0); |
||
522 | else ui->tableView->hideColumn(0); |
||
523 | ui->tableView->resizeColumnsToContents(); |
||
524 | } |
||
525 | |||
526 | void ClassEditor::on_action_showAlias_triggered(bool is_checked){ // " " |
||
527 | if (is_checked) ui->tableView->showColumn(2); |
||
528 | else ui->tableView->hideColumn(2); |
||
529 | ui->tableView->resizeColumnsToContents(); |
||
530 | } |
||
531 | |||
68 | pingvin | 532 | void ClassEditor::on_action_showInstance_triggered(bool is_checked){ // " " |
65 | pingvin | 533 | if (is_checked) ui->tableView->showColumn(3); |
534 | else ui->tableView->hideColumn(3); |
||
535 | ui->tableView->resizeColumnsToContents(); |
||
536 | } |
||
68 | pingvin | 537 | |
538 | |||
539 | |||
540 | void ClassEditor::on_action_removeAllClasses(){ // " " |
||
541 | int row; |
||
542 | row = ClassEditor::mymodel->rowCount(); |
||
543 | for (int m=0; m < row; ++m){ |
||
544 | ClassEditor::removeClass(0); |
||
545 | //ClassEditor::mymodel->removeRows(0, row); |
||
546 | } |
||
547 | ClassEditor::mymodel->submitAll(); |
||
548 | ClassEditor::modelForDescription->select(); |
||
549 | } |
||
550 | |||
551 | void ClassEditor::removeClass(int class_row){ // , class_row |
||
552 | QModelIndex index_tmp; |
||
553 | QString tmp_str, filter_str; |
||
554 | index_tmp = ui->tableView->model()->index(class_row, 0); |
||
555 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
||
556 | currClassID = tmp_str; |
||
557 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
558 | filter_str = tr("ClassIdentifer = "); |
||
559 | filter_str.append(tmp_str); |
||
560 | modelForDescription->setFilter(filter_str); // |
||
561 | ClassEditor::on_pushButton_5_clicked(); // |
||
562 | mymodel->removeRow(class_row); // |
||
563 | mymodel->submitAll(); // |
||
564 | ui->tableView->resizeColumnsToContents(); |
||
565 | ui->tableView_2->resizeColumnsToContents(); |
||
566 | |||
567 | } |