mirror of
https://github.com/altlinux/admc.git
synced 2025-02-19 01:58:09 +03:00
rename attribute editors to dialogs
This commit is contained in:
parent
1089562c9a
commit
55e2e7c7e7
@ -100,11 +100,11 @@ Tests for ADMC
|
||||
%_bindir/admc_test_account_option_edit
|
||||
%_bindir/admc_test_protect_deletion_edit
|
||||
%_bindir/admc_test_gpoptions_edit
|
||||
%_bindir/admc_test_octet_editor
|
||||
%_bindir/admc_test_bool_editor
|
||||
%_bindir/admc_test_string_editor
|
||||
%_bindir/admc_test_multi_editor
|
||||
%_bindir/admc_test_datetime_editor
|
||||
%_bindir/admc_test_octet_attribute_dialog
|
||||
%_bindir/admc_test_bool_attribute_dialog
|
||||
%_bindir/admc_test_string_attribute_dialog
|
||||
%_bindir/admc_test_list_attribute_dialog
|
||||
%_bindir/admc_test_datetime_attribute_dialog
|
||||
%_bindir/admc_test_edit_query_item_widget
|
||||
%_bindir/admc_test_policy_results_widget
|
||||
%_bindir/admc_test_find_object_dialog
|
||||
|
@ -153,12 +153,12 @@ set(ADMC_SOURCES
|
||||
multi_edits/country_multi_edit.cpp
|
||||
multi_edits/manager_multi_edit.cpp
|
||||
|
||||
editors/attribute_editor.cpp
|
||||
editors/multi_editor.cpp
|
||||
editors/string_editor.cpp
|
||||
editors/octet_editor.cpp
|
||||
editors/bool_editor.cpp
|
||||
editors/datetime_editor.cpp
|
||||
attribute_dialogs/attribute_dialog.cpp
|
||||
attribute_dialogs/list_attribute_dialog.cpp
|
||||
attribute_dialogs/string_attribute_dialog.cpp
|
||||
attribute_dialogs/octet_attribute_dialog.cpp
|
||||
attribute_dialogs/bool_attribute_dialog.cpp
|
||||
attribute_dialogs/datetime_attribute_dialog.cpp
|
||||
|
||||
console_widget/console_widget.cpp
|
||||
console_widget/scope_proxy_model.cpp
|
||||
|
@ -217,24 +217,24 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AttributeEditor</name>
|
||||
<name>AttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="44"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="44"/>
|
||||
<source>Attribute: %1</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="55"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="55"/>
|
||||
<source>Edit</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="57"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="57"/>
|
||||
<source>View</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="66"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="66"/>
|
||||
<source>%1 Multi-Valued %2</source>
|
||||
<comment>This is a dialog title for attribute editors. Example: "Edit Multi-Valued String"</comment>
|
||||
<translation></translation>
|
||||
@ -312,19 +312,19 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BoolEditor</name>
|
||||
<name>BoolAttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/bool_editor.ui" line="27"/>
|
||||
<location filename="attribute_dialogs/bool_attribute_dialog.ui" line="27"/>
|
||||
<source>True</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/bool_editor.ui" line="34"/>
|
||||
<location filename="attribute_dialogs/bool_attribute_dialog.ui" line="34"/>
|
||||
<source>False</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/bool_editor.ui" line="41"/>
|
||||
<location filename="attribute_dialogs/bool_attribute_dialog.ui" line="41"/>
|
||||
<source>Unset</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
@ -1740,19 +1740,19 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MultiEditor</name>
|
||||
<name>ListAttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/multi_editor.ui" line="44"/>
|
||||
<location filename="attribute_dialogs/list_attribute_dialog.ui" line="44"/>
|
||||
<source>Add...</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/multi_editor.ui" line="27"/>
|
||||
<location filename="attribute_dialogs/list_attribute_dialog.ui" line="27"/>
|
||||
<source>Values:</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/multi_editor.ui" line="51"/>
|
||||
<location filename="attribute_dialogs/list_attribute_dialog.ui" line="51"/>
|
||||
<source>Remove</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
@ -1903,49 +1903,49 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>OctetEditor</name>
|
||||
<name>OctetAttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="28"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="28"/>
|
||||
<source>Hexadecimal</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="33"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="33"/>
|
||||
<source>Binary</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="38"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="38"/>
|
||||
<source>Decimal</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="43"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="43"/>
|
||||
<source>Octal</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="182"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="182"/>
|
||||
<source>Error</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="186"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="186"/>
|
||||
<source>Input must be strings of 2 hexadecimal digits separated by spaces. Example: "0a 00 b5 ff"</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="187"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="187"/>
|
||||
<source>Input must be strings of 8 binary digits separated by spaces. Example: "01010010 01000010 01000010"</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="188"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="188"/>
|
||||
<source>Input must be strings of 3 decimal digits (0-255) separated by spaces. Example: "010 000 191"</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="189"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="189"/>
|
||||
<source>Input must be strings of 3 octal digits (0-377) separated by spaces.. Example: "070 343 301"</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
@ -217,24 +217,24 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AttributeEditor</name>
|
||||
<name>AttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="44"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="44"/>
|
||||
<source>Attribute: %1</source>
|
||||
<translation>Атрибут: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="55"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="55"/>
|
||||
<source>Edit</source>
|
||||
<translation>Редактировать</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="57"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="57"/>
|
||||
<source>View</source>
|
||||
<translation>Просмотреть</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/attribute_editor.cpp" line="66"/>
|
||||
<location filename="attribute_dialogs/attribute_dialog.cpp" line="66"/>
|
||||
<source>%1 Multi-Valued %2</source>
|
||||
<comment>This is a dialog title for attribute editors. Example: "Edit Multi-Valued String"</comment>
|
||||
<translation>%1 %2 (Многозначный)</translation>
|
||||
@ -312,19 +312,19 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BoolEditor</name>
|
||||
<name>BoolAttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/bool_editor.ui" line="27"/>
|
||||
<location filename="attribute_dialogs/bool_attribute_dialog.ui" line="27"/>
|
||||
<source>True</source>
|
||||
<translation>Истина</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/bool_editor.ui" line="34"/>
|
||||
<location filename="attribute_dialogs/bool_attribute_dialog.ui" line="34"/>
|
||||
<source>False</source>
|
||||
<translation>Ложь</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/bool_editor.ui" line="41"/>
|
||||
<location filename="attribute_dialogs/bool_attribute_dialog.ui" line="41"/>
|
||||
<source>Unset</source>
|
||||
<translation>Без значения</translation>
|
||||
</message>
|
||||
@ -1740,19 +1740,19 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MultiEditor</name>
|
||||
<name>ListAttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/multi_editor.ui" line="44"/>
|
||||
<location filename="attribute_dialogs/list_attribute_dialog.ui" line="44"/>
|
||||
<source>Add...</source>
|
||||
<translation>Добавить...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/multi_editor.ui" line="27"/>
|
||||
<location filename="attribute_dialogs/list_attribute_dialog.ui" line="27"/>
|
||||
<source>Values:</source>
|
||||
<translation>Значения:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/multi_editor.ui" line="51"/>
|
||||
<location filename="attribute_dialogs/list_attribute_dialog.ui" line="51"/>
|
||||
<source>Remove</source>
|
||||
<translation>Удалить</translation>
|
||||
</message>
|
||||
@ -1903,49 +1903,49 @@
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>OctetEditor</name>
|
||||
<name>OctetAttributeDialog</name>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="28"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="28"/>
|
||||
<source>Hexadecimal</source>
|
||||
<translation>Шестнадцатеричный</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="33"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="33"/>
|
||||
<source>Binary</source>
|
||||
<translation>Двоичный</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="38"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="38"/>
|
||||
<source>Decimal</source>
|
||||
<translation>Десятичный</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.ui" line="43"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.ui" line="43"/>
|
||||
<source>Octal</source>
|
||||
<translation>Восьмеричный</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="182"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="182"/>
|
||||
<source>Error</source>
|
||||
<translation>Ошибка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="186"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="186"/>
|
||||
<source>Input must be strings of 2 hexadecimal digits separated by spaces. Example: "0a 00 b5 ff"</source>
|
||||
<translation>Ввод должен состоять из строки, содержащей две шестнадцатеричные цифры, разделённые пробелами. Пример: "0a 00 b5 ff"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="187"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="187"/>
|
||||
<source>Input must be strings of 8 binary digits separated by spaces. Example: "01010010 01000010 01000010"</source>
|
||||
<translation>Ввод должен состоять из строки, содержащей восемь двоичных цифр, разделённых пробелами. Пример: "01010010 01000010 01000010"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="188"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="188"/>
|
||||
<source>Input must be strings of 3 decimal digits (0-255) separated by spaces. Example: "010 000 191"</source>
|
||||
<translation>Ввод должен состоять из строки, содержащей три десятичные цифры (0–255), разделённые пробелами. Пример: "010 000 191"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="editors/octet_editor.cpp" line="189"/>
|
||||
<location filename="attribute_dialogs/octet_attribute_dialog.cpp" line="189"/>
|
||||
<source>Input must be strings of 3 octal digits (0-377) separated by spaces.. Example: "070 343 301"</source>
|
||||
<translation>Ввод должен состоять из строки, содержащей три восьмеричные цифры (0–377), разделённые пробелами. Пример: "070 343 301"</translation>
|
||||
</message>
|
||||
|
@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "editors/attribute_editor.h"
|
||||
#include "attribute_dialogs/attribute_dialog.h"
|
||||
|
||||
#include "ad_config.h"
|
||||
#include "ad_utils.h"
|
||||
@ -26,19 +26,19 @@
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
void AttributeEditor::set_attribute_label(QLabel *attribute_label) {
|
||||
void AttributeDialog::set_attribute_label(QLabel *attribute_label) {
|
||||
m_attribute_label = attribute_label;
|
||||
}
|
||||
|
||||
QString AttributeEditor::get_attribute() const {
|
||||
QString AttributeDialog::get_attribute() const {
|
||||
return m_attribute;
|
||||
}
|
||||
|
||||
bool AttributeEditor::get_read_only() const {
|
||||
bool AttributeDialog::get_read_only() const {
|
||||
return m_read_only;
|
||||
}
|
||||
|
||||
void AttributeEditor::set_attribute(const QString &attribute) {
|
||||
void AttributeDialog::set_attribute(const QString &attribute) {
|
||||
m_attribute = attribute;
|
||||
|
||||
const QString text = QString(tr("Attribute: %1")).arg(m_attribute);
|
||||
@ -70,6 +70,6 @@ void AttributeEditor::set_attribute(const QString &attribute) {
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
void AttributeEditor::set_read_only(const bool read_only) {
|
||||
void AttributeDialog::set_read_only(const bool read_only) {
|
||||
m_read_only = read_only;
|
||||
}
|
@ -18,21 +18,18 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ATTRIBUTE_EDITOR_H
|
||||
#define ATTRIBUTE_EDITOR_H
|
||||
#ifndef ATTRIBUTE_DIALOG_H
|
||||
#define ATTRIBUTE_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QLabel;
|
||||
|
||||
/**
|
||||
* Gets input from user, which can be obtained through
|
||||
* get_value_list(). Different from AttributeEdit because it
|
||||
* is opened as a separate dialog and parent object is
|
||||
* responsible for actually applying the changes.
|
||||
* Dialog for viewing and editing attribute values.
|
||||
*/
|
||||
|
||||
class AttributeEditor : public QDialog {
|
||||
class AttributeDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -43,7 +40,7 @@ public:
|
||||
virtual void set_attribute(const QString &attribute);
|
||||
|
||||
// NOTE: this exists so that it's possible to make a
|
||||
// read only editor for writable attributes
|
||||
// read only dialog even for writable attributes
|
||||
virtual void set_read_only(const bool read_only);
|
||||
|
||||
QString get_attribute() const;
|
||||
@ -66,4 +63,4 @@ private:
|
||||
QLabel *m_attribute_label;
|
||||
};
|
||||
|
||||
#endif /* ATTRIBUTE_EDITOR_H */
|
||||
#endif /* ATTRIBUTE_DIALOG_H */
|
@ -18,38 +18,38 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "editors/bool_editor.h"
|
||||
#include "editors/ui_bool_editor.h"
|
||||
#include "attribute_dialogs/bool_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_bool_attribute_dialog.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "globals.h"
|
||||
#include "settings.h"
|
||||
|
||||
BoolEditor::BoolEditor(QWidget *parent)
|
||||
: AttributeEditor(parent) {
|
||||
ui = new Ui::BoolEditor();
|
||||
BoolAttributeDialog::BoolAttributeDialog(QWidget *parent)
|
||||
: AttributeDialog(parent) {
|
||||
ui = new Ui::BoolAttributeDialog();
|
||||
ui->setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
AttributeEditor::set_attribute_label(ui->attribute_label);
|
||||
AttributeDialog::set_attribute_label(ui->attribute_label);
|
||||
|
||||
settings_setup_dialog_geometry(SETTING_bool_editor_geometry, this);
|
||||
settings_setup_dialog_geometry(SETTING_bool_attribute_dialog_geometry, this);
|
||||
}
|
||||
|
||||
BoolEditor::~BoolEditor() {
|
||||
BoolAttributeDialog::~BoolAttributeDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void BoolEditor::set_read_only(const bool read_only) {
|
||||
AttributeEditor::set_read_only(read_only);
|
||||
void BoolAttributeDialog::set_read_only(const bool read_only) {
|
||||
AttributeDialog::set_read_only(read_only);
|
||||
|
||||
ui->true_button->setEnabled(!read_only);
|
||||
ui->false_button->setEnabled(!read_only);
|
||||
ui->unset_button->setEnabled(!read_only);
|
||||
}
|
||||
|
||||
void BoolEditor::set_value_list(const QList<QByteArray> &values) {
|
||||
void BoolAttributeDialog::set_value_list(const QList<QByteArray> &values) {
|
||||
if (values.isEmpty()) {
|
||||
ui->unset_button->setChecked(true);
|
||||
} else {
|
||||
@ -65,7 +65,7 @@ void BoolEditor::set_value_list(const QList<QByteArray> &values) {
|
||||
}
|
||||
}
|
||||
|
||||
QList<QByteArray> BoolEditor::get_value_list() const {
|
||||
QList<QByteArray> BoolAttributeDialog::get_value_list() const {
|
||||
if (ui->unset_button->isChecked()) {
|
||||
return QList<QByteArray>();
|
||||
} else if (ui->true_button->isChecked()) {
|
@ -21,20 +21,20 @@
|
||||
#ifndef BOOL_EDITOR_H
|
||||
#define BOOL_EDITOR_H
|
||||
|
||||
#include "editors/attribute_editor.h"
|
||||
#include "attribute_dialogs/attribute_dialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class BoolEditor;
|
||||
class BoolAttributeDialog;
|
||||
}
|
||||
|
||||
class BoolEditor final : public AttributeEditor {
|
||||
class BoolAttributeDialog final : public AttributeDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ui::BoolEditor *ui;
|
||||
Ui::BoolAttributeDialog *ui;
|
||||
|
||||
BoolEditor(QWidget *parent);
|
||||
~BoolEditor();
|
||||
BoolAttributeDialog(QWidget *parent);
|
||||
~BoolAttributeDialog();
|
||||
|
||||
void set_read_only(const bool read_only) override;
|
||||
void set_value_list(const QList<QByteArray> &values) override;
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BoolEditor</class>
|
||||
<widget class="QDialog" name="BoolEditor">
|
||||
<class>BoolAttributeDialog</class>
|
||||
<widget class="QDialog" name="BoolAttributeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -59,7 +59,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>BoolEditor</receiver>
|
||||
<receiver>BoolAttributeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -75,7 +75,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>BoolEditor</receiver>
|
||||
<receiver>BoolAttributeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -18,42 +18,42 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "editors/datetime_editor.h"
|
||||
#include "editors/ui_datetime_editor.h"
|
||||
#include "attribute_dialogs/datetime_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_datetime_attribute_dialog.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "globals.h"
|
||||
#include "settings.h"
|
||||
|
||||
DateTimeEditor::DateTimeEditor(QWidget *parent)
|
||||
: AttributeEditor(parent) {
|
||||
ui = new Ui::DateTimeEditor();
|
||||
DatetimeAttributeDialog::DatetimeAttributeDialog(QWidget *parent)
|
||||
: AttributeDialog(parent) {
|
||||
ui = new Ui::DatetimeAttributeDialog();
|
||||
ui->setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
AttributeEditor::set_attribute_label(ui->attribute_label);
|
||||
AttributeDialog::set_attribute_label(ui->attribute_label);
|
||||
|
||||
settings_setup_dialog_geometry(SETTING_datetime_editor_geometry, this);
|
||||
settings_setup_dialog_geometry(SETTING_datetime_attribute_dialog_geometry, this);
|
||||
}
|
||||
|
||||
DateTimeEditor::~DateTimeEditor() {
|
||||
DatetimeAttributeDialog::~DatetimeAttributeDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DateTimeEditor::set_read_only(const bool read_only) {
|
||||
AttributeEditor::set_read_only(read_only);
|
||||
void DatetimeAttributeDialog::set_read_only(const bool read_only) {
|
||||
AttributeDialog::set_read_only(read_only);
|
||||
|
||||
ui->edit->setReadOnly(read_only);
|
||||
}
|
||||
|
||||
void DateTimeEditor::set_value_list(const QList<QByteArray> &values) {
|
||||
void DatetimeAttributeDialog::set_value_list(const QList<QByteArray> &values) {
|
||||
const QByteArray value = values.value(0, QByteArray());
|
||||
const QString value_string = QString(value);
|
||||
const QDateTime value_datetime = datetime_string_to_qdatetime(get_attribute(), value_string, g_adconfig);
|
||||
ui->edit->setDateTime(value_datetime);
|
||||
}
|
||||
|
||||
QList<QByteArray> DateTimeEditor::get_value_list() const {
|
||||
QList<QByteArray> DatetimeAttributeDialog::get_value_list() const {
|
||||
return QList<QByteArray>();
|
||||
}
|
@ -18,8 +18,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DATETIME_EDITOR_H
|
||||
#define DATETIME_EDITOR_H
|
||||
#ifndef DATETIME_ATTRIBUTE_DIALOG_H
|
||||
#define DATETIME_ATTRIBUTE_DIALOG_H
|
||||
|
||||
/**
|
||||
* Editor for datetimes. Note that this is read-only and get
|
||||
@ -27,24 +27,24 @@
|
||||
* attributes are read-only.
|
||||
*/
|
||||
|
||||
#include "editors/attribute_editor.h"
|
||||
#include "attribute_dialogs/attribute_dialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class DateTimeEditor;
|
||||
class DatetimeAttributeDialog;
|
||||
}
|
||||
|
||||
class DateTimeEditor final : public AttributeEditor {
|
||||
class DatetimeAttributeDialog final : public AttributeDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ui::DateTimeEditor *ui;
|
||||
Ui::DatetimeAttributeDialog *ui;
|
||||
|
||||
DateTimeEditor(QWidget *parent);
|
||||
~DateTimeEditor();
|
||||
DatetimeAttributeDialog(QWidget *parent);
|
||||
~DatetimeAttributeDialog();
|
||||
|
||||
void set_read_only(const bool read_only) override;
|
||||
void set_value_list(const QList<QByteArray> &values) override;
|
||||
QList<QByteArray> get_value_list() const override;
|
||||
};
|
||||
|
||||
#endif /* DATETIME_EDITOR_H */
|
||||
#endif /* DATETIME_ATTRIBUTE_DIALOG_H */
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DateTimeEditor</class>
|
||||
<widget class="QDialog" name="DateTimeEditor">
|
||||
<class>DatetimeAttributeDialog</class>
|
||||
<widget class="QDialog" name="DatetimeAttributeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -41,7 +41,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DateTimeEditor</receiver>
|
||||
<receiver>DatetimeAttributeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -57,7 +57,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DateTimeEditor</receiver>
|
||||
<receiver>DatetimeAttributeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
161
src/admc/attribute_dialogs/list_attribute_dialog.cpp
Normal file
161
src/admc/attribute_dialogs/list_attribute_dialog.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* ADMC - AD Management Center
|
||||
*
|
||||
* Copyright (C) 2020-2021 BaseALT Ltd.
|
||||
* Copyright (C) 2020-2021 Dmitry Degtyarev
|
||||
*
|
||||
* 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 "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_list_attribute_dialog.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "attribute_dialogs/bool_attribute_dialog.h"
|
||||
#include "attribute_dialogs/datetime_attribute_dialog.h"
|
||||
#include "attribute_dialogs/octet_attribute_dialog.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
|
||||
ListAttributeDialog::ListAttributeDialog(QWidget *parent)
|
||||
: AttributeDialog(parent) {
|
||||
ui = new Ui::ListAttributeDialog();
|
||||
ui->setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
AttributeDialog::set_attribute_label(ui->attribute_label);
|
||||
|
||||
settings_setup_dialog_geometry(SETTING_list_attribute_dialog_geometry, this);
|
||||
|
||||
connect(
|
||||
ui->add_button, &QAbstractButton::clicked,
|
||||
this, &ListAttributeDialog::on_add_button);
|
||||
connect(
|
||||
ui->remove_button, &QAbstractButton::clicked,
|
||||
this, &ListAttributeDialog::on_remove_button);
|
||||
}
|
||||
|
||||
ListAttributeDialog::~ListAttributeDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ListAttributeDialog::set_read_only(const bool read_only) {
|
||||
AttributeDialog::set_read_only(read_only);
|
||||
|
||||
ui->add_button->setVisible(!read_only);
|
||||
ui->remove_button->setVisible(!read_only);
|
||||
}
|
||||
|
||||
void ListAttributeDialog::on_add_button() {
|
||||
AttributeDialog *dialog = [this]() -> AttributeDialog * {
|
||||
const bool is_bool = (g_adconfig->get_attribute_type(get_attribute()) == AttributeType_Boolean);
|
||||
|
||||
if (is_bool) {
|
||||
return new BoolAttributeDialog(this);
|
||||
} else {
|
||||
return new StringAttributeDialog(this);
|
||||
}
|
||||
}();
|
||||
|
||||
dialog->set_attribute(get_attribute());
|
||||
dialog->set_value_list({});
|
||||
dialog->set_read_only(get_read_only());
|
||||
|
||||
dialog->open();
|
||||
|
||||
connect(
|
||||
dialog, &QDialog::accepted,
|
||||
[this, dialog]() {
|
||||
const QList<QByteArray> new_values = dialog->get_value_list();
|
||||
|
||||
if (!new_values.isEmpty()) {
|
||||
const QByteArray value = new_values[0];
|
||||
add_value(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ListAttributeDialog::on_remove_button() {
|
||||
const QList<QListWidgetItem *> selected = ui->list_widget->selectedItems();
|
||||
|
||||
for (const auto item : selected) {
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
void ListAttributeDialog::set_value_list(const QList<QByteArray> &values) {
|
||||
for (const QByteArray &value : values) {
|
||||
add_value(value);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QByteArray> ListAttributeDialog::get_value_list() const {
|
||||
QList<QByteArray> new_values;
|
||||
|
||||
for (int i = 0; i < ui->list_widget->count(); i++) {
|
||||
const QListWidgetItem *item = ui->list_widget->item(i);
|
||||
const QString new_value_string = item->text();
|
||||
const QByteArray new_value = string_to_bytes(new_value_string);
|
||||
|
||||
new_values.append(new_value);
|
||||
}
|
||||
|
||||
return new_values;
|
||||
}
|
||||
|
||||
void ListAttributeDialog::add_value(const QByteArray value) {
|
||||
const QString text = bytes_to_string(value);
|
||||
ui->list_widget->addItem(text);
|
||||
}
|
||||
|
||||
ListAttributeDialogType ListAttributeDialog::get_type() const {
|
||||
const AttributeType type = g_adconfig->get_attribute_type(get_attribute());
|
||||
|
||||
switch (type) {
|
||||
case AttributeType_Octet: return ListAttributeDialogType_Octet;
|
||||
case AttributeType_Sid: return ListAttributeDialogType_Octet;
|
||||
|
||||
case AttributeType_UTCTime: return ListAttributeDialogType_Datetime;
|
||||
case AttributeType_GeneralizedTime: return ListAttributeDialogType_Datetime;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return ListAttributeDialogType_String;
|
||||
}
|
||||
|
||||
QString ListAttributeDialog::bytes_to_string(const QByteArray bytes) const {
|
||||
const ListAttributeDialogType editor_type = get_type();
|
||||
switch (editor_type) {
|
||||
case ListAttributeDialogType_String: return QString(bytes);
|
||||
case ListAttributeDialogType_Octet: return octet_bytes_to_string(bytes, OctetDisplayFormat_Hexadecimal);
|
||||
case ListAttributeDialogType_Datetime: return QString(bytes);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QByteArray ListAttributeDialog::string_to_bytes(const QString string) const {
|
||||
const ListAttributeDialogType editor_type = get_type();
|
||||
|
||||
switch (editor_type) {
|
||||
case ListAttributeDialogType_String: return string.toUtf8();
|
||||
case ListAttributeDialogType_Octet: return octet_string_to_bytes(string, OctetDisplayFormat_Hexadecimal);
|
||||
case ListAttributeDialogType_Datetime: return string.toUtf8();
|
||||
}
|
||||
|
||||
return QByteArray();
|
||||
}
|
@ -18,31 +18,31 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MULTI_EDITOR_H
|
||||
#define MULTI_EDITOR_H
|
||||
#ifndef LIST_ATTRIBUTE_DIALOG_H
|
||||
#define LIST_ATTRIBUTE_DIALOG_H
|
||||
|
||||
#include "editors/attribute_editor.h"
|
||||
#include "attribute_dialogs/attribute_dialog.h"
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
enum MultiEditorType {
|
||||
MultiEditorType_String,
|
||||
MultiEditorType_Octet,
|
||||
MultiEditorType_Datetime,
|
||||
enum ListAttributeDialogType {
|
||||
ListAttributeDialogType_String,
|
||||
ListAttributeDialogType_Octet,
|
||||
ListAttributeDialogType_Datetime,
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class MultiEditor;
|
||||
class ListAttributeDialog;
|
||||
}
|
||||
|
||||
class MultiEditor final : public AttributeEditor {
|
||||
class ListAttributeDialog final : public AttributeDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ui::MultiEditor *ui;
|
||||
Ui::ListAttributeDialog *ui;
|
||||
|
||||
MultiEditor(QWidget *parent);
|
||||
~MultiEditor();
|
||||
ListAttributeDialog(QWidget *parent);
|
||||
~ListAttributeDialog();
|
||||
|
||||
void set_read_only(const bool read_only) override;
|
||||
|
||||
@ -55,9 +55,9 @@ private:
|
||||
void add_value(const QByteArray value);
|
||||
QString bytes_to_string(const QByteArray bytes) const;
|
||||
QByteArray string_to_bytes(const QString string) const;
|
||||
MultiEditorType get_editor_type() const;
|
||||
void add_values_from_editor(AttributeEditor *editor);
|
||||
void edit_values_from_editor(AttributeEditor *editor);
|
||||
ListAttributeDialogType get_type() const;
|
||||
void add_values_from_editor(AttributeDialog *editor);
|
||||
void edit_values_from_editor(AttributeDialog *editor);
|
||||
};
|
||||
|
||||
#endif /* MULTI_EDITOR_H */
|
||||
#endif /* LIST_ATTRIBUTE_DIALOG_H */
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MultiEditor</class>
|
||||
<widget class="QDialog" name="MultiEditor">
|
||||
<class>ListAttributeDialog</class>
|
||||
<widget class="QDialog" name="ListAttributeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -86,7 +86,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>MultiEditor</receiver>
|
||||
<receiver>ListAttributeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -102,7 +102,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>MultiEditor</receiver>
|
||||
<receiver>ListAttributeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -18,8 +18,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "editors/octet_editor.h"
|
||||
#include "editors/ui_octet_editor.h"
|
||||
#include "attribute_dialogs/octet_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_octet_attribute_dialog.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "globals.h"
|
||||
@ -36,59 +36,59 @@ OctetDisplayFormat current_format(QComboBox *format_combo);
|
||||
int format_base(const OctetDisplayFormat format);
|
||||
char *itoa(int value, char *result, int base);
|
||||
|
||||
OctetEditor::OctetEditor(QWidget *parent)
|
||||
: AttributeEditor(parent) {
|
||||
ui = new Ui::OctetEditor();
|
||||
OctetAttributeDialog::OctetAttributeDialog(QWidget *parent)
|
||||
: AttributeDialog(parent) {
|
||||
ui = new Ui::OctetAttributeDialog();
|
||||
ui->setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
AttributeEditor::set_attribute_label(ui->attribute_label);
|
||||
AttributeDialog::set_attribute_label(ui->attribute_label);
|
||||
|
||||
prev_format = OctetDisplayFormat_Hexadecimal;
|
||||
|
||||
const QFont fixed_font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
ui->edit->setFont(fixed_font);
|
||||
|
||||
settings_setup_dialog_geometry(SETTING_octet_editor_geometry, this);
|
||||
settings_setup_dialog_geometry(SETTING_octet_attribute_dialog_geometry, this);
|
||||
|
||||
connect(
|
||||
ui->format_combo, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &OctetEditor::on_format_combo);
|
||||
this, &OctetAttributeDialog::on_format_combo);
|
||||
}
|
||||
|
||||
OctetEditor::~OctetEditor() {
|
||||
OctetAttributeDialog::~OctetAttributeDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OctetEditor::set_read_only(const bool read_only) {
|
||||
AttributeEditor::set_read_only(read_only);
|
||||
void OctetAttributeDialog::set_read_only(const bool read_only) {
|
||||
AttributeDialog::set_read_only(read_only);
|
||||
|
||||
ui->edit->setReadOnly(read_only);
|
||||
}
|
||||
|
||||
QList<QByteArray> OctetEditor::get_value_list() const {
|
||||
QList<QByteArray> OctetAttributeDialog::get_value_list() const {
|
||||
const QString text = ui->edit->toPlainText();
|
||||
const QByteArray bytes = octet_string_to_bytes(text, current_format(ui->format_combo));
|
||||
|
||||
return {bytes};
|
||||
}
|
||||
|
||||
void OctetEditor::accept() {
|
||||
void OctetAttributeDialog::accept() {
|
||||
const bool input_ok = check_input(current_format(ui->format_combo));
|
||||
|
||||
if (input_ok) {
|
||||
AttributeEditor::accept();
|
||||
AttributeDialog::accept();
|
||||
}
|
||||
}
|
||||
|
||||
void OctetEditor::set_value_list(const QList<QByteArray> &values) {
|
||||
void OctetAttributeDialog::set_value_list(const QList<QByteArray> &values) {
|
||||
const QByteArray value = values.value(0, QByteArray());
|
||||
const QString value_string = octet_bytes_to_string(value, current_format(ui->format_combo));
|
||||
ui->edit->setPlainText(value_string);
|
||||
}
|
||||
|
||||
void OctetEditor::on_format_combo() {
|
||||
void OctetAttributeDialog::on_format_combo() {
|
||||
// Check that input is ok for previous format, otherwise
|
||||
// won't be able to convert it to new format
|
||||
const bool input_ok_for_prev_format = check_input(prev_format);
|
||||
@ -112,7 +112,7 @@ void OctetEditor::on_format_combo() {
|
||||
}
|
||||
}
|
||||
|
||||
bool OctetEditor::check_input(const OctetDisplayFormat format) {
|
||||
bool OctetAttributeDialog::check_input(const OctetDisplayFormat format) {
|
||||
const bool ok = [=]() {
|
||||
const QString text = ui->edit->toPlainText();
|
||||
|
@ -18,10 +18,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OCTET_EDITOR_H
|
||||
#define OCTET_EDITOR_H
|
||||
#ifndef OCTET_ATTRIBUTE_DIALOG_H
|
||||
#define OCTET_ATTRIBUTE_DIALOG_H
|
||||
|
||||
#include "editors/attribute_editor.h"
|
||||
#include "attribute_dialogs/attribute_dialog.h"
|
||||
|
||||
enum OctetDisplayFormat {
|
||||
OctetDisplayFormat_Hexadecimal = 0,
|
||||
@ -31,17 +31,17 @@ enum OctetDisplayFormat {
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class OctetEditor;
|
||||
class OctetAttributeDialog;
|
||||
}
|
||||
|
||||
class OctetEditor final : public AttributeEditor {
|
||||
class OctetAttributeDialog final : public AttributeDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ui::OctetEditor *ui;
|
||||
Ui::OctetAttributeDialog *ui;
|
||||
|
||||
OctetEditor(QWidget *parent);
|
||||
~OctetEditor();
|
||||
OctetAttributeDialog(QWidget *parent);
|
||||
~OctetAttributeDialog();
|
||||
|
||||
void set_read_only(const bool read_only) override;
|
||||
void set_value_list(const QList<QByteArray> &values) override;
|
||||
@ -58,4 +58,4 @@ private:
|
||||
QString octet_bytes_to_string(const QByteArray bytes, const OctetDisplayFormat format);
|
||||
QByteArray octet_string_to_bytes(const QString string, const OctetDisplayFormat format);
|
||||
|
||||
#endif /* OCTET_EDITOR_H */
|
||||
#endif /* OCTET_ATTRIBUTE_DIALOG_H */
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OctetEditor</class>
|
||||
<widget class="QDialog" name="OctetEditor">
|
||||
<class>OctetAttributeDialog</class>
|
||||
<widget class="QDialog" name="OctetAttributeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -65,7 +65,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>OctetEditor</receiver>
|
||||
<receiver>OctetAttributeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -81,7 +81,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>OctetEditor</receiver>
|
||||
<receiver>OctetAttributeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -18,32 +18,32 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "editors/string_editor.h"
|
||||
#include "editors/ui_string_editor.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_string_attribute_dialog.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
|
||||
StringEditor::StringEditor(QWidget *parent)
|
||||
: AttributeEditor(parent) {
|
||||
ui = new Ui::StringEditor();
|
||||
StringAttributeDialog::StringAttributeDialog(QWidget *parent)
|
||||
: AttributeDialog(parent) {
|
||||
ui = new Ui::StringAttributeDialog();
|
||||
ui->setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
AttributeEditor::set_attribute_label(ui->attribute_label);
|
||||
AttributeDialog::set_attribute_label(ui->attribute_label);
|
||||
|
||||
settings_setup_dialog_geometry(SETTING_multi_editor_geometry, this);
|
||||
settings_setup_dialog_geometry(SETTING_list_attribute_dialog_geometry, this);
|
||||
}
|
||||
|
||||
StringEditor::~StringEditor() {
|
||||
StringAttributeDialog::~StringAttributeDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void StringEditor::set_attribute(const QString &attribute) {
|
||||
AttributeEditor::set_attribute(attribute);
|
||||
void StringAttributeDialog::set_attribute(const QString &attribute) {
|
||||
AttributeDialog::set_attribute(attribute);
|
||||
|
||||
// Configure line edit based on attribute type
|
||||
if (g_adconfig->get_attribute_is_number(attribute)) {
|
||||
@ -53,19 +53,19 @@ void StringEditor::set_attribute(const QString &attribute) {
|
||||
limit_edit(ui->edit, attribute);
|
||||
}
|
||||
|
||||
void StringEditor::set_read_only(const bool read_only) {
|
||||
AttributeEditor::set_read_only(read_only);
|
||||
void StringAttributeDialog::set_read_only(const bool read_only) {
|
||||
AttributeDialog::set_read_only(read_only);
|
||||
|
||||
ui->edit->setReadOnly(read_only);
|
||||
}
|
||||
|
||||
void StringEditor::set_value_list(const QList<QByteArray> &values) {
|
||||
void StringAttributeDialog::set_value_list(const QList<QByteArray> &values) {
|
||||
const QByteArray value = values.value(0, QByteArray());
|
||||
const QString value_string = QString(value);
|
||||
ui->edit->setText(value_string);
|
||||
}
|
||||
|
||||
QList<QByteArray> StringEditor::get_value_list() const {
|
||||
QList<QByteArray> StringAttributeDialog::get_value_list() const {
|
||||
const QString new_value_string = ui->edit->text();
|
||||
|
||||
if (new_value_string.isEmpty()) {
|
@ -18,23 +18,23 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef STRING_EDITOR_H
|
||||
#define STRING_EDITOR_H
|
||||
#ifndef STRING_ATTRIBUTE_DIALOG_H
|
||||
#define STRING_ATTRIBUTE_DIALOG_H
|
||||
|
||||
#include "editors/attribute_editor.h"
|
||||
#include "attribute_dialogs/attribute_dialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class StringEditor;
|
||||
class StringAttributeDialog;
|
||||
}
|
||||
|
||||
class StringEditor final : public AttributeEditor {
|
||||
class StringAttributeDialog final : public AttributeDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Ui::StringEditor *ui;
|
||||
Ui::StringAttributeDialog *ui;
|
||||
|
||||
StringEditor(QWidget *parent);
|
||||
~StringEditor();
|
||||
StringAttributeDialog(QWidget *parent);
|
||||
~StringAttributeDialog();
|
||||
|
||||
void set_attribute(const QString &attribute) override;
|
||||
void set_read_only(const bool read_only) override;
|
||||
@ -42,4 +42,4 @@ public:
|
||||
QList<QByteArray> get_value_list() const override;
|
||||
};
|
||||
|
||||
#endif /* STRING_EDITOR_H */
|
||||
#endif /* STRING_ATTRIBUTE_DIALOG_H */
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>StringEditor</class>
|
||||
<widget class="QDialog" name="StringEditor">
|
||||
<class>StringAttributeDialog</class>
|
||||
<widget class="QDialog" name="StringAttributeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -41,7 +41,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>StringEditor</receiver>
|
||||
<receiver>StringAttributeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -57,7 +57,7 @@
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>StringEditor</receiver>
|
||||
<receiver>StringAttributeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -30,7 +30,7 @@
|
||||
#include "create_group_dialog.h"
|
||||
#include "create_ou_dialog.h"
|
||||
#include "create_user_dialog.h"
|
||||
#include "editors/multi_editor.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "find_object_dialog.h"
|
||||
#include "globals.h"
|
||||
#include "password_dialog.h"
|
||||
@ -726,15 +726,15 @@ void ObjectImpl::on_reset_password() {
|
||||
}
|
||||
|
||||
void ObjectImpl::on_edit_upn_suffixes() {
|
||||
auto dialog = new MultiEditor(console);
|
||||
auto dialog = new ListAttributeDialog(console);
|
||||
|
||||
AdInterface ad;
|
||||
if (ad_failed(ad)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Open editor for upn suffixes attribute of partitions
|
||||
// object
|
||||
// Open attribute dialog for upn suffixes attribute of
|
||||
// partitions object
|
||||
const QString partitions_dn = g_adconfig->partitions_dn();
|
||||
const AdObject partitions_object = ad.search_object(partitions_dn);
|
||||
const QList<QByteArray> current_values = partitions_object.get_values(ATTRIBUTE_UPN_SUFFIXES);
|
||||
|
@ -1,161 +0,0 @@
|
||||
/*
|
||||
* ADMC - AD Management Center
|
||||
*
|
||||
* Copyright (C) 2020-2021 BaseALT Ltd.
|
||||
* Copyright (C) 2020-2021 Dmitry Degtyarev
|
||||
*
|
||||
* 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 "editors/multi_editor.h"
|
||||
#include "editors/ui_multi_editor.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "editors/bool_editor.h"
|
||||
#include "editors/datetime_editor.h"
|
||||
#include "editors/octet_editor.h"
|
||||
#include "editors/string_editor.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
|
||||
MultiEditor::MultiEditor(QWidget *parent)
|
||||
: AttributeEditor(parent) {
|
||||
ui = new Ui::MultiEditor();
|
||||
ui->setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
AttributeEditor::set_attribute_label(ui->attribute_label);
|
||||
|
||||
settings_setup_dialog_geometry(SETTING_multi_editor_geometry, this);
|
||||
|
||||
connect(
|
||||
ui->add_button, &QAbstractButton::clicked,
|
||||
this, &MultiEditor::on_add_button);
|
||||
connect(
|
||||
ui->remove_button, &QAbstractButton::clicked,
|
||||
this, &MultiEditor::on_remove_button);
|
||||
}
|
||||
|
||||
MultiEditor::~MultiEditor() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MultiEditor::set_read_only(const bool read_only) {
|
||||
AttributeEditor::set_read_only(read_only);
|
||||
|
||||
ui->add_button->setVisible(!read_only);
|
||||
ui->remove_button->setVisible(!read_only);
|
||||
}
|
||||
|
||||
void MultiEditor::on_add_button() {
|
||||
AttributeEditor *editor = [this]() -> AttributeEditor * {
|
||||
const bool is_bool = (g_adconfig->get_attribute_type(get_attribute()) == AttributeType_Boolean);
|
||||
|
||||
if (is_bool) {
|
||||
return new BoolEditor(this);
|
||||
} else {
|
||||
return new StringEditor(this);
|
||||
}
|
||||
}();
|
||||
|
||||
editor->set_attribute(get_attribute());
|
||||
editor->set_value_list({});
|
||||
editor->set_read_only(get_read_only());
|
||||
|
||||
editor->open();
|
||||
|
||||
connect(
|
||||
editor, &QDialog::accepted,
|
||||
[this, editor]() {
|
||||
const QList<QByteArray> new_values = editor->get_value_list();
|
||||
|
||||
if (!new_values.isEmpty()) {
|
||||
const QByteArray value = new_values[0];
|
||||
add_value(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MultiEditor::on_remove_button() {
|
||||
const QList<QListWidgetItem *> selected = ui->list_widget->selectedItems();
|
||||
|
||||
for (const auto item : selected) {
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
void MultiEditor::set_value_list(const QList<QByteArray> &values) {
|
||||
for (const QByteArray &value : values) {
|
||||
add_value(value);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QByteArray> MultiEditor::get_value_list() const {
|
||||
QList<QByteArray> new_values;
|
||||
|
||||
for (int i = 0; i < ui->list_widget->count(); i++) {
|
||||
const QListWidgetItem *item = ui->list_widget->item(i);
|
||||
const QString new_value_string = item->text();
|
||||
const QByteArray new_value = string_to_bytes(new_value_string);
|
||||
|
||||
new_values.append(new_value);
|
||||
}
|
||||
|
||||
return new_values;
|
||||
}
|
||||
|
||||
void MultiEditor::add_value(const QByteArray value) {
|
||||
const QString text = bytes_to_string(value);
|
||||
ui->list_widget->addItem(text);
|
||||
}
|
||||
|
||||
MultiEditorType MultiEditor::get_editor_type() const {
|
||||
const AttributeType type = g_adconfig->get_attribute_type(get_attribute());
|
||||
|
||||
switch (type) {
|
||||
case AttributeType_Octet: return MultiEditorType_Octet;
|
||||
case AttributeType_Sid: return MultiEditorType_Octet;
|
||||
|
||||
case AttributeType_UTCTime: return MultiEditorType_Datetime;
|
||||
case AttributeType_GeneralizedTime: return MultiEditorType_Datetime;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return MultiEditorType_String;
|
||||
}
|
||||
|
||||
QString MultiEditor::bytes_to_string(const QByteArray bytes) const {
|
||||
const MultiEditorType editor_type = get_editor_type();
|
||||
switch (editor_type) {
|
||||
case MultiEditorType_String: return QString(bytes);
|
||||
case MultiEditorType_Octet: return octet_bytes_to_string(bytes, OctetDisplayFormat_Hexadecimal);
|
||||
case MultiEditorType_Datetime: return QString(bytes);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QByteArray MultiEditor::string_to_bytes(const QString string) const {
|
||||
const MultiEditorType editor_type = get_editor_type();
|
||||
|
||||
switch (editor_type) {
|
||||
case MultiEditorType_String: return string.toUtf8();
|
||||
case MultiEditorType_Octet: return octet_string_to_bytes(string, OctetDisplayFormat_Hexadecimal);
|
||||
case MultiEditorType_Datetime: return string.toUtf8();
|
||||
}
|
||||
|
||||
return QByteArray();
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
#include "edits/string_other_edit.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "editors/multi_editor.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "edits/string_edit.h"
|
||||
#include "globals.h"
|
||||
|
||||
@ -62,17 +62,17 @@ bool StringOtherEdit::apply(AdInterface &ad, const QString &dn) const {
|
||||
}
|
||||
|
||||
void StringOtherEdit::on_other_button() {
|
||||
auto editor = new MultiEditor(other_button);
|
||||
editor->set_read_only(read_only);
|
||||
editor->set_attribute(other_attribute);
|
||||
editor->set_value_list(other_values);
|
||||
auto dialog = new ListAttributeDialog(other_button);
|
||||
dialog->set_read_only(read_only);
|
||||
dialog->set_attribute(other_attribute);
|
||||
dialog->set_value_list(other_values);
|
||||
|
||||
editor->open();
|
||||
dialog->open();
|
||||
|
||||
connect(
|
||||
editor, &QDialog::accepted,
|
||||
[this, editor]() {
|
||||
other_values = editor->get_value_list();
|
||||
dialog, &QDialog::accepted,
|
||||
[this, dialog]() {
|
||||
other_values = dialog->get_value_list();
|
||||
|
||||
emit edited();
|
||||
});
|
||||
|
@ -84,11 +84,11 @@ DEFINE_SETTING(SETTING_filter_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_class_filter_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_logon_hours_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_logon_computers_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_bool_editor_geometry);
|
||||
DEFINE_SETTING(SETTING_datetime_editor_geometry);
|
||||
DEFINE_SETTING(SETTING_multi_editor_geometry);
|
||||
DEFINE_SETTING(SETTING_octet_editor_geometry);
|
||||
DEFINE_SETTING(SETTING_string_editor_geometry);
|
||||
DEFINE_SETTING(SETTING_bool_attribute_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_datetime_attribute_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_list_attribute_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_octet_attribute_dialog_geometry);
|
||||
DEFINE_SETTING(SETTING_string_attribute_dialog_geometry);
|
||||
|
||||
// Header state
|
||||
DEFINE_SETTING(SETTING_results_header);
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include "tabs/ui_attributes_tab.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "editors/bool_editor.h"
|
||||
#include "editors/datetime_editor.h"
|
||||
#include "editors/multi_editor.h"
|
||||
#include "editors/octet_editor.h"
|
||||
#include "editors/string_editor.h"
|
||||
#include "attribute_dialogs/bool_attribute_dialog.h"
|
||||
#include "attribute_dialogs/datetime_attribute_dialog.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/octet_attribute_dialog.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "globals.h"
|
||||
#include "settings.h"
|
||||
#include "tabs/attributes_tab_filter_menu.h"
|
||||
@ -172,18 +172,18 @@ void AttributesTab::view_attribute() {
|
||||
|
||||
const QString attribute = row[AttributesColumn_Name]->text();
|
||||
|
||||
AttributeEditor *editor = get_editor(attribute);
|
||||
AttributeDialog *dialog = get_attribute_dialog(attribute);
|
||||
|
||||
if (editor != nullptr) {
|
||||
if (dialog != nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QList<QByteArray> value_list = current[attribute];
|
||||
|
||||
editor->set_attribute(attribute);
|
||||
editor->set_value_list(value_list);
|
||||
editor->set_read_only(true);
|
||||
editor->open();
|
||||
dialog->set_attribute(attribute);
|
||||
dialog->set_value_list(value_list);
|
||||
dialog->set_read_only(true);
|
||||
dialog->open();
|
||||
}
|
||||
|
||||
void AttributesTab::edit_attribute() {
|
||||
@ -195,23 +195,23 @@ void AttributesTab::edit_attribute() {
|
||||
|
||||
const QString attribute = row[AttributesColumn_Name]->text();
|
||||
|
||||
AttributeEditor *editor = get_editor(attribute);
|
||||
AttributeDialog *dialog = get_attribute_dialog(attribute);
|
||||
|
||||
if (editor == nullptr) {
|
||||
if (dialog == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QList<QByteArray> value_list = current[attribute];
|
||||
|
||||
editor->set_attribute(attribute);
|
||||
editor->set_value_list(value_list);
|
||||
editor->set_read_only(false);
|
||||
editor->open();
|
||||
dialog->set_attribute(attribute);
|
||||
dialog->set_value_list(value_list);
|
||||
dialog->set_read_only(false);
|
||||
dialog->open();
|
||||
|
||||
connect(
|
||||
editor, &QDialog::accepted,
|
||||
[this, editor, row, attribute]() {
|
||||
const QList<QByteArray> new_value_list = editor->get_value_list();
|
||||
dialog, &QDialog::accepted,
|
||||
[this, dialog, row, attribute]() {
|
||||
const QList<QByteArray> new_value_list = dialog->get_value_list();
|
||||
|
||||
current[attribute] = new_value_list;
|
||||
load_row(row, attribute, new_value_list);
|
||||
@ -283,40 +283,40 @@ void AttributesTab::load_row(const QList<QStandardItem *> &row, const QString &a
|
||||
row[AttributesColumn_Type]->setText(type_display);
|
||||
}
|
||||
|
||||
// Select an appropriate editor by attribute type and by
|
||||
// whether attribute is single or multi valued
|
||||
AttributeEditor *AttributesTab::get_editor(const QString &attribute) {
|
||||
// Select an appropriate attribute dialog by attribute type
|
||||
// and by whether attribute is single or multi valued
|
||||
AttributeDialog *AttributesTab::get_attribute_dialog(const QString &attribute) {
|
||||
const bool single_valued = g_adconfig->get_attribute_is_single_valued(attribute);
|
||||
|
||||
// Single/multi valued logic is separated out of the
|
||||
// switch statement for better flow
|
||||
auto octet_editor = [&]() -> AttributeEditor * {
|
||||
auto octet_attribute_dialog = [&]() -> AttributeDialog * {
|
||||
if (single_valued) {
|
||||
return new OctetEditor(this);
|
||||
return new OctetAttributeDialog(this);
|
||||
} else {
|
||||
return new MultiEditor(this);
|
||||
return new ListAttributeDialog(this);
|
||||
}
|
||||
};
|
||||
|
||||
auto string_editor = [&]() -> AttributeEditor * {
|
||||
auto string_attribute_dialog = [&]() -> AttributeDialog * {
|
||||
if (single_valued) {
|
||||
return new StringEditor(this);
|
||||
return new StringAttributeDialog(this);
|
||||
} else {
|
||||
return new MultiEditor(this);
|
||||
return new ListAttributeDialog(this);
|
||||
}
|
||||
};
|
||||
|
||||
auto bool_editor = [&]() -> AttributeEditor * {
|
||||
auto bool_attribute_dialog = [&]() -> AttributeDialog * {
|
||||
if (single_valued) {
|
||||
return new BoolEditor(this);
|
||||
return new BoolAttributeDialog(this);
|
||||
} else {
|
||||
return new MultiEditor(this);
|
||||
return new ListAttributeDialog(this);
|
||||
}
|
||||
};
|
||||
|
||||
auto datetime_editor = [&]() -> AttributeEditor * {
|
||||
auto datetime_attribute_dialog = [&]() -> AttributeDialog * {
|
||||
if (single_valued) {
|
||||
return new DateTimeEditor(this);
|
||||
return new DatetimeAttributeDialog(this);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
@ -325,26 +325,26 @@ AttributeEditor *AttributesTab::get_editor(const QString &attribute) {
|
||||
const AttributeType type = g_adconfig->get_attribute_type(attribute);
|
||||
|
||||
switch (type) {
|
||||
case AttributeType_Octet: return octet_editor();
|
||||
case AttributeType_Sid: return octet_editor();
|
||||
case AttributeType_Octet: return octet_attribute_dialog();
|
||||
case AttributeType_Sid: return octet_attribute_dialog();
|
||||
|
||||
case AttributeType_Boolean: return bool_editor();
|
||||
case AttributeType_Boolean: return bool_attribute_dialog();
|
||||
|
||||
case AttributeType_Unicode: return string_editor();
|
||||
case AttributeType_StringCase: return string_editor();
|
||||
case AttributeType_DSDN: return string_editor();
|
||||
case AttributeType_IA5: return string_editor();
|
||||
case AttributeType_Teletex: return string_editor();
|
||||
case AttributeType_ObjectIdentifier: return string_editor();
|
||||
case AttributeType_Integer: return string_editor();
|
||||
case AttributeType_Enumeration: return string_editor();
|
||||
case AttributeType_LargeInteger: return string_editor();
|
||||
case AttributeType_UTCTime: return datetime_editor();
|
||||
case AttributeType_GeneralizedTime: return datetime_editor();
|
||||
case AttributeType_NTSecDesc: return string_editor();
|
||||
case AttributeType_Numeric: return string_editor();
|
||||
case AttributeType_Printable: return string_editor();
|
||||
case AttributeType_DNString: return string_editor();
|
||||
case AttributeType_Unicode: return string_attribute_dialog();
|
||||
case AttributeType_StringCase: return string_attribute_dialog();
|
||||
case AttributeType_DSDN: return string_attribute_dialog();
|
||||
case AttributeType_IA5: return string_attribute_dialog();
|
||||
case AttributeType_Teletex: return string_attribute_dialog();
|
||||
case AttributeType_ObjectIdentifier: return string_attribute_dialog();
|
||||
case AttributeType_Integer: return string_attribute_dialog();
|
||||
case AttributeType_Enumeration: return string_attribute_dialog();
|
||||
case AttributeType_LargeInteger: return string_attribute_dialog();
|
||||
case AttributeType_UTCTime: return datetime_attribute_dialog();
|
||||
case AttributeType_GeneralizedTime: return datetime_attribute_dialog();
|
||||
case AttributeType_NTSecDesc: return string_attribute_dialog();
|
||||
case AttributeType_Numeric: return string_attribute_dialog();
|
||||
case AttributeType_Printable: return string_attribute_dialog();
|
||||
case AttributeType_DNString: return string_attribute_dialog();
|
||||
|
||||
// NOTE: putting these here as confirmed to be unsupported
|
||||
case AttributeType_ReplicaLink: return nullptr;
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* Show attributes of target in a list. Allows
|
||||
* viewing/editing if possible via attribute editor dialogs.
|
||||
* viewing/editing if possible via attribute dialogs.
|
||||
*/
|
||||
|
||||
#include "tabs/properties_tab.h"
|
||||
@ -39,7 +39,7 @@ class QStandardItemModel;
|
||||
class QStandardItem;
|
||||
class AttributesTabProxy;
|
||||
class AttributesFilterDialog;
|
||||
class AttributeEditor;
|
||||
class AttributeDialog;
|
||||
|
||||
namespace Ui {
|
||||
class AttributesTab;
|
||||
@ -70,7 +70,7 @@ private:
|
||||
void view_attribute();
|
||||
void load_row(const QList<QStandardItem *> &row, const QString &attribute, const QList<QByteArray> &values);
|
||||
QList<QStandardItem *> get_selected_row() const;
|
||||
AttributeEditor *get_editor(const QString &attribute);
|
||||
AttributeDialog *get_attribute_dialog(const QString &attribute);
|
||||
};
|
||||
|
||||
#endif /* ATTRIBUTES_TAB_H */
|
||||
|
@ -21,11 +21,11 @@
|
||||
#include "tabs/attributes_tab_filter_menu.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "editors/bool_editor.h"
|
||||
#include "editors/datetime_editor.h"
|
||||
#include "editors/multi_editor.h"
|
||||
#include "editors/octet_editor.h"
|
||||
#include "editors/string_editor.h"
|
||||
#include "attribute_dialogs/bool_attribute_dialog.h"
|
||||
#include "attribute_dialogs/datetime_attribute_dialog.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/octet_attribute_dialog.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "globals.h"
|
||||
#include "settings.h"
|
||||
#include "utils.h"
|
||||
|
@ -21,11 +21,11 @@
|
||||
#include "tabs/attributes_tab_proxy.h"
|
||||
|
||||
#include "adldap.h"
|
||||
#include "editors/bool_editor.h"
|
||||
#include "editors/datetime_editor.h"
|
||||
#include "editors/multi_editor.h"
|
||||
#include "editors/octet_editor.h"
|
||||
#include "editors/string_editor.h"
|
||||
#include "attribute_dialogs/bool_attribute_dialog.h"
|
||||
#include "attribute_dialogs/datetime_attribute_dialog.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/octet_attribute_dialog.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "globals.h"
|
||||
#include "settings.h"
|
||||
#include "tabs/attributes_tab.h"
|
||||
|
@ -60,11 +60,11 @@ set(TEST_TARGETS
|
||||
admc_test_account_option_edit
|
||||
admc_test_gpoptions_edit
|
||||
admc_test_protect_deletion_edit
|
||||
admc_test_octet_editor
|
||||
admc_test_bool_editor
|
||||
admc_test_datetime_editor
|
||||
admc_test_string_editor
|
||||
admc_test_multi_editor
|
||||
admc_test_octet_attribute_dialog
|
||||
admc_test_bool_attribute_dialog
|
||||
admc_test_datetime_attribute_dialog
|
||||
admc_test_string_attribute_dialog
|
||||
admc_test_list_attribute_dialog
|
||||
admc_test_edit_query_item_widget
|
||||
admc_test_policy_results_widget
|
||||
admc_test_find_object_dialog
|
||||
|
@ -20,10 +20,10 @@
|
||||
|
||||
#include "admc_test_attributes_tab.h"
|
||||
|
||||
#include "editors/multi_editor.h"
|
||||
#include "editors/string_editor.h"
|
||||
#include "editors/ui_multi_editor.h"
|
||||
#include "editors/ui_string_editor.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_string_attribute_dialog.h"
|
||||
#include "tabs/ui_attributes_tab.h"
|
||||
|
||||
#include <QDialog>
|
||||
@ -166,22 +166,22 @@ void ADMCTestAttributesTab::apply() {
|
||||
navigate_until_object(view, "description", Qt::DisplayRole);
|
||||
edit_button->click();
|
||||
|
||||
auto multi_editor = attributes_tab->findChild<MultiEditor *>();
|
||||
QVERIFY(multi_editor);
|
||||
QVERIFY(QTest::qWaitForWindowExposed(multi_editor, 1000));
|
||||
auto list_attribute_dialog = attributes_tab->findChild<ListAttributeDialog *>();
|
||||
QVERIFY(list_attribute_dialog);
|
||||
QVERIFY(QTest::qWaitForWindowExposed(list_attribute_dialog, 1000));
|
||||
|
||||
QPushButton *add_button = multi_editor->ui->add_button;
|
||||
QPushButton *add_button = list_attribute_dialog->ui->add_button;
|
||||
add_button->click();
|
||||
|
||||
auto string_editor = multi_editor->findChild<StringEditor *>();
|
||||
QVERIFY(string_editor);
|
||||
QVERIFY(QTest::qWaitForWindowExposed(string_editor, 1000));
|
||||
auto string_attribute_dialog = list_attribute_dialog->findChild<StringAttributeDialog *>();
|
||||
QVERIFY(string_attribute_dialog);
|
||||
QVERIFY(QTest::qWaitForWindowExposed(string_attribute_dialog, 1000));
|
||||
|
||||
QLineEdit *string_editor_edit = string_editor->ui->edit;
|
||||
string_editor_edit->setText(correct_value);
|
||||
QLineEdit *string_attribute_dialog_edit = string_attribute_dialog->ui->edit;
|
||||
string_attribute_dialog_edit->setText(correct_value);
|
||||
|
||||
string_editor->accept();
|
||||
multi_editor->accept();
|
||||
string_attribute_dialog->accept();
|
||||
list_attribute_dialog->accept();
|
||||
|
||||
attributes_tab->apply(ad, dn);
|
||||
|
||||
|
@ -18,14 +18,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "admc_test_bool_editor.h"
|
||||
#include "admc_test_bool_attribute_dialog.h"
|
||||
|
||||
#include "editors/bool_editor.h"
|
||||
#include "editors/ui_bool_editor.h"
|
||||
#include "attribute_dialogs/bool_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_bool_attribute_dialog.h"
|
||||
|
||||
#include <QRadioButton>
|
||||
|
||||
void ADMCTestBoolEditor::initTestCase_data() {
|
||||
void ADMCTestBoolAttributeDialog::initTestCase_data() {
|
||||
QTest::addColumn<QString>("button_name");
|
||||
QTest::addColumn<QList<QByteArray>>("value");
|
||||
|
||||
@ -34,10 +34,10 @@ void ADMCTestBoolEditor::initTestCase_data() {
|
||||
QTest::newRow("unset") << "unset_button" << QList<QByteArray>();
|
||||
}
|
||||
|
||||
void ADMCTestBoolEditor::init() {
|
||||
void ADMCTestBoolAttributeDialog::init() {
|
||||
ADMCTest::init();
|
||||
|
||||
edit = new BoolEditor(parent_widget);
|
||||
edit = new BoolAttributeDialog(parent_widget);
|
||||
edit->set_attribute(ATTRIBUTE_DESCRIPTION);
|
||||
edit->set_value_list(QList<QByteArray>());
|
||||
edit->open();
|
||||
@ -54,18 +54,18 @@ void ADMCTestBoolEditor::init() {
|
||||
button = button_map[button_name];
|
||||
}
|
||||
|
||||
void ADMCTestBoolEditor::set_value_list() {
|
||||
void ADMCTestBoolAttributeDialog::set_value_list() {
|
||||
QFETCH_GLOBAL(QList<QByteArray>, value);
|
||||
|
||||
edit->set_value_list(value);
|
||||
QVERIFY(button->isChecked());
|
||||
}
|
||||
|
||||
void ADMCTestBoolEditor::get_value_list() {
|
||||
void ADMCTestBoolAttributeDialog::get_value_list() {
|
||||
QFETCH_GLOBAL(QList<QByteArray>, value);
|
||||
|
||||
button->click();
|
||||
QCOMPARE(edit->get_value_list(), value);
|
||||
}
|
||||
|
||||
QTEST_MAIN(ADMCTestBoolEditor)
|
||||
QTEST_MAIN(ADMCTestBoolAttributeDialog)
|
||||
|
@ -18,19 +18,19 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ADMC_TEST_BOOL_EDITOR_H
|
||||
#define ADMC_TEST_BOOL_EDITOR_H
|
||||
#ifndef ADMC_TEST_BOOL_ATTRIBUTE_DIALOG_H
|
||||
#define ADMC_TEST_BOOL_ATTRIBUTE_DIALOG_H
|
||||
|
||||
#include "admc_test.h"
|
||||
|
||||
class BoolEditor;
|
||||
class BoolAttributeDialog;
|
||||
class QRadioButton;
|
||||
|
||||
enum ADMCTestBoolEditorButton {
|
||||
ADMCTestBoolEditorButton_True
|
||||
enum ADMCTestBoolAttributeDialogButton {
|
||||
ADMCTestBoolAttributeDialogButton_True
|
||||
};
|
||||
|
||||
class ADMCTestBoolEditor : public ADMCTest {
|
||||
class ADMCTestBoolAttributeDialog : public ADMCTest {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
@ -41,8 +41,8 @@ private slots:
|
||||
void get_value_list();
|
||||
|
||||
private:
|
||||
BoolEditor *edit;
|
||||
BoolAttributeDialog *edit;
|
||||
QRadioButton *button;
|
||||
};
|
||||
|
||||
#endif /* ADMC_TEST_BOOL_EDITOR_H */
|
||||
#endif /* ADMC_TEST_BOOL_ATTRIBUTE_DIALOG_H */
|
||||
|
@ -18,17 +18,17 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "admc_test_datetime_editor.h"
|
||||
#include "admc_test_datetime_attribute_dialog.h"
|
||||
|
||||
#include "editors/datetime_editor.h"
|
||||
#include "editors/ui_datetime_editor.h"
|
||||
#include "attribute_dialogs/datetime_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_datetime_attribute_dialog.h"
|
||||
|
||||
#include <QDateTimeEdit>
|
||||
|
||||
void ADMCTestDateTimeEditor::init() {
|
||||
void ADMCTestDatetimeAttributeDialog::init() {
|
||||
ADMCTest::init();
|
||||
|
||||
edit = new DateTimeEditor(parent_widget);
|
||||
edit = new DatetimeAttributeDialog(parent_widget);
|
||||
edit->set_attribute(ATTRIBUTE_WHEN_CHANGED);
|
||||
edit->open();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
|
||||
@ -36,7 +36,7 @@ void ADMCTestDateTimeEditor::init() {
|
||||
datetime_edit = edit->ui->edit;
|
||||
}
|
||||
|
||||
void ADMCTestDateTimeEditor::set_value_list() {
|
||||
void ADMCTestDatetimeAttributeDialog::set_value_list() {
|
||||
edit->set_value_list({QByteArray("20210706131457.0Z")});
|
||||
const QDateTime correct_datetime = QDateTime(QDate(2021, 7, 6), QTime(13, 14, 57));
|
||||
QCOMPARE(datetime_edit->dateTime(), correct_datetime);
|
||||
@ -44,10 +44,10 @@ void ADMCTestDateTimeEditor::set_value_list() {
|
||||
|
||||
// NOTE: datetime edit always returns empty list, see
|
||||
// comment in it's source
|
||||
void ADMCTestDateTimeEditor::get_value_list() {
|
||||
void ADMCTestDatetimeAttributeDialog::get_value_list() {
|
||||
edit->set_value_list({QByteArray("20210706131457.0Z")});
|
||||
const QList<QByteArray> value_list = edit->get_value_list();
|
||||
QVERIFY(value_list.isEmpty());
|
||||
}
|
||||
|
||||
QTEST_MAIN(ADMCTestDateTimeEditor)
|
||||
QTEST_MAIN(ADMCTestDatetimeAttributeDialog)
|
||||
|
@ -23,10 +23,10 @@
|
||||
|
||||
#include "admc_test.h"
|
||||
|
||||
class DateTimeEditor;
|
||||
class DatetimeAttributeDialog;
|
||||
class QDateTimeEdit;
|
||||
|
||||
class ADMCTestDateTimeEditor : public ADMCTest {
|
||||
class ADMCTestDatetimeAttributeDialog : public ADMCTest {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
@ -36,7 +36,7 @@ private slots:
|
||||
void get_value_list();
|
||||
|
||||
private:
|
||||
DateTimeEditor *edit;
|
||||
DatetimeAttributeDialog *edit;
|
||||
QDateTimeEdit *datetime_edit;
|
||||
};
|
||||
|
||||
|
@ -18,12 +18,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "admc_test_multi_editor.h"
|
||||
#include "admc_test_list_attribute_dialog.h"
|
||||
|
||||
#include "editors/multi_editor.h"
|
||||
#include "editors/string_editor.h"
|
||||
#include "editors/ui_multi_editor.h"
|
||||
#include "editors/ui_string_editor.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_string_attribute_dialog.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
@ -31,10 +31,10 @@
|
||||
|
||||
const QList<QByteArray> test_value = {QByteArray("hello")};
|
||||
|
||||
void ADMCTestMultiEditor::init() {
|
||||
void ADMCTestListAttributeDialog::init() {
|
||||
ADMCTest::init();
|
||||
|
||||
edit = new MultiEditor(parent_widget);
|
||||
edit = new ListAttributeDialog(parent_widget);
|
||||
edit->set_attribute(ATTRIBUTE_DESCRIPTION);
|
||||
edit->open();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
|
||||
@ -44,39 +44,39 @@ void ADMCTestMultiEditor::init() {
|
||||
remove_button = edit->ui->remove_button;
|
||||
}
|
||||
|
||||
void ADMCTestMultiEditor::set_value_list_empty() {
|
||||
void ADMCTestListAttributeDialog::set_value_list_empty() {
|
||||
edit->set_value_list({});
|
||||
QCOMPARE(list_widget->count(), 0);
|
||||
}
|
||||
|
||||
void ADMCTestMultiEditor::set_value_list() {
|
||||
void ADMCTestListAttributeDialog::set_value_list() {
|
||||
edit->set_value_list(test_value);
|
||||
QListWidgetItem *item = list_widget->item(0);
|
||||
QVERIFY(item);
|
||||
QCOMPARE(item->text(), "hello");
|
||||
}
|
||||
|
||||
void ADMCTestMultiEditor::get_value_list() {
|
||||
void ADMCTestListAttributeDialog::get_value_list() {
|
||||
edit->set_value_list(test_value);
|
||||
const QList<QByteArray> current = edit->get_value_list();
|
||||
QCOMPARE(current, test_value);
|
||||
}
|
||||
|
||||
void ADMCTestMultiEditor::add() {
|
||||
void ADMCTestListAttributeDialog::add() {
|
||||
edit->set_value_list(test_value);
|
||||
|
||||
add_button->click();
|
||||
|
||||
auto string_editor = edit->findChild<StringEditor *>();
|
||||
QVERIFY(string_editor);
|
||||
auto string_attribute_dialog = edit->findChild<StringAttributeDialog *>();
|
||||
QVERIFY(string_attribute_dialog);
|
||||
|
||||
QLineEdit *line_edit = string_editor->ui->edit;
|
||||
QLineEdit *line_edit = string_attribute_dialog->ui->edit;
|
||||
|
||||
const QString new_value = "new value";
|
||||
|
||||
line_edit->setText(new_value);
|
||||
|
||||
string_editor->accept();
|
||||
string_attribute_dialog->accept();
|
||||
|
||||
QCOMPARE(list_widget->count(), 2);
|
||||
|
||||
@ -85,7 +85,7 @@ void ADMCTestMultiEditor::add() {
|
||||
QCOMPARE(added_item->text(), new_value);
|
||||
}
|
||||
|
||||
void ADMCTestMultiEditor::remove() {
|
||||
void ADMCTestListAttributeDialog::remove() {
|
||||
edit->set_value_list({
|
||||
QByteArray("first"),
|
||||
QByteArray("second"),
|
||||
@ -100,4 +100,4 @@ void ADMCTestMultiEditor::remove() {
|
||||
QCOMPARE(list_widget->item(1)->text(), "third");
|
||||
}
|
||||
|
||||
QTEST_MAIN(ADMCTestMultiEditor)
|
||||
QTEST_MAIN(ADMCTestListAttributeDialog)
|
||||
|
@ -23,11 +23,11 @@
|
||||
|
||||
#include "admc_test.h"
|
||||
|
||||
class MultiEditor;
|
||||
class ListAttributeDialog;
|
||||
class QListWidget;
|
||||
class QPushButton;
|
||||
|
||||
class ADMCTestMultiEditor : public ADMCTest {
|
||||
class ADMCTestListAttributeDialog : public ADMCTest {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
@ -40,7 +40,7 @@ private slots:
|
||||
void remove();
|
||||
|
||||
private:
|
||||
MultiEditor *edit;
|
||||
ListAttributeDialog *edit;
|
||||
QListWidget *list_widget;
|
||||
QPushButton *add_button;
|
||||
QPushButton *remove_button;
|
||||
|
@ -18,17 +18,17 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "admc_test_octet_editor.h"
|
||||
#include "admc_test_octet_attribute_dialog.h"
|
||||
|
||||
#include "editors/octet_editor.h"
|
||||
#include "editors/ui_octet_editor.h"
|
||||
#include "attribute_dialogs/octet_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_octet_attribute_dialog.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
const QList<QByteArray> value_bytes = {QByteArray("12345")};
|
||||
|
||||
void ADMCTestOctetEditor::initTestCase_data() {
|
||||
void ADMCTestOctetAttributeDialog::initTestCase_data() {
|
||||
QTest::addColumn<int>("index");
|
||||
QTest::addColumn<int>("other_index");
|
||||
QTest::addColumn<QString>("value");
|
||||
@ -40,10 +40,10 @@ void ADMCTestOctetEditor::initTestCase_data() {
|
||||
;
|
||||
}
|
||||
|
||||
void ADMCTestOctetEditor::init() {
|
||||
void ADMCTestOctetAttributeDialog::init() {
|
||||
ADMCTest::init();
|
||||
|
||||
edit = new OctetEditor(parent_widget);
|
||||
edit = new OctetAttributeDialog(parent_widget);
|
||||
edit->set_attribute(ATTRIBUTE_DESCRIPTION);
|
||||
edit->open();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
|
||||
@ -52,7 +52,7 @@ void ADMCTestOctetEditor::init() {
|
||||
text_edit = edit->ui->edit;
|
||||
}
|
||||
|
||||
void ADMCTestOctetEditor::display() {
|
||||
void ADMCTestOctetAttributeDialog::display() {
|
||||
QFETCH_GLOBAL(int, index);
|
||||
QFETCH_GLOBAL(QString, value);
|
||||
|
||||
@ -64,7 +64,7 @@ void ADMCTestOctetEditor::display() {
|
||||
|
||||
// Check that edit correctly converts formatted strings back
|
||||
// to bytes for each format
|
||||
void ADMCTestOctetEditor::get_value_list() {
|
||||
void ADMCTestOctetAttributeDialog::get_value_list() {
|
||||
QFETCH_GLOBAL(int, index);
|
||||
QFETCH_GLOBAL(QString, value);
|
||||
|
||||
@ -76,7 +76,7 @@ void ADMCTestOctetEditor::get_value_list() {
|
||||
QCOMPARE(edit->get_value_list(), value_bytes);
|
||||
}
|
||||
|
||||
void ADMCTestOctetEditor::handle_empty_value() {
|
||||
void ADMCTestOctetAttributeDialog::handle_empty_value() {
|
||||
QFETCH_GLOBAL(int, index);
|
||||
QFETCH_GLOBAL(int, other_index);
|
||||
QFETCH_GLOBAL(QString, value);
|
||||
@ -96,7 +96,7 @@ void ADMCTestOctetEditor::handle_empty_value() {
|
||||
|
||||
// Check that when incorrectly formatted value is entered,
|
||||
// edit fails to switch to different format
|
||||
void ADMCTestOctetEditor::handle_incorrect_input() {
|
||||
void ADMCTestOctetAttributeDialog::handle_incorrect_input() {
|
||||
QFETCH_GLOBAL(int, index);
|
||||
QFETCH_GLOBAL(int, other_index);
|
||||
QFETCH_GLOBAL(QString, value);
|
||||
@ -114,4 +114,4 @@ void ADMCTestOctetEditor::handle_incorrect_input() {
|
||||
QCOMPARE(format_combo->currentIndex(), index);
|
||||
}
|
||||
|
||||
QTEST_MAIN(ADMCTestOctetEditor)
|
||||
QTEST_MAIN(ADMCTestOctetAttributeDialog)
|
||||
|
@ -23,11 +23,11 @@
|
||||
|
||||
#include "admc_test.h"
|
||||
|
||||
class OctetEditor;
|
||||
class OctetAttributeDialog;
|
||||
class QComboBox;
|
||||
class QPlainTextEdit;
|
||||
|
||||
class ADMCTestOctetEditor : public ADMCTest {
|
||||
class ADMCTestOctetAttributeDialog : public ADMCTest {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
@ -40,7 +40,7 @@ private slots:
|
||||
void handle_incorrect_input();
|
||||
|
||||
private:
|
||||
OctetEditor *edit;
|
||||
OctetAttributeDialog *edit;
|
||||
QComboBox *format_combo;
|
||||
QPlainTextEdit *text_edit;
|
||||
};
|
||||
|
@ -18,17 +18,17 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "admc_test_string_editor.h"
|
||||
#include "admc_test_string_attribute_dialog.h"
|
||||
|
||||
#include "editors/string_editor.h"
|
||||
#include "editors/ui_string_editor.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_string_attribute_dialog.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
void ADMCTestStringEditor::init() {
|
||||
void ADMCTestStringAttributeDialog::init() {
|
||||
ADMCTest::init();
|
||||
|
||||
edit = new StringEditor(parent_widget);
|
||||
edit = new StringAttributeDialog(parent_widget);
|
||||
edit->set_attribute(ATTRIBUTE_NAME);
|
||||
edit->open();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(edit, 1000));
|
||||
@ -36,21 +36,21 @@ void ADMCTestStringEditor::init() {
|
||||
line_edit = edit->ui->edit;
|
||||
}
|
||||
|
||||
void ADMCTestStringEditor::set_value_list_empty() {
|
||||
void ADMCTestStringAttributeDialog::set_value_list_empty() {
|
||||
edit->set_value_list({});
|
||||
QVERIFY(line_edit->text().isEmpty());
|
||||
}
|
||||
|
||||
void ADMCTestStringEditor::set_value_list() {
|
||||
void ADMCTestStringAttributeDialog::set_value_list() {
|
||||
edit->set_value_list({QByteArray("hello")});
|
||||
QCOMPARE(line_edit->text(), "hello");
|
||||
}
|
||||
|
||||
void ADMCTestStringEditor::get_value_list() {
|
||||
void ADMCTestStringAttributeDialog::get_value_list() {
|
||||
const QList<QByteArray> correct_value_list = {QByteArray("hello")};
|
||||
edit->set_value_list(correct_value_list);
|
||||
const QList<QByteArray> value_list = edit->get_value_list();
|
||||
QCOMPARE(correct_value_list, value_list);
|
||||
}
|
||||
|
||||
QTEST_MAIN(ADMCTestStringEditor)
|
||||
QTEST_MAIN(ADMCTestStringAttributeDialog)
|
||||
|
@ -23,10 +23,10 @@
|
||||
|
||||
#include "admc_test.h"
|
||||
|
||||
class StringEditor;
|
||||
class StringAttributeDialog;
|
||||
class QLineEdit;
|
||||
|
||||
class ADMCTestStringEditor : public ADMCTest {
|
||||
class ADMCTestStringAttributeDialog : public ADMCTest {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
@ -37,7 +37,7 @@ private slots:
|
||||
void get_value_list();
|
||||
|
||||
private:
|
||||
StringEditor *edit;
|
||||
StringAttributeDialog *edit;
|
||||
QLineEdit *line_edit;
|
||||
};
|
||||
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include "admc_test_string_other_edit.h"
|
||||
|
||||
#include "editors/multi_editor.h"
|
||||
#include "editors/string_editor.h"
|
||||
#include "editors/ui_multi_editor.h"
|
||||
#include "attribute_dialogs/list_attribute_dialog.h"
|
||||
#include "attribute_dialogs/string_attribute_dialog.h"
|
||||
#include "attribute_dialogs/ui_list_attribute_dialog.h"
|
||||
#include "edits/string_other_edit.h"
|
||||
|
||||
#include <QFormLayout>
|
||||
@ -92,10 +92,10 @@ void ADMCTestStringOtherEdit::load() {
|
||||
|
||||
other_button->click();
|
||||
|
||||
auto multi_editor = parent_widget->findChild<MultiEditor *>();
|
||||
QVERIFY(multi_editor);
|
||||
auto list_attribute_dialog = parent_widget->findChild<ListAttributeDialog *>();
|
||||
QVERIFY(list_attribute_dialog);
|
||||
|
||||
auto list_widget = multi_editor->findChild<QListWidget *>();
|
||||
auto list_widget = list_attribute_dialog->findChild<QListWidget *>();
|
||||
QVERIFY(list_widget);
|
||||
|
||||
QCOMPARE(line_edit->text(), main_value);
|
||||
@ -145,23 +145,23 @@ void ADMCTestStringOtherEdit::apply_modified_other_value() {
|
||||
void ADMCTestStringOtherEdit::add_new_other_value() {
|
||||
other_button->click();
|
||||
|
||||
auto multi_editor = parent_widget->findChild<MultiEditor *>();
|
||||
QVERIFY(multi_editor);
|
||||
auto list_attribute_dialog = parent_widget->findChild<ListAttributeDialog *>();
|
||||
QVERIFY(list_attribute_dialog);
|
||||
|
||||
QPushButton *add_button = multi_editor->ui->add_button;
|
||||
QPushButton *add_button = list_attribute_dialog->ui->add_button;
|
||||
add_button->click();
|
||||
|
||||
auto string_editor = multi_editor->findChild<StringEditor *>();
|
||||
QVERIFY(string_editor);
|
||||
auto string_attribute_dialog = list_attribute_dialog->findChild<StringAttributeDialog *>();
|
||||
QVERIFY(string_attribute_dialog);
|
||||
|
||||
auto string_editor_line_edit = string_editor->findChild<QLineEdit *>();
|
||||
QVERIFY(string_editor_line_edit);
|
||||
auto string_attribute_dialog_line_edit = string_attribute_dialog->findChild<QLineEdit *>();
|
||||
QVERIFY(string_attribute_dialog_line_edit);
|
||||
|
||||
string_editor_line_edit->setText(new_value);
|
||||
string_attribute_dialog_line_edit->setText(new_value);
|
||||
|
||||
string_editor->accept();
|
||||
string_attribute_dialog->accept();
|
||||
|
||||
multi_editor->accept();
|
||||
list_attribute_dialog->accept();
|
||||
}
|
||||
|
||||
QTEST_MAIN(ADMCTestStringOtherEdit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user