1
0
mirror of https://github.com/altlinux/admc.git synced 2024-10-27 01:55:37 +03:00

remove create_entry_dialog

doesn't need it's own file yet
This commit is contained in:
Dmitry Degtyarev 2020-06-08 16:02:44 +04:00
parent d08a4c5fb5
commit d34039143e
5 changed files with 31 additions and 90 deletions

View File

@ -56,7 +56,6 @@ set(ADTOOL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/attributes_model.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/containers_widget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/contents_widget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/create_entry_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/main_window.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/entry_widget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/status_bar.cpp

View File

@ -1,54 +0,0 @@
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020 BaseALT Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "create_entry_dialog.h"
#include "ad_interface.h"
#include <QInputDialog>
#include <QString>
void create_entry_dialog(NewEntryType type, const QString &parent_dn) {
// Open new user dialog and name of entry from it
QString type_string = new_entry_type_to_string[type];
QString dialog_title = "New " + type_string;
QString input_label = type_string + " name";
bool ok;
QString name = QInputDialog::getText(nullptr, dialog_title, input_label, QLineEdit::Normal, "", &ok);
// TODO: maybe expand tree to newly created entry?
// Create user once dialog is complete
if (ok && !name.isEmpty()) {
// Attempt to create user in AD
const QMap<NewEntryType, QString> new_entry_type_to_suffix = {
{NewEntryType::User, "CN"},
{NewEntryType::Computer, "CN"},
{NewEntryType::OU, "OU"},
{NewEntryType::Group, "CN"},
};
QString suffix = new_entry_type_to_suffix[type];
const QString dn = suffix + "=" + name + "," + parent_dn;
AD()->create_entry(name, dn, type);
}
}

View File

@ -1,27 +0,0 @@
/*
* ADMC - AD Management Center
*
* Copyright (C) 2020 BaseALT Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CREATE_ENTRY_H
#define CREATE_ENTRY_H
#include "ad_interface.h"
void create_entry_dialog(NewEntryType type, const QString &given_parent_dn);
#endif /* CREATE_ENTRY_H */

View File

@ -26,7 +26,6 @@
#include "details_widget.h"
#include "ad_model.h"
#include "attributes_model.h"
#include "create_entry_dialog.h"
#include "status_bar.h"
#include "entry_widget.h"
#include "settings.h"
@ -222,24 +221,48 @@ void MainWindow::on_context_menu_delete(const QString &dn) {
contents_widget->setEnabled(false);
}
void MainWindow::new_entry_generic(const QString &dn, NewEntryType type) {
create_entry_dialog(type, dn);
void MainWindow::new_entry_dialog(const QString &parent_dn, NewEntryType type) {
QString type_string = new_entry_type_to_string[type];
QString dialog_title = "New " + type_string;
QString input_label = type_string + " name";
bool ok;
QString name = QInputDialog::getText(nullptr, dialog_title, input_label, QLineEdit::Normal, "", &ok);
// TODO: maybe expand tree to newly created entry?
// Create user once dialog is complete
if (ok && !name.isEmpty()) {
// Attempt to create user in AD
const QMap<NewEntryType, QString> new_entry_type_to_suffix = {
{NewEntryType::User, "CN"},
{NewEntryType::Computer, "CN"},
{NewEntryType::OU, "OU"},
{NewEntryType::Group, "CN"},
};
QString suffix = new_entry_type_to_suffix[type];
const QString dn = suffix + "=" + name + "," + parent_dn;
AD()->create_entry(name, dn, type);
}
}
void MainWindow::on_context_menu_new_user(const QString &dn) {
new_entry_generic(dn, NewEntryType::User);
new_entry_dialog(dn, NewEntryType::User);
}
void MainWindow::on_context_menu_new_computer(const QString &dn) {
new_entry_generic(dn, NewEntryType::Computer);
new_entry_dialog(dn, NewEntryType::Computer);
}
void MainWindow::on_context_menu_new_group(const QString &dn) {
new_entry_generic(dn, NewEntryType::Group);
new_entry_dialog(dn, NewEntryType::Group);
}
void MainWindow::on_context_menu_new_ou(const QString &dn) {
new_entry_generic(dn, NewEntryType::OU);
new_entry_dialog(dn, NewEntryType::OU);
}
void MainWindow::on_context_menu_rename(const QString &dn) {

View File

@ -51,7 +51,7 @@ private slots:
void on_ad_interface_login_complete(const QString &base, const QString &head);
private:
void new_entry_generic(const QString &dn, NewEntryType type);
void new_entry_dialog(const QString &parent_dn, NewEntryType type);
void set_enabled_for_widgets(bool enabled);
bool confirmation_dialog(const QString &text);
void connect_entry_widget(const EntryWidget &widget);