diff --git a/afanasy/src/watch/item.h b/afanasy/src/watch/item.h index 50d1c71e6..3931f2246 100644 --- a/afanasy/src/watch/item.h +++ b/afanasy/src/watch/item.h @@ -100,7 +100,7 @@ class Item virtual bool calcHeight(); - inline void setHidded(bool i_hidden) {m_hidden = i_hidden;} + inline void setHidden(bool i_hidden) {m_hidden = i_hidden;} inline bool isHidden() const {return m_hidden;} inline bool hasParam(const QString & i_name) const {return m_params.contains(i_name);} diff --git a/afanasy/src/watch/itembranch.cpp b/afanasy/src/watch/itembranch.cpp index 530a762cc..2efddf079 100644 --- a/afanasy/src/watch/itembranch.cpp +++ b/afanasy/src/watch/itembranch.cpp @@ -23,6 +23,10 @@ ItemBranch::ItemBranch(ListWork * i_list_work, af::Branch * i_branch, const Ctrl ItemWork(i_list_work, i_branch, TBranch, i_ctrl_sf), m_empty(false) { + // Add buttons: + addChildsHideShowButton(); + m_buttons_width = 16; + updateValues(i_branch, 0); } @@ -187,14 +191,15 @@ void ItemBranch::v_paint(QPainter * i_painter, const QRect & i_rect, const QStyl else i_painter->setFont(afqt::QEnvironment::f_info); QRect rect_name; - i_painter->drawText(x, y, w, h, Qt::AlignLeft | Qt::AlignTop, strName, &rect_name); + i_painter->drawText(x+m_buttons_width, y, w-m_buttons_width, h, Qt::AlignLeft | Qt::AlignTop, strName, &rect_name); rect_name.adjust(0,0,10,0); i_painter->setPen(clrTextInfo(i_option)); i_painter->setFont(afqt::QEnvironment::f_info); if (false == m_empty) { - i_painter->drawText(x + rect_name.width(), y+1, w - rect_name.width(), height_branch, Qt::AlignLeft | Qt::AlignTop, strCounts); + i_painter->drawText(x+m_buttons_width + rect_name.width(), y+1, w-rect_name.width()-m_buttons_width, height_branch, + Qt::AlignLeft | Qt::AlignTop, strCounts); } i_painter->setPen(afqt::QEnvironment::qclr_black); i_painter->drawText(x, y, w, height_branch, Qt::AlignRight | Qt::AlignTop, strParameters); diff --git a/afanasy/src/watch/itembranch.h b/afanasy/src/watch/itembranch.h index 621aa3fb0..7eba8a742 100644 --- a/afanasy/src/watch/itembranch.h +++ b/afanasy/src/watch/itembranch.h @@ -37,6 +37,8 @@ class ItemBranch : public ItemWork static const int HeightBranch; static const int HeightBranch_Idle; + int m_buttons_width; + QString strName; QString strCounts; QString strParameters; diff --git a/afanasy/src/watch/itembutton.h b/afanasy/src/watch/itembutton.h index c5162a9d7..a7c883d56 100644 --- a/afanasy/src/watch/itembutton.h +++ b/afanasy/src/watch/itembutton.h @@ -15,7 +15,7 @@ class ItemButton void paint(QPainter * i_painter, const QRect & i_item_rect) const; - inline void setHidded(bool i_hidden) {m_hidden = i_hidden;} + inline void setHidden(bool i_hidden) {m_hidden = i_hidden;} bool isClicked(int i_x, int i_y) const; diff --git a/afanasy/src/watch/itemjob.cpp b/afanasy/src/watch/itemjob.cpp index 95b50b7ae..8a6a0c028 100644 --- a/afanasy/src/watch/itemjob.cpp +++ b/afanasy/src/watch/itemjob.cpp @@ -63,18 +63,15 @@ ItemJob::ItemJob(ListNodes * i_list_nodes, bool i_inworklist, af::Job * i_job, c m_item_collapsed = afqt::QEnvironment::hasCollapsedJobSerial(m_serial); // Add buttons: - //if ((false == m_inworklist) && (false == af::Environment::VISOR())) - { - m_buttons_width = 16; + m_buttons_width = 16; - m_btn_item_collapse = new ItemButton("item_collapse", 2, 2, 12, "▼", "Collapse item."); - m_btn_item_collapse->setHidded(m_item_collapsed); - m_btn_item_expand = new ItemButton("item_expand", 2, 2, 12, "▶", "Expand item."); - m_btn_item_expand->setHidded(false == m_item_collapsed); + m_btn_item_collapse = new ItemButton("item_collapse", 2, 2, 12, "▼", "Collapse item."); + m_btn_item_collapse->setHidden(m_item_collapsed); + m_btn_item_expand = new ItemButton("item_expand", 2, 2, 12, "▶", "Expand item."); + m_btn_item_expand->setHidden(false == m_item_collapsed); - addButton(m_btn_item_collapse); - addButton(m_btn_item_expand); - } + addButton(m_btn_item_collapse); + addButton(m_btn_item_expand); updateValues((af::Node*)i_job, af::Msg::TJobsList); @@ -374,8 +371,8 @@ void ItemJob::setItemCollapsed(bool i_collapse) else afqt::QEnvironment::delCollapsedJobSerial(m_serial); - m_btn_item_collapse->setHidded(m_item_collapsed); - m_btn_item_expand->setHidded(false == m_item_collapsed); + m_btn_item_collapse->setHidden(m_item_collapsed); + m_btn_item_expand->setHidden(false == m_item_collapsed); calcHeight(); } diff --git a/afanasy/src/watch/itemnode.cpp b/afanasy/src/watch/itemnode.cpp index 85f176a84..020e72831 100644 --- a/afanasy/src/watch/itemnode.cpp +++ b/afanasy/src/watch/itemnode.cpp @@ -3,6 +3,7 @@ #include "../libafqt/name_afqt.h" #include "ctrlsortfilter.h" +#include "itembutton.h" #include "watch.h" #include @@ -19,11 +20,25 @@ ItemNode::ItemNode(ListNodes * i_list_nodes, af::Node * node, EType i_type, cons m_sort_int1( 0), m_sort_int2( 0), m_hide_flags( 0), + m_childs_hidden(false), + m_btn_childs_hide(NULL), + m_btn_childs_show(NULL), m_parent_item(NULL) { m_locked = node->isLocked(); } +void ItemNode::addChildsHideShowButton() +{ + m_btn_childs_hide = new ItemButton("hide_childs", 2, 2, 12, "▼", "Hide childs."); + m_btn_childs_hide->setHidden(m_childs_hidden); + m_btn_childs_show = new ItemButton("show_childs", 2, 2, 12, "▶", "Show childs."); + m_btn_childs_show->setHidden(false == m_childs_hidden); + + addButton(m_btn_childs_hide); + addButton(m_btn_childs_show); +} + ItemNode::~ItemNode() { for (int i = 0; i < m_child_list.size(); i++) @@ -252,6 +267,46 @@ bool ItemNode::getHideFlags(int32_t i_hide_flags) const return result; } +bool ItemNode::isHiddenByParents() const +{ + if (NULL == m_parent_item) + return false; + + if (m_parent_item->m_childs_hidden) + return true; + + return m_parent_item->isHiddenByParents(); +} + +void ItemNode::setChildsHidden(bool i_hidden) +{ + if (i_hidden == m_childs_hidden) + return; + + m_childs_hidden = i_hidden; + + m_list_nodes->processHidden(); +} + +void ItemNode::v_buttonClicked(ItemButton * i_b) +{ + if ((m_btn_childs_hide && m_btn_childs_show) && + ((i_b == m_btn_childs_hide) || (i_b == m_btn_childs_show))) + { + if (i_b == m_btn_childs_hide) + { + setChildsHidden(true); + } + else if (i_b == m_btn_childs_show) + { + setChildsHidden(false); + } + + m_btn_childs_hide->setHidden(m_childs_hidden); + m_btn_childs_show->setHidden(false == m_childs_hidden); + } +} + void ItemNode::drawRunningServices(QPainter * i_painter, int i_x, int i_y, int i_w, int i_h) const { if (m_running_services.size() == 0) diff --git a/afanasy/src/watch/itemnode.h b/afanasy/src/watch/itemnode.h index 1bc940b5c..35114069f 100644 --- a/afanasy/src/watch/itemnode.h +++ b/afanasy/src/watch/itemnode.h @@ -6,6 +6,7 @@ #include "../libafanasy/afnode.h" class CtrlSortFilter; +class ItemButton; class MainWidget; class ItemNode : public Item @@ -22,6 +23,9 @@ class ItemNode : public Item virtual void v_setSortType( int i_type1, int i_type2 ) = 0; virtual void v_setFilterType( int i_type ) = 0; + virtual void v_buttonClicked(ItemButton * i_b); + + void addChildsHideShowButton(); inline void resetSorting() { m_sort_int1 = 0; m_sort_int2 = 0; m_sort_str1.clear(); m_sort_str2.clear(); } inline void resetFiltering() { m_filter_str.clear(); } @@ -54,6 +58,10 @@ class ItemNode : public Item bool getHideFlags(int32_t i_hide_flags) const; + inline bool isHidingChilds() const {return m_childs_hidden;} + bool isHiddenByParents() const; + void setChildsHidden(bool i_hidden); + inline const QString & getParentPath() const {return m_parent_path;} inline ItemNode * getParentItem() {return m_parent_item;} @@ -94,6 +102,11 @@ class ItemNode : public Item private: int32_t m_hide_flags; + bool m_childs_hidden; + + ItemButton * m_btn_childs_hide; + ItemButton * m_btn_childs_show; + QString m_parent_path; ItemNode * m_parent_item; diff --git a/afanasy/src/watch/itempool.cpp b/afanasy/src/watch/itempool.cpp index 4c7199267..cc79fb868 100644 --- a/afanasy/src/watch/itempool.cpp +++ b/afanasy/src/watch/itempool.cpp @@ -36,6 +36,10 @@ ItemPool::ItemPool(ListRenders * i_list_renders, af::Pool * i_pool, const CtrlSo m_resources_update_timer = new QTimer(this); connect(m_resources_update_timer, SIGNAL(timeout()), this, SLOT(slot_RequestResources())); + // Add buttons: + addChildsHideShowButton(); + m_buttons_width = 16; + updateValues(i_pool, 0); } @@ -316,7 +320,7 @@ void ItemPool::v_paint(QPainter * i_painter, const QRect & i_rect, const QStyleO QRect qr_LeftTop; i_painter->setPen(clrTextMain(i_option)); i_painter->setFont(afqt::QEnvironment::f_name); - i_painter->drawText(x, y, w, h, Qt::AlignLeft | Qt::AlignTop, strLeftTop, &qr_LeftTop); + i_painter->drawText(x+m_buttons_width, y, w-m_buttons_width, h, Qt::AlignLeft | Qt::AlignTop, strLeftTop, &qr_LeftTop); i_painter->setPen(clrTextInfo(i_option)); i_painter->setFont(afqt::QEnvironment::f_info); @@ -325,7 +329,7 @@ void ItemPool::v_paint(QPainter * i_painter, const QRect & i_rect, const QStyleO i_painter->setPen(afqt::QEnvironment::qclr_black); if (afqt::QEnvironment::render_item_size.n != ListRenders::ESmallSize) i_painter->drawText(x, y, w, height_pool, Qt::AlignRight | Qt::AlignBottom, strRightBottom); - i_painter->drawText(x, y, w, height_pool, Qt::AlignRight | Qt::AlignTop, strRightTop); + i_painter->drawText(x+m_buttons_width, y, w-m_buttons_width, height_pool, Qt::AlignRight | Qt::AlignTop, strRightTop); if (afqt::QEnvironment::render_item_size.n != ListRenders::ESmallSize) { diff --git a/afanasy/src/watch/itempool.h b/afanasy/src/watch/itempool.h index 5a39c4c99..ca178a8e8 100644 --- a/afanasy/src/watch/itempool.h +++ b/afanasy/src/watch/itempool.h @@ -82,5 +82,7 @@ private slots: int m_idle_netmbs; int m_busy_netmbs; + int m_buttons_width; + QTimer * m_resources_update_timer; }; diff --git a/afanasy/src/watch/listnodes.cpp b/afanasy/src/watch/listnodes.cpp index 18cf515a2..cdb8f3239 100755 --- a/afanasy/src/watch/listnodes.cpp +++ b/afanasy/src/watch/listnodes.cpp @@ -292,14 +292,25 @@ void ListNodes::processHidden() { for (int i = 0; i < m_model->count(); i++) { - ItemNode * item = (ItemNode*)(m_model->item(i)); + ItemNode * item = static_cast(m_model->item(i)); + // Node can be filtered by name bool hidden = item->filter(); if (false == hidden) + { + // Node can be hidden by View Options. + // For example user can hide offline jobs. hidden = item->getHideFlags(m_hide_flags); + } + + if (false == hidden) + { + // Parent node can hide childs + hidden = item->isHiddenByParents(); + } - item->setHidded(hidden); + item->setHidden(hidden); if (hidden != m_view->isRowHidden(i)) m_view->setRowHidden(i, hidden); diff --git a/afanasy/src/watch/listnodes.h b/afanasy/src/watch/listnodes.h index ad6616565..26c78d159 100644 --- a/afanasy/src/watch/listnodes.h +++ b/afanasy/src/watch/listnodes.h @@ -42,6 +42,8 @@ class ListNodes : public ListItems void hrParentChanged(ItemNode * i_item); + void processHidden(); + public slots: void actHideShow( int i_type); @@ -76,6 +78,8 @@ public slots: /// Needed for jobs, to get user jobs list from server virtual void v_resetSorting(); + // Nedded to store hide flags. + // Each descendant class should store flags in own variable. virtual void v_hideChanged(); protected: @@ -98,7 +102,6 @@ private slots: void filterSettingsChanged(); private: - void processHidden(); private: bool m_subscribed; diff --git a/docs/changes_log/changes_log.rst b/docs/changes_log/changes_log.rst index 81c7937c1..01e1b0d82 100644 --- a/docs/changes_log/changes_log.rst +++ b/docs/changes_log/changes_log.rst @@ -16,7 +16,7 @@ v3.2.1 *Not released* -2021.08.11 +2021.08.12 - Houdini Afanasy `TOP Scheduler <../software/houdini.html#afanasy-top-scheduler>`_. @@ -30,6 +30,8 @@ v3.2.1 - AfWatch Preferences menu got Reset Windows Geometry item. +- AfWatch can hide branch jobs and pool renders. + - Pools got some operations that will be applied to all renders in it: ejects tasks, launch command, exit renders and delete renders. - **Bugfixes**