Редакция 69 | Редакция 71 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | 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); |
||
70 | pingvin | 348 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New class")), Qt::EditRole); // " " |
54 | pingvin | 349 | |
70 | pingvin | 350 | |
54 | pingvin | 351 | mymodel->submitAll(); |
352 | row = mymodel->rowCount(); |
||
70 | pingvin | 353 | QString tmp_str1, sql_str; |
54 | pingvin | 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")); |
||
70 | pingvin | 359 | SqlTable* tbl; |
360 | tbl = new SqlTable(tmp_str1); // |
||
361 | sql_str = tbl->sqlString(); |
||
362 | bool ok; |
||
363 | |||
364 | ok = sql.createTable(tbl); |
||
365 | |||
366 | if (!ok) { |
||
367 | QMessageBox::critical( // . |
||
368 | this, // . |
||
369 | QObject::tr("Database Error"), // . |
||
370 | sql.lasError()); // . |
||
371 | delete tbl; |
||
372 | mymodel->removeRow(row-1); |
||
373 | mymodel->submitAll(); |
||
374 | mymodel->select(); |
||
375 | ui->tableView_2->resizeRowsToContents(); |
||
376 | return; // |
||
377 | |||
378 | } |
||
379 | |||
380 | delete tbl; |
||
54 | pingvin | 381 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // |
382 | |||
70 | pingvin | 383 | |
384 | |||
54 | pingvin | 385 | // model->setData(model->index(row, 1), tr(" ")); |
386 | // model->setData(model->index(row, 2) , tr(" , 1")); |
||
387 | |||
388 | |||
56 | pingvin | 389 | //mymodel->submitAll(); |
54 | pingvin | 390 | |
391 | //row = mymodel->rowCount(); |
||
392 | |||
393 | |||
56 | pingvin | 394 | //mymodel->select(); |
54 | pingvin | 395 | |
396 | |||
397 | } |
||
398 | |||
399 | |||
62 | pingvin | 400 | void ClassEditor::addNewField(){ |
401 | // QSqlRecord rec = mymodel->record(1); |
||
402 | //bool ok; |
||
403 | //ok = rec.isEmpty(); |
||
404 | //QString currientClassID; |
||
405 | //currientClassID = rec.value(1).toString(); |
||
406 | int row = modelForDescription->rowCount(); |
||
407 | modelForDescription->insertRows(row, 1); |
||
408 | modelForDescription->setData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole); |
||
409 | modelForDescription->setData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole); |
||
410 | |||
411 | modelForDescription->submitAll(); |
||
412 | } |
||
413 | |||
414 | |||
415 | |||
416 | |||
417 | |||
418 | |||
419 | |||
420 | |||
421 | |||
422 | |||
68 | pingvin | 423 | // |
51 | pingvin | 424 | void ClassEditor::on_pushButton_clicked(){ |
54 | pingvin | 425 | //int i; |
426 | //i++; |
||
427 | /////ClassEditor::addNewClass(); |
||
428 | ClassEditor::addNewClass_new(); |
||
429 | mymodel->select(); |
||
430 | //ui->tableView->setModel(mymodel); |
||
431 | |||
51 | pingvin | 432 | } |
54 | pingvin | 433 | |
55 | pingvin | 434 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
435 | int i, row, column; |
||
436 | i++; |
||
437 | row = index.row(); |
||
438 | column = index.column(); |
||
62 | pingvin | 439 | currIndexOfClassesTable = index; |
440 | QModelIndex index_tmp; |
||
56 | pingvin | 441 | QString tmp_str, filter_str; |
442 | index_tmp = ui->tableView->model()->index(row, 0); |
||
443 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
||
62 | pingvin | 444 | currClassID = tmp_str; |
445 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
56 | pingvin | 446 | filter_str = tr("ClassIdentifer = "); |
447 | filter_str.append(tmp_str); |
||
448 | modelForDescription->setFilter(filter_str); |
||
68 | pingvin | 449 | modelForDescription->select(); |
62 | pingvin | 450 | ui->tableView_2->resizeColumnsToContents(); |
56 | pingvin | 451 | i++; |
55 | pingvin | 452 | } |
54 | pingvin | 453 | |
59 | pingvin | 454 | |
455 | |||
68 | pingvin | 456 | void ClassEditor::on_pushButton_2_clicked(){ // " " |
457 | QModelIndex model_index; |
||
458 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
||
459 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
||
460 | QList<int> selectedRows; |
||
461 | selectedRows.clear(); |
||
462 | foreach (model_index, indexes){ // |
||
463 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // |
||
59 | pingvin | 464 | |
68 | pingvin | 465 | } |
466 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
467 | |||
468 | |||
469 | for (int m =0; m < selectedRows.size(); ++m){ |
||
470 | |||
471 | ClassEditor::removeClass(selectedRows.at(m)); |
||
472 | |||
473 | |||
474 | |||
475 | } |
||
476 | mymodel->submitAll(); |
||
477 | ClassEditor::modelForDescription->select(); |
||
478 | |||
59 | pingvin | 479 | } |
480 | |||
481 | void ClassEditor::on_pushButton_3_clicked(){ // " " |
||
482 | int i; |
||
483 | i++; |
||
62 | pingvin | 484 | ClassEditor::addNewField(); |
485 | ClassEditor::modelForDescription->select(); |
||
64 | pingvin | 486 | ui->tableView_2->resizeColumnsToContents(); |
59 | pingvin | 487 | } |
68 | pingvin | 488 | |
489 | |||
59 | pingvin | 490 | void ClassEditor::on_pushButton_4_clicked(){ // " " |
69 | pingvin | 491 | // int i; |
62 | pingvin | 492 | QModelIndex model_index; |
63 | pingvin | 493 | QItemSelectionModel *selectionModel = ui->tableView_2->selectionModel(); |
62 | pingvin | 494 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
69 | pingvin | 495 | //QModelIndexList indexes_fo_first_col; // ( ) |
62 | pingvin | 496 | //model_index = mymodel->selec; |
497 | //modelList = ui->tableView->SelectItems; |
||
69 | pingvin | 498 | //i = indexes.size(); |
63 | pingvin | 499 | QList<int> selectedRows; |
69 | pingvin | 500 | //indexes_fo_first_col.clear(); |
501 | /* |
||
67 | pingvin | 502 | foreach (model_index, indexes){ // |
503 | if (!indexes_fo_first_col.contains(model_index) && (model_index.column()==1)) indexes_fo_first_col.append(model_index); // |
||
504 | |||
505 | } |
||
69 | pingvin | 506 | */ |
63 | pingvin | 507 | selectedRows.clear(); |
508 | foreach (model_index, indexes){ // |
||
67 | pingvin | 509 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // |
62 | pingvin | 510 | |
63 | pingvin | 511 | } |
67 | pingvin | 512 | |
513 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // |
||
514 | |||
515 | |||
516 | for (int m =0; m < selectedRows.size(); ++m){ |
||
517 | |||
518 | modelForDescription->removeRow(selectedRows.at(m)); |
||
519 | } |
||
520 | |||
69 | pingvin | 521 | //i = selectedRows.size(); |
63 | pingvin | 522 | |
69 | pingvin | 523 | //if (i > 0) model_index = indexes.at(0); |
59 | pingvin | 524 | } |
62 | pingvin | 525 | |
526 | |||
63 | pingvin | 527 | void ClassEditor::on_pushButton_5_clicked(){ // " " |
528 | int row; |
||
529 | row = ClassEditor::modelForDescription->rowCount(); |
||
530 | ClassEditor::modelForDescription->removeRows(0, row); |
||
531 | ClassEditor::modelForDescription->submitAll(); |
||
532 | } |
||
533 | |||
62 | pingvin | 534 | void ClassEditor::on_myModel_dataChanged( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
535 | int i; |
||
536 | i++; |
||
537 | ui->tableView->resizeColumnsToContents(); |
||
538 | } |
||
539 | |||
540 | void ClassEditor::on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
||
541 | ui->tableView_2->resizeColumnsToContents(); |
||
542 | } |
||
65 | pingvin | 543 | |
544 | void ClassEditor::on_action_ID_triggered(bool is_checked){ // " ID" |
||
545 | if (is_checked) ui->tableView->showColumn(0); |
||
546 | else ui->tableView->hideColumn(0); |
||
547 | ui->tableView->resizeColumnsToContents(); |
||
548 | } |
||
549 | |||
550 | void ClassEditor::on_action_showAlias_triggered(bool is_checked){ // " " |
||
551 | if (is_checked) ui->tableView->showColumn(2); |
||
552 | else ui->tableView->hideColumn(2); |
||
553 | ui->tableView->resizeColumnsToContents(); |
||
554 | } |
||
555 | |||
68 | pingvin | 556 | void ClassEditor::on_action_showInstance_triggered(bool is_checked){ // " " |
65 | pingvin | 557 | if (is_checked) ui->tableView->showColumn(3); |
558 | else ui->tableView->hideColumn(3); |
||
559 | ui->tableView->resizeColumnsToContents(); |
||
560 | } |
||
68 | pingvin | 561 | |
562 | |||
563 | |||
564 | void ClassEditor::on_action_removeAllClasses(){ // " " |
||
565 | int row; |
||
566 | row = ClassEditor::mymodel->rowCount(); |
||
567 | for (int m=0; m < row; ++m){ |
||
568 | ClassEditor::removeClass(0); |
||
569 | //ClassEditor::mymodel->removeRows(0, row); |
||
570 | } |
||
571 | ClassEditor::mymodel->submitAll(); |
||
572 | ClassEditor::modelForDescription->select(); |
||
573 | } |
||
574 | |||
575 | void ClassEditor::removeClass(int class_row){ // , class_row |
||
576 | QModelIndex index_tmp; |
||
577 | QString tmp_str, filter_str; |
||
578 | index_tmp = ui->tableView->model()->index(class_row, 0); |
||
579 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
||
580 | currClassID = tmp_str; |
||
581 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
||
582 | filter_str = tr("ClassIdentifer = "); |
||
583 | filter_str.append(tmp_str); |
||
584 | modelForDescription->setFilter(filter_str); // |
||
585 | ClassEditor::on_pushButton_5_clicked(); // |
||
586 | mymodel->removeRow(class_row); // |
||
587 | mymodel->submitAll(); // |
||
588 | ui->tableView->resizeColumnsToContents(); |
||
589 | ui->tableView_2->resizeColumnsToContents(); |
||
590 | |||
591 | } |