fastonosql::serverTypes convertFromString(const std::string& text) { for (size_t i = 0; i < SIZEOFMASS(serverTypes); ++i) { if (text == serverTypes[i]) { return static_cast<fastonosql::serverTypes>(i); } } return fastonosql::MASTER; }
fastonosql::connectionTypes convertFromString(const std::string& text) { for (size_t i = 0; i < SIZEOFMASS(fastonosql::connnectionType); ++i) { if (text == fastonosql::connnectionType[i]) { return static_cast<fastonosql::connectionTypes>(i); } } return fastonosql::DBUNKNOWN; }
fastonosql::supportedViews ConvertFromString(const std::string& from) { for(size_t i = 0; i < SIZEOFMASS(fastonosql::viewsText); ++i){ if(from == fastonosql::viewsText[i]){ return static_cast<fastonosql::supportedViews>(i); } } return fastonosql::Tree; }
void LeveldbLexer::paintCommands(const QString& source, int start) { for(int i = 0; i < SIZEOFMASS(leveldbCommandsKeywords); ++i){ QString word = leveldbCommandsKeywords[i]; int index = 0; int begin = 0; while( (begin = source.indexOf(word, index, Qt::CaseInsensitive)) != -1){ index = begin + word.length(); startStyling(start + begin); setStyling(word.length(), Command); startStyling(start + begin); } } }
QStringList LmdbApi::callTips(const QStringList& context, int commas, QsciScintilla::CallTipsStyle style, QList<int>& shifts) { for(QStringList::const_iterator it = context.begin(); it != context.end() - 1; ++it){ QString val = *it; for(int i = 0; i < SIZEOFMASS(lmdbCommands); ++i){ CommandInfo cmd = lmdbCommands[i]; QString jval = common::convertFromString<QString>(cmd.name_); if(QString::compare(jval, val, Qt::CaseInsensitive) == 0){ return QStringList() << makeCallTip(cmd); } } } return QStringList(); }
void LmdbLexer::paintCommands(const QString& source, int start) { for(int i = 0; i < SIZEOFMASS(lmdbCommands); ++i){ CommandInfo cmd = lmdbCommands[i]; QString word = common::convertFromString<QString>(cmd.name_); int index = 0; int begin = 0; while( (begin = source.indexOf(word, index, Qt::CaseInsensitive)) != -1){ index = begin + word.length(); startStyling(start + begin); setStyling(word.length(), Command); startStyling(start + begin); } } }
void LeveldbApi::updateAutoCompletionList(const QStringList& context, QStringList& list) { for(QStringList::const_iterator it = context.begin(); it != context.end(); ++it){ QString val = *it; for(int i = 0; i < SIZEOFMASS(leveldbCommandsKeywords); ++i){ QString jval = leveldbCommandsKeywords[i]; if(jval.startsWith(val, Qt::CaseInsensitive) || (val == ALL_COMMANDS && context.size() == 1) ){ list.append(jval + "?1"); } } if(help.startsWith(val, Qt::CaseInsensitive) || (val == ALL_COMMANDS && context.size() == 1) ){ list.append(help + "?2"); } } }
EncodeDecodeDialog::EncodeDecodeDialog(QWidget* parent) : QDialog(parent) { setWindowIcon(GuiFactory::instance().encodeDecodeIcon()); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Remove help // button (?) QVBoxLayout* layout = new QVBoxLayout; QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); QPushButton* closeButton = buttonBox->button(QDialogButtonBox::Close); buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole)); VERIFY(connect(buttonBox, &QDialogButtonBox::rejected, this, &EncodeDecodeDialog::reject)); QToolButton* decode = new QToolButton; decode->setIcon(GuiFactory::instance().executeIcon()); VERIFY(connect(decode, &QToolButton::clicked, this, &EncodeDecodeDialog::decodeOrEncode)); decoders_ = new QComboBox; for (size_t i = 0; i < SIZEOFMASS(common::EDecoderTypes); ++i) { std::string estr = common::EDecoderTypes[i]; common::EDTypes etype = common::ConvertFromString<common::EDTypes>(estr); decoders_->addItem(common::ConvertFromString<QString>(estr), etype); } QHBoxLayout* toolBarLayout = new QHBoxLayout; toolBarLayout->addWidget(decode); toolBarLayout->addWidget(decoders_); encodeButton_ = new QRadioButton; decodeButton_ = new QRadioButton; toolBarLayout->addWidget(encodeButton_); toolBarLayout->addWidget(decodeButton_); toolBarLayout->addWidget(new QSplitter(Qt::Horizontal)); input_ = new FastoEditor; output_ = new FastoEditor; layout->addWidget(input_); layout->addLayout(toolBarLayout); layout->addWidget(output_); layout->addWidget(buttonBox); setMinimumSize(QSize(min_width, min_height)); setLayout(layout); retranslateUi(); }
void LmdbApi::updateAutoCompletionList(const QStringList& context, QStringList& list) { for(QStringList::const_iterator it = context.begin(); it != context.end(); ++it){ QString val = *it; for(int i = 0; i < SIZEOFMASS(lmdbCommands); ++i){ CommandInfo cmd = lmdbCommands[i]; if(canSkipCommand(cmd)){ continue; } QString jval = common::convertFromString<QString>(cmd.name_); if(jval.startsWith(val, Qt::CaseInsensitive)){ list.append(jval + "?1"); } } if(help.startsWith(val, Qt::CaseInsensitive)){ list.append(help + "?2"); } } }
std::vector<uint32_t> LmdbLexer::supportedVersions() const { std::vector<uint32_t> result; for(int i = 0; i < SIZEOFMASS(lmdbCommands); ++i){ CommandInfo cmd = lmdbCommands[i]; bool needed_insert = true; for(int j = 0; j < result.size(); ++j){ if(result[j] == cmd.since_){ needed_insert = false; break; } } if(needed_insert){ result.push_back(cmd.since_); } } std::sort(result.begin(), result.end()); return result; }
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(); }
uint32_t LmdbLexer::commandsCount() const { return SIZEOFMASS(lmdbCommands); }
uint32_t RocksdbLexer::commandsCount() const { return SIZEOFMASS(rocksdbCommands); }
uint32_t UnqliteLexer::commandsCount() const { return SIZEOFMASS(unqliteCommands); }
PreferencesDialog::PreferencesDialog(QWidget* parent) : QDialog(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // ui settings generalBox_ = new QGroupBox; QHBoxLayout *styleswLayout = new QHBoxLayout; stylesLabel_ = new QLabel; stylesComboBox_ = new QComboBox; stylesComboBox_->addItems(fasto::qt::gui::getSupportedStyles()); styleswLayout->addWidget(stylesLabel_); styleswLayout->addWidget(stylesComboBox_); QHBoxLayout *langLayout = new QHBoxLayout; langLabel_ = new QLabel; langLayout->addWidget(langLabel_); languagesComboBox_ = new QComboBox; languagesComboBox_->addItems(fasto::qt::translations::supportedLanguages()); langLayout->addWidget(languagesComboBox_); QVBoxLayout *generalLayout = new QVBoxLayout; autoCheckUpdates_ = new QCheckBox; generalLayout->addWidget(autoCheckUpdates_); autoComletionEnable_ = new QCheckBox; generalLayout->addWidget(autoComletionEnable_); autoOpneConsole_ = new QCheckBox; generalLayout->addWidget(autoOpneConsole_); generalLayout->addLayout(styleswLayout); generalLayout->addLayout(langLayout); generalBox_->setLayout(generalLayout); // servers settings serverSettingsBox_ = new QGroupBox; QHBoxLayout* defaultViewLayaut = new QHBoxLayout; defaultViewLabel_ = new QLabel; defaultViewComboBox_ = new QComboBox; for(int i = 0; i < SIZEOFMASS(viewsText); ++i){ defaultViewComboBox_->addItem(common::convertFromString<QString>(viewsText[i])); } defaultViewLayaut->addWidget(defaultViewLabel_); defaultViewLayaut->addWidget(defaultViewComboBox_); syncTabs_ = new QCheckBox; logDirPath_ = new QLineEdit; QHBoxLayout *logLayout = new QHBoxLayout; logDirLabel_ = new QLabel; logLayout->addWidget(logDirLabel_); logLayout->addWidget(logDirPath_); QVBoxLayout *serverSettingsLayout = new QVBoxLayout; serverSettingsLayout->addLayout(defaultViewLayaut); serverSettingsLayout->addWidget(syncTabs_); serverSettingsLayout->addLayout(logLayout); serverSettingsBox_->setLayout(serverSettingsLayout); // main layout QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(generalBox_); layout->addWidget(serverSettingsBox_); QDialogButtonBox *buttonBox = new QDialogButtonBox; buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); VERIFY(connect(buttonBox, &QDialogButtonBox::accepted, this, &PreferencesDialog::accept)); VERIFY(connect(buttonBox, &QDialogButtonBox::rejected, this, &PreferencesDialog::reject)); layout->addWidget(buttonBox); setMinimumSize(QSize(min_width, min_height)); setLayout(layout); syncWithSettings(); retranslateUi(); }