Skip to content

Commit

Permalink
afwatch can hide branch jobs and pool renders
Browse files Browse the repository at this point in the history
  • Loading branch information
timurhai committed Aug 12, 2021
1 parent ef69e4d commit 0fa712e
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 22 deletions.
2 changes: 1 addition & 1 deletion afanasy/src/watch/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);}
Expand Down
9 changes: 7 additions & 2 deletions afanasy/src/watch/itembranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions afanasy/src/watch/itembranch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion afanasy/src/watch/itembutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
21 changes: 9 additions & 12 deletions afanasy/src/watch/itemjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
Expand Down
55 changes: 55 additions & 0 deletions afanasy/src/watch/itemnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../libafqt/name_afqt.h"

#include "ctrlsortfilter.h"
#include "itembutton.h"
#include "watch.h"

#include <QtGui/QPainter>
Expand All @@ -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++)
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions afanasy/src/watch/itemnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../libafanasy/afnode.h"

class CtrlSortFilter;
class ItemButton;
class MainWidget;

class ItemNode : public Item
Expand All @@ -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(); }
Expand Down Expand Up @@ -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;}
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions afanasy/src/watch/itempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions afanasy/src/watch/itempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@ private slots:
int m_idle_netmbs;
int m_busy_netmbs;

int m_buttons_width;

QTimer * m_resources_update_timer;
};
15 changes: 13 additions & 2 deletions afanasy/src/watch/listnodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemNode*>(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);
Expand Down
5 changes: 4 additions & 1 deletion afanasy/src/watch/listnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ListNodes : public ListItems

void hrParentChanged(ItemNode * i_item);

void processHidden();

public slots:
void actHideShow( int i_type);

Expand Down Expand Up @@ -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:
Expand All @@ -98,7 +102,6 @@ private slots:
void filterSettingsChanged();

private:
void processHidden();

private:
bool m_subscribed;
Expand Down
4 changes: 3 additions & 1 deletion docs/changes_log/changes_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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>`_.

Expand All @@ -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**
Expand Down

0 comments on commit 0fa712e

Please sign in to comment.