Debian Codegraph @

src/dj.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 "dj.h"cxx . . $ `<file>/src/dj.h`/
19 #include "filter.h"cxx . . $ `<file>/src/filter.h`/
20 #include <qdebug.h>
21 #include <qmutex.h>
22 #include <qwaitcondition.h>
23
24 struct DjPrivatecxx . . $ DjPrivate# {
25 int rotationcxx . . $ DjPrivate#rotation.;
26 QListcxx . . $ QList#<Filtercxx . . $ Filter#*> filterscxx . . $ DjPrivate#filters.;
27 Filtercxx . . $ Filter#* filtercxx . . $ DjPrivate#filter.;
28 long countTrackscxx . . $ DjPrivate#countTracks.;
29 long lengthTrackscxx . . $ DjPrivate#lengthTracks.;
30 QStringcxx . . $ QString# descriptioncxx . . $ DjPrivate#description.;
31 };
32
33 Djcxx . . $ Dj#::Djcxx . . $ Dj#Dj(49f6e7a06ebc5aa8).()
34 : pcxx . . $ Dj#p.(new DjPrivatecxx . . $ DjPrivate#)
35 {
36 pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. = 0;
37 pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter. = nullptr;
38 pcxx . . $ Dj#p.->descriptioncxx . . $ DjPrivate#description. =cxx . . $ QString#`operator=`(8a593bb14aaa45f5). QStringcxx . . $ QString#::nullcxx . . $ QString#null.;
39 pcxx . . $ Dj#p.->countTrackscxx . . $ DjPrivate#countTracks. = 0;
40 pcxx . . $ Dj#p.->lengthTrackscxx . . $ DjPrivate#lengthTracks. = 0;
41 }
42
43 Djcxx . . $ Dj#::~cxx . . $ Dj#`~Dj`(ced63f7c635d850d).Djcxx . . $ Dj#()
44 {
45 delete pcxx . . $ Dj#p.;
46 }
47
48 void Djcxx . . $ Dj#::addFiltercxx . . $ Dj#addFilter(d4630526fa8b762f).(Filtercxx . . $ Filter#* filter)
49 {
50 //qDebug() << Q_FUNC_INFO;
51 pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..appendcxx . . $ QList#append(77d9f17553126ecb).(filter);
52 connectcxx . . $ QObject#connect(158df1d9a01a3410).(filter, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(activated()),
53 this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(on_filter_activated()));
54 connectcxx . . $ QObject#connect(158df1d9a01a3410).(filter, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(filterChanged()),
55 this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(on_filter_filterChanged()));
56 connectcxx . . $ QObject#connect(158df1d9a01a3410).(filter, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(maxUsageChanged()),
57 this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(on_filter_maxUsageChanged()));
58 }
59
60 void Djcxx . . $ Dj#::removeFiltercxx . . $ Dj#removeFilter(d4630526fa8b762f).(Filtercxx . . $ Filter#* filter)
61 {
62 pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..removeOnecxx . . $ QList#removeOne(fe1ba53999e710f3).(filter);
63 }
64
65 QListcxx . . $ QList#<Filtercxx . . $ Filter#*> Djcxx . . $ Dj#::filterscxx . . $ Dj#filters(7f69582c18edfd8d).()
66 {
67 return pcxx . . $ QList#QList(3d2301cfd89f773a).->filterscxx . . $ DjPrivate#filters.;
68 }
69
70 void Djcxx . . $ Dj#::setActiveFilterIdxcxx . . $ Dj#setActiveFilterIdx(d4f767463ce0a6b3).(int idx)
71 {
72 pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. = idx;
73 if (pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. >= pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..countcxx . . $ QList#count(455f465bc33b4cdf).())
74 pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. = 0;
75 pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.]->setActivecxx . . $ Filter#setActive(b45ddcbc8423892c).(true);
76 }
77
78 int Djcxx . . $ Dj#::activeFilterIdxcxx . . $ Dj#activeFilterIdx(b126dc7c1de90089).()
79 {
80 return pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.;
81 }
82
83 void Djcxx . . $ Dj#::on_filter_filterChangedcxx . . $ Dj#on_filter_filterChanged(49f6e7a06ebc5aa8).()
84 {
85 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:240:11`!;
86 Filtercxx . . $ Filter#* f = qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<Filtercxx . . $ Filter#*>(QObjectcxx . . $ QObject#::sendercxx . . $ QObject#sender(2dbb680a34285c44).());
87 Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! filterChangedcxx . . $ Dj#filterChanged(d4630526fa8b762f).(f);
88 }
89
90 void Djcxx . . $ Dj#::on_filter_countChangedcxx . . $ Dj#on_filter_countChanged(49f6e7a06ebc5aa8).()
91 {
92 //qDebug() << Q_FUNC_INFO ;
93 //Filter* f = qobject_cast<Filter*>(QObject::sender());
94 //Q_EMIT countChanged();
95 }
96
97 void Djcxx . . $ Dj#::on_filter_activatedcxx . . $ Dj#on_filter_activated(49f6e7a06ebc5aa8).()
98 {
99 Filtercxx . . $ Filter#* f = qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<Filtercxx . . $ Filter#*>(QObjectcxx . . $ QObject#::sendercxx . . $ QObject#sender(2dbb680a34285c44).());
100 QListcxx . . $ QList#<Filter*>::iteratorcxx . . $ QList#iterator# icxx . . $ QList#iterator#iterator(ced63f7c635d850d).;
101 for (i =cxx . . $ QList#iterator#`operator=`(bf4a19a5c7778deb). pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..begincxx . . $ QList#begin(ca2520f641887418).(); i !=cxx . . $ QList#iterator#`operator!=`(afde28160b321935). pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..endcxx . . $ QList#end(ca2520f641887418).(); ++cxx . . $ QList#iterator#operator++(c343742bd746e713).i) {
102 if ((*cxx . . $ QList#iterator#`operator*`(c93303b41ac66b6d).i) != f)
103 (*cxx . . $ QList#iterator#`operator*`(c93303b41ac66b6d).i)->setActivecxx . . $ Filter#setActive(b45ddcbc8423892c).(false);
104 else {
105 pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. = pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..indexOfcxx . . $ QList#indexOf(fc79640c865a6596).((*cxx . . $ QList#iterator#`operator*`(c93303b41ac66b6d).i));
106 }
107 }
108 //p->wc.wakeAll();
109 }
110
111 void Djcxx . . $ Dj#::on_filter_maxUsageChangedcxx . . $ Dj#on_filter_maxUsageChanged(49f6e7a06ebc5aa8).()
112 {
113 Filtercxx . . $ Filter#* f = qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<Filtercxx . . $ Filter#*>(QObjectcxx . . $ QObject#::sendercxx . . $ QObject#sender(2dbb680a34285c44).());
114 if (pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter. == f)
115 checkSequencecxx . . $ Dj#checkSequence(49f6e7a06ebc5aa8).();
116 }
117
118 void Djcxx . . $ Dj#::checkSequencecxx . . $ Dj#checkSequence(49f6e7a06ebc5aa8).()
119 {
120
121 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "rotation=" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "/" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..countcxx . . $ QList#count(455f465bc33b4cdf).()
122 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " repeat=" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->usagecxx . . $ Filter#usage(b126dc7c1de90089).() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "/" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->maxUsagecxx . . $ Filter#maxUsage(b126dc7c1de90089).();
123
124 if (pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->usagecxx . . $ Filter#usage(b126dc7c1de90089).() >= pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->maxUsagecxx . . $ Filter#maxUsage(b126dc7c1de90089).()) {
125 int i = pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..countcxx . . $ QList#count(455f465bc33b4cdf).();
126 do {
127 pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.++;
128 i--;
129 if (pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. >= pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..countcxx . . $ QList#count(455f465bc33b4cdf).())
130 pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. = 0;
131 } while (pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..atcxx . . $ QList#at(e2681f9bb6b2f357).(pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.)->maxUsagecxx . . $ Filter#maxUsage(b126dc7c1de90089).() == 0
132 && i > 0);
133
134 pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..atcxx . . $ QList#at(e2681f9bb6b2f357).(pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.)->setActivecxx . . $ Filter#setActive(b45ddcbc8423892c).(true);
135
136 // setActive goes twice through SIGNAL/SLOT and back here,
137 // therefore a waitcondition is necessary to avoid race condition
138 /*p->mutex.lock();
139 p->wc.wait(&p->mutex);
140 p->mutex.unlock();*/
141 }
142 }
143
144 //ToDo: - Switch LED before add the Track
145 // - Allow 0 filter (skip)
146 // - DJwidget: Playbutton für start
147 Filtercxx . . $ Filter#* Djcxx . . $ Dj#::requestFiltercxx . . $ Dj#requestFilter(d71fbddbec531fa6).()
148 {
149 if (pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..isEmptycxx . . $ QList#isEmpty(3482b152b9333168).())
150 return nullptr;
151
152 pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter. = pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..atcxx . . $ QList#at(e2681f9bb6b2f357).(pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.);
153
154 pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->setUsagecxx . . $ Filter#setUsage(d4f767463ce0a6b3).(pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->usagecxx . . $ Filter#usage(b126dc7c1de90089).() + 1);
155
156 checkSequencecxx . . $ Dj#checkSequence(49f6e7a06ebc5aa8).();
157
158 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "rotation=" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation. <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "/" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..countcxx . . $ QList#count(455f465bc33b4cdf).()
159 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " repeat=" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->usagecxx . . $ Filter#usage(b126dc7c1de90089).() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "/" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.->maxUsagecxx . . $ Filter#maxUsage(b126dc7c1de90089).();
160
161 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). Q_FUNC_INFOcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:240:11`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "return filter=" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..atcxx . . $ QList#at(e2681f9bb6b2f357).(pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.)->pathcxx . . $ Filter#path(4365c3963150523e).()
162 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "/" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..atcxx . . $ QList#at(e2681f9bb6b2f357).(pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.)->genrecxx . . $ Filter#genre(4365c3963150523e).()
163 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "/" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). pcxx . . $ Dj#p.->filterscxx . . $ DjPrivate#filters..atcxx . . $ QList#at(e2681f9bb6b2f357).(pcxx . . $ Dj#p.->rotationcxx . . $ DjPrivate#rotation.)->artistcxx . . $ Filter#artist(4365c3963150523e).();
164
165 return pcxx . . $ Dj#p.->filtercxx . . $ DjPrivate#filter.;
166 }
167
168 QStringcxx . . $ QString# Djcxx . . $ Dj#::descriptioncxx . . $ Dj#description(4365c3963150523e).()
169 {
170 return pcxx . . $ QString#QString(132dd6869045752b).->descriptioncxx . . $ DjPrivate#description.;
171 }
172
173 void Djcxx . . $ Dj#::setDescriptioncxx . . $ Dj#setDescription(7df51288a9ebd664).(QStringcxx . . $ QString# value)
174 {
175 pcxx . . $ Dj#p.->descriptioncxx . . $ DjPrivate#description. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). value;
176 }
177
178 long Djcxx . . $ Dj#::countTrackscxx . . $ Dj#countTracks(da6335ded91d79c2).()
179 {
180 return pcxx . . $ Dj#p.->countTrackscxx . . $ DjPrivate#countTracks.;
181 }
182
183 void Djcxx . . $ Dj#::setCountTrackscxx . . $ Dj#setCountTracks(d4f767463ce0a6b3).(int value)
184 {
185 pcxx . . $ Dj#p.->countTrackscxx . . $ DjPrivate#countTracks. = value;
186 Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! countChangedcxx . . $ Dj#countChanged(49f6e7a06ebc5aa8).();
187 }
188
189 long Djcxx . . $ Dj#::lengthTrackscxx . . $ Dj#lengthTracks(da6335ded91d79c2).()
190 {
191 return pcxx . . $ Dj#p.->lengthTrackscxx . . $ DjPrivate#lengthTracks.;
192 }
193
194 void Djcxx . . $ Dj#::setLengthTrackscxx . . $ Dj#setLengthTracks(d4f767463ce0a6b3).(int value)
195 {
196 pcxx . . $ Dj#p.->lengthTrackscxx . . $ DjPrivate#lengthTracks. = value;
197 }