1
0
mirror of https://github.com/altlinux/admc.git synced 2025-02-09 17:57:28 +03:00

add "create OU" action to OU's

in policy tree
reuse code from object_impl
doesn't affect policy tree yet
This commit is contained in:
kevl 2022-05-16 16:40:35 +04:00
parent 49e5652ae3
commit baad18a202
4 changed files with 49 additions and 5 deletions

View File

@ -910,13 +910,17 @@ void ObjectImpl::on_reset_account() {
}
void ObjectImpl::new_object(const QString &object_class) {
const QString parent_dn = get_selected_target_dn_object(console);
console_new_object(console, buddy_console, object_class, parent_dn);
}
void console_new_object(ConsoleWidget *console, ConsoleWidget *buddy_console, const QString &object_class, const QString &parent_dn) {
AdInterface ad;
if (ad_failed(ad, console)) {
return;
}
const QString parent_dn = get_selected_target_dn_object(console);
// NOTE: creating dialogs here instead of directly
// in "on_new_x" slots looks backwards but it's
// necessary to avoid even more code duplication
@ -956,10 +960,10 @@ void ObjectImpl::new_object(const QString &object_class) {
dialog->open();
connect(
QObject::connect(
dialog, &QDialog::accepted,
this,
[this, dialog, parent_dn]() {
console,
[console, buddy_console, dialog, parent_dn]() {
AdInterface ad_inner;
if (ad_failed(ad_inner, console)) {
return;

View File

@ -162,5 +162,6 @@ bool console_object_is_ou(const QModelIndex &index);
// of objects setup
QModelIndex get_object_tree_root(ConsoleWidget *console);
QString console_object_count_string(ConsoleWidget *console, const QModelIndex &index);
void console_new_object(ConsoleWidget *console, ConsoleWidget *buddy_console, const QString &object_class, const QString &parent_dn);
#endif /* OBJECT_IMPL_H */

View File

@ -54,6 +54,12 @@ void policy_ou_impl_add_objects_to_console(ConsoleWidget *console, const QList<A
PolicyOUImpl::PolicyOUImpl(ConsoleWidget *console_arg)
: ConsoleImpl(console_arg) {
set_results_view(new ResultsView(console_arg));
create_ou_action = new QAction(tr("Create OU"), this);
connect(
create_ou_action, &QAction::triggered,
this, &PolicyOUImpl::create_ou);
}
// TODO: perform searches in separate threads
@ -149,6 +155,26 @@ void PolicyOUImpl::refresh(const QList<QModelIndex> &index_list) {
fetch(index);
}
QList<QAction *> PolicyOUImpl::get_all_custom_actions() const {
QList<QAction *> out;
out.append(create_ou_action);
return out;
}
QSet<QAction *> PolicyOUImpl::get_custom_actions(const QModelIndex &index, const bool single_selection) const {
UNUSED_ARG(index);
QSet<QAction *> out;
if (single_selection) {
out.insert(create_ou_action);
}
return out;
}
QSet<StandardAction> PolicyOUImpl::get_standard_actions(const QModelIndex &index, const bool single_selection) const {
UNUSED_ARG(index);
UNUSED_ARG(single_selection);
@ -167,3 +193,9 @@ QList<QString> PolicyOUImpl::column_labels() const {
QList<int> PolicyOUImpl::default_columns() const {
return {0};
}
void PolicyOUImpl::create_ou() {
const QString parent_dn = get_selected_target_dn(console, ItemType_PolicyOU, ObjectRole_DN);
console_new_object(console, nullptr, CLASS_OU, parent_dn);
}

View File

@ -33,10 +33,17 @@ public:
void fetch(const QModelIndex &index) override;
void refresh(const QList<QModelIndex> &index_list) override;
QList<QAction *> get_all_custom_actions() const override;
QSet<QAction *> get_custom_actions(const QModelIndex &index, const bool single_selection) const override;
QSet<StandardAction> get_standard_actions(const QModelIndex &index, const bool single_selection) const override;
QList<QString> column_labels() const override;
QList<int> default_columns() const override;
private:
QAction *create_ou_action;
void create_ou();
};
#endif /* POLICY_OU_IMPL_H */