Commits

Iñigo Serna  committed e58b5ef

Create a new model each time a lib is loaded => switching libs is much faster

  • Participants
  • Parent commits 764d8c0

Comments (0)

Files changed (2)

-_zcdd============================================================================
-Last update:	Time-stamp: <2012-05-28 12:38:51 inigo>
+============================================================================
+Last update:	Time-stamp: <2012-05-28 14:55:27 inigo>
 ============================================================================
 
 
 . fix bug: stop loading covers if creating new library
 . fix bug: crash at libs check if library name with non-ascii chars
 . fix bug: add ebooks, switch lib => default covers are shown, not ebook
+. create a new model each time a lib is loaded => switching libs is much faster
 
 
 v0.6
         self.bulkedit = BulkEditWin(self)
 
         ##### Model and filter
-        # fields: id, path, format, size, added, modified,
-        #         title, authors, author_sort, publisher, pubdate, edition,
-        #         isbn, lang, rating, tags
-        self.model = gtk.ListStore(long, str, str, long, object, object,
-                                   str, str, str, str, float, int,
-                                   str, str, int, str)
-        self.model.connect('sort-column-changed', self.listview.on_sort_changed)
-        self.model.set_sort_func(4, self.__sort_by_time, 4) # added
-        self.model.set_sort_func(5, self.__sort_by_time, 5) # modified
+        self.model = None
         self.ids_all, self.ids_filtered = [], []
 
         ##### initialize states and show main window
         self.prettyview.set_model(None)
         self.iconview.set_model(None)
         self.cover_factory.clear()
-        self.model.clear()
         del self.ids_all[:]
         del self.ids_filtered[:]
+        if self.model is not None:
+            self.model.clear()
+            del self.model
+            del self.model_filtered
+        # fields: id, path, format, size, added, modified,
+        #         title, authors, author_sort, publisher, pubdate, edition,
+        #         isbn, lang, rating, tags
+        self.model = gtk.ListStore(long, str, str, long, object, object,
+                                   str, str, str, str, float, int,
+                                   str, str, int, str)
+        self.model.connect('sort-column-changed', self.listview.on_sort_changed)
+        self.model.set_sort_func(4, self.__sort_by_time, 4) # added
+        self.model.set_sort_func(5, self.__sort_by_time, 5) # modified
         log.debug('Calling garbage collector')
         gc.collect()
         for i, b in enumerate(db.get_books()):