DocumentTextEditor::DocumentTextEditor(const QString &server, const QString &database, const QString &collection, const QString &json, bool readonly /* = false */, QWidget *parent) : QDialog(parent), _readonly(readonly) { setMinimumWidth(700); setMinimumHeight(550); Indicator *collectionIndicator = new Indicator(GuiRegistry::instance().collectionIcon(), collection); Indicator *databaseIndicator = new Indicator(GuiRegistry::instance().databaseIcon(), database); Indicator *serverIndicator = new Indicator(GuiRegistry::instance().serverIcon(), server); QPushButton *validate = new QPushButton("Validate"); validate->setIcon(qApp->style()->standardIcon(QStyle::SP_MessageBoxInformation)); VERIFY(connect(validate, SIGNAL(clicked()), this, SLOT(onValidateButtonClicked()))); _queryText = new FindFrame(this); _configureQueryText(); _queryText->sciScintilla()->setText(json); VERIFY(connect(_queryText->sciScintilla(), SIGNAL(textChanged()), this, SLOT(onQueryTextChanged()))); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(2, 0, 5, 1); hlayout->setSpacing(0); hlayout->addWidget(serverIndicator, 0, Qt::AlignLeft); hlayout->addWidget(databaseIndicator, 0, Qt::AlignLeft); hlayout->addWidget(collectionIndicator, 0, Qt::AlignLeft); hlayout->addStretch(1); QDialogButtonBox *buttonBox = new QDialogButtonBox (this); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); VERIFY(connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()))); VERIFY(connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()))); QHBoxLayout *bottomlayout = new QHBoxLayout(); bottomlayout->addWidget(validate); bottomlayout->addStretch(1); bottomlayout->addWidget(buttonBox); QVBoxLayout *layout = new QVBoxLayout(); // show top bar only if we have info for it if (!(server.isEmpty() && database.isEmpty() && collection.isEmpty())) layout->addLayout(hlayout); layout->addWidget(_queryText); layout->addLayout(bottomlayout); setLayout(layout); if (_readonly) buttonBox->button(QDialogButtonBox::Save)->hide(); }
ScriptWidget::ScriptWidget(MongoShell *shell) : _shell(shell), _textChanged(false), _disableTextAndCursorNotifications(false) { setStyleSheet("QFrame {background-color: rgb(255, 255, 255); border: 0px solid #c7c5c4; border-radius: 0px; margin: 0px; padding: 0px;}"); _queryText = new RoboScintilla; _topStatusBar = new TopStatusBar(shell); QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); layout->setContentsMargins(5, 1, 5, 5); layout->addWidget(_topStatusBar, 0, Qt::AlignTop); layout->addWidget(_queryText, 1, Qt::AlignTop); setLayout(layout); // Query text widget _textFont = chooseTextFont(); _configureQueryText(); _queryText->setFixedHeight(10); ui_queryLinesCountChanged(); _queryText->setFocus(); _queryText->installEventFilter(this); _completer = new QCompleter(this); _completer->setWidget(_queryText); _completer->setCompletionMode(QCompleter::PopupCompletion); _completer->setCaseSensitivity(Qt::CaseInsensitive); _completer->setMaxVisibleItems(20); _completer->setWrapAround(false); _completer->popup()->setFont(_textFont); connect(_completer, SIGNAL(activated(QString)), this, SLOT(onCompletionActivated(QString))); QStringListModel *model = new QStringListModel(_completer); _completer->setModel(model); }
DocumentTextEditor::DocumentTextEditor(const CollectionInfo &info, const QString &json, bool readonly /* = false */, QWidget *parent) : QDialog(parent), _info(info), _readonly(readonly) { QRect screenGeometry = QApplication::desktop()->availableGeometry(); int horizontalMargin = (int)(screenGeometry.width() * 0.35); int verticalMargin = (int)(screenGeometry.height() * 0.20); QSize size(screenGeometry.width() - horizontalMargin, screenGeometry.height() - verticalMargin); QSettings settings("3T", "Robomongo"); if (settings.contains("DocumentTextEditor/size")) { restoreWindowSettings(); } else { resize(size); } setWindowFlags(Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); Indicator *collectionIndicator = new Indicator(GuiRegistry::instance().collectionIcon(), QtUtils::toQString(_info._ns.collectionName())); Indicator *databaseIndicator = new Indicator(GuiRegistry::instance().databaseIcon(), QtUtils::toQString(_info._ns.databaseName())); Indicator *serverIndicator = new Indicator(GuiRegistry::instance().serverIcon(), QtUtils::toQString(detail::prepareServerAddress(_info._serverAddress))); QPushButton *validate = new QPushButton("Validate"); validate->setIcon(qApp->style()->standardIcon(QStyle::SP_MessageBoxInformation)); VERIFY(connect(validate, SIGNAL(clicked()), this, SLOT(onValidateButtonClicked()))); _queryText = new FindFrame(this); _configureQueryText(); _queryText->sciScintilla()->setText(json); // clear modification state after setting the content _queryText->sciScintilla()->setModified(false); VERIFY(connect(_queryText->sciScintilla(), SIGNAL(textChanged()), this, SLOT(onQueryTextChanged()))); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(2, 0, 5, 1); hlayout->setSpacing(0); hlayout->addWidget(serverIndicator, 0, Qt::AlignLeft); hlayout->addWidget(databaseIndicator, 0, Qt::AlignLeft); hlayout->addWidget(collectionIndicator, 0, Qt::AlignLeft); hlayout->addStretch(1); QDialogButtonBox *buttonBox = new QDialogButtonBox (this); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); VERIFY(connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()))); VERIFY(connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()))); QHBoxLayout *bottomlayout = new QHBoxLayout(); bottomlayout->addWidget(validate); bottomlayout->addStretch(1); bottomlayout->addWidget(buttonBox); QVBoxLayout *layout = new QVBoxLayout(); // show top bar only if we have info for it if (_info.isValid()) layout->addLayout(hlayout); layout->addWidget(_queryText); layout->addLayout(bottomlayout); setLayout(layout); if (_readonly) { validate->hide(); buttonBox->button(QDialogButtonBox::Save)->hide(); _queryText->sciScintilla()->setReadOnly(true); } }