void ExplorerCollectionDirIndexesTreeItem::ui_viewIndex() { ExplorerCollectionTreeItem *par = dynamic_cast<ExplorerCollectionTreeItem *>(parent()); if (par) { par->openCurrentCollectionShell("getIndexes()"); } }
void ExplorerWidget::ui_itemDoubleClicked(QTreeWidgetItem *item, int column) { ExplorerCollectionTreeItem *collectionItem = dynamic_cast<ExplorerCollectionTreeItem *>(item); if (collectionItem) { AppRegistry::instance().app()->openShell(collectionItem->collection()); } }
void ExplorerCollectionDirIndexesTreeItem::ui_refreshIndex() { ExplorerCollectionTreeItem *par = dynamic_cast<ExplorerCollectionTreeItem *>(parent()); if (par) { par->expand(); } }
void ExplorerCollectionDirIndexesTreeItem::ui_dropIndex() { ExplorerCollectionTreeItem *par = dynamic_cast<ExplorerCollectionTreeItem *>(parent()); if (par) { par->openCurrentCollectionShell("dropIndex({ \"<field>\" : 1 });", false); } }
void ExplorerTreeWidget::ui_renameCollection() { ExplorerCollectionTreeItem *collectionItem = selectedCollectionItem(); if (!collectionItem) return; MongoCollection *collection = collectionItem->collection(); MongoDatabase *database = collection->database(); MongoServer *server = database->server(); ConnectionSettings *settings = server->connectionRecord(); CreateDatabaseDialog dlg(settings->getFullAddress(), database->name(), collection->name()); dlg.setWindowTitle("Rename Collection"); dlg.setOkButtonText("&Rename"); dlg.setInputLabelText("New Collection Name:"); dlg.setInputText(collection->name()); int result = dlg.exec(); if (result == QDialog::Accepted) { database->renameCollection(collection->name(), dlg.databaseName()); // refresh list of collections database->loadCollections(); } }
void ExplorerCollectionDirIndexesTreeItem::ui_reIndex() { ExplorerCollectionTreeItem *par = dynamic_cast<ExplorerCollectionTreeItem *>(parent()); if (par) { par->openCurrentCollectionShell("reIndex()", false); } }
void ExplorerTreeWidget::ui_dropCollection() { ExplorerCollectionTreeItem *collectionItem = selectedCollectionItem(); if (!collectionItem) return; MongoCollection *collection = collectionItem->collection(); MongoDatabase *database = collection->database(); MongoServer *server = database->server(); ConnectionSettings *settings = server->connectionRecord(); // Ask user int answer = QMessageBox::question(this, "Drop Collection", QString("Drop <b>%1</b> collection?").arg(collection->name()), QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton); if (answer != QMessageBox::Yes) return; database->dropCollection(collection->name()); database->loadCollections(); //openCurrentCollectionShell("db.%1.drop()", false); }
void ExplorerTreeWidget::ui_removeAllDocuments() { ExplorerCollectionTreeItem *collectionItem = selectedCollectionItem(); if (!collectionItem) return; MongoCollection *collection = collectionItem->collection(); MongoDatabase *database = collection->database(); MongoServer *server = database->server(); ConnectionSettings *settings = server->connectionRecord(); // Ask user int answer = QMessageBox::question(this, "Remove All Documents", QString("Remove all documents from <b>%1</b> collection?").arg(collection->name()), QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton); if (answer != QMessageBox::Yes) return; mongo::BSONObjBuilder builder; mongo::BSONObj bsonQuery = builder.obj(); mongo::Query query(bsonQuery); server->removeDocuments(query, database->name(), collection->name(), false); }
void ExplorerTreeWidget::ui_addDocument() { ExplorerCollectionTreeItem *collectionItem = selectedCollectionItem(); if (!collectionItem) return; MongoCollection *collection = collectionItem->collection(); MongoDatabase *database = collection->database(); MongoServer *server = database->server(); ConnectionSettings *settings = server->connectionRecord(); DocumentTextEditor editor(settings->getFullAddress(), database->name(), collection->name(), "{\n \n}"); editor.setCursorPosition(1, 4); editor.setWindowTitle("Insert Document"); int result = editor.exec(); activateWindow(); if (result == QDialog::Accepted) { mongo::BSONObj obj = editor.bsonObj(); server->insertDocument(obj, database->name(), collection->name()); } /* openCurrentCollectionShell( "db.%1.insert({\n" " '' : '',\n" "})" , false, CursorPosition(1, 5)); */ }
void ExplorerWidget::ui_itemClicked(QTreeWidgetItem *item, int cloumn) { if (!AppRegistry::instance().settingsManager()->useTabbar()) { ExplorerCollectionTreeItem *collectionItem = dynamic_cast<ExplorerCollectionTreeItem *>(item); if (collectionItem) { AppRegistry::instance().app()->openShell(collectionItem->collection()); } } }
void ExplorerTreeWidget::openCurrentCollectionShell(const QString &script, bool execute, const CursorPosition &cursor) { ExplorerCollectionTreeItem *collectionItem = selectedCollectionItem(); if (!collectionItem) return; MongoCollection *collection = collectionItem->collection(); QString query = QString(script).arg(collection->name()); AppRegistry::instance().app()-> openShell(collection->database(), query, execute, collection->name(), cursor); }
void ExplorerCollectionDirIndexesTreeItem::ui_addIndex() { ExplorerCollectionTreeItem *par = dynamic_cast<ExplorerCollectionTreeItem *>(parent()); if (par) { par->openCurrentCollectionShell( "ensureIndex({ \"<field>\" : 1 }); \n" "\n" "// options: \n" "// { unique : true } - A unique index causes MongoDB to reject all documents that contain a duplicate value for the indexed field. \n" "// { sparse : true } - Sparse indexes only contain entries for documents that have the indexed field. \n" "// { dropDups : true } - Sparse indexes only contain entries for documents that have the indexed field. \n" , false); } }
void ExplorerCollectionDirIndexesTreeItem::ui_addIndexGui() { ExplorerCollectionTreeItem *par = dynamic_cast<ExplorerCollectionTreeItem *const>(parent()); if (!par) return; EnsureIndexInfo fakeInfo(par->collection()->info(),""); EditIndexDialog dlg(fakeInfo , QtUtils::toQString(par->databaseItem()->database()->name()),QtUtils::toQString(par->databaseItem()->database()->server()->connectionRecord()->getFullAddress()), treeWidget()); int result = dlg.exec(); if (result != QDialog::Accepted) return; ExplorerDatabaseTreeItem *databaseTreeItem = static_cast<ExplorerDatabaseTreeItem *>(par->databaseItem()); if (!databaseTreeItem) return; databaseTreeItem->enshureIndex(par,fakeInfo, dlg.info()); }
void ExplorerCollectionIndexesTreeItem::ui_dropIndex() { // Ask user int answer = utils::questionDialog(treeWidget(),"Drop","Index",text(0)); if (answer != QMessageBox::Yes) return; ExplorerCollectionDirIndexesTreeItem *par = dynamic_cast<ExplorerCollectionDirIndexesTreeItem *>(parent()); if (!par) return; ExplorerCollectionTreeItem *grandParent = dynamic_cast<ExplorerCollectionTreeItem *>(par->parent()); if (!grandParent) return; grandParent->dropIndex(this); }