void BarcodeGenerator::updateUIFromOptionsText() { ui.includetextCheck->blockSignals(true); ui.includetextCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bincludetext\\b"))); ui.includetextCheck->blockSignals(false); ui.guardwhitespaceCheck->blockSignals(true); ui.guardwhitespaceCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bguardwhitespace\\b"))); ui.guardwhitespaceCheck->blockSignals(false); ui.includecheckCheck->blockSignals(true); ui.includecheckCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bincludecheck\\b"))); ui.includecheckCheck->blockSignals(false); ui.includecheckintextCheck->blockSignals(true); ui.includecheckintextCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bincludecheckintext\\b"))); ui.includecheckintextCheck->blockSignals(false); ui.parseCheck->blockSignals(true); ui.parseCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bparse\\b"))); ui.parseCheck->blockSignals(false); ui.parsefncCheck->blockSignals(true); ui.parsefncCheck->setChecked(ui.optionsEdit->text().contains(QRegExp("\\bparsefnc\\b"))); ui.parsefncCheck->blockSignals(false); QString enc=map[ui.bcCombo->currentText()].command; QString vlbl=resvlbl[enc]!="" ? resvlbl[enc].toLower() : "version"; QRegExp rxf("\\b"+QRegExp::escape(vlbl)+"=(\\S*)\\b"); ui.formatCombo->blockSignals(true); if (ui.optionsEdit->text().contains(rxf)) { int idx=ui.formatCombo->findText(rxf.cap(1)); if (idx == -1) idx=0; ui.formatCombo->setCurrentIndex(idx); } else { ui.formatCombo->setCurrentIndex(0); } ui.formatCombo->blockSignals(false); QRegExp rxe("\\beclevel=(\\S*)\\b"); ui.eccCombo->blockSignals(true); if (ui.optionsEdit->text().contains(rxe)) { int idx=ui.eccCombo->findText(rxe.cap(1)); if (idx == -1) idx=0; ui.eccCombo->setCurrentIndex(idx); } else { ui.eccCombo->setCurrentIndex(0); } ui.eccCombo->blockSignals(false); }
ClusterDialog::ClusterDialog(QWidget* parent, core::IClusterSettingsBase* connection) : QDialog(parent), cluster_connection_(connection) { setWindowIcon(GuiFactory::instance().serverIcon()); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Remove help // button (?) connectionName_ = new QLineEdit; connectionFolder_ = new QLineEdit; QRegExp rxf("^/[A-z0-9]+/$"); connectionFolder_->setValidator(new QRegExpValidator(rxf, this)); folderLabel_ = new QLabel; QHBoxLayout* folderLayout = new QHBoxLayout; folderLayout->addWidget(folderLabel_); folderLayout->addWidget(connectionFolder_); QString conFolder = defaultNameConnectionFolder; QString conName = defaultNameConnection; if (cluster_connection_) { core::connection_path_t path = cluster_connection_->Path(); conName = common::ConvertFromString<QString>(path.Name()); conFolder = common::ConvertFromString<QString>(path.Directory()); } connectionName_->setText(conName); connectionFolder_->setText(conFolder); typeConnection_ = new QComboBox; for (size_t i = 0; i < SIZEOFMASS(core::compiled_types); ++i) { core::connectionTypes ct = core::compiled_types[i]; std::string str = common::ConvertToString(ct); typeConnection_->addItem(GuiFactory::instance().icon(ct), common::ConvertFromString<QString>(str), ct); } if (cluster_connection_) { typeConnection_->setCurrentIndex(cluster_connection_->Type()); } typedef void (QComboBox::*qind)(int); VERIFY(connect(typeConnection_, static_cast<qind>(&QComboBox::currentIndexChanged), this, &ClusterDialog::typeConnectionChange)); QHBoxLayout* loggingLayout = new QHBoxLayout; logging_ = new QCheckBox; loggingMsec_ = new QSpinBox; loggingMsec_->setRange(0, INT32_MAX); loggingMsec_->setSingleStep(1000); if (cluster_connection_) { logging_->setChecked(cluster_connection_->IsLoggingEnabled()); loggingMsec_->setValue(cluster_connection_->LoggingMsTimeInterval()); } else { logging_->setChecked(false); } VERIFY(connect(logging_, &QCheckBox::stateChanged, this, &ClusterDialog::loggingStateChange)); loggingLayout->addWidget(logging_); loggingLayout->addWidget(loggingMsec_); listWidget_ = new QTreeWidget; listWidget_->setIndentation(5); QStringList colums; colums << translations::trName << translations::trAddress; listWidget_->setHeaderLabels(colums); listWidget_->setIndentation(15); listWidget_->setSelectionMode(QAbstractItemView::SingleSelection); // single item // can be draged // or // droped listWidget_->setSelectionBehavior(QAbstractItemView::SelectRows); listWidget_->setContextMenuPolicy(Qt::CustomContextMenu); VERIFY(connect(listWidget_, &QTreeWidget::customContextMenuRequested, this, &ClusterDialog::showContextMenu)); setDefault_ = new QAction(this); VERIFY(connect(setDefault_, &QAction::triggered, this, &ClusterDialog::setStartNode)); if (cluster_connection_) { auto nodes = cluster_connection_->Nodes(); for (const auto& node : nodes) { addConnection(node); } } VERIFY(connect(listWidget_, &QTreeWidget::itemSelectionChanged, this, &ClusterDialog::itemSelectionChanged)); QHBoxLayout* toolBarLayout = new QHBoxLayout; savebar_ = new QToolBar; toolBarLayout->addWidget(savebar_); QAction* addB = new QAction(GuiFactory::instance().loadIcon(), translations::trAddConnection, savebar_); typedef void (QAction::*trig)(bool); VERIFY(connect(addB, static_cast<trig>(&QAction::triggered), this, &ClusterDialog::add)); savebar_->addAction(addB); QAction* rmB = new QAction(GuiFactory::instance().removeIcon(), translations::trRemoveConnection, savebar_); VERIFY(connect(rmB, static_cast<trig>(&QAction::triggered), this, &ClusterDialog::remove)); savebar_->addAction(rmB); QAction* editB = new QAction(GuiFactory::instance().editIcon(), translations::trEditConnection, savebar_); VERIFY(connect(editB, static_cast<trig>(&QAction::triggered), this, &ClusterDialog::edit)); savebar_->addAction(editB); QSpacerItem* hSpacer = new QSpacerItem(300, 0, QSizePolicy::Expanding); toolBarLayout->addSpacerItem(hSpacer); QVBoxLayout* inputLayout = new QVBoxLayout; inputLayout->addWidget(connectionName_); inputLayout->addLayout(folderLayout); inputLayout->addWidget(typeConnection_); inputLayout->addLayout(loggingLayout); inputLayout->addLayout(toolBarLayout); inputLayout->addWidget(listWidget_); testButton_ = new QPushButton("&Test"); testButton_->setIcon(GuiFactory::instance().messageBoxInformationIcon()); VERIFY(connect(testButton_, &QPushButton::clicked, this, &ClusterDialog::testConnection)); testButton_->setEnabled(false); discoveryButton_ = new QPushButton("&Discovery"); discoveryButton_->setIcon(GuiFactory::instance().discoveryIcon()); VERIFY(connect(discoveryButton_, &QPushButton::clicked, this, &ClusterDialog::discoveryCluster)); discoveryButton_->setEnabled(false); QHBoxLayout* bottomLayout = new QHBoxLayout; bottomLayout->addWidget(testButton_, 0, Qt::AlignLeft); bottomLayout->addWidget(discoveryButton_, 0, Qt::AlignLeft); buttonBox_ = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save); buttonBox_->setOrientation(Qt::Horizontal); VERIFY(connect(buttonBox_, &QDialogButtonBox::accepted, this, &ClusterDialog::accept)); VERIFY(connect(buttonBox_, &QDialogButtonBox::rejected, this, &ClusterDialog::reject)); bottomLayout->addWidget(buttonBox_); QVBoxLayout* mainLayout = new QVBoxLayout; mainLayout->addLayout(inputLayout); mainLayout->addLayout(bottomLayout); mainLayout->setSizeConstraint(QLayout::SetFixedSize); setLayout(mainLayout); // update controls typeConnectionChange(typeConnection_->currentIndex()); loggingStateChange(logging_->checkState()); retranslateUi(); }
ConnectionBaseWidget::ConnectionBaseWidget(QWidget* parent) : QWidget(parent) { connectionName_ = new QLineEdit; QVBoxLayout* basicLayout = new QVBoxLayout; QHBoxLayout* connectionNameLayout = new QHBoxLayout; connectionNameLabel_ = new QLabel; connectionNameLayout->addWidget(connectionNameLabel_); connectionNameLayout->addWidget(connectionName_); basicLayout->addLayout(connectionNameLayout); QHBoxLayout* namespaceDelimiterLayout = new QHBoxLayout; QHBoxLayout* namespaceSeparatorLayout = new QHBoxLayout; namespaceSeparatorLabel_ = new QLabel; namespaceSeparator_ = new QComboBox; namespaceSeparator_->addItems(separators); namespaceSeparatorLayout->addWidget(namespaceSeparatorLabel_); namespaceSeparatorLayout->addWidget(namespaceSeparator_); namespaceDelimiterLayout->addLayout(namespaceSeparatorLayout); QHBoxLayout* delimiterLayout = new QHBoxLayout; delimiterLabel_ = new QLabel; delimiter_ = new QComboBox; delimiter_->addItems(delimiters); delimiterLayout->addWidget(delimiterLabel_); delimiterLayout->addWidget(delimiter_); namespaceDelimiterLayout->addLayout(delimiterLayout); basicLayout->addLayout(namespaceDelimiterLayout); connectionFolder_ = new QLineEdit; QRegExp rxf("^/[A-z0-9]+/$"); connectionFolder_->setValidator(new QRegExpValidator(rxf, this)); folderLabel_ = new QLabel; QHBoxLayout* folderLayout = new QHBoxLayout; folderLayout->addWidget(folderLabel_); folderLayout->addWidget(connectionFolder_); QHBoxLayout* loggingLayout = new QHBoxLayout; logging_ = new QCheckBox; loggingMsec_ = new QSpinBox; loggingMsec_->setRange(0, INT32_MAX); loggingMsec_->setSingleStep(1000); VERIFY( connect(logging_, &QCheckBox::stateChanged, this, &ConnectionBaseWidget::loggingStateChange)); loggingMsec_->setEnabled(false); loggingLayout->addWidget(logging_); QHBoxLayout* loggingVLayout = new QHBoxLayout; loggingVLayout->addWidget(new QLabel(QObject::tr("msec:"))); loggingVLayout->addWidget(loggingMsec_); loggingLayout->addWidget(new QSplitter(Qt::Horizontal)); loggingLayout->addLayout(loggingVLayout); basicLayout->addLayout(folderLayout); basicLayout->addLayout(loggingLayout); setLayout(basicLayout); }