Make more space available vertically for tag browser

This commit is contained in:
Kovid Goyal 2009-12-31 09:53:45 -07:00
parent 4b66da2fe6
commit 928f7b8db8
3 changed files with 37 additions and 38 deletions

View File

@ -231,7 +231,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="library">
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -239,33 +239,6 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="match_any">
<property name="text">
<string>Match any</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="match_all">
<property name="text">
<string>Match all</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="popularity">
<property name="text">
<string>Sort by &amp;popularity</string>
</property>
</widget>
</item>
<item>
<widget class="TagsView" name="tags_view">
<property name="tabKeyNavigation">
@ -282,6 +255,30 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="popularity">
<property name="text">
<string>Sort by &amp;popularity</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="tag_match">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Match any</string>
</property>
</item>
<item>
<property name="text">
<string>Match all</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -21,16 +21,21 @@ class TagsView(QTreeView):
self.setUniformRowHeights(True)
self.setCursor(Qt.PointingHandCursor)
self.setIconSize(QSize(30, 30))
self.tag_match = None
def set_database(self, db, match_all, popularity):
def set_database(self, db, tag_match, popularity):
self._model = TagsModel(db, parent=self)
self.popularity = popularity
self.match_all = match_all
self.tag_match = tag_match
self.setModel(self._model)
self.connect(self, SIGNAL('clicked(QModelIndex)'), self.toggle)
self.popularity.setChecked(config['sort_by_popularity'])
self.connect(self.popularity, SIGNAL('stateChanged(int)'), self.sort_changed)
@property
def match_all(self):
return self.tag_match and self.tag_match.currentIndex() > 0
def sort_changed(self, state):
config.set('sort_by_popularity', state == Qt.Checked)
self.model().refresh()
@ -40,7 +45,7 @@ class TagsView(QTreeView):
exclusive = modifiers not in (Qt.CTRL, Qt.SHIFT)
if self._model.toggle(index, exclusive):
self.emit(SIGNAL('tags_marked(PyQt_PyObject, PyQt_PyObject)'),
self._model.tokens(), self.match_all.isChecked())
self._model.tokens(), self.match_all)
def clear(self):
self.model().clear_state()

View File

@ -498,10 +498,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.cover_cache.start()
self.library_view.model().cover_cache = self.cover_cache
self.tags_view.setVisible(False)
self.match_all.setVisible(False)
self.match_any.setVisible(False)
self.tag_match.setVisible(False)
self.popularity.setVisible(False)
self.tags_view.set_database(db, self.match_all, self.popularity)
self.tags_view.set_database(db, self.tag_match, self.popularity)
self.connect(self.tags_view,
SIGNAL('tags_marked(PyQt_PyObject, PyQt_PyObject)'),
self.search.search_from_tags)
@ -708,14 +707,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
def toggle_tags_view(self, show):
if show:
self.tags_view.setVisible(True)
self.match_all.setVisible(True)
self.match_any.setVisible(True)
self.tag_match.setVisible(True)
self.popularity.setVisible(True)
self.tags_view.setFocus(Qt.OtherFocusReason)
else:
self.tags_view.setVisible(False)
self.match_all.setVisible(False)
self.match_any.setVisible(False)
self.tag_match.setVisible(False)
self.popularity.setVisible(False)
def search_done(self, view, ok):