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"
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)