예제 #1
0
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);
    headerView->setClickable(previousHeaderView->isClickable());
    headerView->setMovable(previousHeaderView->isMovable());
    headerView->setHighlightSections(previousHeaderView->highlightSections());
    headerView->setPropagateToItems(true);
    viewer.setHeader(headerView);
    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;
    }
}
//-----------------------------------------------------------------------------
int ctkCheckableHeaderViewTest2(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QStringList headers;
  headers << "Title 1" << "Title 2" << "Title 3";
  QStandardItemModel model;
  model.setHorizontalHeaderLabels(headers);
  QList<QStandardItem*> row0;
  row0 << new QStandardItem << new QStandardItem << new QStandardItem;
  row0[0]->setText("not user checkable");
  model.appendRow(row0);
  QList<QStandardItem*> row1;
  row1 << new QStandardItem << new QStandardItem << new QStandardItem;
  row1[0]->setCheckable(true);
  row1[0]->setText("checkable1");
  model.appendRow(row1);
  QList<QStandardItem*> row2;
  row2 << new QStandardItem << new QStandardItem << new QStandardItem;
  row2[0]->setCheckable(true);
  row2[0]->setText("checkable2");
  model.appendRow(row2);

  QTreeView view;
  view.setModel(&model);

  model.setHeaderData(0, Qt::Horizontal, Qt::Checked, Qt::CheckStateRole);

  QHeaderView* previousHeaderView = view.header();
  bool oldClickable = previousHeaderView->isClickable();

  ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, &view);  
  headerView->setClickable(oldClickable);
  headerView->setMovable(previousHeaderView->isMovable());
  headerView->setHighlightSections(previousHeaderView->highlightSections());
  headerView->checkableModelHelper()->setPropagateDepth(-1);
  headerView->checkableModelHelper()->setForceCheckability(true);

  // sets the model to the headerview
  view.setHeader(headerView);
  headers << "4";
  model.setHorizontalHeaderLabels(headers);
  view.show();

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(500, &app, SLOT(quit()));
    }
  
  return app.exec();
}
예제 #3
0
//----------------------------------------------------------------------------
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()));
}
예제 #4
0
//-----------------------------------------------------------------------------
int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

#if 0
    QFileSystemModel model;
    model.setRootPath(QDir::currentPath());
#else
    QStandardItemModel model;
    QStandardItem item;
    item.insertColumns(0, 5);
    item.insertRows(0, 7);
    model.insertRow(0, &item);
#endif

  QTableView table;
  table.setModel(&model);


  model.setHeaderData(0, Qt::Horizontal, Qt::Checked, Qt::CheckStateRole);
  QHeaderView* previousHeaderView = table.horizontalHeader();
  ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, &table);
  qDebug() << previousHeaderView->isClickable();
  headerView->setClickable(previousHeaderView->isClickable());
  headerView->setMovable(previousHeaderView->isMovable());
  headerView->setHighlightSections(previousHeaderView->highlightSections());
  headerView->setPropagateToItems(true);

  table.setHorizontalHeader(headerView);
  qDebug() << headerView->isCheckable(0);

  table.show();
  table.raise();

  //app.exec();

  return EXIT_SUCCESS;
}
예제 #5
0
//----------------------------------------------------------------------------
ctkDICOMServerNodeWidget::ctkDICOMServerNodeWidget(QWidget* _parent):Superclass(_parent),
  d_ptr(new ctkDICOMServerNodeWidgetPrivate)
{
  Q_D(ctkDICOMServerNodeWidget);
 
  d->setupUi(this);

  // checkable headers.
  d->nodeTable->model()->setHeaderData(0, Qt::Horizontal, Qt::Unchecked, Qt::CheckStateRole);
  QHeaderView* previousHeaderView = d->nodeTable->horizontalHeader();
  ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, d->nodeTable);
  headerView->setClickable(previousHeaderView->isClickable());
  headerView->setMovable(previousHeaderView->isMovable());
  headerView->setHighlightSections(previousHeaderView->highlightSections());
  headerView->setPropagateToItems(true);
  d->nodeTable->setHorizontalHeader(headerView);

  d->removeButton->setEnabled(false);


  QSettings settings;

  QMap<QString, QVariant> node;
  if ( settings.value("ServerNodeCount").toInt() == 0 )
  {
    node["Name"] = "Local Database";
    node["CheckState"] = Qt::Checked;
    node["AETitle"] = "N/A";
    node["Address"] = "N/A";
    node["Port"] = "N/A";
    settings.setValue("ServerNodeCount", 2);
    settings.setValue("ServerNodes/0", QVariant(node));
    node["Name"] = "ExampleHost";
    node["CheckState"] = Qt::Unchecked;
    node["AETitle"] = "CTK_AE";
    node["Address"] = "localhost";
    node["Port"] = "11112";
    settings.setValue("ServerNodes/1", QVariant(node));
    settings.sync();
  }

  int count = settings.value("ServerNodeCount").toInt();
  d->nodeTable->setRowCount(count);
  for (int row = 0; row < count; row++)
  {
    node = settings.value(QString("ServerNodes/%1").arg(row)).toMap();
    QTableWidgetItem *newItem;
    newItem = new QTableWidgetItem( node["Name"].toString() );
    newItem->setCheckState( Qt::CheckState(node["CheckState"].toInt()) );
    d->nodeTable->setItem(row, 0, newItem);
    newItem = new QTableWidgetItem( node["AETitle"].toString() );
    d->nodeTable->setItem(row, 1, newItem);
    newItem = new QTableWidgetItem( node["Address"].toString() );
    d->nodeTable->setItem(row, 2, newItem);
    newItem = new QTableWidgetItem( node["Port"].toString() );
    d->nodeTable->setItem(row, 3, newItem);
  }

  connect(d->addButton
    ,SIGNAL(clicked()),
    this,
    SLOT(addNode()));
  connect(d->removeButton
    ,SIGNAL(clicked()),
    this,
    SLOT(removeNode()));
  connect(d->nodeTable,
    SIGNAL(cellChanged(int,int)),
    this,
    SLOT(onCellChanged(int,int)));
  connect(d->nodeTable,
    SIGNAL(currentItemChanged(QTableWidgetItem*, QTableWidgetItem*)),
    this,
    SLOT(onCurrentItemChanged(QTableWidgetItem*, QTableWidgetItem*)));
}
예제 #6
0
int HeaderView::isMovable(lua_State * L) // const : bool
{
    QHeaderView* obj = QtObject<QHeaderView>::check( L, 1);
	Util::push( L, obj->isMovable() );
	return 1;
}