diff options
-rw-r--r-- | src/ui.py | 58 |
1 files changed, 23 insertions, 35 deletions
@@ -64,11 +64,13 @@ class KPLayerList(QtGui.QWidget): -class KPObjectSelector(QtGui.QListView): +class KPObjectSelector(QtGui.QWidget): def __init__(self): """Initialises the widget. Remember to call setModel() on it with a KPGroupModel whenever the layer changes.""" + QtGui.QWidget.__init__(self) + font = QtGui.QFont() font.setPixelSize(22) font.setBold(True) @@ -91,44 +93,30 @@ class KPObjectSelector(QtGui.QListView): self.sorterButton.setMenu(self.sorterMenu) - layout = QtGui.QBoxLayout(2) - layout.setAlignment(Qt.AlignTop) - layout.setContentsMargins(0,0,0,0) - layout.setMargin(0) - layout.setSpacing(0) - - - - thing = QtGui.QListView.__init__(self) - self.setFlow(QtGui.QListView.LeftToRight) - self.setLayoutMode(QtGui.QListView.SinglePass) - self.setMovement(QtGui.QListView.Static) - self.setResizeMode(QtGui.QListView.Adjust) - self.setWrapping(True) - + self.layout = QtGui.QVBoxLayout() + self.layout.setSpacing(0) self.toolbar = QtGui.QToolBar() self.toolbar.setFixedHeight(28) self.toolbar.addWidget(self.sorterButton) - layout.addWidget(self.toolbar) - + self.layout.addWidget(self.toolbar) - self.setLayout(layout) + self.listView = QtGui.QListView() + self.listView.setFlow(QtGui.QListView.LeftToRight) + self.listView.setLayoutMode(QtGui.QListView.SinglePass) + self.listView.setMovement(QtGui.QListView.Static) + self.listView.setResizeMode(QtGui.QListView.Adjust) + self.listView.setWrapping(True) + self.layout.addWidget(self.listView) + self.setLayout(self.layout) # Borrowed the signals and junk from Reggie, figure we'll need em' - - self.clicked.connect(self.handleObjReplace) + self.listView.clicked.connect(self.handleObjReplace) self.sorterMenu.triggered.connect(self.toggleTopLevel) - def resizeEvent(self, event): - QtGui.QListView.resizeEvent(self, event) - - self.sorterMenu.setFixedWidth(self.width()-self.verticalScrollBar().width()) - - def currentSelectedObject(self): """Returns the currently selected object reference, for painting purposes.""" @@ -141,9 +129,10 @@ class KPObjectSelector(QtGui.QListView): def setModel(self, model): """Sets the model and the menu sorting list""" - QtGui.QListView.setModel(self, model) + self.model = model + self.listView.setModel(model) - model.view = self + model.view = self.listView menuList = model.groupItem().getGroupList() @@ -166,12 +155,11 @@ class KPObjectSelector(QtGui.QListView): startRow = action.data().toPyObject()[0] endRow = action.data().toPyObject()[1] - for row in xrange(self.model().rowCount()): - + for row in xrange(self.model.rowCount()): if (row < startRow) or (row > endRow): - self.setRowHidden(row, True) + self.listView.setRowHidden(row, True) else: - self.setRowHidden(row, False) + self.listView.setRowHidden(row, False) string = QtCore.QString(QtCore.QChar(0x25BE)) string.append(' ' + name) @@ -183,7 +171,7 @@ class KPObjectSelector(QtGui.QListView): def currentChanged(self, current, previous): """Throws a signal emitting the current object when changed""" i = current.row() - object = self.model().groupItem().getItem(i) + object = self.model.groupItem().getItem(i) self.objChanged.emit(object) @@ -192,7 +180,7 @@ class KPObjectSelector(QtGui.QListView): """Throws a signal when the selected object is used as a replacement""" if QtGui.QApplication.keyboardModifiers() == QtCore.Qt.AltModifier: i = current.row() - object = self.model().groupItem().getItem(i) + object = self.model.groupItem().getItem(i) self.objReplaced.emit(object) |