From c6329bf47bb381a75a23c34c02071e6f7571ba7b Mon Sep 17 00:00:00 2001 From: smbaker Date: Tue, 4 Oct 2011 12:42:39 -0700 Subject: [PATCH] update view color-coding code --- sface/screens/mainscreen.py | 48 +++++++++++-------------------------- sface/screens/userscreen.py | 5 +--- sface/sfidata.py | 2 ++ 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/sface/screens/mainscreen.py b/sface/screens/mainscreen.py index 22c321f..43e3e31 100644 --- a/sface/screens/mainscreen.py +++ b/sface/screens/mainscreen.py @@ -24,6 +24,10 @@ tag_status = { "in": "Already Set", "add": "To be Added", "remove": "To be Removed"} +color_status = { "in": QColor.fromRgb(0, 250, 250), + "add": QColor.fromRgb(0, 250, 0), + "remove": QColor.fromRgb(250, 0, 0) } + default_tags = "Default tags" settable_tags = ['delegations', 'initscript'] @@ -189,44 +193,20 @@ class NodeNameDelegate(QStyledItemDelegate): painter.fillRect(option.rect, option.palette.color(QPalette.Active, QPalette.Highlight)) if itemType(index) == "node": - if status_data == node_status['in']: # already in the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 250)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - elif status_data == node_status['add']: # newly added to the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + for x in node_status.keys(): + if (node_status[x] == status_data) and (x in color_status): + painter.fillPath(path, color_status[x]) - elif status_data == node_status['remove']: # removed from the slice - painter.fillPath(path, QColor.fromRgb(250, 0, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - else: - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + painter.setPen(QColor.fromRgb(0, 0, 0)) + painter.drawText(rect, 0, QString(data)) else: - if status_data == tag_status['in']: # already in the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 250)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - elif status_data == tag_status['add']: # newly added to the slice - painter.fillPath(path, QColor.fromRgb(0, 250, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + for x in tag_status.keys(): + if (tag_status[x] == status_data) and (x in color_status): + painter.fillPath(path, color_status[x]) - elif status_data == tag_status['remove']: # removed from the slice - painter.fillPath(path, QColor.fromRgb(250, 0, 0)) - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) - - else: - painter.setPen(QColor.fromRgb(0, 0, 0)) - painter.drawText(rect, 0, QString(data)) + painter.setPen(QColor.fromRgb(0, 0, 0)) + painter.drawText(rect, 0, QString(data)) painter.restore() diff --git a/sface/screens/userscreen.py b/sface/screens/userscreen.py index 677a2db..cfb7e47 100644 --- a/sface/screens/userscreen.py +++ b/sface/screens/userscreen.py @@ -68,13 +68,10 @@ class UserNameDelegate(QStyledItemDelegate): if option.state & QStyle.State_Selected: painter.fillRect(option.rect, option.palette.color(QPalette.Active, QPalette.Highlight)) - color = None for x in user_status.keys(): if (user_status[x] == status_data) and (x in color_status): - color = color_status[x] + painter.fillPath(path, color_status[x]) - if color != None: - painter.fillPath(path, color) painter.setPen(QColor.fromRgb(0, 0, 0)) painter.drawText(textRect, Qt.AlignVCenter, QString(data)) diff --git a/sface/sfidata.py b/sface/sfidata.py index 7b52b56..315fddc 100644 --- a/sface/sfidata.py +++ b/sface/sfidata.py @@ -36,6 +36,8 @@ class SfiData: return None def purgeNonSliceResources(self, rspec): + # This can probably go away once the new slice manager is fully + # deployed. networks = rspec.get_networks() for network in networks: all_nodes = rspec.get_nodes(network) -- 2.43.0