~victored/beat-box/miller-columns

« back to all changes in this revision

Viewing changes to src/Views/ListView/MillerColumns/MillerColumn.vala

  • Committer: Victor Eduardo
  • Date: 2012-03-02 20:37:16 UTC
  • Revision ID: victoreduardm@gmail.com-20120302203716-auedqhpl1k1tqxac
Improve performance a bit by sharing search data between the millers and the view wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
                TOP       = 1
39
39
        }
40
40
 
41
 
        public Position position {get; private set; default = Position.AUTOMATIC;}
 
41
        // All the medias
 
42
        public Collection<int> medias {get; private set;}
 
43
 
 
44
        // Displayed medias (search results)
 
45
        public LinkedList<int> media_results;
 
46
        public LinkedList<int> album_results;
42
47
 
43
48
        public LibraryManager lm {get; private set;}
44
49
        public LibraryWindow lw {get; private set;}
45
50
 
46
51
        public ViewWrapper.Hint view_type {get; private set;}
47
 
        public Collection<int> medias {get; private set;}
 
52
        public Position position {get; private set; default = Position.AUTOMATIC;}
48
53
        public LinkedList<unowned MillerColumn> columns {get; private set;}
49
54
 
50
55
        private Gtk.Menu column_chooser_menu;
196
201
 
197
202
                foreach (var col in columns) {
198
203
                        // Higher hierarchical levels (parent columns)
199
 
                        if (col.category <= category) {
200
 
                                if (col.category == MillerColumn.Category.GENRE) {
201
 
                                        search_genre = (col.category == category) ? val : col.get_selected ();
202
 
                                }
203
 
                                else if (col.category == MillerColumn.Category.ARTIST) {
204
 
                                        search_artist = (col.category == category) ? val : col.get_selected ();
205
 
                                }
206
 
                                else if (col.category == MillerColumn.Category.ALBUM) {
207
 
                                        search_album = (col.category == category) ? val : col.get_selected ();
208
 
                                }
209
 
                                else if (col.category == MillerColumn.Category.YEAR) {
210
 
                                        var year = (col.category == category) ? val : col.get_selected ();
211
 
                                        search_year = (year == "") ? -1 : int.parse (year);
212
 
                                }
213
 
                                else if (col.category == MillerColumn.Category.RATING) {
214
 
                                        var rating = (col.category == category) ? val : col.get_selected ();
215
 
                                        search_rating = (rating == "") ? -1 : int.parse (rating);
 
204
                        if (col.category < category) {
 
205
                                if (col.category == MillerColumn.Category.GENRE) {
 
206
                                        search_genre = col.get_selected ();
 
207
                                }
 
208
                                else if (col.category == MillerColumn.Category.ARTIST) {
 
209
                                        search_artist = col.get_selected ();
 
210
                                }
 
211
                                else if (col.category == MillerColumn.Category.ALBUM) {
 
212
                                        search_album = col.get_selected ();
 
213
                                }
 
214
                                else if (col.category == MillerColumn.Category.YEAR) {
 
215
                                        search_year = (col.get_selected () == "") ? -1 : int.parse (col.get_selected ());
 
216
                                }
 
217
                                else if (col.category == MillerColumn.Category.RATING) {
 
218
                                        search_rating = (col.get_selected () == "") ? -1 : int.parse (col.get_selected ());
 
219
                                }
 
220
                        } else if (col.category == category) {
 
221
                                if (col.category == MillerColumn.Category.GENRE) {
 
222
                                        search_genre = val;
 
223
                                }
 
224
                                else if (col.category == MillerColumn.Category.ARTIST) {
 
225
                                        search_artist = val;
 
226
                                }
 
227
                                else if (col.category == MillerColumn.Category.ALBUM) {
 
228
                                        search_album = val;
 
229
                                }
 
230
                                else if (col.category == MillerColumn.Category.YEAR) {
 
231
                                        search_year = (val == "") ? -1 : int.parse (val);
 
232
                                }
 
233
                                else if (col.category == MillerColumn.Category.RATING) {
 
234
                                        search_rating = (val == "") ? -1 : int.parse (val);
216
235
                                }
217
236
                        }
218
237
                }
219
238
 
220
239
                // Perform search
221
 
                LinkedList<int> search_results;
222
240
 
223
 
                lm.do_search (medias, out search_results, null, null, null, null, hint,
 
241
                lm.do_search (medias, out media_results, out album_results, null, null, null, hint,
224
242
                              lw.searchField.get_text (),
225
243
                              search_artist, search_album, search_genre, search_year, search_rating);
226
244
 
230
248
                        if (column.category > category) {
231
249
                                var column_set = new HashMap<string, int> ();
232
250
 
233
 
                                foreach(int id in search_results) {
 
251
                                foreach(int id in media_results) {
234
252
                                        var media = lm.media_from_id(id);
235
253
                                        string _val = "";
236
254
 
289
307
                }
290
308
                // </to_remove>
291
309
 
292
 
                LinkedList<int> searched_medias, searched_medias_albums;
293
 
 
294
 
                lm.do_search (medias, out searched_medias, out searched_medias_albums, null, null, null,
 
310
                lm.do_search (medias, out media_results, out album_results, null, null, null,
295
311
                              hint, lw.searchField.get_text ());
296
312
 
297
313
                foreach (var column in columns) {
298
314
                        var column_set = new HashMap<string, int>();
299
315
 
300
 
                        foreach (int id in searched_medias) {
 
316
                        foreach (int id in media_results) {
301
317
                                var media = lm.media_from_id (id);
302
318
                                string val = "";
303
319