mirror of
https://github.com/altlinux/admc.git
synced 2025-04-02 10:50:15 +03:00
move slots from attributes model to widget
add target_dn member to AttributesWidget now slots affect all tabs of AttributesWidget group members tab is now properly synced keep currently selected attributes tab through target changes
This commit is contained in:
parent
81d7617b8d
commit
6dcd571ffa
@ -25,16 +25,6 @@ AttributesModel::AttributesModel(QObject *parent)
|
||||
: QStandardItemModel(0, Column::COUNT, parent)
|
||||
{
|
||||
change_target(QString(""));
|
||||
|
||||
connect(
|
||||
&ad_interface, &AdInterface::delete_entry_complete,
|
||||
this, &AttributesModel::on_delete_entry_complete);
|
||||
connect(
|
||||
&ad_interface, &AdInterface::move_user_complete,
|
||||
this, &AttributesModel::on_move_user_complete);
|
||||
connect(
|
||||
&ad_interface, &AdInterface::load_attributes_complete,
|
||||
this, &AttributesModel::on_load_attributes_complete);
|
||||
}
|
||||
|
||||
// This will be called when an attribute value is edited
|
||||
@ -85,24 +75,3 @@ void AttributesModel::change_target(const QString &new_target_dn) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AttributesModel::on_delete_entry_complete(const QString &dn) {
|
||||
// Clear data if current target was deleted
|
||||
if (target_dn == dn) {
|
||||
change_target(QString(""));
|
||||
}
|
||||
}
|
||||
|
||||
void AttributesModel::on_move_user_complete(const QString &user_dn, const QString &container_dn, const QString &new_dn) {
|
||||
// Switch to the entry at new dn (entry stays the same)
|
||||
if (target_dn == user_dn) {
|
||||
change_target(new_dn);
|
||||
}
|
||||
}
|
||||
|
||||
void AttributesModel::on_load_attributes_complete(const QString &dn) {
|
||||
// Reload entry since attributes were updated
|
||||
if (target_dn == dn) {
|
||||
change_target(dn);
|
||||
}
|
||||
}
|
||||
|
@ -37,11 +37,6 @@ public:
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
void change_target(const QString &new_target_dn);
|
||||
|
||||
private slots:
|
||||
void on_delete_entry_complete(const QString &dn);
|
||||
void on_move_user_complete(const QString &user_dn, const QString &container_dn, const QString &new_dn);
|
||||
void on_load_attributes_complete(const QString &dn);
|
||||
|
||||
private:
|
||||
QString target_dn;
|
||||
|
||||
|
@ -44,13 +44,28 @@ AttributesWidget::AttributesWidget()
|
||||
members_view->setAcceptDrops(true);
|
||||
members_view->setDragDropMode(QAbstractItemView::DragDrop);
|
||||
|
||||
connect(
|
||||
&ad_interface, &AdInterface::delete_entry_complete,
|
||||
this, &AttributesWidget::on_delete_entry_complete);
|
||||
connect(
|
||||
&ad_interface, &AdInterface::move_user_complete,
|
||||
this, &AttributesWidget::on_move_user_complete);
|
||||
connect(
|
||||
&ad_interface, &AdInterface::load_attributes_complete,
|
||||
this, &AttributesWidget::on_load_attributes_complete);
|
||||
|
||||
change_target("");
|
||||
};
|
||||
|
||||
void AttributesWidget::change_target(const QString &dn) {
|
||||
attributes_model->change_target(dn);
|
||||
// Save current tab/index to restore later
|
||||
QWidget *old_tab = widget(currentIndex());
|
||||
|
||||
members_model->change_target(dn);
|
||||
target_dn = dn;
|
||||
|
||||
attributes_model->change_target(target_dn);
|
||||
|
||||
members_model->change_target(target_dn);
|
||||
members_view->setColumnHidden(MembersModel::Column::DN, true);
|
||||
|
||||
// Setup tabs
|
||||
@ -58,8 +73,36 @@ void AttributesWidget::change_target(const QString &dn) {
|
||||
|
||||
addTab(attributes_view, "All Attributes");
|
||||
|
||||
bool is_group = attribute_value_exists(dn, "objectClass", "group");
|
||||
bool is_group = attribute_value_exists(target_dn, "objectClass", "group");
|
||||
if (is_group) {
|
||||
addTab(members_view, "Group members");
|
||||
}
|
||||
|
||||
// Restore current index if it is still shown
|
||||
// Otherwise current index is set to first tab by default
|
||||
const int old_tab_index_in_new_tabs = indexOf(old_tab);
|
||||
if (old_tab_index_in_new_tabs != -1) {
|
||||
setCurrentIndex(old_tab_index_in_new_tabs);
|
||||
}
|
||||
}
|
||||
|
||||
void AttributesWidget::on_delete_entry_complete(const QString &dn) {
|
||||
// Clear data if current target was deleted
|
||||
if (target_dn == dn) {
|
||||
change_target(QString(""));
|
||||
}
|
||||
}
|
||||
|
||||
void AttributesWidget::on_move_user_complete(const QString &user_dn, const QString &container_dn, const QString &new_dn) {
|
||||
// Switch to the entry at new dn (entry stays the same)
|
||||
if (target_dn == user_dn) {
|
||||
change_target(new_dn);
|
||||
}
|
||||
}
|
||||
|
||||
void AttributesWidget::on_load_attributes_complete(const QString &dn) {
|
||||
// Reload entry since attributes were updated
|
||||
if (target_dn == dn) {
|
||||
change_target(dn);
|
||||
}
|
||||
}
|
||||
|
@ -34,15 +34,21 @@ Q_OBJECT
|
||||
public:
|
||||
AttributesWidget();
|
||||
|
||||
public slots:
|
||||
void change_target(const QString &dn);
|
||||
|
||||
private slots:
|
||||
void on_delete_entry_complete(const QString &dn);
|
||||
void on_move_user_complete(const QString &user_dn, const QString &container_dn, const QString &new_dn);
|
||||
void on_load_attributes_complete(const QString &dn);
|
||||
|
||||
private:
|
||||
AttributesModel *attributes_model = nullptr;
|
||||
QTreeView *attributes_view = nullptr;
|
||||
|
||||
QTreeView *members_view = nullptr;
|
||||
MembersModel *members_model = nullptr;
|
||||
|
||||
QString target_dn;
|
||||
};
|
||||
|
||||
#endif /* ATTRIBUTES_WIDGET_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user