MongoShell *App::openShell(MongoCollection *collection,const QString &filePathToSave) { ConnectionSettings *connection = collection->database()->server()->connectionRecord(); connection->setDefaultDatabase(collection->database()->name()); QString script = detail::buildCollectionQuery(collection->name(), "find({})"); return openShell(connection, ScriptInfo(script, true, CursorPosition(0, -2), QtUtils::toQString(collection->database()->name()),filePathToSave)); }
MongoShell *App::openShell(MongoDatabase *database, const QString &script, bool execute, const QString &shellName, const CursorPosition &cursorPosition,const QString &filePathToSave) { ConnectionSettings *connection = database->server()->connectionRecord(); connection->setDefaultDatabase(database->name()); return openShell(connection, ScriptInfo(script, execute, cursorPosition, shellName,filePathToSave)); }
MongoShell *App::openShell(MongoServer *server,const QString &script, const std::string &dbName, bool execute, const QString &shellName, const CursorPosition &cursorPosition,const QString &filePathToSave) { ConnectionSettings *connection = server->connectionRecord(); if (!dbName.empty()) connection->setDefaultDatabase(dbName); return openShell(connection, ScriptInfo(script, execute, cursorPosition, shellName,filePathToSave)); }
void MainWindow::open() { QueryWidget *wid = _workArea->currentQueryWidget(); if (wid) { wid->openFile(); } else { SettingsManager::ConnectionSettingsContainerType connections = AppRegistry::instance().settingsManager()->connections(); if (connections.size() == 1) { ScriptInfo inf = ScriptInfo(QString()); if (inf.loadFromFile()) { _app->openShell(connections.at(0), inf); } } } }
void ExplorerWidget::ui_itemDoubleClicked(QTreeWidgetItem *item, int column) { auto collectionItem = dynamic_cast<ExplorerCollectionTreeItem *>(item); if (collectionItem) { AppRegistry::instance().app()->openShell(collectionItem->collection()); return; } auto replicaMemberItem = dynamic_cast<ExplorerReplicaSetTreeItem*>(item); if (replicaMemberItem && replicaMemberItem->isUp()) { AppRegistry::instance().app()->openShell(replicaMemberItem->server(), replicaMemberItem->connectionSettings(), ScriptInfo("", true)); return; } // Toggle expanded state item->setExpanded(!item->isExpanded()); }