本文整理汇总了C++中ExplorerDatabaseTreeItem::database方法的典型用法代码示例。如果您正苦于以下问题:C++ ExplorerDatabaseTreeItem::database方法的具体用法?C++ ExplorerDatabaseTreeItem::database怎么用?C++ ExplorerDatabaseTreeItem::database使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExplorerDatabaseTreeItem
的用法示例。
在下文中一共展示了ExplorerDatabaseTreeItem::database方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ui_addFunction
void ExplorerTreeWidget::ui_addFunction()
{
ExplorerDatabaseCategoryTreeItem *categoryItem = selectedDatabaseCategoryItem();
if (!categoryItem)
return;
ExplorerDatabaseTreeItem *databaseItem = categoryItem->databaseItem();
FunctionTextEditor dlg(databaseItem->database()->server()->connectionRecord()->getFullAddress(),
databaseItem->database()->name(), MongoFunction());
dlg.setWindowTitle("Create Function");
dlg.setCode(
"function() {\n"
" // write your code here\n"
"}");
dlg.setCursorPosition(1, 4);
int result = dlg.exec();
if (result == QDialog::Accepted) {
MongoFunction function = dlg.function();
databaseItem->database()->createFunction(function);
// refresh list of functions
databaseItem->expandFunctions();
}
}
示例2: ui_addUser
void ExplorerDatabaseCategoryTreeItem::ui_addUser()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if(databaseItem){
CreateUserDialog dlg(QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress()),
QtUtils::toQString(databaseItem->database()->name()));
int result = dlg.exec();
if (result == QDialog::Accepted) {
MongoUser user = dlg.user();
databaseItem->database()->createUser(user, false);
// refresh list of users
databaseItem->expandUsers();
}
}
}
示例3: ui_viewFunctions
void ExplorerDatabaseCategoryTreeItem::ui_viewFunctions()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (databaseItem) {
openDatabaseShell(databaseItem->database(), "db.system.js.find()");
}
}
示例4: ui_viewUsers
void ExplorerDatabaseCategoryTreeItem::ui_viewUsers()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (databaseItem) {
openDatabaseShell(databaseItem->database(), "db.getUsers()");
}
}
示例5: ui_dbCollectionsStatistics
void ExplorerDatabaseCategoryTreeItem::ui_dbCollectionsStatistics()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (databaseItem) {
openDatabaseShell(databaseItem->database(), "db.printCollectionStats()");
}
}
示例6: ui_createCollection
void ExplorerDatabaseCategoryTreeItem::ui_createCollection()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (databaseItem){
CreateDatabaseDialog dlg(QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress()),
QtUtils::toQString(databaseItem->database()->name()));
dlg.setWindowTitle("Create Collection");
dlg.setOkButtonText("&Create");
dlg.setInputLabelText("Collection Name:");
int result = dlg.exec();
if (result == QDialog::Accepted) {
databaseItem->database()->createCollection(QtUtils::toStdString<std::string>(dlg.databaseName()));
// refresh list of databases
databaseItem->expandCollections();
}
}
}
示例7: ui_addUser
void ExplorerDatabaseCategoryTreeItem::ui_addUser()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (!databaseItem)
return;
std::unique_ptr<CreateUserDialog> dlg = nullptr;
float const version = databaseItem->database()->server()->version();
if (version < MongoUser::minimumSupportedVersion) {
dlg.reset(new CreateUserDialog(
QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress()),
QtUtils::toQString(databaseItem->database()->name()), MongoUser(version), treeWidget()));
}
else {
dlg.reset(new CreateUserDialog(databaseItem->database()->server()->getDatabasesNames(),
QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress()),
QtUtils::toQString(databaseItem->database()->name()), MongoUser(version), treeWidget()));
}
if (dlg->exec() != QDialog::Accepted)
return;
MongoUser user = dlg->user();
databaseItem->database()->createUser(user);
}
示例8: openCurrentDatabaseShell
void ExplorerTreeWidget::openCurrentDatabaseShell(const QString &script, bool execute,
const CursorPosition &cursor)
{
ExplorerDatabaseTreeItem *collectionItem = selectedDatabaseItem();
if (!collectionItem)
return;
MongoDatabase *database = collectionItem->database();
openDatabaseShell(database, script, execute, cursor);
}
示例9: ui_createCollection
void ExplorerDatabaseCategoryTreeItem::ui_createCollection()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (!databaseItem)
return;
const float dbVersion = databaseItem->database()->server()->version();
const std::string& engineName = databaseItem->database()->server()->getStorageEngineType();
const QString& serverName = QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress());
const QString& dbName = QtUtils::toQString(databaseItem->database()->name());
CreateCollectionDialog dlg(serverName, dbVersion, engineName, dbName, QString(), treeWidget());
int result = dlg.exec();
if (result != QDialog::Accepted)
return;
std::string collectionName = QtUtils::toStdString(dlg.getCollectionName());
databaseItem->database()->createCollection(collectionName,
dlg.getSizeInputValue(), dlg.isCapped(), dlg.getMaxDocNumberInputValue(), dlg.getExtraOptions());
}
示例10: ui_addFunction
void ExplorerDatabaseCategoryTreeItem::ui_addFunction()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (!databaseItem)
return;
FunctionTextEditor dlg(QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress()), QtUtils::toQString(databaseItem->database()->name()), MongoFunction());
dlg.setWindowTitle("Create Function");
dlg.setCode(
"function() {\n"
" // write your code here\n"
"}");
dlg.setCursorPosition(1, 4);
int result = dlg.exec();
if (result != QDialog::Accepted)
return;
MongoFunction function = dlg.function();
databaseItem->database()->createFunction(function);
}
示例11: ui_addUser
void ExplorerTreeWidget::ui_addUser()
{
ExplorerDatabaseCategoryTreeItem *categoryItem = selectedDatabaseCategoryItem();
if (!categoryItem)
return;
ExplorerDatabaseTreeItem *databaseItem = categoryItem->databaseItem();
CreateUserDialog dlg(databaseItem->database()->server()->connectionRecord()->getFullAddress(),
databaseItem->database()->name());
int result = dlg.exec();
if (result == QDialog::Accepted) {
MongoUser user = dlg.user();
databaseItem->database()->createUser(user, false);
// refresh list of users
databaseItem->expandUsers();
}
}
示例12: ui_addUser
void ExplorerDatabaseCategoryTreeItem::ui_addUser()
{
ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem();
if (!databaseItem)
return;
float version = databaseItem->database()->server()->version();
CreateUserDialog *dlg = NULL;
if (version < MongoUser::minimumSupportedVersion) {
dlg = new CreateUserDialog(QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress()),
QtUtils::toQString(databaseItem->database()->name()), MongoUser(version));
}
else {
dlg = new CreateUserDialog(databaseItem->database()->server()->getDatabasesNames(), QtUtils::toQString(databaseItem->database()->server()->connectionRecord()->getFullAddress()),
QtUtils::toQString(databaseItem->database()->name()), MongoUser(version));
}
int result = dlg->exec();
if (result != QDialog::Accepted)
return;
MongoUser user = dlg->user();
databaseItem->database()->createUser(user, false);
// refresh list of users
databaseItem->expandUsers();
}
示例13: ui_createCollection
void ExplorerTreeWidget::ui_createCollection()
{
ExplorerDatabaseCategoryTreeItem *categoryItem = selectedDatabaseCategoryItem();
if (!categoryItem)
return;
ExplorerDatabaseTreeItem *databaseItem = categoryItem->databaseItem();
if (!databaseItem)
return;
CreateDatabaseDialog dlg(databaseItem->database()->server()->connectionRecord()->getFullAddress(),
databaseItem->database()->name());
dlg.setWindowTitle("Create Collection");
dlg.setOkButtonText("&Create");
dlg.setInputLabelText("Collection Name:");
int result = dlg.exec();
if (result == QDialog::Accepted) {
databaseItem->database()->createCollection(dlg.databaseName());
// refresh list of databases
databaseItem->expandCollections();
}
}
示例14: ui_dbDrop
void ExplorerTreeWidget::ui_dbDrop()
{
ExplorerDatabaseTreeItem *dbItem = selectedDatabaseItem();
if (!dbItem)
return;
MongoDatabase *database = dbItem->database();
MongoServer *server = database->server();
// Ask user
int answer = QMessageBox::question(this,
"Drop Database",
QString("Drop <b>%1</b> database?").arg(database->name()),
QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
if (answer != QMessageBox::Yes)
return;
server->dropDatabase(database->name());
server->loadDatabases(); // refresh list of databases
//openCurrentDatabaseShell("db.dropDatabase()", false);
}