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();
    }
    void ExplorerUserTreeItem::ui_editUser()
    {
        float version = _user.version();
        CreateUserDialog *dlg = NULL;

        if (version < MongoUser::minimumSupportedVersion) {
            dlg = new CreateUserDialog(QtUtils::toQString(_database->server()->connectionRecord()->getFullAddress()), QtUtils::toQString(_database->name()), _user, treeWidget());
        }
        else {
           dlg = new CreateUserDialog(_database->server()->getDatabasesNames(), QtUtils::toQString(_database->server()->connectionRecord()->getFullAddress()), QtUtils::toQString(_database->name()), _user, treeWidget());
        }
        
        dlg->setWindowTitle("Edit User");
        dlg->setUserPasswordLabelText("New Password:");
        int result = dlg->exec();

        if (result == QDialog::Accepted) {

            MongoUser user = dlg->user();
            _database->createUser(user, true);

            // refresh list of users
            _database->loadUsers();
        }
        delete dlg;
    }