// вывод таблицы средствvoid PotokMainWindow::on_act_skkp_triggered(){ int index ; bool find ; int cols_to_show[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12, 13, 14, 15, 16, 17, 18, 19, 20,21, 22, 23}; model_skkp->setHeaderData(0, Qt::Horizontal, QString::fromLocal8Bit("Порядковый номер")); model_skkp->setHeaderData(1, Qt::Horizontal, QString::fromLocal8Bit("Название")); model_skkp->setHeaderData(2, Qt::Horizontal, QString::fromLocal8Bit("Система"));..... model_skkp->setHeaderData(22, Qt::Horizontal, QString::fromLocal8Bit("")); model_skkp->setHeaderData(23, Qt::Horizontal, QString::fromLocal8Bit("")); index = findTypeTab(2, find) ; if(!find) { clear_derevo(); QProgressDialog progress(QString::fromLocal8Bit("Загрузка каталога НС..."), QString::fromLocal8Bit("Прервать"), 0, model_skkp->rowCount(), this); for (int n = 0; n < model_skkp->rowCount(); ++n) { addspis(QString::fromLocal8Bit("НС"), model_skkp->record(n).value("name").toString()); progress.setValue(n); if (progress.wasCanceled()) break; } } skkp_view = new QPotokKOTableView(this, filter_ko); skkp_view->setModel(model_skkp); skkp_view->hideColumn(0); skkp_view -> setSelectionMode (QAbstractItemView::ExtendedSelection) ; skkp_view -> setSelectionBehavior (QAbstractItemView::SelectRows) ; skkp_view->setWindowTitle(QString::fromLocal8Bit("НС")); skkp_view->setWindowIcon(QIcon(QString::fromUtf8("img/skkp.png"))); connect(skkp_view, SIGNAL(clicked(const QModelIndex&)), this, SLOT(selected_SKP_Tree(const QModelIndex&))); connect(skkp_view->verticalHeader(), SIGNAL(sectionPressed(int)), this, SLOT(selected_SKP_Tree(int))) ; connect(skkp_view, SIGNAL(dataChanged(int)), this, SLOT(selected_SKP_Tree(int))); tabWidget->insertTab(index, skkp_view, tr("НС")); tabWidget->setCurrentWidget( skkp_view ); updateToolButtonState(); for (int k = 0; k < model_ko->columnCount(); ++k) { skkp_view->setColumnHidden(k, true); } for (int j = 0; j < 24; ++j) { skkp_view->setColumnHidden(cols_to_show[j], false); } Tab_list.push_back(Tab_indexes( tabWidget->indexOf( skkp_view ), 2)) ;}
connect(skkp_view, SIGNAL(clicked(const QModelIndex&)), this, SLOT(selected_SKP_Tree(const QModelIndex&)));connect(skkp_view->verticalHeader(), SIGNAL(sectionPressed(int)), this, SLOT(selected_SKP_Tree(int))) ;
void PotokMainWindow::selected_SKP_Tree(const QModelIndex & index ){ int n_rows = model_skkp -> rowCount() ; QItemSelectionModel* skkp_selection_model = skkp_view->selectionModel() ; for(int n = 0; n < n_rows; ++n) variant_NS -> topLevelItem(0) -> child(n) -> setCheckState(0, Qt::Unchecked) ; for(int n = 0; n < n_rows; ++n) if(skkp_selection_model -> isRowSelected(n, QModelIndex())) variant_NS -> topLevelItem(0) -> child(n) -> setCheckState(0, Qt::Checked) ;}и void PotokMainWindow::selected_SKP_Tree(int index ){ int n_rows = model_skkp -> rowCount() ; QItemSelectionModel* skkp_selection_model = skkp_view->selectionModel() ; for(int n = 0; n < n_rows; ++n) variant_NS -> topLevelItem(0) -> child(n) -> setCheckState(0, Qt::Unchecked) ; for(int n = 0; n < n_rows; ++n) if(skkp_selection_model -> isRowSelected(n, QModelIndex())) variant_NS -> topLevelItem(0) -> child(n) -> setCheckState(0, Qt::Checked) ;}
QItemSelectionModel* skkp_selection_model = variant_NS->selectionModel() ;int n_rows = model_skkp -> rowCount() ;skkp_view->clearSelection();for(int n = 0; n<n_rows; ++n) if(variant_NS -> topLevelItem(0) -> child(n)->checkState(0) == Qt::Checked) skkp_view->selectRow(n);