View Single Post
Old 04-15-2011, 05:56 AM   #57
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The thread would be difficult, because threading the GUI and the database is very hard.

I backed out the changes.

I was wrong when I said that adding a multisort would be complicated. It isn't. Try adding the following at the end of the books view class in gui.library.views (near line 730) and let me know if it works for you.

Call it using something like:
Code:
        self.library_view.multisort((('title',False), ('authors', True)))
where True means ascending and False means descending.

Code:
    def multisort(self, fields):
        if len(fields) == 0:
            return
        sh = self._model.sort_history
        for n,d in reversed(fields):
            sh.insert(0, (n, d))
        sh = self.cleanup_sort_history(sh)
        self._model.sort_history = [tuple(x) for x in sh]
        self._model.resort()
        col = fields[0][0]
        dir = Qt.AscendingOrder if fields[0][1] else Qt.DescendingOrder
        if col in self.column_map:
            col = self.column_map.index(col)
            hdrs = self.horizontalHeader()
            try:
                hdrs.setSortIndicator(col, dir)
            except:
                pass
chaley is offline   Reply With Quote