2
* Copyright (C) 2011 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by Alex Launi <alex.launi@canonical.com>
22
namespace Unity.MusicLens {
24
public class BansheeDecadeFilterParser : BansheeFilterParser, DecadeFilterParser
27
public BansheeDecadeFilterParser (DecadeFilterParser parser)
29
base (parser.filter as MultiRangeFilter);
32
public override string parse ()
34
int start_year, end_year;
36
MultiRangeFilter range_filter = filter as MultiRangeFilter;
37
FilterOption start = range_filter.get_first_active ();
38
FilterOption end = range_filter.get_last_active ();
40
start_year = int.parse (start.id);
41
end_year = int.parse (end.id);
43
// bump the end_year up to the beginning of the next range
44
int end_index = range_filter.options.index (end);
45
// if we have already selected the last option
46
if (end_index == range_filter.options.length () - 1)
49
end_year = int.parse (range_filter.options.nth_data (end_index + 1).id);
51
return "(CoreTracks.Year >= %d AND CoreTracks.Year < %d) ".printf (start_year, end_year);
b'\\ No newline at end of file'