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" "}"); if (dlg.exec() != QDialog::Accepted) return; MongoFunction function = dlg.function(); databaseItem->database()->createFunction(function); }
void ExplorerDatabaseCategoryTreeItem::ui_addFunction() { ExplorerDatabaseTreeItem *databaseItem = ExplorerDatabaseCategoryTreeItem::databaseItem(); if(databaseItem){ 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) { MongoFunction function = dlg.function(); databaseItem->database()->createFunction(function); // refresh list of functions databaseItem->expandFunctions(); } } }