CreateUserDialog::CreateUserDialog(const QString &serverName, const QString &database, const MongoUser &user, QWidget *parent) : QDialog(parent), _user(user) { VERIFY(user.version() < MongoUser::minimumSupportedVersion); setWindowTitle("Add User"); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Remove help button (?) setMinimumWidth(400); Indicator *serverIndicator = new Indicator(GuiRegistry::instance().serverIcon(), serverName); Indicator *databaseIndicator = new Indicator(GuiRegistry::instance().databaseIcon(), database); QFrame *hline = new QFrame(); hline->setFrameShape(QFrame::HLine); hline->setFrameShadow(QFrame::Sunken); _userNameLabel= new QLabel("Name:"); _userNameEdit = new QLineEdit(); _userNameEdit->setText(QtUtils::toQString(user.name())); _userPassLabel= new QLabel("Password:"******"Read Only"); _readOnlyCheckBox->setChecked(user.readOnly()); QDialogButtonBox *buttonBox = new QDialogButtonBox(this); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); VERIFY(connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()))); VERIFY(connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()))); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->addStretch(1); hlayout->addWidget(buttonBox); QHBoxLayout *vlayout = new QHBoxLayout(); vlayout->addWidget(serverIndicator, 0, Qt::AlignLeft); vlayout->addWidget(databaseIndicator, 0, Qt::AlignLeft); vlayout->addStretch(1); QGridLayout *namelayout = new QGridLayout(); namelayout->setContentsMargins(0, 7, 0, 7); namelayout->addWidget(_userNameLabel, 0, 0); namelayout->addWidget(_userNameEdit, 0, 1); namelayout->addWidget(_userPassLabel, 1, 0); namelayout->addWidget(_userPassEdit, 1, 1); namelayout->addWidget(_readOnlyCheckBox, 2, 1); QVBoxLayout *layout = new QVBoxLayout(); layout->addLayout(vlayout); layout->addWidget(hline); layout->addLayout(namelayout); layout->addLayout(hlayout); setLayout(layout); _userNameEdit->setFocus(); }
CreateUserDialog::CreateUserDialog(const QString &serverName, const QString &database, const MongoUser &user, QWidget *parent) : QDialog(parent), _user(user) { setWindowTitle("Add User"); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Remove help button (?) setMinimumWidth(400); Indicator *serverIndicator = new Indicator(GuiRegistry::instance().serverIcon(), serverName); Indicator *databaseIndicator = new Indicator(GuiRegistry::instance().databaseIcon(), database); QFrame *hline = new QFrame(); hline->setFrameShape(QFrame::HLine); hline->setFrameShadow(QFrame::Sunken); _userNameLabel= new QLabel("Name:"); _userNameEdit = new QLineEdit(); _userNameEdit->setText(user.name()); _userPassLabel= new QLabel("Password:"******"Read Only"); _readOnlyCheckBox->setChecked(user.readOnly()); QPushButton *cancelButton = new QPushButton("&Cancel"); connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); QPushButton *_okButton = new QPushButton("&Create"); connect(_okButton, SIGNAL(clicked()), this, SLOT(accept())); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->addStretch(1); hlayout->addWidget(_okButton, 0, Qt::AlignRight); hlayout->addWidget(cancelButton, 0, Qt::AlignRight); QHBoxLayout *vlayout = new QHBoxLayout(); vlayout->addWidget(serverIndicator, 0, Qt::AlignLeft); vlayout->addWidget(databaseIndicator, 0, Qt::AlignLeft); vlayout->addStretch(1); QGridLayout *namelayout = new QGridLayout(); namelayout->setContentsMargins(0, 7, 0, 7); namelayout->addWidget(_userNameLabel, 0, 0); namelayout->addWidget(_userNameEdit, 0, 1); namelayout->addWidget(_userPassLabel, 1, 0); namelayout->addWidget(_userPassEdit, 1, 1); namelayout->addWidget(_readOnlyCheckBox, 2, 1); QVBoxLayout *layout = new QVBoxLayout(); layout->addLayout(vlayout); layout->addWidget(hline); layout->addLayout(namelayout); layout->addLayout(hlayout); setLayout(layout); }
void ExplorerTreeWidget::ui_dropUser() { ExplorerUserTreeItem *userItem = selectedUserItem(); if (!userItem) return; MongoUser user = userItem->user(); MongoDatabase *database = userItem->database(); MongoServer *server = database->server(); // Ask user int answer = QMessageBox::question(this, "Remove User", QString("Remove <b>%1</b> user?").arg(user.name()), QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton); if (answer != QMessageBox::Yes) return; database->dropUser(user.id()); database->loadUsers(); // refresh list of users }
CreateUserDialog::CreateUserDialog(const QStringList &databases, const QString &serverName, const QString &database, const MongoUser &user, QWidget *parent) : QDialog(parent), _user(user) { setWindowTitle("Add User"); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Remove help button (?) setMinimumSize(minimumSize); Indicator *serverIndicator = new Indicator(GuiRegistry::instance().serverIcon(), serverName); Indicator *databaseIndicator = new Indicator(GuiRegistry::instance().databaseIcon(), database); QFrame *hline = new QFrame(); hline->setFrameShape(QFrame::HLine); hline->setFrameShadow(QFrame::Sunken); _userNameLabel = new QLabel("Name:"); _userNameEdit = new QLineEdit(); _userNameEdit->setText(QtUtils::toQString(user.name())); _userPassLabel = new QLabel("Password:"******"UserSource:"); _userSourceComboBox = new QComboBox(); _userSourceComboBox->addItems(QStringList() << "" << databases); //setText(QtUtils::toQString(user.userSource())); utils::setCurrentText(_userSourceComboBox, QtUtils::toQString(user.userSource())); QGridLayout *gridRoles = new QGridLayout(); MongoUser::RoleType userRoles = user.role(); for (unsigned i = 0; i<RolesCount; ++i) { int row = i%3; int col = i/3; _rolesArray[i] = new QCheckBox(rolesText[i], this); MongoUser::RoleType::const_iterator it = std::find(userRoles.begin(), userRoles.end(), rolesText[i]); _rolesArray[i]->setChecked(it!= userRoles.end()); gridRoles->addWidget(_rolesArray[i], row, col); } QDialogButtonBox *buttonBox = new QDialogButtonBox(this); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); VERIFY(connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()))); VERIFY(connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()))); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->addStretch(1); hlayout->addWidget(buttonBox); QHBoxLayout *vlayout = new QHBoxLayout(); vlayout->addWidget(serverIndicator, 0, Qt::AlignLeft); vlayout->addWidget(databaseIndicator, 0, Qt::AlignLeft); vlayout->addStretch(1); QGridLayout *namelayout = new QGridLayout(); namelayout->setContentsMargins(0, 7, 0, 7); namelayout->addWidget(_userNameLabel, 0, 0); namelayout->addWidget(_userNameEdit, 0, 1); namelayout->addWidget(_userPassLabel, 1, 0); namelayout->addWidget(_userPassEdit, 1, 1); namelayout->addWidget(_userSourceLabel, 2, 0); namelayout->addWidget(_userSourceComboBox, 2, 1); namelayout->addLayout(gridRoles, 3, 1); QVBoxLayout *layout = new QVBoxLayout(); layout->addLayout(vlayout); layout->addWidget(hline); layout->addLayout(namelayout); layout->addLayout(hlayout); setLayout(layout); _userNameEdit->setFocus(); }