1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-23 22:03:54 +03:00

rename to select base widget

This commit is contained in:
Dmitry Degtyarev 2021-05-27 16:21:57 +04:00
parent 5851b346b3
commit ce371882c8
17 changed files with 70 additions and 70 deletions

View File

@ -77,7 +77,7 @@ cd BUILD
%_bindir/admc_test_country_edit
%_bindir/admc_test_gplink
%_bindir/admc_test_ad_interface
%_bindir/admc_test_search_base_widget
%_bindir/admc_test_select_base_widget
%_bindir/admc_test_filter_widget
%changelog

View File

@ -81,7 +81,7 @@ set(ADMC_SOURCES
filter_widget/filter_widget_advanced_tab.cpp
filter_widget/select_classes_widget.cpp
filter_widget/filter_builder.cpp
filter_widget/search_base_widget.cpp
filter_widget/select_base_widget.cpp
tabs/properties_tab.cpp
tabs/general_tab.cpp

View File

@ -1414,9 +1414,9 @@
</message>
</context>
<context>
<name>SearchBaseWidget</name>
<name>SelectBaseWidget</name>
<message>
<location filename="filter_widget/search_base_widget.cpp" line="52"/>
<location filename="filter_widget/select_base_widget.cpp" line="52"/>
<source>Browse</source>
<translation></translation>
</message>

View File

@ -1417,9 +1417,9 @@
</message>
</context>
<context>
<name>SearchBaseWidget</name>
<name>SelectBaseWidget</name>
<message>
<location filename="filter_widget/search_base_widget.cpp" line="52"/>
<location filename="filter_widget/select_base_widget.cpp" line="52"/>
<source>Browse</source>
<translation>Выбор</translation>
</message>

View File

@ -148,7 +148,7 @@ void console_query_item_load(QStandardItem *scope_item, const QList<QStandardIte
item->setData(description, QueryItemRole_Description);
item->setData(filter, QueryItemRole_Filter);
item->setData(filter_state, QueryItemRole_FilterState);
item->setData(base, QueryItemRole_SearchBase);
item->setData(base, QueryItemRole_Base);
item->setData(scope_is_children, QueryItemRole_ScopeIsChildren);
item->setIcon(QIcon::fromTheme("emblem-system"));
};
@ -175,7 +175,7 @@ void console_query_item_create(ConsoleWidget *console, const QString &name, cons
void console_query_item_fetch(ConsoleWidget *console, const QModelIndex &index) {
const QString filter = index.data(QueryItemRole_Filter).toString();
const QString base = index.data(QueryItemRole_SearchBase).toString();
const QString base = index.data(QueryItemRole_Base).toString();
const QList<QString> search_attributes = console_object_search_attributes();
const SearchScope scope =
[&]() {
@ -488,7 +488,7 @@ void console_query_move(ConsoleWidget *console, const QList<QPersistentModelInde
const QString description = index.data(QueryItemRole_Description).toString();
const QString filter = index.data(QueryItemRole_Filter).toString();
const QByteArray filter_state = index.data(QueryItemRole_FilterState).toByteArray();
const QString base = index.data(QueryItemRole_SearchBase).toString();
const QString base = index.data(QueryItemRole_Base).toString();
const QString name = index.data(Qt::DisplayRole).toString();
const bool scope_is_children = index.data(QueryItemRole_ScopeIsChildren).toBool();
@ -608,7 +608,7 @@ void console_query_paste(ConsoleWidget *console) {
QHash<QString, QVariant> console_query_item_save(const QModelIndex &index) {
const QString name = index.data(Qt::DisplayRole).toString();
const QString description = index.data(QueryItemRole_Description).toString();
const QString base = index.data(QueryItemRole_SearchBase).toString();
const QString base = index.data(QueryItemRole_Base).toString();
const QString filter = index.data(QueryItemRole_Filter).toString();
const QByteArray filter_state = index.data(QueryItemRole_FilterState).toByteArray();
const bool scope_is_children = index.data(QueryItemRole_ScopeIsChildren).toBool();

View File

@ -36,7 +36,7 @@ enum QueryItemRole {
QueryItemRole_Description = ConsoleRole_LAST + 1,
QueryItemRole_Filter = ConsoleRole_LAST + 2,
QueryItemRole_FilterState = ConsoleRole_LAST + 3,
QueryItemRole_SearchBase = ConsoleRole_LAST + 4,
QueryItemRole_Base = ConsoleRole_LAST + 4,
QueryItemRole_ScopeIsChildren = ConsoleRole_LAST + 5,
QueryItemRole_LAST = ConsoleRole_LAST + 7,

View File

@ -23,7 +23,7 @@
#include "status.h"
#include "globals.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/search_base_widget.h"
#include "filter_widget/select_base_widget.h"
#include "console_types/console_query.h"
#include <QLineEdit>

View File

@ -27,7 +27,7 @@
class QLineEdit;
class FilterWidget;
class SearchBaseWidget;
class SelectBaseWidget;
class ConsoleWidget;
class EditQueryFolderDialog : public QDialog {

View File

@ -22,7 +22,7 @@
#include "ad_filter.h"
#include "console_types/console_query.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/search_base_widget.h"
#include "filter_widget/select_base_widget.h"
#include <QLineEdit>
#include <QTextEdit>
@ -38,7 +38,7 @@ EditQueryItemWidget::EditQueryItemWidget()
{
setMinimumWidth(400);
search_base_widget = new SearchBaseWidget();
select_base_widget = new SelectBaseWidget();
filter_widget = new FilterWidget(filter_classes);
@ -68,7 +68,7 @@ EditQueryItemWidget::EditQueryItemWidget()
auto form_layout = new QFormLayout();
form_layout->addRow(tr("Name:"), name_edit);
form_layout->addRow(tr("Description:"), description_edit);
form_layout->addRow(tr("Search in:"), search_base_widget);
form_layout->addRow(tr("Search in:"), select_base_widget);
form_layout->addRow(scope_checkbox);
form_layout->addRow(new QLabel(tr("Filter:")));
form_layout->addRow(filter_display);
@ -98,10 +98,10 @@ void EditQueryItemWidget::load(const QModelIndex &index) {
QHash<QString, QVariant> state;
filter_state_stream >> state;
const QHash<QString, QVariant> search_base_widget_state = state["search_base_widget"].toHash();
const QHash<QString, QVariant> select_base_widget_state = state["select_base_widget"].toHash();
const QHash<QString, QVariant> filter_widget_state = state["filter_widget"].toHash();
search_base_widget->load_state(search_base_widget_state);
select_base_widget->load_state(select_base_widget_state);
filter_widget->load_state(filter_widget_state);
update_filter_display();
@ -120,19 +120,19 @@ void EditQueryItemWidget::save(QString &name, QString &description, QString &fil
name = name_edit->text();
description = description_edit->text();
filter = filter_widget->get_filter();
base = search_base_widget->get_base();
base = select_base_widget->get_base();
scope_is_children = !scope_checkbox->isChecked();
filter_state =
[&]() {
QHash<QString, QVariant> search_base_widget_state;
QHash<QString, QVariant> select_base_widget_state;
QHash<QString, QVariant> filter_widget_state;
search_base_widget->save_state(search_base_widget_state);
select_base_widget->save_state(select_base_widget_state);
filter_widget->save_state(filter_widget_state);
QHash<QString, QVariant> state;
state["search_base_widget"] = search_base_widget_state;
state["select_base_widget"] = select_base_widget_state;
state["filter_widget"] = filter_widget_state;
state["filter"] = filter;

View File

@ -32,7 +32,7 @@
class QLineEdit;
class QTextEdit;
class FilterWidget;
class SearchBaseWidget;
class SelectBaseWidget;
class QCheckBox;
class EditQueryItemWidget : public QWidget {
@ -49,7 +49,7 @@ private:
QLineEdit *description_edit;
QTextEdit *filter_display;
FilterWidget *filter_widget;
SearchBaseWidget *search_base_widget;
SelectBaseWidget *select_base_widget;
QCheckBox *scope_checkbox;
void update_filter_display();

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filter_widget/search_base_widget.h"
#include "filter_widget/select_base_widget.h"
#include "adldap.h"
#include "globals.h"
@ -29,7 +29,7 @@
// TODO: missing "Entire directory" in search base combo. Not 100% sure what it's supposed to be, the tippy-top domain? Definitely need it for work with multiple domains.
SearchBaseWidget::SearchBaseWidget(const QString &default_base)
SelectBaseWidget::SelectBaseWidget(const QString &default_base)
: QWidget()
{
const QString domain_head = g_adconfig->domain_head();
@ -64,17 +64,17 @@ SearchBaseWidget::SearchBaseWidget(const QString &default_base)
connect(
browse_button, &QAbstractButton::clicked,
this, &SearchBaseWidget::browse);
this, &SelectBaseWidget::browse);
}
QString SearchBaseWidget::get_base() const {
QString SelectBaseWidget::get_base() const {
const int index = combo->currentIndex();
const QVariant item_data = combo->itemData(index);
return item_data.toString();
}
void SearchBaseWidget::browse() {
void SelectBaseWidget::browse() {
auto dialog = new SelectContainerDialog(this);
connect(
@ -93,12 +93,12 @@ void SearchBaseWidget::browse() {
dialog->open();
}
void SearchBaseWidget::save_state(QHash<QString, QVariant> &state) const {
void SelectBaseWidget::save_state(QHash<QString, QVariant> &state) const {
const QString base = combo->currentData().toString();
state["base"] = QVariant(base);
}
void SearchBaseWidget::load_state(const QHash<QString, QVariant> &state) {
void SelectBaseWidget::load_state(const QHash<QString, QVariant> &state) {
const QString base = state["base"].toString();
const QString base_name = dn_get_name(base);
combo->clear();

View File

@ -17,8 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEARCH_BASE_WIDGET_H
#define SEARCH_BASE_WIDGET_H
#ifndef SELECT_BASE_WIDGET_H
#define SELECT_BASE_WIDGET_H
/**
* Allows user to select a search base object.
@ -29,11 +29,11 @@
class QComboBox;
class QString;
class SearchBaseWidget final : public QWidget {
class SelectBaseWidget final : public QWidget {
Q_OBJECT
public:
SearchBaseWidget(const QString &default_base = QString());
SelectBaseWidget(const QString &default_base = QString());
QString get_base() const;
@ -46,4 +46,4 @@ private:
void browse();
};
#endif /* SEARCH_BASE_WIDGET_H */
#endif /* SELECT_BASE_WIDGET_H */

View File

@ -24,7 +24,7 @@
#include "settings.h"
#include "utils.h"
#include "filter_widget/filter_widget.h"
#include "filter_widget/search_base_widget.h"
#include "filter_widget/select_base_widget.h"
#include "find_results.h"
#include "search_thread.h"
#include "console_types/console_object.h"
@ -39,7 +39,7 @@
FindWidget::FindWidget(const QList<QString> classes, const QString &default_base)
: QWidget()
{
search_base_widget = new SearchBaseWidget(default_base);
select_base_widget = new SelectBaseWidget(default_base);
filter_widget = new FilterWidget(classes);
@ -56,8 +56,8 @@ FindWidget::FindWidget(const QList<QString> classes, const QString &default_base
filter_widget_frame->setFrameShape(QFrame::Box);
{
auto search_base_layout = new QFormLayout();
search_base_layout->addRow(tr("Search in:"), search_base_widget);
auto select_base_layout = new QFormLayout();
select_base_layout->addRow(tr("Search in:"), select_base_widget);
auto buttons_layout = new QHBoxLayout();
buttons_layout->addWidget(find_button);
@ -66,7 +66,7 @@ FindWidget::FindWidget(const QList<QString> classes, const QString &default_base
auto layout = new QVBoxLayout();
filter_widget_frame->setLayout(layout);
layout->addLayout(search_base_layout);
layout->addLayout(select_base_layout);
layout->addWidget(filter_widget);
layout->addLayout(buttons_layout);
}
@ -101,7 +101,7 @@ FindWidget::FindWidget(const QList<QString> classes, const QString &default_base
void FindWidget::find() {
// Prepare search args
const QString filter = filter_widget->get_filter();
const QString base = search_base_widget->get_base();
const QString base = select_base_widget->get_base();
const QList<QString> search_attributes = console_object_search_attributes();
auto find_thread = new SearchThread(base, SearchScope_All, filter, search_attributes);

View File

@ -33,7 +33,7 @@ class FindResults;
class QStandardItem;
class QPushButton;
class AdObject;
class SearchBaseWidget;
class SelectBaseWidget;
template <typename T> class QList;
template <typename K, typename V> class QHash;
@ -59,7 +59,7 @@ private:
FilterWidget *filter_widget;
QPushButton *find_button;
QPushButton *stop_button;
SearchBaseWidget *search_base_widget;
SelectBaseWidget *select_base_widget;
};
#endif /* FIND_WIDGET_H */

View File

@ -39,7 +39,7 @@ set(TEST_TARGETS
admc_test_string_edit
admc_test_country_edit
admc_test_gplink
admc_test_search_base_widget
admc_test_select_base_widget
admc_test_filter_widget
)

View File

@ -17,9 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admc_test_search_base_widget.h"
#include "admc_test_select_base_widget.h"
#include "filter_widget/search_base_widget.h"
#include "filter_widget/select_base_widget.h"
#include "console_types/console_object.h"
#include "select_container_dialog.h"
#include "globals.h"
@ -29,22 +29,22 @@
#include <QPushButton>
#include <QTreeView>
void ADMCTestSearchBaseWidget::init() {
void ADMCTestSelectBaseWidget::init() {
ADMCTest::init();
search_base_widget = new SearchBaseWidget();
select_base_widget = new SelectBaseWidget();
auto layout = new QVBoxLayout();
parent_widget->setLayout(layout);
layout->addWidget(search_base_widget);
layout->addWidget(select_base_widget);
parent_widget->show();
QVERIFY(QTest::qWaitForWindowExposed(parent_widget, 1000));
combo = search_base_widget->findChild<QComboBox *>();
combo = select_base_widget->findChild<QComboBox *>();
QVERIFY(combo != nullptr);
browse_button = search_base_widget->findChild<QPushButton *>();
browse_button = select_base_widget->findChild<QPushButton *>();
QVERIFY(browse_button != nullptr);
// Create test OU's
@ -65,40 +65,40 @@ void ADMCTestSearchBaseWidget::init() {
}
// By default, domain head should be selected
void ADMCTestSearchBaseWidget::default_to_domain_head() {
void ADMCTestSelectBaseWidget::default_to_domain_head() {
const QString domain_head = g_adconfig->domain_head();
const QString base = search_base_widget->get_base();
const QString base = select_base_widget->get_base();
QVERIFY(base == domain_head);
}
// After selecting a search base, the widget should return
// the DN of selected search base
void ADMCTestSearchBaseWidget::select_base() {
void ADMCTestSelectBaseWidget::select_base() {
const QString select_dn = dn_list[0];
add_base(select_dn);
const QString base = search_base_widget->get_base();
const QString base = select_base_widget->get_base();
QVERIFY(base == select_dn);
}
// Adding multiple search bases to combo box, then selecting
// one of them in the combobox should make the widget return
// that search base.
void ADMCTestSearchBaseWidget::select_base_multiple() {
void ADMCTestSelectBaseWidget::select_base_multiple() {
for (const QString &dn : dn_list) {
add_base(dn);
}
// Alpha is at index 1 in the combo (0 is domain)
combo->setCurrentIndex(1);
const QString base = search_base_widget->get_base();
const QString base = select_base_widget->get_base();
QVERIFY(base == dn_list[0]);
}
void ADMCTestSearchBaseWidget::add_base(const QString &dn) {
void ADMCTestSelectBaseWidget::add_base(const QString &dn) {
browse_button->click();
auto select_container_dialog = search_base_widget->findChild<SelectContainerDialog *>();
auto select_container_dialog = select_base_widget->findChild<SelectContainerDialog *>();
QVERIFY(select_container_dialog != nullptr);
QVERIFY(QTest::qWaitForWindowExposed(select_container_dialog, 1000));
@ -107,7 +107,7 @@ void ADMCTestSearchBaseWidget::add_base(const QString &dn) {
navigate_until_object(select_container_view, dn, ContainerRole_DN);
QTest::keyClick(QApplication::focusWidget(), Qt::Key_Enter);
QVERIFY(QTest::qWaitForWindowExposed(search_base_widget, 1000));
QVERIFY(QTest::qWaitForWindowExposed(select_base_widget, 1000));
// NOTE: have to delete manually, dialog deletes itself
// on close a bit late which causes consecutive add_base()
@ -115,29 +115,29 @@ void ADMCTestSearchBaseWidget::add_base(const QString &dn) {
delete select_container_dialog;
}
void ADMCTestSearchBaseWidget::save_state() {
void ADMCTestSelectBaseWidget::save_state() {
// Setup some state
for (const QString &dn : dn_list) {
add_base(dn);
}
combo->setCurrentIndex(1);
const QString base_original = search_base_widget->get_base();
const QString base_original = select_base_widget->get_base();
// Serialize
QHash<QString, QVariant> state;
search_base_widget->save_state(state);
select_base_widget->save_state(state);
// Change state
combo->setCurrentIndex(2);
// Deserialize
search_base_widget->load_state(state);
select_base_widget->load_state(state);
// Check that deserialization successfully restored
// original state
const QString base_deserialized = search_base_widget->get_base();
const QString base_deserialized = select_base_widget->get_base();
QVERIFY(base_original == base_deserialized);
}
QTEST_MAIN(ADMCTestSearchBaseWidget)
QTEST_MAIN(ADMCTestSelectBaseWidget)

View File

@ -24,9 +24,9 @@
class QComboBox;
class QPushButton;
class SearchBaseWidget;
class SelectBaseWidget;
class ADMCTestSearchBaseWidget : public ADMCTest {
class ADMCTestSelectBaseWidget : public ADMCTest {
Q_OBJECT
private slots:
@ -38,7 +38,7 @@ private slots:
void save_state();
private:
SearchBaseWidget *search_base_widget;
SelectBaseWidget *select_base_widget;
QComboBox *combo;
QPushButton *browse_button;
QList<QString> dn_list;