//----------------------------------------------------------------------------- void ctkCollapsibleButtonPrivate::init() { CTK_P(ctkCollapsibleButton); p->setCheckable(true); // checked and Collapsed are synchronized: checked != Collapsed p->setChecked(true); this->Collapsed = false; this->ContentsFrameShape = QFrame::NoFrame; this->ContentsFrameShadow = QFrame::Plain; this->ContentsLineWidth = 1; this->ContentsMidLineWidth = 0; this->CollapsedHeight = 10; this->ExclusiveMouseOver = false; this->LookOffWhenChecked = true; // set as a prop ? this->MaximumHeight = p->maximumHeight(); p->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred, QSizePolicy::DefaultType)); p->setContentsMargins(0, p->buttonSizeHint().height(),0 , 0); QObject::connect(p, SIGNAL(toggled(bool)), p, SLOT(onToggled(bool))); }
//----------------------------------------------------------------------------- void ctkVTKScalarBarWidgetPrivate::init() { CTK_P(ctkVTKScalarBarWidget); this->setupUi(p); p->setEnabled(this->ScalarBarWidget != 0); QObject::connect(this->DisplayScalarBarCheckBox, SIGNAL(toggled(bool)), p, SLOT(setDisplay(bool))); QObject::connect(this->MaxNumberOfColorsSpinBox, SIGNAL(valueChanged(int)), p, SLOT(setMaxNumberOfColors(int))); QObject::connect(this->NumberOfLabelsSpinBox, SIGNAL(valueChanged(int)), p, SLOT(setNumberOfLabels(int))); QObject::connect(this->TitleTextPropertyWidget, SIGNAL(textChanged(const QString&)), p, SLOT(setTitle(const QString&))); QObject::connect(this->LabelsTextPropertyWidget, SIGNAL(textChanged(const QString&)), p, SLOT(setLabelsFormat(const QString&))); }
//----------------------------------------------------------------------------- void ctkMatrixWidgetPrivate::init() { CTK_P(ctkMatrixWidget); // Set Read-only p->setEditable(false); // Set parameters for the spinbox this->Minimum = -100; this->Maximum = 100; this->Decimals = 2; this->SingleStep = 0.01; // Hide headers p->verticalHeader()->hide(); p->horizontalHeader()->hide(); // Disable scrollBars p->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); p->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Don't expand for no reason p->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); // Disable the frame by default p->setFrameStyle(QFrame::NoFrame); // Register custom editors QItemEditorFactory *editorFactory = new QItemEditorFactory; editorFactory->registerEditor(QVariant::Double, new QStandardItemEditorCreator<CustomDoubleSpinBox>); QStyledItemDelegate* defaultItemDelegate = qobject_cast<QStyledItemDelegate*>(p->itemDelegate()); Q_ASSERT(defaultItemDelegate); defaultItemDelegate->setItemEditorFactory(editorFactory); // Define prototype item QTableWidgetItem* _item = new QTableWidgetItem(); _item->setData(Qt::DisplayRole, QVariant(0.0)); _item->setTextAlignment(Qt::AlignCenter); // The table takes ownership of the prototype. p->setItemPrototype(_item); // Initialize p->reset(); }
// -------------------------------------------------------------------------- void ctkMatrixWidgetPrivate::validateElements() { CTK_P(ctkMatrixWidget); for (int i=0; i < p->rowCount(); i++) { for (int j=0; j < p->columnCount(); j++) { double value = p->item(i, j)->data(Qt::DisplayRole).toDouble(); if (value < this->Minimum) { p->item(i,j)->setData(Qt::DisplayRole, QVariant(this->Minimum)); } if (value > this->Maximum) { p->item(i,j)->setData(Qt::DisplayRole, QVariant(this->Maximum)); } } } }
// ----------------------------------------------------------------------------- void ctkDynamicSpacerPrivate::init() { CTK_P(ctkDynamicSpacer); this->ActiveSizePolicy = p->sizePolicy(); this->InactiveSizePolicy = p->sizePolicy(); }