Debian Codegraph @

src/filter.cpp

raw symbols SCIP
1 /*
2 Copyright (C) 2005-2014 Mario Stephan <[email protected]>
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "filter.h"
19 #include <QtCore>
20
21
22
23 struct Filter::Private
24 {
25 int maxUsage;
26 int usage;
27 bool isActive;
28 QString path;
29 QString genre;
30 QString artist;
31 int count;
32 long length;
33 };
34
35 /*
36 *
37 *ToDo: - replace path with a string from Tag (if we have a good tagger tool inside)
38 **/
39
40 Filter::Filter()
41 :p(new Private)
42 {
43 p->usage = 0;
44 p->maxUsage = 0;
45 p->count = 0;
46 p->length = 0;
47 p->path = "",
48 p->genre = "";
49 p->artist = "";
50 p->isActive = false;
51 }
52
53 Filter::Filter(QString genre, int maxUsage)
54 :p(new Private)
55 {
56 p->maxUsage = maxUsage;
57 p->genre = genre;
58 }
59
60 Filter::~Filter()
61 {
62 delete p;
63 }
64
65
66 int Filter::maxUsage()
67 {
68 return p->maxUsage;
69 }
70
71 void Filter::setMaxUsage(int value)
72 {
73 p->maxUsage = value;
74 emit maxUsageChanged();
75 }
76
77 bool Filter::active()
78 {
79 return p->isActive;
80 }
81
82 void Filter::setActive(bool b)
83 {
84 p->isActive = b;
85 Q_EMIT statusChanged(b);
86 if ( b == true )
87 {
88 setUsage(0);
89 Q_EMIT activated();
90 }
91 }
92
93 void Filter::update()
94 {
95 //qDebug() << Q_FUNC_INFO ;
96 Q_EMIT filterChanged();
97 }
98
99 QString Filter::path()
100 {
101 return p->path;
102 }
103
104 void Filter::setPath(QString path)
105 {
106 p->path = path;
107 }
108
109 QString Filter::genre()
110 {
111 return p->genre;
112 }
113
114 void Filter::setGenre(QString genre)
115 {
116 p->genre = genre;
117 }
118
119 QString Filter::artist()
120 {
121 return p->artist;
122 }
123
124 void Filter::setArtist(QString artist)
125 {
126 p->artist = artist;
127 }
128
129 int Filter::usage()
130 {
131 return p->usage;
132 }
133
134 void Filter::setUsage(int value)
135 {
136 p->usage = value;
137 emit usageChanged();
138 }
139
140 int Filter::count()
141 {
142 return p->count;
143 }
144
145 void Filter::setCount(int value)
146 {
147 p->count = value;
148 emit countChanged();
149 }
150
151 long Filter::length()
152 {
153 return p->length;
154 }
155
156 void Filter::setLength(long value)
157 {
158 p->length = value;
159 }
160
161 QString Filter::description()
162 {
163 QString ret;
164 if ( !p->artist.isEmpty())
165 ret+=p->artist +" ";
166 if ( !p->genre.isEmpty())
167 ret+=p->genre +" ";
168 if ( !p->path.isEmpty())
169 {
170 QStringList token = p->path.split("/");
171 ret+=token.last() +" ";
172
173 }
174 return ret;
175 }