- # TODO: do a dynamic size for widget
- def sizeHint(self):
- s = QtCore.QSize()
- s.setHeight(super(BufferListWidget,self).sizeHint().height())
- s.setWidth(self.sizeHintForColumn(0))
- return s
+ def auto_resize(self):
+ size = self.sizeHintForColumn(0)
+ if size > 0:
+ size += 4
+ self.setMaximumWidth(size)
+
+ def clear(self, *args):
+ """Re-implement clear to set dynamic size after clear."""
+ QtGui.QListWidget.clear(*(self,) + args)
+ self.auto_resize()
+
+ def addItem(self, *args):
+ """Re-implement addItem to set dynamic size after add."""
+ QtGui.QListWidget.addItem(*(self,) + args)
+ self.auto_resize()
+
+ def insertItem(self, *args):
+ """Re-implement insertItem to set dynamic size after insert."""
+ QtGui.QListWidget.insertItem(*(self,) + args)
+ self.auto_resize()
+
+
+class BufferListWidget(GenericListWidget):
+ """Widget with list of buffers."""
+
+ def __init__(self, *args):
+ GenericListWidget.__init__(*(self,) + args)