X-Git-Url: http://git.onelab.eu/?p=sface.git;a=blobdiff_plain;f=sface%2Fscreens%2Fmainscreen.py;h=43e3e31e006c453526067868367e5da88720ffa0;hp=c2a2118c2a4dacc701596089eb2d0f6570310fa7;hb=c6329bf47bb381a75a23c34c02071e6f7571ba7b;hpb=dc5a4a16b0819bc27efd1f77d632a76463db82c0 diff --git a/sface/screens/mainscreen.py b/sface/screens/mainscreen.py index c2a2118..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() @@ -410,10 +390,10 @@ class SliceWidget(QWidget): def itemStatus(self, item): statusItem = item.parent().child(item.row(), MEMBERSHIP_STATUS_COLUMN) - return statusItem.data(Qt.DisplayRole).toString() + return str(statusItem.data(Qt.DisplayRole).toString()) def itemText(self, item): - return item.data(Qt.DisplayRole).toString() + return str(item.data(Qt.DisplayRole).toString()) # Recursively walk the tree, making changes to the RSpec def process_subtree(self, rspec, resources, item, depth = 0):