diff --git a/CMakeLists.txt b/CMakeLists.txt
index b9fcc903..50913872 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
diff --git a/src/create_entry_dialog.cpp b/src/create_entry_dialog.cpp
deleted file mode 100644
index c9be46cf..00000000
--- a/src/create_entry_dialog.cpp
+++ /dev/null
@@ -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 .
- */
-
-#include "create_entry_dialog.h"
-#include "ad_interface.h"
-
-#include
-#include
-
-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 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);
- }
-}
diff --git a/src/create_entry_dialog.h b/src/create_entry_dialog.h
deleted file mode 100644
index d6b947c4..00000000
--- a/src/create_entry_dialog.h
+++ /dev/null
@@ -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 .
- */
-
-#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 */
diff --git a/src/main_window.cpp b/src/main_window.cpp
index 8d370e71..e3999061 100644
--- a/src/main_window.cpp
+++ b/src/main_window.cpp
@@ -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 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) {
diff --git a/src/main_window.h b/src/main_window.h
index 74225148..8b5d8de9 100644
--- a/src/main_window.h
+++ b/src/main_window.h
@@ -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);