コード例 #1
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;
}
コード例 #2
0
void QgsEffectStackPropertiesWidget::moveEffectByOffset( int offset )
{
  EffectItem *item = currentEffectItem();
  if ( !item )
    return;

  int row = item->row();

  QStandardItem* root = mModel->invisibleRootItem();

  int layerIdx = root->rowCount() - row - 1;
  // switch effects
  QgsPaintEffect* tmpEffect = mStack->takeEffect( layerIdx );
  mStack->insertEffect( layerIdx - offset, tmpEffect );

  QList<QStandardItem *> toMove = root->takeRow( row );
  root->insertRows( row + offset, toMove );

  QModelIndex newIdx = toMove[ 0 ]->index();
  mEffectsList->setCurrentIndex( newIdx );

  updatePreview();
  updateUi();
}