convert reverse order menu item to toggle button

This commit is contained in:
Damien Elmes 2010-02-12 16:35:11 +09:00
parent 20f9e69b79
commit 0f3a083278
5 changed files with 53 additions and 13 deletions

View file

@ -366,8 +366,7 @@ class EditDeck(QMainWindow):
SIGNAL("selectionChanged(QItemSelection,QItemSelection)"),
self.updateFilterLabel)
self.dialog.tableView.setItemDelegate(StatusDelegate(self, self.model))
if self.deck.getInt("reverseOrder"):
self.dialog.actionReverseOrder.setChecked(True)
self.updateSortOrder()
self.updateFont()
self.setupMenus()
self.setupFilter()
@ -422,6 +421,8 @@ class EditDeck(QMainWindow):
self.connect(self.dialog.sortBox, SIGNAL("activated(int)"),
self.sortChanged)
self.sortChanged(self.sortIndex, refresh=False)
self.connect(self.dialog.sortOrder, SIGNAL("clicked()"),
self.reverseOrder)
def drawTags(self):
self.dialog.tagList.view().setFixedWidth(200)
@ -496,6 +497,12 @@ class EditDeck(QMainWindow):
self.sortIndex = 0
self.dialog.sortBox.setCurrentIndex(self.sortIndex)
def updateSortOrder(self):
if self.deck.getInt("reverseOrder"):
self.dialog.sortOrder.setIcon(QIcon(":/icons/view-sort-descending.png"))
else:
self.dialog.sortOrder.setIcon(QIcon(":/icons/view-sort-ascending.png"))
def sortChanged(self, idx, refresh=True):
if idx == 0:
self.sortKey = "question"
@ -684,7 +691,6 @@ class EditDeck(QMainWindow):
self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo)
self.connect(self.dialog.actionRedo, SIGNAL("triggered()"), self.onRedo)
self.connect(self.dialog.actionInvertSelection, SIGNAL("triggered()"), self.invertSelection)
self.connect(self.dialog.actionReverseOrder, SIGNAL("triggered()"), self.reverseOrder)
self.connect(self.dialog.actionSelectFacts, SIGNAL("triggered()"), self.selectFacts)
self.connect(self.dialog.actionFindReplace, SIGNAL("triggered()"), self.onFindReplace)
# jumps
@ -696,6 +702,7 @@ class EditDeck(QMainWindow):
self.connect(self.dialog.actionFact, SIGNAL("triggered()"), self.onFact)
self.connect(self.dialog.actionTags, SIGNAL("triggered()"), self.onTags)
self.connect(self.dialog.actionSort, SIGNAL("triggered()"), self.onSort)
self.connect(self.dialog.actionCardList, SIGNAL("triggered()"), self.onCardList)
# help
self.connect(self.dialog.actionGuide, SIGNAL("triggered()"), self.onHelp)
runHook('editor.setupMenus', self)
@ -1040,6 +1047,7 @@ where id in %s""" % ids2str(sf))
self.model.cards.reverse()
self.model.reset()
self.focusCurrentCard()
self.updateSortOrder()
# Edit: undo/redo
######################################################################
@ -1192,6 +1200,9 @@ where id in %s""" % ids2str(sf))
def onSort(self):
self.dialog.sortBox.setFocus()
def onCardList(self):
self.dialog.tableView.setFocus()
# Help
######################################################################

View file

@ -82,6 +82,29 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sortOrder">
<property name="maximumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/view-sort-ascending.png</normaloff>:/icons/view-sort-ascending.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="sortBox"/>
</item>
@ -204,7 +227,6 @@
<addaction name="separator"/>
<addaction name="actionFindReplace"/>
<addaction name="separator"/>
<addaction name="actionReverseOrder"/>
<addaction name="separator"/>
<addaction name="actionFont"/>
</widget>
@ -236,6 +258,7 @@
<addaction name="actionTags"/>
<addaction name="actionSort"/>
<addaction name="actionFact"/>
<addaction name="actionCardList"/>
<addaction name="separator"/>
<addaction name="actionFirstCard"/>
<addaction name="actionPreviousCard"/>
@ -429,14 +452,6 @@
<string>Ctrl+End</string>
</property>
</action>
<action name="actionReverseOrder">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Reverse &amp;Order</string>
</property>
</action>
<action name="actionGuide">
<property name="icon">
<iconset resource="../icons.qrc">
@ -560,6 +575,18 @@
<string>Toggle Mark</string>
</property>
</action>
<action name="actionCardList">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/generate_07.png</normaloff>:/icons/generate_07.png</iconset>
</property>
<property name="text">
<string>Card List</string>
</property>
<property name="shortcut">
<string>Ctrl+L</string>
</property>
</action>
</widget>
<resources>
<include location="../icons.qrc"/>

View file

@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/" >
<qresource prefix="/">
<file>icons/generate_07.png</file>
<file>icons/view-sort-descending.png</file>
<file>icons/emblem-important.png</file>
<file>icons/view-sort-ascending.png</file>
<file>icons/media-playback-start2.png</file>

BIN
icons/generate_07.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB