202,10 → 202,10 |
// model->setFilter(tr("Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = '7' and Èíâåíòàðíûé_íîìåð = 'i09090909'")); |
////////////////////model->select(); |
mymodel->select(); |
modelForDescription->setFilter(tr("ClassIdentifer = 1")); |
modelForDescription->select(); |
|
|
|
|
/////////////////////////model->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà")); |
mymodel->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà")); |
|
255,14 → 255,27 |
selectionModel->select(selection, QItemSelectionModel::Select); |
|
|
QString class_indx; |
QString str_fltr = tr("ClassIdentifer = "); |
class_indx = mymodel->data(mymodel->index(0,0)).toString(); |
str_fltr.append(class_indx); |
|
modelForDescription->setFilter(str_fltr); |
modelForDescription->select(); |
|
|
|
//connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex))); |
connect(mymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_myModel_dataChanged(QModelIndex,QModelIndex))); |
connect(modelForDescription, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_modelForDescription_dataChanged(QModelIndex,QModelIndex))); |
connect(ui->newClassAction, SIGNAL(triggered(bool)), this, SLOT(on_pushButton_clicked(bool))); |
connect(ui->action_ID, SIGNAL(triggered(bool)), this, SLOT(on_action_ID_triggered(bool))); |
connect(ui->action_showAlias, SIGNAL(triggered(bool)), this, SLOT(on_action_showAlias_triggered(bool))); |
connect(ui->action_showInstance, SIGNAL(triggered(bool)), this, SLOT(on_action_showInstance_triggered(bool))); |
connect(ui->action_showAlias, SIGNAL(triggered(bool)), this, SLOT(on_action_showAlias_triggered(bool))); // ïîêàçûâàòü ïñåâäîíèìû |
connect(ui->action_showInstance, SIGNAL(triggered(bool)), this, SLOT(on_action_showInstance_triggered(bool))); // ïîêàçûâàòü õðàíèëèùà îáúåêòîâ |
connect(ui->action_removeSelectedFields, SIGNAL(triggered()), this, SLOT(on_pushButton_4_clicked())); // óäàëèòü âûäåëåííûå ïîëÿ |
connect(ui->action_removeAllFields, SIGNAL(triggered()), this, SLOT(on_pushButton_5_clicked())); // óäàëèòü âñå ïîëÿ |
connect(ui->action_removeSelectedClasses, SIGNAL(triggered()), this, SLOT(on_pushButton_2_clicked())); // óäàëèòü âûäåëåííûå êëàññû |
connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // óäàëèòü âûäåëåííûå êëàññû |
} |
|
|
382,7 → 395,7 |
|
|
|
|
// äîáàâëÿåì íîâûé êëàññ |
void ClassEditor::on_pushButton_clicked(){ |
//int i; |
//i++; |
408,6 → 421,7 |
filter_str = tr("ClassIdentifer = "); |
filter_str.append(tmp_str); |
modelForDescription->setFilter(filter_str); |
modelForDescription->select(); |
ui->tableView_2->resizeColumnsToContents(); |
i++; |
} |
414,12 → 428,31 |
|
|
|
void ClassEditor::on_pushButton_2_clicked(){ |
int i; |
i++; |
void ClassEditor::on_pushButton_2_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïðêè "Óäàëèòü êëàññ" |
QModelIndex model_index; |
QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
QModelIndexList indexes = selectionModel->selectedIndexes(); |
QList<int> selectedRows; |
selectedRows.clear(); |
foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
|
} |
qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå |
|
|
for (int m =0; m < selectedRows.size(); ++m){ |
|
ClassEditor::removeClass(selectedRows.at(m)); |
|
|
|
} |
mymodel->submitAll(); |
ClassEditor::modelForDescription->select(); |
|
} |
|
void ClassEditor::on_pushButton_3_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Íîâîå ïîëå" |
int i; |
i++; |
427,6 → 460,8 |
ClassEditor::modelForDescription->select(); |
ui->tableView_2->resizeColumnsToContents(); |
} |
|
|
void ClassEditor::on_pushButton_4_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ïîëå" |
int i; |
i++; |
494,8 → 529,39 |
ui->tableView->resizeColumnsToContents(); |
} |
|
void ClassEditor::on_action_showInstance_triggered(bool is_checked){ |
void ClassEditor::on_action_showInstance_triggered(bool is_checked){ // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü õðàíèëèùà îáúåêòîâ" |
if (is_checked) ui->tableView->showColumn(3); |
else ui->tableView->hideColumn(3); |
ui->tableView->resizeColumnsToContents(); |
} |
|
|
|
void ClassEditor::on_action_removeAllClasses(){ // îáðàáàòûâàåì âûáîð â ìåíþ "Óäàëèòü âñå êëàññû" |
int row; |
row = ClassEditor::mymodel->rowCount(); |
for (int m=0; m < row; ++m){ |
ClassEditor::removeClass(0); |
//ClassEditor::mymodel->removeRows(0, row); |
} |
ClassEditor::mymodel->submitAll(); |
ClassEditor::modelForDescription->select(); |
} |
|
void ClassEditor::removeClass(int class_row){ // ôóíêöèÿ óäàëÿåò êëàññ, íàõîäÿùèéñÿ â ñòðîêå ñ íîìåðîì class_row |
QModelIndex index_tmp; |
QString tmp_str, filter_str; |
index_tmp = ui->tableView->model()->index(class_row, 0); |
tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
currClassID = tmp_str; |
// ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString()); |
filter_str = tr("ClassIdentifer = "); |
filter_str.append(tmp_str); |
modelForDescription->setFilter(filter_str); // îáíîâëÿåì òàáëèöó ïîëåé |
ClassEditor::on_pushButton_5_clicked(); // ñíà÷àëà óäàëèì âñå ïîëÿ êëàññà |
mymodel->removeRow(class_row); // òåïåðü óäàëÿåì ñàì êëàññ |
mymodel->submitAll(); // ôèêñèðóåì èçìåíåíèÿ |
ui->tableView->resizeColumnsToContents(); |
ui->tableView_2->resizeColumnsToContents(); |
|
} |