QuickAddCapacitorDialog::QuickAddCapacitorDialog(ModelsRepository *modelsProvider, QWidget *parent) : QDialog(parent), ui(new Ui::QuickAddCapacitorDialog), _partsModel(modelsProvider->partsModel()) { ui->setupUi(this); ui->messageWidget->hide(); _saveButtonHelper = new SaveButtonHelper(this); QSettings settings; _capacitorNameTemplate = settings.value("capacitor_template", tr("Capacitor %1 %2 (%3)")).toString(); _capacitanceParam = PartParameterTableModel::findParameter("capacitance"); _voltageRatingParam = PartParameterTableModel::findParameter("voltage_rating_dc"); _toleranceParam = PartParameterTableModel::findParameter("capacitance_tolerance"); _partParams = new PartParameterTableModel(this); _partStockLogModel = PartStockLogTableModel::createNew(this); _partStockModel = PartStockTableModel2::createNew(this); //XXX: Disabled the validator to allow "auto complete" (ctrl+space) to work //ui->capacitanceValueLineEdit->setValidator(new ParameterValueValidator(_capacitanceParam.unitSymbol(), this)); QShortcut *sc = new QShortcut(QKeySequence("Ctrl+Space"), this); connect(sc, SIGNAL(activated()), this, SLOT(slotAttemptAutoComplete())); //ui->capacitanceValueLineEdit->installEventFilter(this); ui->voltageRatingLineEdit->setValidator(new ParameterValueValidator(_voltageRatingParam.unitSymbol(), this)); ui->partCategoryComboBox->setModel(modelsProvider->partCategoryModel()); ui->partCategoryComboBox->setMinimumContentsLength(22); ui->partCategoryComboBox->setMaxVisibleItems(20); ui->partStorageComboBox->setModel(modelsProvider->partStorageModel()); ui->partStorageComboBox->setMinimumContentsLength(22); ui->partStorageComboBox->setMaxVisibleItems(20); ui->partConditionComboBox->setModel(modelsProvider->partConditionModel()); ui->partConditionComboBox->setModelKeyColumn(PartConditionModel::ColumnId); ui->partConditionComboBox->setModelColumn(PartConditionModel::ColumnValue); int defaultConditionRow = modelsProvider->partConditionModel()->findDefaultValueRow(); ui->partConditionComboBox->setCurrentIndex(defaultConditionRow); ui->partPackageComboBox->setModel(modelsProvider->packageModel()); ui->partPackageComboBox->setModelKeyColumn(PackageTableModel::ColumnId); ui->partPackageComboBox->setModelColumn(PackageTableModel::ColumnName); QPushButton * resetButton = ui->buttonBox->button(QDialogButtonBox::Reset); connect(resetButton, SIGNAL(clicked(bool)), this, SLOT(slotReset())); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(slotAddCapacitor())); connect(ui->messageWidget, SIGNAL(hideAnimationFinished()), ui->messageWidget, SLOT(hide())); _saveButtonHelper->monitor(ui->capacitanceValueLineEdit); _saveButtonHelper->monitor(ui->voltageRatingLineEdit); _saveButtonHelper->monitor(ui->toleranceLineEdit); _saveButtonHelper->monitor(ui->partCategoryComboBox); _saveButtonHelper->monitor(ui->partPackageComboBox); _saveButtonHelper->monitor(ui->partStorageComboBox); _saveButtonHelper->monitor(ui->partConditionComboBox); _saveButtonHelper->monitor(ui->quantitySpinBox); _saveButtonHelper->setButtonBox(ui->buttonBox, QDialogButtonBox::Save); }
void DNotificationWidget::animatedHide() { if (!style()->styleHint(QStyle::SH_Widget_Animate, 0, this)) { hide(); emit hideAnimationFinished(); return; } if (!isVisible()) { return; } d->content->move(0, -d->content->height()); d->updateSnapShot(); d->timeLine->setDirection(QTimeLine::Backward); if (d->timeLine->state() == QTimeLine::NotRunning) { d->timeLine->start(); } }