Merge lp:~marcus-lundgren/noise/improve-readability-in-SPE into lp:~elementary-apps/noise/trunk

Proposed by Marcus Lundgren
Status: Merged
Merged at revision: 917
Proposed branch: lp:~marcus-lundgren/noise/improve-readability-in-SPE
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 107 lines (+46/-21)
1 file modified
src/Dialogs/SmartPlaylistEditor.vala (+46/-21)
To merge this branch: bzr merge lp:~marcus-lundgren/noise/improve-readability-in-SPE
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+117348@code.launchpad.net
To post a comment you must log in.
917. By Marcus Lundgren

Shortened the lines in certain functions.

918. By Marcus Lundgren

Clean up.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Dialogs/SmartPlaylistEditor.vala'
2--- src/Dialogs/SmartPlaylistEditor.vala 2012-07-26 17:29:26 +0000
3+++ src/Dialogs/SmartPlaylistEditor.vala 2012-07-30 22:27:17 +0000
4@@ -340,11 +340,19 @@
5 comparators.insert (0, SmartQuery.ComparatorType.IS);
6 comparators.insert (1, SmartQuery.ComparatorType.CONTAINS);
7 comparators.insert (2, SmartQuery.ComparatorType.NOT_CONTAINS);
8-
9- if ((_q.comparator == SmartQuery.ComparatorType.IS) || ((int)_q.comparator-1 > 2))
10- _comparator.set_active(0);
11- else
12- _comparator.set_active((int)_q.comparator-1);
13+
14+ switch (_q.comparator)
15+ {
16+ case SmartQuery.ComparatorType.CONTAINS:
17+ _comparator.set_active(1);
18+ break;
19+ case SmartQuery.ComparatorType.NOT_CONTAINS:
20+ _comparator.set_active(2);
21+ break;
22+ default: // SmartQuery.ComparatorType.IS or unset
23+ _comparator.set_active(0);
24+ break;
25+ }
26 }
27 else if(_field.get_active () == SmartQuery.FieldType.MEDIA_TYPE) {
28 _value.hide();
29@@ -366,10 +374,16 @@
30 _comparator.append_text(_("is not"));
31 comparators.insert (0, SmartQuery.ComparatorType.IS);
32 comparators.insert (1, SmartQuery.ComparatorType.IS_NOT);
33-
34- _comparator.set_active((int)_q.comparator);
35- if ((int)_q.comparator > 1)
36- _comparator.set_active(0);
37+
38+ switch (_q.comparator)
39+ {
40+ case SmartQuery.ComparatorType.IS_NOT:
41+ _comparator.set_active(1);
42+ break;
43+ default: // SmartQuery.ComparatorType.IS or unset
44+ _comparator.set_active(0);
45+ break;
46+ }
47 }
48 else {
49 if(is_rating ((SmartQuery.FieldType)_field.get_active ())) {
50@@ -405,11 +419,19 @@
51 comparators.insert (0, SmartQuery.ComparatorType.IS_EXACTLY);
52 comparators.insert (1, SmartQuery.ComparatorType.IS_WITHIN);
53 comparators.insert (2, SmartQuery.ComparatorType.IS_BEFORE);
54-
55- if ((_q.comparator == SmartQuery.ComparatorType.IS_EXACTLY) || ((int)_q.comparator-6 < 0))
56- _comparator.set_active(0);
57- else
58- _comparator.set_active((int)_q.comparator-6);
59+
60+ switch (_q.comparator)
61+ {
62+ case SmartQuery.ComparatorType.IS_WITHIN:
63+ _comparator.set_active (1);
64+ break;
65+ case SmartQuery.ComparatorType.IS_BEFORE:
66+ _comparator.set_active (2);
67+ break;
68+ default: // SmartQuery.ComparatorType.IS_EXACTLY or unset
69+ _comparator.set_active (0);
70+ break;
71+ }
72 }
73 }
74
75@@ -438,15 +460,17 @@
76 }
77
78 public bool needs_value (SmartQuery.FieldType compared) {
79- return (compared == SmartQuery.FieldType.ALBUM || compared == SmartQuery.FieldType.ARTIST || compared == SmartQuery.FieldType.COMMENT ||
80- compared == SmartQuery.FieldType.COMPOSER || compared == SmartQuery.FieldType.GENRE || compared == SmartQuery.FieldType.GROUPING ||
81- compared == SmartQuery.FieldType.TITLE);
82+ return (compared == SmartQuery.FieldType.ALBUM || compared == SmartQuery.FieldType.ARTIST
83+ || compared == SmartQuery.FieldType.COMMENT || compared == SmartQuery.FieldType.COMPOSER
84+ || compared == SmartQuery.FieldType.GENRE || compared == SmartQuery.FieldType.GROUPING
85+ || compared == SmartQuery.FieldType.TITLE);
86 }
87
88 public bool needs_value_2 (SmartQuery.FieldType compared) {
89- return (compared == SmartQuery.FieldType.BITRATE || compared == SmartQuery.FieldType.YEAR || compared == SmartQuery.FieldType.RATING ||
90- compared == SmartQuery.FieldType.PLAYCOUNT || compared == SmartQuery.FieldType.SKIPCOUNT || compared == SmartQuery.FieldType.LENGTH ||
91- compared == SmartQuery.FieldType.TITLE);
92+ return (compared == SmartQuery.FieldType.BITRATE || compared == SmartQuery.FieldType.YEAR
93+ || compared == SmartQuery.FieldType.RATING || compared == SmartQuery.FieldType.PLAYCOUNT
94+ || compared == SmartQuery.FieldType.SKIPCOUNT || compared == SmartQuery.FieldType.LENGTH
95+ || compared == SmartQuery.FieldType.TITLE);
96 }
97
98 public bool is_rating (SmartQuery.FieldType compared) {
99@@ -454,7 +478,8 @@
100 }
101
102 public bool is_date (SmartQuery.FieldType compared) {
103- return (compared == SmartQuery.FieldType.LAST_PLAYED || compared == SmartQuery.FieldType.DATE_ADDED || compared == SmartQuery.FieldType.DATE_RELEASED);
104+ return (compared == SmartQuery.FieldType.LAST_PLAYED || compared == SmartQuery.FieldType.DATE_ADDED
105+ || compared == SmartQuery.FieldType.DATE_RELEASED);
106 }
107 }
108

Subscribers

People subscribed via source and target branches