ALL_STATUS = "Any"
MESSAGE_STATUSES = [UNREAD_STATUS, UNARCHIVED_STATUS, ALL_STATUS]
- _MIN_MESSAGES_SHOWN = 1
+ _MIN_MESSAGES_SHOWN = 4
def __init__(self, app, session, errorLog):
self._selectedTypeFilter = self.ALL_TYPES
self._itemView.setItemsExpandable(False)
self._itemView.setItemDelegate(self._htmlDelegate)
self._itemView.activated.connect(self._on_row_activated)
+ self._itemView.header().sectionResized.connect(self._on_column_resized)
self._layout = QtGui.QVBoxLayout()
self._layout.addLayout(self._selectionLayout)
numbersWithDescriptions = [(number, "")]
self._session.draft.add_contact(contactId, title, description, numbersWithDescriptions)
+ @QtCore.pyqtSlot(QtCore.QModelIndex)
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_column_resized(self, index, oldSize, newSize):
+ self._htmlDelegate.setWidth(newSize)
+
class Contacts(object):
class QHtmlDelegate(QtGui.QStyledItemDelegate):
- # @bug Not showing all of a message
+ UNDEFINED_SIZE = -1
+
+ def __init__(self, *args, **kwd):
+ QtGui.QStyledItemDelegate.__init__(*((self, ) + args), **kwd)
+ self._width = self.UNDEFINED_SIZE
def paint(self, painter, option, index):
newOption = QtGui.QStyleOptionViewItemV4(option)
doc.documentLayout().draw(painter, ctx)
painter.restore()
+ def setWidth(self, width):
+ # @bug we need to be emitting sizeHintChanged but it requires an index
+ self._width = width
+
def sizeHint(self, option, index):
newOption = QtGui.QStyleOptionViewItemV4(option)
self.initStyleOption(newOption, index)
doc = QtGui.QTextDocument()
doc.setHtml(newOption.text)
- doc.setTextWidth(newOption.rect.width())
+ if self._width != self.UNDEFINED_SIZE:
+ width = self._width
+ else:
+ width = newOption.rect.width()
+ doc.setTextWidth(width)
size = QtCore.QSize(doc.idealWidth(), doc.size().height())
return size