//---------------------------------------------------------------------------- ctkDICOMServerNodeWidget::ctkDICOMServerNodeWidget(QWidget* parentWidget) : Superclass(parentWidget) , d_ptr(new ctkDICOMServerNodeWidgetPrivate) { Q_D(ctkDICOMServerNodeWidget); d->setupUi(this); // checkable headers. d->NodeTable->model()->setHeaderData( NameColumn, Qt::Horizontal, static_cast<int>(Qt::Unchecked), Qt::CheckStateRole); QHeaderView* previousHeaderView = d->NodeTable->horizontalHeader(); ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, d->NodeTable); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) headerView->setSectionsClickable(previousHeaderView->sectionsClickable()); headerView->setSectionsMovable(previousHeaderView->sectionsMovable()); #else headerView->setClickable(previousHeaderView->isClickable()); headerView->setMovable(previousHeaderView->isMovable()); #endif headerView->setHighlightSections(previousHeaderView->highlightSections()); headerView->checkableModelHelper()->setPropagateDepth(-1); d->NodeTable->setHorizontalHeader(headerView); d->RemoveButton->setEnabled(false); this->readSettings(); connect(d->CallingAETitle, SIGNAL(textChanged(QString)), this, SLOT(saveSettings())); connect(d->StorageAETitle, SIGNAL(textChanged(QString)), this, SLOT(saveSettings())); connect(d->StoragePort, SIGNAL(textChanged(QString)), this, SLOT(saveSettings())); connect(d->AddButton, SIGNAL(clicked()), this, SLOT(addServerNode())); connect(d->RemoveButton, SIGNAL(clicked()), this, SLOT(removeCurrentServerNode())); connect(d->NodeTable, SIGNAL(cellChanged(int,int)), this, SLOT(saveSettings())); connect(d->NodeTable, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), this, SLOT(updateRemoveButtonEnableState())); }
int ctkDICOMModelTest2( int argc, char * argv [] ) { QApplication app(argc, argv); if (argc <= 2) { std::cerr << "Warning, no sql file given. Test stops" << std::endl; std::cerr << "Usage: qctkDICOMModelTest1 <scratch.db> <dumpfile.sql>" << std::endl; return EXIT_FAILURE; } try { ctkDICOMDatabase myCTK( argv[1] ); if (!myCTK.initializeDatabase(argv[2])) { std::cerr << "Error when initializing the data base: " << argv[2] << " error: " << myCTK.lastError().toStdString(); } ctkDICOMModel model; model.setDatabase(myCTK.database()); QWidget topLevel; QTreeView viewer; QHBoxLayout* layout = new QHBoxLayout; layout->addWidget(&viewer); topLevel.setLayout(layout); viewer.setModel(&model); QHeaderView* previousHeaderView = viewer.header(); qDebug() << "previous: " << previousHeaderView->isHidden(); ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, &viewer); #if QT_VERSION < QT_VERSION_CHECK(5,0,0) headerView->setClickable(previousHeaderView->isClickable()); headerView->setMovable(previousHeaderView->isMovable()); #else headerView->setSectionsClickable(previousHeaderView->sectionsClickable()); headerView->setSectionsMovable(previousHeaderView->sectionsMovable()); #endif headerView->setHighlightSections(previousHeaderView->highlightSections()); headerView->checkableModelHelper()->setPropagateDepth(-1); headerView->checkableModelHelper()->setForceCheckability(true); viewer.setHeader(headerView); model.setHeaderData(0, Qt::Horizontal, Qt::Checked, Qt::CheckStateRole); qDebug() << "new: " << headerView->isHidden(); topLevel.show(); if (argc <= 3 || QString(argv[3]) != "-I") { QTimer::singleShot(200, &app, SLOT(quit())); } return app.exec(); } catch (std::exception e) { std::cerr << "Error when opening the data base file: " << argv[1] << " error: " << e.what(); return EXIT_FAILURE; } }