X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sface%2Fscreens%2Fmainscreen.py;h=e6e4fb41d4e597106dff91a574966771085d7a4d;hb=95ffcc9a39b6df94c6296cc42511c0140fd8a388;hp=29637540f678c220ad7b169d155886a687e24486;hpb=e05a4f6ac4c3e6d0e8a88ad31ec8516440cdd2b3;p=sface.git diff --git a/sface/screens/mainscreen.py b/sface/screens/mainscreen.py index 2963754..e6e4fb4 100644 --- a/sface/screens/mainscreen.py +++ b/sface/screens/mainscreen.py @@ -31,6 +31,9 @@ NODE_STATUS_COLUMN = 1 MEMBERSHIP_STATUS_COLUMN = 2 KIND_COLUMN = 3 +# maximum length of a name to display before clipping +NAME_MAX_LEN = 48 + def itemType(index): if index.parent().parent().isValid(): return "tag" @@ -144,15 +147,21 @@ class NodeNameDelegate(QStyledItemDelegate): def __init__(self, parent): QStyledItemDelegate.__init__(self, parent) + def displayText(self, value, locale): + data = str(QStyledItemDelegate.displayText(self, value, locale)) + if (len(data)>NAME_MAX_LEN): + data = data[:(NAME_MAX_LEN-3)] + "..." + return QString(data) + def paint(self, painter, option, index): model = index.model() + data = str(self.displayText(index.data(), QLocale())) status_index = model.index(index.row(), MEMBERSHIP_STATUS_COLUMN, index.parent()) status_data = status_index.data().toString() fm = QFontMetrics(option.font) rect = QRect(option.rect) - data = index.data().toString() rect.setHeight(rect.height() - 2) rect.setWidth(fm.width(QString(data)) + 6) rect.setX(rect.x() + 5) @@ -379,7 +388,7 @@ class SliceWidget(QWidget): self.filterModel.setNodeStatusFilter(str(filter_string)) def itemStatus(self, item): - statusItem = item.parent().child(item.row(), 1) + statusItem = item.parent().child(item.row(), MEMBERSHIP_STATUS_COLUMN) return statusItem.data(Qt.DisplayRole).toString() def itemText(self, item): @@ -512,7 +521,8 @@ class SliceWidget(QWidget): # Add default slice tags nodeItem = QStandardItem(QString("%s for %s" % (default_tags, network))) statusItem = QStandardItem(QString("")) - networkItem.appendRow([nodeItem, statusItem]) + nodeStatus = QStandardItem(QString("")) + networkItem.appendRow([nodeItem, nodeStatus, statusItem, QStandardItem(QString("defaults"))]) attrs = rspec.get_default_sliver_attributes(network) for (name, value) in attrs: tagstring = QString("%s: %s" % (name, value))