mirror of
https://github.com/altlinux/admc.git
synced 2025-03-22 14:50:36 +03:00
relocate object item setup f-ns
to object_model.cpp make ConsoleRole_HasProperties public
This commit is contained in:
parent
e22f3241b0
commit
810e58b76c
@ -245,7 +245,7 @@ void CentralWidget::go_online(AdInterface &ad) {
|
||||
|
||||
scope_head_index = QPersistentModelIndex(item->index());
|
||||
|
||||
setup_scope_item(item, head_object);
|
||||
setup_object_scope_item(item, head_object);
|
||||
|
||||
console_widget->set_current_scope(item->index());
|
||||
|
||||
@ -834,27 +834,6 @@ void CentralWidget::fetch_scope_node(const QModelIndex &index) {
|
||||
hide_busy_indicator();
|
||||
}
|
||||
|
||||
void CentralWidget::setup_scope_item(QStandardItem *item, const AdObject &object) {
|
||||
const QString name =
|
||||
[&]() {
|
||||
const QString dn = object.get_dn();
|
||||
return dn_get_name(dn);
|
||||
}();
|
||||
|
||||
item->setText(name);
|
||||
|
||||
console_widget->set_has_properties(item->index(), true);
|
||||
|
||||
load_object_item_data(item, object);
|
||||
disable_drag_if_object_cant_be_moved({item}, object);
|
||||
}
|
||||
|
||||
void CentralWidget::setup_results_row(const QList<QStandardItem *> row, const AdObject &object) {
|
||||
console_widget->set_has_properties(row[0]->index(), true);
|
||||
load_object_row(row, object);
|
||||
disable_drag_if_object_cant_be_moved(row, object);
|
||||
}
|
||||
|
||||
// NOTE: "containers" referenced here don't mean objects
|
||||
// with "container" object class. Instead it means all the
|
||||
// objects that can have children(some of which are not
|
||||
@ -889,11 +868,11 @@ void CentralWidget::add_object_to_console(const AdObject &object, const QModelIn
|
||||
QList<QStandardItem *> results_row;
|
||||
console_widget->add_buddy_scope_and_results(object_results_id, ScopeNodeType_Dynamic, parent, &scope_item, &results_row);
|
||||
|
||||
setup_scope_item(scope_item, object);
|
||||
setup_results_row(results_row, object);
|
||||
setup_object_scope_item(scope_item, object);
|
||||
setup_object_results_row(results_row, object);
|
||||
} else {
|
||||
const QList<QStandardItem *> results_row = console_widget->add_results_row(parent);
|
||||
setup_results_row(results_row, object);
|
||||
setup_object_results_row(results_row, object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -939,7 +918,7 @@ void CentralWidget::update_console_item(const QModelIndex &index, const AdObject
|
||||
const QString old_dn = scope_item->data(ObjectRole_DN).toString();
|
||||
const bool dn_changed = (old_dn != object.get_dn());
|
||||
|
||||
setup_scope_item(scope_item, object);
|
||||
setup_object_scope_item(scope_item, object);
|
||||
|
||||
// NOTE: if dn changed, then this change affects
|
||||
// this item's children, so have to refresh to
|
||||
@ -983,14 +962,6 @@ void CentralWidget::update_policy_item(const QModelIndex &index, const AdObject
|
||||
}
|
||||
}
|
||||
|
||||
void CentralWidget::disable_drag_if_object_cant_be_moved(const QList<QStandardItem *> &items, const AdObject &object) {
|
||||
const bool cannot_move = object.get_system_flag(SystemFlagsBit_CannotMove);
|
||||
|
||||
for (auto item : items) {
|
||||
item->setDragEnabled(!cannot_move);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine what kind of drop type is dropping this object
|
||||
// onto target. If drop type is none, then can't drop this
|
||||
// object on this target.
|
||||
|
@ -121,13 +121,10 @@ private:
|
||||
ResultsView *object_results;
|
||||
|
||||
void update_description_bar();
|
||||
void setup_scope_item(QStandardItem *item, const AdObject &object);
|
||||
void setup_results_row(const QList<QStandardItem *> row, const AdObject &object);
|
||||
void add_object_to_console(const AdObject &object, const QModelIndex &parent);
|
||||
void move_object_in_console(AdInterface &ad, const QPersistentModelIndex &old_index, const QString &new_parent_dn, const QPersistentModelIndex &new_parent_index);
|
||||
void update_console_item(const QModelIndex &index, const AdObject &object);
|
||||
void update_policy_item(const QModelIndex &index, const AdObject &object);
|
||||
void disable_drag_if_object_cant_be_moved(const QList<QStandardItem *> &items, const AdObject &object);
|
||||
QList<QString> get_dns(const QList<QModelIndex> &indexes);
|
||||
void enable_disable_helper(const bool disabled);
|
||||
void update_actions_visibility();
|
||||
|
@ -53,7 +53,9 @@ class QStandardItem;
|
||||
class QMenu;
|
||||
class QAbstractItemView;
|
||||
|
||||
enum ConsoleRoleLast {
|
||||
enum ConsoleRolePublic {
|
||||
ConsoleRole_HasProperties = Qt::UserRole + 18,
|
||||
|
||||
// Use this role to set and get item types
|
||||
ConsoleRole_Type = Qt::UserRole + 19,
|
||||
|
||||
|
@ -56,11 +56,10 @@ enum ConsoleRole {
|
||||
// Determines whether scope is dynamic.
|
||||
ConsoleRole_ScopeIsDynamic = Qt::UserRole + 6,
|
||||
|
||||
ConsoleRole_HasProperties = Qt::UserRole + 7,
|
||||
|
||||
// NOTE: don't go above ConsoleRole_Type and
|
||||
// ConsoleRole_LAST (defined in public header)
|
||||
|
||||
// ConsoleRole_HasProperties = Qt::UserRole + 18,
|
||||
// ConsoleRole_Type = Qt::UserRole + 19,
|
||||
// ConsoleRole_LAST = Qt::UserRole + 20
|
||||
};
|
||||
|
@ -65,6 +65,8 @@ void load_object_row(const QList<QStandardItem *> row, const AdObject &object) {
|
||||
}
|
||||
|
||||
void load_object_item_data(QStandardItem *item, const AdObject &object) {
|
||||
item->setData(true, ConsoleRole_HasProperties);
|
||||
|
||||
item->setData(ItemType_DomainObject, ConsoleRole_Type);
|
||||
|
||||
const QIcon icon = get_object_icon(object);
|
||||
@ -122,3 +124,29 @@ QList<QString> object_model_search_attributes() {
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
void setup_object_scope_item(QStandardItem *item, const AdObject &object) {
|
||||
const QString name =
|
||||
[&]() {
|
||||
const QString dn = object.get_dn();
|
||||
return dn_get_name(dn);
|
||||
}();
|
||||
|
||||
item->setText(name);
|
||||
|
||||
load_object_item_data(item, object);
|
||||
disable_drag_if_object_cant_be_moved({item}, object);
|
||||
}
|
||||
|
||||
void setup_object_results_row(const QList<QStandardItem *> row, const AdObject &object) {
|
||||
load_object_row(row, object);
|
||||
disable_drag_if_object_cant_be_moved(row, object);
|
||||
}
|
||||
|
||||
void disable_drag_if_object_cant_be_moved(const QList<QStandardItem *> &items, const AdObject &object) {
|
||||
const bool cannot_move = object.get_system_flag(SystemFlagsBit_CannotMove);
|
||||
|
||||
for (auto item : items) {
|
||||
item->setDragEnabled(!cannot_move);
|
||||
}
|
||||
}
|
||||
|
@ -46,5 +46,8 @@ void load_object_item_data(QStandardItem *item, const AdObject &object);
|
||||
QList<QString> object_model_header_labels();
|
||||
QList<int> object_model_default_columns();
|
||||
QList<QString> object_model_search_attributes();
|
||||
void setup_object_scope_item(QStandardItem *item, const AdObject &object);
|
||||
void setup_object_results_row(const QList<QStandardItem *> row, const AdObject &object);
|
||||
void disable_drag_if_object_cant_be_moved(const QList<QStandardItem *> &items, const AdObject &object);
|
||||
|
||||
#endif /* OBJECT_MODEL_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user