Menu

#105 [PATCH] Sort by date/path in Library

open
5
2009-04-03
2009-03-21
valvwen
No

Once a comic collection becomes rather large, it can be difficult to locate a group of newly added comics that you want to view. You could search for each of them individually, but this can be cumbersome after a while.

This is a patch to add "Sort by" and "Order" radio buttons to the library menu, for sorting the books in the book area by date or path, in ascending or descending order. It adds two fields to the book area's liststore (Added and Path), and sets a method to sort by one of these fields. It also unfortunately required a small change to the library backend, replacing the added column in the book table with a timestamp.

I'm sure it could use some work, and I'd be happy to mess with it if desired. The included patch is against svn from March 20, 2009.

Discussion

  • valvwen

    valvwen - 2009-03-21

    Patch to add sorting to the library

     
  • Pontus Ekberg

    Pontus Ekberg - 2009-04-03
    • assigned_to: nobody --> herrekberg
     
  • Pontus Ekberg

    Pontus Ekberg - 2009-04-03

    Hi, thanks for the patch. It is a good idea to be able to sort the books in the library in different ways. It is too bad I didn't think of using current_timestamp instead of current_date when creating the tables. Unfortunately, SQLite doesn't allow modification of columns, or creation of new columns in existing tables with current_timestamp as the default value. This means we'll have to create an entirely new table in order to get a column with current_timestamp, which seems a bit messy. I will look into fixing better sorting functionality though, and use your patch as a base (I was positively surprised at how quick resorting of an iconview is!).

     
  • valvwen

    valvwen - 2009-04-05

    Patch to add sorting with no database modifications

     
  • valvwen

    valvwen - 2009-04-05

    It occurred to me this morning that no database changes would be necessary if the liststore is sorted using the file's last modified time instead of the time the file was added to the database. So instead of looking up the added column in the database, it just uses os.path.getmtime. This also has the bonus that the liststore no longer needs a custom sorting function to deal with the object (datetime) column because getmtime returns a float.

    Uploaded library_sort_nodb.patch with these changes. It is almost identical to the first patch, but removes the changes to the backend and the custom sorting method, and adds the few changes needed to use getmtime instead.

     

Log in to post a comment.