Merge lp:~daschuer/mixxx/1.10-autodj into lp:mixxx/1.10
- 1.10-autodj
- Merge into release-1.10.x
Proposed by
Daniel Schürmann
Status: | Merged | ||||
---|---|---|---|---|---|
Merge reported by: | Daniel Schürmann | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~daschuer/mixxx/1.10-autodj | ||||
Merge into: | lp:mixxx/1.10 | ||||
Diff against target: |
1731 lines (+680/-326) 31 files modified
mixxx/src/dlgautodj.cpp (+467/-233) mixxx/src/dlgautodj.h (+32/-10) mixxx/src/dlgprepare.h (+2/-0) mixxx/src/dlgrecording.cpp (+1/-0) mixxx/src/dlgrecording.h (+1/-0) mixxx/src/library/autodjfeature.cpp (+31/-25) mixxx/src/library/autodjfeature.h (+2/-0) mixxx/src/library/basesqltablemodel.cpp (+2/-1) mixxx/src/library/browse/browsefeature.cpp (+2/-1) mixxx/src/library/browse/browsefeature.h (+0/-1) mixxx/src/library/browse/browsetablemodel.cpp (+9/-9) mixxx/src/library/cratefeature.cpp (+1/-0) mixxx/src/library/dao/cratedao.h (+2/-0) mixxx/src/library/dao/playlistdao.cpp (+11/-3) mixxx/src/library/dao/playlistdao.h (+3/-1) mixxx/src/library/itunes/itunesfeature.cpp (+2/-3) mixxx/src/library/playlistfeature.cpp (+9/-2) mixxx/src/library/playlistfeature.h (+1/-0) mixxx/src/library/playlisttablemodel.cpp (+33/-11) mixxx/src/library/playlisttablemodel.h (+2/-3) mixxx/src/library/preparefeature.cpp (+16/-11) mixxx/src/library/preparefeature.h (+2/-0) mixxx/src/library/proxytrackmodel.cpp (+2/-1) mixxx/src/library/recording/recordingfeature.cpp (+20/-5) mixxx/src/library/recording/recordingfeature.h (+0/-1) mixxx/src/library/rhythmbox/rhythmboxfeature.cpp (+1/-2) mixxx/src/library/traktor/traktorfeature.cpp (+2/-2) mixxx/src/soundmanager.h (+1/-1) mixxx/src/widget/wsearchlineedit.cpp (+11/-0) mixxx/src/widget/wtracktableview.cpp (+9/-0) mixxx/src/widget/wtracktableview.h (+3/-0) |
||||
To merge this branch: | bzr merge lp:~daschuer/mixxx/1.10-autodj | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
RJ Skerry-Ryan | Approve | ||
Review via email: mp+108245@code.launchpad.net |
Commit message
Description of the change
Back port of the auto DJ patches, without the new controls.
To post a comment you must log in.
Revision history for this message
Daniel Schürmann (daschuer) wrote : | # |
Merged to #3107
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'mixxx/src/dlgautodj.cpp' |
2 | --- mixxx/src/dlgautodj.cpp 2011-11-30 06:19:47 +0000 |
3 | +++ mixxx/src/dlgautodj.cpp 2012-05-31 20:47:26 +0000 |
4 | @@ -1,28 +1,35 @@ |
5 | #include <QSqlTableModel> |
6 | -#include "widget/wwidget.h" |
7 | -#include "widget/wskincolor.h" |
8 | -#include "widget/wtracktableview.h" |
9 | + |
10 | +#include "dlgautodj.h" |
11 | + |
12 | #include "controlobject.h" |
13 | #include "controlobjectthreadmain.h" |
14 | +#include "library/playlisttablemodel.h" |
15 | #include "library/trackcollection.h" |
16 | -#include "library/playlisttablemodel.h" |
17 | -#include "dlgautodj.h" |
18 | +#include "playerinfo.h" |
19 | +#include "widget/wskincolor.h" |
20 | +#include "widget/wtracktableview.h" |
21 | +#include "widget/wwidget.h" |
22 | |
23 | +#define CONFIG_KEY "[Auto DJ]" |
24 | |
25 | DlgAutoDJ::DlgAutoDJ(QWidget* parent, ConfigObject<ConfigValue>* pConfig, |
26 | - TrackCollection* pTrackCollection, MixxxKeyboard* pKeyboard) |
27 | - : QWidget(parent), Ui::DlgAutoDJ(), m_playlistDao(pTrackCollection->getPlaylistDAO()) |
28 | -{ |
29 | + TrackCollection* pTrackCollection, |
30 | + MixxxKeyboard* pKeyboard) |
31 | + : QWidget(parent), |
32 | + Ui::DlgAutoDJ(), |
33 | + m_pConfig(pConfig), |
34 | + m_pTrackCollection(pTrackCollection), |
35 | + m_pTrackTableView( |
36 | + new WTrackTableView(this, pConfig, m_pTrackCollection)), |
37 | + m_playlistDao(pTrackCollection->getPlaylistDAO()), |
38 | + m_bFadeNow(false), |
39 | + m_eState(ADJ_DISABLED), |
40 | + m_posThreshold1(1.0f), |
41 | + m_posThreshold2(1.0f) { |
42 | setupUi(this); |
43 | |
44 | - m_pConfig = pConfig; |
45 | - m_pTrackCollection = pTrackCollection; |
46 | - m_bAutoDJEnabled = false; |
47 | - m_bPlayer1Primed = false; |
48 | - m_bPlayer2Primed = false; |
49 | - m_pTrackTableView = new WTrackTableView(this, pConfig, m_pTrackCollection); |
50 | m_pTrackTableView->installEventFilter(pKeyboard); |
51 | - |
52 | connect(m_pTrackTableView, SIGNAL(loadTrack(TrackPointer)), |
53 | this, SIGNAL(loadTrack(TrackPointer))); |
54 | connect(m_pTrackTableView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)), |
55 | @@ -34,8 +41,8 @@ |
56 | m_pTrackTablePlaceholder->hide(); |
57 | box->insertWidget(1, m_pTrackTableView); |
58 | |
59 | - m_pAutoDJTableModel = new PlaylistTableModel(this, pTrackCollection, |
60 | - "mixxx.db.model.autodj"); |
61 | + m_pAutoDJTableModel = new PlaylistTableModel(this, pTrackCollection, |
62 | + "mixxx.db.model.autodj"); |
63 | int playlistId = m_playlistDao.getPlaylistIdFromName(AUTODJ_TABLE); |
64 | if (playlistId < 0) { |
65 | m_playlistDao.createPlaylist(AUTODJ_TABLE, true); |
66 | @@ -44,7 +51,7 @@ |
67 | m_pAutoDJTableModel->setPlaylist(playlistId); |
68 | m_pTrackTableView->loadTrackModel(m_pAutoDJTableModel); |
69 | |
70 | - //Override some playlist-view properties: |
71 | + // Override some playlist-view properties: |
72 | |
73 | // Do not set this because it disables auto-scrolling |
74 | //m_pTrackTableView->setDragDropMode(QAbstractItemView::InternalMove); |
75 | @@ -58,40 +65,49 @@ |
76 | connect(pushButtonAutoDJ, SIGNAL(toggled(bool)), |
77 | this, SLOT(toggleAutoDJ(bool))); _blah; |
78 | |
79 | + // playposition is from -0.14 to + 1.14 |
80 | m_pCOPlayPos1 = new ControlObjectThreadMain( |
81 | - ControlObject::getControl(ConfigKey("[Channel1]", "playposition"))); |
82 | + ControlObject::getControl(ConfigKey("[Channel1]", "playposition"))); |
83 | m_pCOPlayPos2 = new ControlObjectThreadMain( |
84 | - ControlObject::getControl(ConfigKey("[Channel2]", "playposition"))); |
85 | + ControlObject::getControl(ConfigKey("[Channel2]", "playposition"))); |
86 | m_pCOPlay1 = new ControlObjectThreadMain( |
87 | - ControlObject::getControl(ConfigKey("[Channel1]", "play"))); |
88 | + ControlObject::getControl(ConfigKey("[Channel1]", "play"))); |
89 | m_pCOPlay2 = new ControlObjectThreadMain( |
90 | - ControlObject::getControl(ConfigKey("[Channel2]", "play"))); |
91 | + ControlObject::getControl(ConfigKey("[Channel2]", "play"))); |
92 | + m_pCOPlay1Fb = new ControlObjectThreadMain( |
93 | + ControlObject::getControl(ConfigKey("[Channel1]", "play"))); |
94 | + m_pCOPlay2Fb = new ControlObjectThreadMain( |
95 | + ControlObject::getControl(ConfigKey("[Channel2]", "play"))); |
96 | m_pCORepeat1 = new ControlObjectThreadMain( |
97 | - ControlObject::getControl(ConfigKey("[Channel1]", "repeat"))); |
98 | + ControlObject::getControl(ConfigKey("[Channel1]", "repeat"))); |
99 | m_pCORepeat2 = new ControlObjectThreadMain( |
100 | - ControlObject::getControl(ConfigKey("[Channel2]", "repeat"))); |
101 | + ControlObject::getControl(ConfigKey("[Channel2]", "repeat"))); |
102 | m_pCOCrossfader = new ControlObjectThreadMain( |
103 | - ControlObject::getControl(ConfigKey("[Master]", "crossfader"))); |
104 | + ControlObject::getControl(ConfigKey("[Master]", "crossfader"))); |
105 | } |
106 | |
107 | -DlgAutoDJ::~DlgAutoDJ() |
108 | -{ |
109 | +DlgAutoDJ::~DlgAutoDJ() { |
110 | + qDebug() << "~DlgAutoDJ()"; |
111 | delete m_pCOPlayPos1; |
112 | delete m_pCOPlayPos2; |
113 | delete m_pCOPlay1; |
114 | delete m_pCOPlay2; |
115 | + delete m_pCOPlay1Fb; |
116 | + delete m_pCOPlay2Fb; |
117 | + delete m_pCORepeat1; |
118 | delete m_pCORepeat2; |
119 | delete m_pCOCrossfader; |
120 | + // Delete m_pTrackTableView before the table model. This is because the |
121 | + // table view saves the header state using the model. |
122 | + delete m_pTrackTableView; |
123 | + delete m_pAutoDJTableModel; |
124 | } |
125 | |
126 | -void DlgAutoDJ::onShow() |
127 | -{ |
128 | +void DlgAutoDJ::onShow() { |
129 | m_pAutoDJTableModel->select(); |
130 | } |
131 | |
132 | -void DlgAutoDJ::setup(QDomNode node) |
133 | -{ |
134 | - |
135 | +void DlgAutoDJ::setup(QDomNode node) { |
136 | QPalette pal = palette(); |
137 | |
138 | // Row colors |
139 | @@ -108,9 +124,6 @@ |
140 | // the future this should be configurable from the skin with this as the |
141 | // fallback option |
142 | QColor text(255 - r1.red(), 255 - r1.green(), 255 - r1.blue()); |
143 | - |
144 | - //setAlternatingRowColors ( true ); |
145 | - |
146 | QColor fgColor; |
147 | fgColor.setNamedColor(WWidget::selectNodeQString(node, "FgColor")); |
148 | fgColor = WSkinColor::getCorrectColor(fgColor); |
149 | @@ -119,26 +132,24 @@ |
150 | pal.setColor(QPalette::AlternateBase, r2); |
151 | pal.setColor(QPalette::Text, text); |
152 | pal.setColor(QPalette::WindowText, fgColor); |
153 | - |
154 | } |
155 | |
156 | setPalette(pal); |
157 | |
158 | pushButtonAutoDJ->setPalette(pal); |
159 | - //m_pTrackTableView->setPalette(pal); //Since we're getting this passed into us already created, |
160 | - //shouldn't need to set the palette. |
161 | -} |
162 | - |
163 | -void DlgAutoDJ::onSearchStarting() |
164 | -{ |
165 | -} |
166 | - |
167 | -void DlgAutoDJ::onSearchCleared() |
168 | -{ |
169 | -} |
170 | - |
171 | -void DlgAutoDJ::onSearch(const QString& text) |
172 | -{ |
173 | + |
174 | + // Since we're getting this passed into us already created, shouldn't need |
175 | + // to set the palette. |
176 | + //m_pTrackTableView->setPalette(pal); |
177 | +} |
178 | + |
179 | +void DlgAutoDJ::onSearchStarting() { |
180 | +} |
181 | + |
182 | +void DlgAutoDJ::onSearchCleared() { |
183 | +} |
184 | + |
185 | +void DlgAutoDJ::onSearch(const QString& text) { |
186 | m_pAutoDJTableModel->search(text); |
187 | } |
188 | |
189 | @@ -154,204 +165,427 @@ |
190 | m_pTrackTableView->moveSelection(delta); |
191 | } |
192 | |
193 | -void DlgAutoDJ::shufflePlaylist(bool buttonChecked) |
194 | -{ |
195 | +void DlgAutoDJ::shufflePlaylist(bool buttonChecked) { |
196 | Q_UNUSED(buttonChecked); |
197 | qDebug() << "Shuffling AutoDJ playlist"; |
198 | - m_pAutoDJTableModel->shuffleTracks(m_pAutoDJTableModel->index(0, 0)); |
199 | + int row; |
200 | + if(m_eState == ADJ_DISABLED) { |
201 | + row = 0; |
202 | + } else { |
203 | + row = 1; |
204 | + } |
205 | + m_pAutoDJTableModel->shuffleTracks(m_pAutoDJTableModel->index(row, 0)); |
206 | qDebug() << "Shuffling done"; |
207 | } |
208 | |
209 | -void DlgAutoDJ::toggleAutoDJ(bool toggle) |
210 | -{ |
211 | - if (toggle) //Enable Auto DJ |
212 | - { |
213 | - if (m_pCOPlay1->get() == 1.0f && m_pCOPlay2->get() == 1.0f) { |
214 | - qDebug() << "One player must be stopped before enabling Auto DJ mode"; |
215 | - pushButtonAutoDJ->setChecked(false); |
216 | - return; |
217 | - } |
218 | - |
219 | +void DlgAutoDJ::skipNext(bool buttonChecked) { |
220 | + Q_UNUSED(buttonChecked); |
221 | + qDebug() << "Skip Next"; |
222 | + // Load the next song from the queue. |
223 | + if (m_pCOPlay1Fb->get() == 0.0f) { |
224 | + removePlayingTrackFromQueue("[Channel1]"); |
225 | + loadNextTrackFromQueue(); |
226 | + } else if (m_pCOPlay2Fb->get() == 0.0f) { |
227 | + removePlayingTrackFromQueue("[Channel2]"); |
228 | + loadNextTrackFromQueue(); |
229 | + } |
230 | +} |
231 | + |
232 | +void DlgAutoDJ::fadeNow(bool buttonChecked) { |
233 | + Q_UNUSED(buttonChecked); |
234 | + qDebug() << "Fade Now"; |
235 | + if (m_eState == ADJ_IDLE) { |
236 | + m_bFadeNow = true; |
237 | + double crossfader = m_pCOCrossfader->get(); |
238 | + if (crossfader <= 0.3f && m_pCOPlay1Fb->get() == 1.0f) { |
239 | + m_posThreshold1 = m_pCOPlayPos1->get() - |
240 | + ((crossfader + 1.0f) / 2 * (m_fadeDuration1)); |
241 | + // Repeat is disabled by FadeNow but disables auto Fade |
242 | + m_pCORepeat1->slotSet(0.0f); |
243 | + } else if (crossfader >= -0.3f && m_pCOPlay2Fb->get() == 1.0f) { |
244 | + m_posThreshold2 = m_pCOPlayPos2->get() - |
245 | + ((1.0f - crossfader) / 2 * (m_fadeDuration2)); |
246 | + // Repeat is disabled by FadeNow but disables auto Fade |
247 | + m_pCORepeat2->slotSet(0.0f); |
248 | + } |
249 | + } |
250 | +} |
251 | + |
252 | +void DlgAutoDJ::toggleAutoDJ(bool toggle) { |
253 | + bool deck1Playing = m_pCOPlay1Fb->get() == 1.0f; |
254 | + bool deck2Playing = m_pCOPlay2Fb->get() == 1.0f; |
255 | + |
256 | + if (toggle) { // Enable Auto DJ |
257 | + if (deck1Playing && deck2Playing) { |
258 | + QMessageBox::warning( |
259 | + NULL, tr("Auto-DJ"), |
260 | + tr("One deck must be stopped to enable Auto-DJ mode."), |
261 | + QMessageBox::Ok); |
262 | + qDebug() << "One deck must be stopped before enabling Auto DJ mode"; |
263 | + pushButtonAutoDJ->setChecked(false); |
264 | + return; |
265 | + } |
266 | + |
267 | + // Never load the same track if it is already playing |
268 | + if (deck1Playing) { |
269 | + removePlayingTrackFromQueue("[Channel1]"); |
270 | + } |
271 | + if (deck2Playing) { |
272 | + removePlayingTrackFromQueue("[Channel2]"); |
273 | + } |
274 | + |
275 | + TrackPointer nextTrack = getNextTrackFromQueue(); |
276 | + if (!nextTrack) { |
277 | + qDebug() << "Queue is empty now"; |
278 | + pushButtonAutoDJ->setChecked(false); |
279 | + return; |
280 | + } |
281 | + |
282 | + // Track is available so GO |
283 | + pushButtonAutoDJ->setToolTip(tr("Disable Auto DJ")); |
284 | pushButtonAutoDJ->setText(tr("Disable Auto DJ")); |
285 | - m_bAutoDJEnabled = true; |
286 | + qDebug() << "Auto DJ enabled"; |
287 | + |
288 | connect(m_pCOPlayPos1, SIGNAL(valueChanged(double)), |
289 | - this, SLOT(player1PositionChanged(double))); |
290 | + this, SLOT(player1PositionChanged(double))); |
291 | connect(m_pCOPlayPos2, SIGNAL(valueChanged(double)), |
292 | - this, SLOT(player2PositionChanged(double))); |
293 | - |
294 | - |
295 | - //Manually override the "next track is already loaded" flag |
296 | - //because we've already primed a player with the first track. |
297 | - //We do this so that you don't lose the first song in your |
298 | - //Auto DJ queue if you enable Auto DJ then change your mind |
299 | - //and disable it right away. This just makes it a little bit |
300 | - //more user friendly. :) |
301 | - //m_bNextTrackAlreadyLoaded = true; |
302 | - m_bPlayer1Primed = false; |
303 | - m_bPlayer2Primed = false; |
304 | - |
305 | - //If there are no tracks in the Auto DJ queue, disable Auto DJ mode. |
306 | - /* if (m_pAutoDJTableModel->rowCount() == 0) |
307 | - { |
308 | - //Queue was empty. Disable and return. |
309 | - pushButtonAutoDJ->setChecked(false); |
310 | - return; |
311 | - }*/ //don't need this code, above block takes care of this case. |
312 | - |
313 | - //If only one of the players is playing... |
314 | - if ((m_pCOPlay1->get() == 1.0f && m_pCOPlay2->get() == 0.0f) || |
315 | - (m_pCOPlay1->get() == 0.0f && m_pCOPlay2->get() == 1.0f)) |
316 | - { |
317 | - //Load the first song from the queue. |
318 | - if (!loadNextTrackFromQueue(false)) { |
319 | - //Queue was empty. Disable and return. |
320 | - pushButtonAutoDJ->setChecked(false); |
321 | - return; |
322 | - } |
323 | - //Set the primed flags so the crossfading algorithm knows |
324 | - //that it doesn't need to load a track into whatever player. |
325 | - if (m_pCOPlay1->get() == 1.0f) |
326 | - { |
327 | - m_bPlayer1Primed = true; |
328 | - } |
329 | - if (m_pCOPlay2->get() == 1.0f) |
330 | - { |
331 | - m_bPlayer2Primed = true; |
332 | - } |
333 | - } |
334 | - //If both players are stopped, start the first one (which should have just had a track loaded into it) |
335 | - else if (m_pCOPlay1->get() == 0.0f && m_pCOPlay2->get() == 0.0f) { |
336 | - //Load the first song from the queue. |
337 | - if (!loadNextTrackFromQueue(false)) { |
338 | - //Queue was empty. Disable and return. |
339 | - pushButtonAutoDJ->setChecked(false); |
340 | - return; |
341 | - } |
342 | - m_pCOCrossfader->slotSet(-1.0f); //Move crossfader to the left! |
343 | - m_pCORepeat1->slotSet(1.0f); //Turn on repeat mode to avoid race condition between async load |
344 | - //and "play" command. |
345 | - m_pCOPlay1->slotSet(1.0f); //Play the track in player 1 |
346 | - } |
347 | - } |
348 | - else //Disable Auto DJ |
349 | - { |
350 | + this, SLOT(player2PositionChanged(double))); |
351 | + |
352 | + connect(m_pCOPlay1Fb, SIGNAL(valueChanged(double)), |
353 | + this, SLOT(player1PlayChanged(double))); |
354 | + connect(m_pCOPlay2Fb, SIGNAL(valueChanged(double)), |
355 | + this, SLOT(player2PlayChanged(double))); |
356 | + |
357 | + if (!deck1Playing && !deck2Playing) { |
358 | + // both decks are stopped |
359 | + m_eState = ADJ_ENABLE_P1LOADED; |
360 | + // Force Update on load Track |
361 | + m_pCOPlayPos1->slotSet(-0.001f); |
362 | + } else { |
363 | + m_eState = ADJ_IDLE; |
364 | + if (deck1Playing) { |
365 | + // deck 1 is already playing |
366 | + player1PlayChanged(1.0f); |
367 | + } else { |
368 | + // deck 2 is already playing |
369 | + player2PlayChanged(1.0f); |
370 | + } |
371 | + } |
372 | + // Loads into first deck If stopped else into second else not |
373 | + emit(loadTrack(nextTrack)); |
374 | + } else { // Disable Auto DJ |
375 | + pushButtonAutoDJ->setToolTip(tr("Enable Auto DJ")); |
376 | pushButtonAutoDJ->setText(tr("Enable Auto DJ")); |
377 | qDebug() << "Auto DJ disabled"; |
378 | - m_bAutoDJEnabled = false; |
379 | + m_eState = ADJ_DISABLED; |
380 | + m_bFadeNow = false; |
381 | m_pCOPlayPos1->disconnect(this); |
382 | m_pCOPlayPos2->disconnect(this); |
383 | - m_pCORepeat1->slotSet(0.0f); //Turn off repeat mode |
384 | - m_pCORepeat2->slotSet(0.0f); //Turn off repeat mode |
385 | - } |
386 | -} |
387 | - |
388 | -void DlgAutoDJ::player1PositionChanged(double value) |
389 | -{ |
390 | - const float posThreshold = 0.95; //95% playback is when we crossfade and do stuff |
391 | - if (value > posThreshold) |
392 | - { |
393 | - //Crossfade! |
394 | - float crossfadeValue = -1.0f + 2*(value-posThreshold)/(1.0f-posThreshold); |
395 | - m_pCOCrossfader->slotSet(crossfadeValue); //Move crossfader to the right! |
396 | - //If the second player doesn't have a new track loaded in it... |
397 | - if (!m_bPlayer2Primed) |
398 | - { |
399 | - qDebug() << "pp1c loading"; |
400 | - |
401 | - //Load the next track into Player 2 |
402 | - //if (!m_bNextTrackAlreadyLoaded) //Fudge to make us not skip the first track |
403 | - { |
404 | - if (!loadNextTrackFromQueue(true)) |
405 | - return; |
406 | - } |
407 | - //m_bNextTrackAlreadyLoaded = false; //Reset fudge |
408 | - m_bPlayer2Primed = true; |
409 | - } |
410 | - //If the second player is stopped... |
411 | - if (m_pCOPlay2->get() == 0.0f) |
412 | - { |
413 | - //Turn off repeat mode to tell Player 1 to stop at the end |
414 | - m_pCORepeat1->slotSet(0.0f); |
415 | - |
416 | - //Turn on repeat mode to tell Player 2 to start playing when the new track is loaded. |
417 | - //This helps us get around the fact that it takes time for the track to be loaded |
418 | - //and that is executed asynchronously (so we get around the race condition). |
419 | - m_pCORepeat2->slotSet(1.0f); |
420 | - //Play! |
421 | - m_pCOPlay2->slotSet(1.0f); |
422 | - } |
423 | - |
424 | - if (value == 1.0f) |
425 | - { |
426 | - m_pCOPlay1->slotSet(0.0f); //Stop the player |
427 | - m_bPlayer1Primed = false; |
428 | - } |
429 | - } |
430 | -} |
431 | - |
432 | -void DlgAutoDJ::player2PositionChanged(double value) |
433 | -{ |
434 | - const float posThreshold = 0.95; //95% playback is when we crossfade and do stuff |
435 | - if (value > posThreshold) |
436 | - { |
437 | - //Crossfade! |
438 | - float crossfadeValue = 1.0f - 2*(value-posThreshold)/(1.0f-posThreshold); |
439 | - m_pCOCrossfader->slotSet(crossfadeValue); //Move crossfader to the right! |
440 | - |
441 | - //If the first player doesn't have the next track loaded, load a track into |
442 | - //it and start playing it! |
443 | - if (!m_bPlayer1Primed) |
444 | - { |
445 | - //Load the next track into player 1 |
446 | - //if (!m_bNextTrackAlreadyLoaded) //Fudge to make us not skip the first track |
447 | - { |
448 | - if (!loadNextTrackFromQueue(true)) |
449 | - return; |
450 | - } |
451 | - //m_bNextTrackAlreadyLoaded = false; //Reset fudge |
452 | - m_bPlayer1Primed = true; |
453 | - } |
454 | - if (m_pCOPlay1->get() == 0.0f) |
455 | - { |
456 | - //Turn off repeat mode to tell Player 2 to stop at the end |
457 | - m_pCORepeat2->slotSet(0.0f); |
458 | - |
459 | - //Turn on repeat mode to tell Player 1 to start playing when the new track is loaded. |
460 | - //This helps us get around the fact that it takes time for the track to be loaded |
461 | - //and that is executed asynchronously (so we get around the race condition). |
462 | - m_pCORepeat1->slotSet(1.0f); |
463 | - m_pCOPlay1->slotSet(1.0f); |
464 | - } |
465 | - |
466 | - if (value == 1.0f) |
467 | - { |
468 | - m_pCOPlay2->slotSet(0.0f); //Stop the player |
469 | - m_bPlayer2Primed = false; |
470 | - } |
471 | - } |
472 | -} |
473 | - |
474 | - |
475 | -bool DlgAutoDJ::loadNextTrackFromQueue(bool removeTopMostBeforeLoading) |
476 | -{ |
477 | - if (removeTopMostBeforeLoading) { |
478 | - //Only remove the top track if this isn't the start of Auto DJ mode. |
479 | - m_pAutoDJTableModel->removeTrack(m_pAutoDJTableModel->index(0, 0)); |
480 | - } |
481 | - |
482 | - //Get the track at the top of the playlist... |
483 | - TrackPointer nextTrack = m_pAutoDJTableModel->getTrack(m_pAutoDJTableModel->index(0, 0)); |
484 | - |
485 | - if (!nextTrack) //We ran out of tracks in the queue... |
486 | - { |
487 | - //Disable auto DJ and return... |
488 | + m_pCOPlay1->disconnect(this); |
489 | + m_pCOPlay2->disconnect(this); |
490 | + } |
491 | +} |
492 | + |
493 | +void DlgAutoDJ::player1PositionChanged(double value) { |
494 | + // 95% playback is when we crossfade and do stuff |
495 | + // const float posThreshold = 0.95; |
496 | + |
497 | + // 0.05; // 5% playback is crossfade duration |
498 | + const float fadeDuration = m_fadeDuration1; |
499 | + |
500 | + // qDebug() << "player1PositionChanged(" << value << ")"; |
501 | + if (m_eState == ADJ_DISABLED) { |
502 | + //nothing to do |
503 | + return; |
504 | + } |
505 | + |
506 | + bool deck1Playing = m_pCOPlay1Fb->get() == 1.0f; |
507 | + bool deck2Playing = m_pCOPlay2Fb->get() == 1.0f; |
508 | + |
509 | + if (m_eState == ADJ_ENABLE_P1LOADED) { |
510 | + // Auto DJ Start |
511 | + if (!deck1Playing && !deck2Playing) { |
512 | + m_pCOCrossfader->slotSet(-1.0f); // Move crossfader to the left! |
513 | + m_pCOPlay1->slotSet(1.0f); // Play the track in player 1 |
514 | + removePlayingTrackFromQueue("[Channel1]"); |
515 | + } else { |
516 | + m_eState = ADJ_IDLE; |
517 | + if (deck1Playing && !deck2Playing) { |
518 | + // Here we are, if first deck was playing before starting Auto DJ |
519 | + // or if it was started just before |
520 | + loadNextTrackFromQueue(); |
521 | + // if we start the deck from code we don`t get a signal |
522 | + player1PlayChanged(1.0f); |
523 | + // call function manually |
524 | + } else { |
525 | + player2PlayChanged(1.0f); |
526 | + } |
527 | + } |
528 | + return; |
529 | + } |
530 | + |
531 | + if (m_eState == ADJ_P2FADING) { |
532 | + if (deck1Playing && !deck2Playing) { |
533 | + // End State |
534 | + m_pCOCrossfader->slotSet(-1.0f); // Move crossfader to the left! |
535 | + // qDebug() << "1: m_pCOCrossfader->slotSet(_-1.0f_);"; |
536 | + m_eState = ADJ_IDLE; |
537 | + loadNextTrackFromQueue(); |
538 | + } |
539 | + return; |
540 | + } |
541 | + |
542 | + if (m_eState == ADJ_IDLE) { |
543 | + if (m_pCORepeat1->get() == 1.0f) { |
544 | + // repeat disables auto DJ |
545 | + return; |
546 | + } |
547 | + } |
548 | + |
549 | + if (value >= m_posThreshold1) { |
550 | + if (m_eState == ADJ_IDLE && |
551 | + (deck1Playing || m_posThreshold1 >= 1.0f)) { |
552 | + if (!deck2Playing) { |
553 | + // Start Deck 2 |
554 | + player2PlayChanged(1.0f); |
555 | + m_pCOPlay2->slotSet(1.0f); |
556 | + if (fadeDuration < 0.0f) { |
557 | + // Scroll back for pause between tracks |
558 | + m_pCOPlayPos2->slotSet(m_fadeDuration2); |
559 | + } |
560 | + } |
561 | + removePlayingTrackFromQueue("[Channel2]"); |
562 | + m_eState = ADJ_P1FADING; |
563 | + } |
564 | + |
565 | + float posFadeEnd = math_min(1.0, m_posThreshold1 + fadeDuration); |
566 | + |
567 | + if (value >= posFadeEnd) { |
568 | + // Pre-EndState |
569 | + // m_pCOCrossfader->slotSet(1.0f); //Move crossfader to the right! |
570 | + |
571 | + m_pCOPlay1->slotSet(0.0f); // Stop the player |
572 | + //m_posThreshold = 1.0f - fadeDuration; // back to default |
573 | + |
574 | + // does not work always immediately after stop |
575 | + // loadNextTrackFromQueue(); |
576 | + // m_eState = ADJ_IDLE; // Fading ready |
577 | + } else { |
578 | + // Crossfade! |
579 | + float crossfadeValue = -1.0f + |
580 | + 2*(value-m_posThreshold1)/(posFadeEnd-m_posThreshold1); |
581 | + // crossfadeValue = -1.0f -> + 1.0f |
582 | + // Move crossfader to the right! |
583 | + m_pCOCrossfader->slotSet(crossfadeValue); |
584 | + // qDebug() << "1: m_pCOCrossfader->slotSet " << crossfadeValue; |
585 | + } |
586 | + } |
587 | +} |
588 | + |
589 | +void DlgAutoDJ::player2PositionChanged(double value) { |
590 | + // 95% playback is when we crossfade and do stuff |
591 | + // const float posThreshold = 0.95; |
592 | + |
593 | + // 0.05; // 5% playback is crossfade duration |
594 | + float fadeDuration = m_fadeDuration2; |
595 | + |
596 | + //qDebug() << "player2PositionChanged(" << value << ")"; |
597 | + if (m_eState == ADJ_DISABLED) { |
598 | + //nothing to do |
599 | + return; |
600 | + } |
601 | + |
602 | + bool deck1Playing = m_pCOPlay1Fb->get() == 1.0f; |
603 | + bool deck2Playing = m_pCOPlay2Fb->get() == 1.0f; |
604 | + |
605 | + if (m_eState == ADJ_P1FADING) { |
606 | + if (!deck1Playing && deck2Playing) { |
607 | + // End State |
608 | + // Move crossfader to the right! |
609 | + m_pCOCrossfader->slotSet(1.0f); |
610 | + // qDebug() << "1: m_pCOCrossfader->slotSet(_1.0f_);"; |
611 | + m_eState = ADJ_IDLE; |
612 | + loadNextTrackFromQueue(); |
613 | + } |
614 | + return; |
615 | + } |
616 | + |
617 | + if (m_eState == ADJ_IDLE) { |
618 | + if (m_pCORepeat2->get() == 1.0f) { |
619 | + //repeat disables auto DJ |
620 | + return; |
621 | + } |
622 | + } |
623 | + |
624 | + if (value >= m_posThreshold2) { |
625 | + if (m_eState == ADJ_IDLE && |
626 | + (deck2Playing || m_posThreshold2 >= 1.0f)) { |
627 | + if (!deck1Playing) { |
628 | + player1PlayChanged(1.0f); |
629 | + m_pCOPlay1->slotSet(1.0f); |
630 | + if (fadeDuration < 0) { |
631 | + // Scroll back for pause between tracks |
632 | + m_pCOPlayPos1->slotSet(m_fadeDuration1); |
633 | + } |
634 | + } |
635 | + removePlayingTrackFromQueue("[Channel1]"); |
636 | + m_eState = ADJ_P2FADING; |
637 | + } |
638 | + |
639 | + float posFadeEnd = math_min(1.0, m_posThreshold2 + fadeDuration); |
640 | + |
641 | + if (value >= posFadeEnd) { |
642 | + // Pre-End State |
643 | + //m_pCOCrossfader->slotSet(-1.0f); //Move crossfader to the left! |
644 | + |
645 | + m_pCOPlay2->slotSet(0.0f); // Stop the player |
646 | + |
647 | + //m_posThreshold = 1.0f - fadeDuration; // back to default |
648 | + |
649 | + // does not work always immediately after stop |
650 | + // loadNextTrackFromQueue(); |
651 | + // m_eState = ADJ_IDLE; // Fading ready |
652 | + } else { |
653 | + //Crossfade! |
654 | + float crossfadeValue = 1.0f - |
655 | + 2*(value-m_posThreshold2)/(posFadeEnd-m_posThreshold2); |
656 | + // crossfadeValue = 1.0f -> + -1.0f |
657 | + m_pCOCrossfader->slotSet(crossfadeValue); //Move crossfader to the right! |
658 | + // qDebug() << "2: m_pCOCrossfader->slotSet " << crossfadeValue; |
659 | + } |
660 | + } |
661 | +} |
662 | + |
663 | +TrackPointer DlgAutoDJ::getNextTrackFromQueue() { |
664 | + // Get the track at the top of the playlist... |
665 | + TrackPointer nextTrack; |
666 | + |
667 | + while (true) { |
668 | + nextTrack = m_pAutoDJTableModel->getTrack( |
669 | + m_pAutoDJTableModel->index(0, 0)); |
670 | + |
671 | + if (nextTrack) { |
672 | + if (nextTrack->exists()) { |
673 | + // found a valid Track |
674 | + return nextTrack; |
675 | + } else { |
676 | + // Remove missing song from auto DJ playlist |
677 | + m_pAutoDJTableModel->removeTrack( |
678 | + m_pAutoDJTableModel->index(0, 0)); |
679 | + } |
680 | + } else { |
681 | + // we are running out of tracks |
682 | + break; |
683 | + } |
684 | + } |
685 | + return nextTrack; |
686 | +} |
687 | + |
688 | +bool DlgAutoDJ::loadNextTrackFromQueue() { |
689 | + TrackPointer nextTrack = getNextTrackFromQueue(); |
690 | + |
691 | + // We ran out of tracks in the queue... |
692 | + if (!nextTrack) { |
693 | + // Disable auto DJ and return... |
694 | pushButtonAutoDJ->setChecked(false); |
695 | + // And eject track as "End of auto DJ warning" |
696 | + emit(loadTrack(nextTrack)); |
697 | return false; |
698 | } |
699 | |
700 | - //m_bNextTrackAlreadyLoaded = false; |
701 | - |
702 | emit(loadTrack(nextTrack)); |
703 | - |
704 | - return true; |
705 | + return true; |
706 | +} |
707 | + |
708 | +bool DlgAutoDJ::removePlayingTrackFromQueue(QString group) { |
709 | + TrackPointer nextTrack, loadedTrack; |
710 | + int nextId = 0, loadedId = 0; |
711 | + |
712 | + // Get the track at the top of the playlist... |
713 | + nextTrack = m_pAutoDJTableModel->getTrack(m_pAutoDJTableModel->index(0, 0)); |
714 | + if (nextTrack) { |
715 | + nextId = nextTrack->getId(); |
716 | + } |
717 | + |
718 | + // Get loaded track |
719 | + loadedTrack = PlayerInfo::Instance().getTrackInfo(group); |
720 | + if (loadedTrack) { |
721 | + loadedId = loadedTrack->getId(); |
722 | + } |
723 | + |
724 | + // When enable auto DJ and Topmost Song is already on second deck, nothing to do |
725 | + //BaseTrackPlayer::getLoadedTrack() |
726 | + //pTrack = PlayerInfo::Instance().getCurrentPlayingTrack(); |
727 | + |
728 | + if (loadedId != nextId) { |
729 | + // Do not remove when the user has loaded a track manually |
730 | + return false; |
731 | + } |
732 | + |
733 | + // remove the top track |
734 | + m_pAutoDJTableModel->removeTrack(m_pAutoDJTableModel->index(0, 0)); |
735 | + |
736 | + return true; |
737 | +} |
738 | + |
739 | +void DlgAutoDJ::player1PlayChanged(double value) { |
740 | + //qDebug() << "player1PlayChanged(" << value << ")"; |
741 | + if (value == 1.0f && m_eState == ADJ_IDLE) { |
742 | + TrackPointer loadedTrack = |
743 | + PlayerInfo::Instance().getTrackInfo("[Channel1]"); |
744 | + if (loadedTrack) { |
745 | + int TrackDuration = loadedTrack->getDuration(); |
746 | + qDebug() << "TrackDuration = " << TrackDuration; |
747 | + |
748 | + int autoDjTransition = 5; |
749 | + |
750 | + if (TrackDuration > autoDjTransition) { |
751 | + m_fadeDuration1 = static_cast<float>(autoDjTransition) / |
752 | + static_cast<float>(TrackDuration); |
753 | + } else { |
754 | + m_fadeDuration1 = 0; |
755 | + } |
756 | + |
757 | + if (autoDjTransition > 0) { |
758 | + m_posThreshold1 = 1.0f - m_fadeDuration1; |
759 | + } else { |
760 | + // in case of pause |
761 | + m_posThreshold1 = 1.0f; |
762 | + } |
763 | + qDebug() << "m_fadeDuration1 = " << m_fadeDuration1; |
764 | + } |
765 | + } |
766 | +} |
767 | + |
768 | +void DlgAutoDJ::player2PlayChanged(double value) { |
769 | + //qDebug() << "player2PlayChanged(" << value << ")"; |
770 | + if (value == 1.0f && m_eState == ADJ_IDLE) { |
771 | + TrackPointer loadedTrack = |
772 | + PlayerInfo::Instance().getTrackInfo("[Channel2]"); |
773 | + if (loadedTrack) { |
774 | + int TrackDuration = loadedTrack->getDuration(); |
775 | + qDebug() << "TrackDuration = " << TrackDuration; |
776 | + |
777 | + int autoDjTransition = 5; |
778 | + |
779 | + if (TrackDuration > autoDjTransition) { |
780 | + m_fadeDuration2 = static_cast<float>(autoDjTransition) / |
781 | + static_cast<float>(TrackDuration); |
782 | + } else { |
783 | + m_fadeDuration2 = 0; |
784 | + } |
785 | + |
786 | + if (autoDjTransition > 0) { |
787 | + m_posThreshold2 = 1.0f - m_fadeDuration2; |
788 | + } else { |
789 | + // in case of pause |
790 | + m_posThreshold2 = 1.0f; |
791 | + } |
792 | + qDebug() << "m_fadeDuration2 = " << m_fadeDuration2; |
793 | + } |
794 | + } |
795 | +} |
796 | + |
797 | +bool DlgAutoDJ::appendTrack(int trackId) { |
798 | + return m_pAutoDJTableModel->appendTrack(trackId); |
799 | } |
800 | |
801 | === modified file 'mixxx/src/dlgautodj.h' |
802 | --- mixxx/src/dlgautodj.h 2011-04-24 06:00:11 +0000 |
803 | +++ mixxx/src/dlgautodj.h 2012-05-31 20:47:26 +0000 |
804 | @@ -31,37 +31,59 @@ |
805 | virtual void loadSelectedTrack(); |
806 | virtual void loadSelectedTrackToGroup(QString group); |
807 | virtual void moveSelection(int delta); |
808 | + virtual bool appendTrack(int trackId); |
809 | |
810 | public slots: |
811 | void shufflePlaylist(bool buttonChecked); |
812 | + void skipNext(bool buttonChecked); |
813 | + void fadeNow(bool buttonChecked); |
814 | void toggleAutoDJ(bool toggle); |
815 | void player1PositionChanged(double value); |
816 | void player2PositionChanged(double value); |
817 | + void player1PlayChanged(double value); |
818 | + void player2PlayChanged(double value); |
819 | |
820 | signals: |
821 | void loadTrack(TrackPointer tio); |
822 | void loadTrackToPlayer(TrackPointer tio, QString group); |
823 | |
824 | private: |
825 | - bool loadNextTrackFromQueue(bool removeTopMostBeforeLoading); |
826 | + enum ADJstates { |
827 | + ADJ_IDLE = 0, |
828 | + ADJ_P1FADING, |
829 | + ADJ_P2FADING, |
830 | + ADJ_ENABLE_P1LOADED, |
831 | + ADJ_ENABLE_P1PLAYING, |
832 | + ADJ_DISABLED |
833 | + }; |
834 | + |
835 | + TrackPointer getNextTrackFromQueue(); |
836 | + bool loadNextTrackFromQueue(); |
837 | + bool removePlayingTrackFromQueue(QString group); |
838 | |
839 | ConfigObject<ConfigValue>* m_pConfig; |
840 | TrackCollection* m_pTrackCollection; |
841 | WTrackTableView* m_pTrackTableView; |
842 | PlaylistTableModel* m_pAutoDJTableModel; |
843 | PlaylistDAO& m_playlistDao; |
844 | - bool m_bAutoDJEnabled; |
845 | - bool m_bNextTrackAlreadyLoaded; /** Makes our Auto DJ logic assume the |
846 | - next track that should be played is |
847 | - already loaded. We need this flag to |
848 | - make our first-track-gets-loaded-but- |
849 | - not-removed-from-the-queue behaviour |
850 | - work. */ |
851 | - bool m_bPlayer1Primed, m_bPlayer2Primed; |
852 | + |
853 | + // Makes our Auto DJ logic assume the next track that should be played is |
854 | + // already loaded. We need this flag to make our |
855 | + // first-track-gets-loaded-but- not-removed-from-the-queue behaviour work. |
856 | + bool m_bNextTrackAlreadyLoaded; |
857 | + |
858 | + bool m_bFadeNow; |
859 | + enum ADJstates m_eState; |
860 | + float m_posThreshold1; |
861 | + float m_posThreshold2; |
862 | + float m_fadeDuration1; |
863 | + float m_fadeDuration2; |
864 | ControlObjectThreadMain* m_pCOPlayPos1; |
865 | ControlObjectThreadMain* m_pCOPlayPos2; |
866 | ControlObjectThreadMain* m_pCOPlay1; |
867 | ControlObjectThreadMain* m_pCOPlay2; |
868 | + ControlObjectThreadMain* m_pCOPlay1Fb; |
869 | + ControlObjectThreadMain* m_pCOPlay2Fb; |
870 | ControlObjectThreadMain* m_pCORepeat1; |
871 | ControlObjectThreadMain* m_pCORepeat2; |
872 | ControlObjectThreadMain* m_pCOCrossfader; |
873 | @@ -82,7 +104,7 @@ |
874 | |
875 | |
876 | #define _blah if ((QDate::currentDate().day() == 1) && (QDate::currentDate().month() == 4)) \ |
877 | - pushButtonAutoDJ->setText("\x45\x6e\x61\x62\x6c\x65\x20\x50\x65\x65" \ |
878 | + pushButtonAutoDJ->setText("\x45\x6e\x61\x62\x6c\x65\x20\x50\x65\x65" \ |
879 | "\x20\x42\x72\x65\x61\x6b\x20\x4d\x6f\x64\x65") |
880 | |
881 | |
882 | |
883 | === modified file 'mixxx/src/dlgprepare.h' |
884 | --- mixxx/src/dlgprepare.h 2011-03-26 12:29:21 +0000 |
885 | +++ mixxx/src/dlgprepare.h 2012-05-31 20:47:26 +0000 |
886 | @@ -6,6 +6,7 @@ |
887 | #include "configobject.h" |
888 | #include "library/libraryview.h" |
889 | #include "library/trackcollection.h" |
890 | +#include "library/preparelibrarytablemodel.h" |
891 | |
892 | class PrepareLibraryTableModel; |
893 | class WPrepareCratesTableView; |
894 | @@ -29,6 +30,7 @@ |
895 | virtual void loadSelectedTrack(); |
896 | virtual void loadSelectedTrackToGroup(QString group); |
897 | virtual void moveSelection(int delta); |
898 | + inline const QString currentSearch() { return m_pPrepareLibraryTableModel->currentSearch(); }; |
899 | |
900 | public slots: |
901 | void tableSelectionChanged(const QItemSelection& selected, |
902 | |
903 | === modified file 'mixxx/src/dlgrecording.cpp' |
904 | --- mixxx/src/dlgrecording.cpp 2011-11-04 23:15:03 +0000 |
905 | +++ mixxx/src/dlgrecording.cpp 2012-05-31 20:47:26 +0000 |
906 | @@ -119,6 +119,7 @@ |
907 | void DlgRecording::onSearchCleared() |
908 | { |
909 | } |
910 | + |
911 | void DlgRecording::refreshBrowseModel(){ |
912 | m_browseModel.setPath(m_recordingDir); |
913 | } |
914 | |
915 | === modified file 'mixxx/src/dlgrecording.h' |
916 | --- mixxx/src/dlgrecording.h 2011-03-31 18:47:04 +0000 |
917 | +++ mixxx/src/dlgrecording.h 2012-05-31 20:47:26 +0000 |
918 | @@ -35,6 +35,7 @@ |
919 | virtual void loadSelectedTrackToGroup(QString group); |
920 | virtual void moveSelection(int delta); |
921 | void refreshBrowseModel(); |
922 | + inline const QString currentSearch() { return m_proxyModel.currentSearch(); } |
923 | |
924 | public slots: |
925 | void toggleRecording(bool toggle); |
926 | |
927 | === modified file 'mixxx/src/library/autodjfeature.cpp' |
928 | --- mixxx/src/library/autodjfeature.cpp 2011-10-12 17:29:43 +0000 |
929 | +++ mixxx/src/library/autodjfeature.cpp 2012-05-31 20:47:26 +0000 |
930 | @@ -23,6 +23,7 @@ |
931 | m_pConfig(pConfig), |
932 | m_pTrackCollection(pTrackCollection), |
933 | m_playlistDao(pTrackCollection->getPlaylistDAO()) { |
934 | + m_pAutoDJView = NULL; |
935 | } |
936 | |
937 | AutoDJFeature::~AutoDJFeature() { |
938 | @@ -36,19 +37,19 @@ |
939 | return QIcon(":/images/library/ic_library_autodj.png"); |
940 | } |
941 | |
942 | -void AutoDJFeature::bindWidget(WLibrarySidebar* sidebarWidget, |
943 | +void AutoDJFeature::bindWidget(WLibrarySidebar* /*sidebarWidget*/, |
944 | WLibrary* libraryWidget, |
945 | MixxxKeyboard* keyboard) { |
946 | |
947 | - DlgAutoDJ* pAutoDJView = new DlgAutoDJ(libraryWidget, |
948 | + m_pAutoDJView = new DlgAutoDJ(libraryWidget, |
949 | m_pConfig, |
950 | m_pTrackCollection, |
951 | keyboard); |
952 | - pAutoDJView->installEventFilter(keyboard); |
953 | - libraryWidget->registerView(m_sAutoDJViewName, pAutoDJView); |
954 | - connect(pAutoDJView, SIGNAL(loadTrack(TrackPointer)), |
955 | + m_pAutoDJView->installEventFilter(keyboard); |
956 | + libraryWidget->registerView(m_sAutoDJViewName, m_pAutoDJView); |
957 | + connect(m_pAutoDJView, SIGNAL(loadTrack(TrackPointer)), |
958 | this, SIGNAL(loadTrack(TrackPointer))); |
959 | - connect(pAutoDJView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)), |
960 | + connect(m_pAutoDJView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)), |
961 | this, SIGNAL(loadTrackToPlayer(TrackPointer, QString))); |
962 | } |
963 | |
964 | @@ -58,19 +59,18 @@ |
965 | |
966 | void AutoDJFeature::activate() { |
967 | //qDebug() << "AutoDJFeature::activate()"; |
968 | - //emit(showTrackModel(m_pAutoDJTableModelProxy)); |
969 | - emit(switchToView("Auto DJ")); |
970 | -} |
971 | - |
972 | -void AutoDJFeature::activateChild(const QModelIndex& index) { |
973 | - |
974 | -} |
975 | - |
976 | -void AutoDJFeature::onRightClick(const QPoint& globalPos) { |
977 | -} |
978 | - |
979 | -void AutoDJFeature::onRightClickChild(const QPoint& globalPos, |
980 | - QModelIndex index) { |
981 | + emit(switchToView(m_sAutoDJViewName)); |
982 | + emit(restoreSearch(QString())); //Null String disables search box |
983 | +} |
984 | + |
985 | +void AutoDJFeature::activateChild(const QModelIndex& /*index*/) { |
986 | +} |
987 | + |
988 | +void AutoDJFeature::onRightClick(const QPoint& /*globalPos*/) { |
989 | +} |
990 | + |
991 | +void AutoDJFeature::onRightClickChild(const QPoint& /*globalPos*/, |
992 | + QModelIndex /*index*/) { |
993 | } |
994 | |
995 | bool AutoDJFeature::dropAccept(QUrl url) { |
996 | @@ -98,12 +98,18 @@ |
997 | } |
998 | |
999 | // TODO(XXX) No feedback on whether this worked. |
1000 | - int playlistId = m_playlistDao.getPlaylistIdFromName(AUTODJ_TABLE); |
1001 | - m_playlistDao.appendTrackToPlaylist(trackId, playlistId); |
1002 | + if( m_pAutoDJView ){ |
1003 | + m_pAutoDJView->appendTrack(trackId); |
1004 | + } |
1005 | + else{ |
1006 | + int playlistId = m_playlistDao.getPlaylistIdFromName(AUTODJ_TABLE); |
1007 | + m_playlistDao.appendTrackToPlaylist(trackId, playlistId); |
1008 | + } |
1009 | + |
1010 | return true; |
1011 | } |
1012 | |
1013 | -bool AutoDJFeature::dropAcceptChild(const QModelIndex& index, QUrl url) { |
1014 | +bool AutoDJFeature::dropAcceptChild(const QModelIndex& /*index*/, QUrl /*url*/) { |
1015 | return false; |
1016 | } |
1017 | |
1018 | @@ -112,10 +118,10 @@ |
1019 | return SoundSourceProxy::isFilenameSupported(file.fileName()); |
1020 | } |
1021 | |
1022 | -bool AutoDJFeature::dragMoveAcceptChild(const QModelIndex& index, |
1023 | - QUrl url) { |
1024 | +bool AutoDJFeature::dragMoveAcceptChild(const QModelIndex& /*index*/, |
1025 | + QUrl /*url*/) { |
1026 | return false; |
1027 | } |
1028 | -void AutoDJFeature::onLazyChildExpandation(const QModelIndex &index){ |
1029 | +void AutoDJFeature::onLazyChildExpandation(const QModelIndex& /*index*/){ |
1030 | //Nothing to do because the childmodel is not of lazy nature. |
1031 | } |
1032 | |
1033 | === modified file 'mixxx/src/library/autodjfeature.h' |
1034 | --- mixxx/src/library/autodjfeature.h 2011-03-10 13:37:21 +0000 |
1035 | +++ mixxx/src/library/autodjfeature.h 2012-05-31 20:47:26 +0000 |
1036 | @@ -11,6 +11,7 @@ |
1037 | #include "library/dao/playlistdao.h" |
1038 | #include "configobject.h" |
1039 | #include "treeitemmodel.h" |
1040 | +#include "dlgautodj.h" |
1041 | |
1042 | class PlaylistTableModel; |
1043 | class TrackCollection; |
1044 | @@ -50,6 +51,7 @@ |
1045 | PlaylistDAO& m_playlistDao; |
1046 | const static QString m_sAutoDJViewName; |
1047 | TreeItemModel m_childModel; |
1048 | + DlgAutoDJ* m_pAutoDJView; |
1049 | }; |
1050 | |
1051 | |
1052 | |
1053 | === modified file 'mixxx/src/library/basesqltablemodel.cpp' |
1054 | --- mixxx/src/library/basesqltablemodel.cpp 2011-12-18 18:50:40 +0000 |
1055 | +++ mixxx/src/library/basesqltablemodel.cpp 2012-05-31 20:47:26 +0000 |
1056 | @@ -18,6 +18,7 @@ |
1057 | QString settingsNamespace) |
1058 | : QAbstractTableModel(pParent), |
1059 | TrackModel(db, settingsNamespace), |
1060 | + m_currentSearch(""), |
1061 | m_pTrackCollection(pTrackCollection), |
1062 | m_trackDAO(m_pTrackCollection->getTrackDAO()), |
1063 | m_database(db) { |
1064 | @@ -528,7 +529,7 @@ |
1065 | // waveform widget to load a track into a Player). |
1066 | defaultFlags |= Qt::ItemIsDragEnabled; |
1067 | |
1068 | - int row = index.row(); |
1069 | + //int row = index.row(); // not used |
1070 | int column = index.column(); |
1071 | |
1072 | if ( column == fieldIndex(LIBRARYTABLE_FILETYPE) |
1073 | |
1074 | === modified file 'mixxx/src/library/browse/browsefeature.cpp' |
1075 | --- mixxx/src/library/browse/browsefeature.cpp 2012-03-13 04:36:19 +0000 |
1076 | +++ mixxx/src/library/browse/browsefeature.cpp 2012-05-31 20:47:26 +0000 |
1077 | @@ -141,8 +141,9 @@ |
1078 | } |
1079 | |
1080 | void BrowseFeature::activate() { |
1081 | - emit(restoreSearch(m_currentSearch)); |
1082 | + emit(restoreSearch(QString())); |
1083 | } |
1084 | + |
1085 | /* |
1086 | * Note: This is executed whenever you single click on an child item |
1087 | * Single clicks will not populate sub folders |
1088 | |
1089 | === modified file 'mixxx/src/library/browse/browsefeature.h' |
1090 | --- mixxx/src/library/browse/browsefeature.h 2011-03-30 21:53:33 +0000 |
1091 | +++ mixxx/src/library/browse/browsefeature.h 2012-05-31 20:47:26 +0000 |
1092 | @@ -54,7 +54,6 @@ |
1093 | ProxyTrackModel m_proxyModel; |
1094 | TrackCollection* m_pTrackCollection; |
1095 | FolderTreeModel m_childModel; |
1096 | - QString m_currentSearch; |
1097 | }; |
1098 | |
1099 | #endif /* BROWSEFEATURE_H */ |
1100 | |
1101 | === modified file 'mixxx/src/library/browse/browsetablemodel.cpp' |
1102 | --- mixxx/src/library/browse/browsetablemodel.cpp 2011-12-22 10:56:03 +0000 |
1103 | +++ mixxx/src/library/browse/browsetablemodel.cpp 2012-05-31 20:47:26 +0000 |
1104 | @@ -112,23 +112,23 @@ |
1105 | } |
1106 | |
1107 | int BrowseTableModel::getTrackId(const QModelIndex& index) const { |
1108 | - Q_UNUSED(index); |
1109 | - // We can't implement this as it stands. |
1110 | + Q_UNUSED(index); |
1111 | + // We can't implement this as it stands. |
1112 | return -1; |
1113 | } |
1114 | |
1115 | const QLinkedList<int> BrowseTableModel::getTrackRows(int trackId) const { |
1116 | - Q_UNUSED(trackId); |
1117 | - // We can't implement this as it stands. |
1118 | - return QLinkedList<int>(); |
1119 | + Q_UNUSED(trackId); |
1120 | + // We can't implement this as it stands. |
1121 | + return QLinkedList<int>(); |
1122 | } |
1123 | |
1124 | void BrowseTableModel::search(const QString& searchText) { |
1125 | - Q_UNUSED(searchText); |
1126 | + Q_UNUSED(searchText); |
1127 | } |
1128 | |
1129 | const QString BrowseTableModel::currentSearch() const { |
1130 | - return QString(); |
1131 | + return QString(""); |
1132 | } |
1133 | |
1134 | bool BrowseTableModel::isColumnInternal(int) { |
1135 | @@ -215,7 +215,7 @@ |
1136 | { |
1137 | Q_UNUSED(index); |
1138 | Q_UNUSED(location); |
1139 | - return false; |
1140 | + return false; |
1141 | } |
1142 | |
1143 | QMimeData* BrowseTableModel::mimeData(const QModelIndexList &indexes) const { |
1144 | @@ -318,7 +318,7 @@ |
1145 | { |
1146 | Q_UNUSED(role); |
1147 | |
1148 | - if(!index.isValid()) |
1149 | + if(!index.isValid()) |
1150 | return false; |
1151 | qDebug() << "BrowseTableModel::setData(" << index.data() << ")"; |
1152 | int row = index.row(); |
1153 | |
1154 | === modified file 'mixxx/src/library/cratefeature.cpp' |
1155 | --- mixxx/src/library/cratefeature.cpp 2011-12-09 02:49:02 +0000 |
1156 | +++ mixxx/src/library/cratefeature.cpp 2012-05-31 20:47:26 +0000 |
1157 | @@ -137,6 +137,7 @@ |
1158 | void CrateFeature::activate() { |
1159 | emit(showPage(QUrl("qrc:/html/crates.html"))); |
1160 | emit(switchToView("CRATEHOME")); |
1161 | + emit(restoreSearch(QString())); //disable search on crate home |
1162 | } |
1163 | |
1164 | void CrateFeature::activateChild(const QModelIndex& index) { |
1165 | |
1166 | === modified file 'mixxx/src/library/dao/cratedao.h' |
1167 | --- mixxx/src/library/dao/cratedao.h 2012-05-04 05:38:59 +0000 |
1168 | +++ mixxx/src/library/dao/cratedao.h 2012-05-31 20:47:26 +0000 |
1169 | @@ -50,6 +50,8 @@ |
1170 | void changed(int crateId); |
1171 | void trackAdded(int crateId, int trackId); |
1172 | void trackRemoved(int crateId, int trackId); |
1173 | + void renamed(int crateId); |
1174 | + void lockChanged(int crateId); |
1175 | |
1176 | private: |
1177 | QSqlDatabase& m_database; |
1178 | |
1179 | === modified file 'mixxx/src/library/dao/playlistdao.cpp' |
1180 | --- mixxx/src/library/dao/playlistdao.cpp 2012-05-04 05:38:59 +0000 |
1181 | +++ mixxx/src/library/dao/playlistdao.cpp 2012-05-31 20:47:26 +0000 |
1182 | @@ -505,7 +505,7 @@ |
1183 | return tracksAdded; |
1184 | } |
1185 | |
1186 | -void PlaylistDAO::addToAutoDJQueue(int playlistId) { |
1187 | +void PlaylistDAO::addToAutoDJQueue(int playlistId, bool bTop) { |
1188 | //qDebug() << "Adding tracks from playlist " << playlistId << " to the Auto-DJ Queue"; |
1189 | |
1190 | // Query the PlaylistTracks database to locate tracks in the selected playlist |
1191 | @@ -520,7 +520,15 @@ |
1192 | // Get the ID of the Auto-DJ playlist |
1193 | int autoDJId = getPlaylistIdFromName(AUTODJ_TABLE); |
1194 | // Loop through the tracks, adding them to the Auto-DJ Queue |
1195 | - while(query.next()) { |
1196 | - appendTrackToPlaylist(query.value(0).toInt(), autoDJId); |
1197 | + |
1198 | + int i = 2; // Start at position 2 because position 1 was already loaded to the deck |
1199 | + |
1200 | + while (query.next()) { |
1201 | + if (bTop) { |
1202 | + insertTrackIntoPlaylist(query.value(0).toInt(), autoDJId, i++); |
1203 | + } |
1204 | + else { |
1205 | + appendTrackToPlaylist(query.value(0).toInt(), autoDJId); |
1206 | + } |
1207 | } |
1208 | } |
1209 | |
1210 | === modified file 'mixxx/src/library/dao/playlistdao.h' |
1211 | --- mixxx/src/library/dao/playlistdao.h 2012-05-04 05:38:59 +0000 |
1212 | +++ mixxx/src/library/dao/playlistdao.h 2012-05-31 20:47:26 +0000 |
1213 | @@ -57,13 +57,15 @@ |
1214 | /** Inserts a list of tracks into playlist*/ |
1215 | int insertTracksIntoPlaylist(QList<int> trackIds, int playlistId, int position); |
1216 | /** Add a playlist to the Auto-DJ Queue */ |
1217 | - void addToAutoDJQueue(int playlistId); |
1218 | + void addToAutoDJQueue(int playlistId, bool bTop); |
1219 | signals: |
1220 | void added(int playlistId); |
1221 | void deleted(int playlistId); |
1222 | void changed(int playlistId); |
1223 | void trackAdded(int playlistId, int trackId, int position); |
1224 | void trackRemoved(int playlistId, int trackId, int position); |
1225 | + void renamed(int playlistId); |
1226 | + void lockChanged(int playlistId); |
1227 | private: |
1228 | QSqlDatabase& m_database; |
1229 | DISALLOW_COPY_AND_ASSIGN(PlaylistDAO); |
1230 | |
1231 | === modified file 'mixxx/src/library/itunes/itunesfeature.cpp' |
1232 | --- mixxx/src/library/itunes/itunesfeature.cpp 2011-10-16 03:12:52 +0000 |
1233 | +++ mixxx/src/library/itunes/itunesfeature.cpp 2012-05-31 20:47:26 +0000 |
1234 | @@ -116,6 +116,7 @@ |
1235 | tr("Select your iTunes library"), |
1236 | QDir::homePath(), "*.xml"); |
1237 | if (m_dbfile.isEmpty() || !QFile::exists(m_dbfile)) { |
1238 | + emit(showTrackModel(m_pITunesTrackModel)); |
1239 | return; |
1240 | } |
1241 | settings.setValue(ITDB_PATH_KEY, m_dbfile); |
1242 | @@ -138,10 +139,8 @@ |
1243 | //calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. |
1244 | emit (featureIsLoading(this)); |
1245 | } |
1246 | - else{ |
1247 | - emit(showTrackModel(m_pITunesTrackModel)); |
1248 | - } |
1249 | |
1250 | + emit(showTrackModel(m_pITunesTrackModel)); |
1251 | } |
1252 | |
1253 | void ITunesFeature::activateChild(const QModelIndex& index) { |
1254 | |
1255 | === modified file 'mixxx/src/library/playlistfeature.cpp' |
1256 | --- mixxx/src/library/playlistfeature.cpp 2012-03-27 18:17:26 +0000 |
1257 | +++ mixxx/src/library/playlistfeature.cpp 2012-05-31 20:47:26 +0000 |
1258 | @@ -102,6 +102,7 @@ |
1259 | void PlaylistFeature::activate() { |
1260 | emit(showPage(QUrl("qrc:/html/playlists.html"))); |
1261 | emit(switchToView("PLAYLISTHOME")); |
1262 | + emit(restoreSearch(QString())); // Null String disables search box |
1263 | } |
1264 | |
1265 | void PlaylistFeature::activateChild(const QModelIndex& index) { |
1266 | @@ -448,7 +449,7 @@ |
1267 | new PlaylistTableModel(this, m_pTrackCollection, |
1268 | "mixxx.db.model.playlist_export")); |
1269 | |
1270 | - pPlaylistTableModel->setPlaylist(m_pPlaylistTableModel->getPlaylist()); |
1271 | + pPlaylistTableModel->setPlaylist(m_pPlaylistTableModel->getPlaylistId()); |
1272 | pPlaylistTableModel->setSort(pPlaylistTableModel->fieldIndex(PLAYLISTTRACKSTABLE_POSITION), Qt::AscendingOrder); |
1273 | pPlaylistTableModel->select(); |
1274 | int rows = pPlaylistTableModel->rowCount(); |
1275 | @@ -481,12 +482,18 @@ |
1276 | |
1277 | void PlaylistFeature::slotAddToAutoDJ() { |
1278 | //qDebug() << "slotAddToAutoDJ() row:" << m_lastRightClickedIndex.data(); |
1279 | + addToAutoDJ(false); // Top = True |
1280 | +} |
1281 | + |
1282 | +void PlaylistFeature::addToAutoDJ(bool bTop) { |
1283 | + //qDebug() << "slotAddToAutoDJ() row:" << m_lastRightClickedIndex.data(); |
1284 | |
1285 | if (m_lastRightClickedIndex.isValid()) { |
1286 | int playlistId = m_playlistDao.getPlaylistIdFromName( |
1287 | m_lastRightClickedIndex.data().toString()); |
1288 | if (playlistId >= 0) { |
1289 | - m_playlistDao.addToAutoDJQueue(playlistId); |
1290 | + // Insert this playlist |
1291 | + m_playlistDao.addToAutoDJQueue(playlistId, bTop); |
1292 | } |
1293 | } |
1294 | emit(featureUpdated()); |
1295 | |
1296 | === modified file 'mixxx/src/library/playlistfeature.h' |
1297 | --- mixxx/src/library/playlistfeature.h 2011-11-27 06:59:02 +0000 |
1298 | +++ mixxx/src/library/playlistfeature.h 2012-05-31 20:47:26 +0000 |
1299 | @@ -59,6 +59,7 @@ |
1300 | private: |
1301 | void constructChildModel(); |
1302 | void clearChildModel(); |
1303 | + void addToAutoDJ(bool bTop); |
1304 | |
1305 | TrackCollection* m_pTrackCollection; |
1306 | PlaylistTableModel* m_pPlaylistTableModel; |
1307 | |
1308 | === modified file 'mixxx/src/library/playlisttablemodel.cpp' |
1309 | --- mixxx/src/library/playlisttablemodel.cpp 2012-05-04 05:38:59 +0000 |
1310 | +++ mixxx/src/library/playlisttablemodel.cpp 2012-05-31 20:47:26 +0000 |
1311 | @@ -5,7 +5,6 @@ |
1312 | #include "library/trackcollection.h" |
1313 | #include "library/playlisttablemodel.h" |
1314 | #include "library/queryutil.h" |
1315 | - |
1316 | #include "mixxxutils.cpp" |
1317 | |
1318 | PlaylistTableModel::PlaylistTableModel(QObject* parent, |
1319 | @@ -64,6 +63,12 @@ |
1320 | initHeaderData(); |
1321 | setSearch(""); |
1322 | setDefaultSort(fieldIndex("position"), Qt::AscendingOrder); |
1323 | + setSort(defaultSortColumn(),defaultSortOrder()); |
1324 | +} |
1325 | + |
1326 | +int PlaylistTableModel::getPlaylistId() |
1327 | +{ |
1328 | + return m_iPlaylistId; |
1329 | } |
1330 | |
1331 | bool PlaylistTableModel::addTrack(const QModelIndex& index, QString location) { |
1332 | @@ -94,6 +99,16 @@ |
1333 | return true; |
1334 | } |
1335 | |
1336 | +bool PlaylistTableModel::appendTrack(int trackId) { |
1337 | + if (trackId < 0) { |
1338 | + return false; |
1339 | + } |
1340 | + |
1341 | + m_playlistDao.appendTrackToPlaylist(trackId, m_iPlaylistId); |
1342 | + |
1343 | + select(); //Repopulate the data model. |
1344 | + return true; |
1345 | +} |
1346 | |
1347 | int PlaylistTableModel::addTracks(const QModelIndex& index, QList<QString> locations) { |
1348 | const int positionColumn = fieldIndex(PLAYLISTTRACKSTABLE_POSITION); |
1349 | @@ -272,32 +287,38 @@ |
1350 | |
1351 | //Print out any SQL error, if there was one. |
1352 | if (query.lastError().isValid()) { |
1353 | - qDebug() << query.lastError(); |
1354 | + qDebug() << query.lastError(); |
1355 | } |
1356 | |
1357 | select(); |
1358 | } |
1359 | |
1360 | -void PlaylistTableModel::shuffleTracks(const QModelIndex& currentIndex) { |
1361 | +void PlaylistTableModel::shuffleTracks(const QModelIndex& shuffleStartIndex) { |
1362 | int numOfTracks = rowCount(); |
1363 | int seed = QDateTime::currentDateTime().toTime_t(); |
1364 | qsrand(seed); |
1365 | QSqlQuery query(m_pTrackCollection->getDatabase()); |
1366 | const int positionColumnIndex = fieldIndex(PLAYLISTTRACKSTABLE_POSITION); |
1367 | - int currentPosition = currentIndex.sibling(currentIndex.row(), positionColumnIndex).data().toInt(); |
1368 | - int shuffleStartIndex = currentPosition + 1; |
1369 | + int shuffleStartRow = shuffleStartIndex.row(); |
1370 | |
1371 | m_pTrackCollection->getDatabase().transaction(); |
1372 | |
1373 | // This is a simple Fisher-Yates shuffling algorithm |
1374 | - for (int i=numOfTracks-1; i >= shuffleStartIndex; i--) |
1375 | + for (int i=numOfTracks-1; i >= shuffleStartRow; i--) |
1376 | { |
1377 | - int random = int(qrand() / (RAND_MAX + 1.0) * (numOfTracks + 1 - shuffleStartIndex) + shuffleStartIndex); |
1378 | - qDebug() << "Swapping tracks " << i << " and " << random; |
1379 | + int oldPosition = index(i, positionColumnIndex).data().toInt(); |
1380 | + int random = int(qrand() / (RAND_MAX + 1.0) * (numOfTracks - shuffleStartRow) + shuffleStartRow + 1); |
1381 | + qDebug() << "Swapping tracks " << oldPosition << " and " << random; |
1382 | QString swapQuery = "UPDATE PlaylistTracks SET position=%1 WHERE position=%2 AND playlist_id=%3"; |
1383 | - query.exec(swapQuery.arg(-1).arg(i).arg(m_iPlaylistId)); |
1384 | - query.exec(swapQuery.arg(i).arg(random).arg(m_iPlaylistId)); |
1385 | - query.exec(swapQuery.arg(random).arg(-1).arg(m_iPlaylistId)); |
1386 | + query.exec(swapQuery.arg(QString::number(-1), |
1387 | + QString::number(oldPosition), |
1388 | + QString::number(m_iPlaylistId))); |
1389 | + query.exec(swapQuery.arg(QString::number(oldPosition), |
1390 | + QString::number(random), |
1391 | + QString::number(m_iPlaylistId))); |
1392 | + query.exec(swapQuery.arg(QString::number(random), |
1393 | + QString::number(-1), |
1394 | + QString::number(m_iPlaylistId))); |
1395 | |
1396 | if (query.lastError().isValid()) |
1397 | qDebug() << query.lastError(); |
1398 | @@ -336,6 +357,7 @@ |
1399 | } |
1400 | |
1401 | QItemDelegate* PlaylistTableModel::delegateForColumn(const int i) { |
1402 | + Q_UNUSED(i); |
1403 | return NULL; |
1404 | } |
1405 | |
1406 | |
1407 | === modified file 'mixxx/src/library/playlisttablemodel.h' |
1408 | --- mixxx/src/library/playlisttablemodel.h 2012-05-04 05:38:59 +0000 |
1409 | +++ mixxx/src/library/playlisttablemodel.h 2012-05-31 20:47:26 +0000 |
1410 | @@ -19,9 +19,7 @@ |
1411 | QString settingsNamespace); |
1412 | virtual ~PlaylistTableModel(); |
1413 | void setPlaylist(int playlistId); |
1414 | - int getPlaylist() const { |
1415 | - return m_iPlaylistId; |
1416 | - } |
1417 | + int getPlaylistId(void); |
1418 | virtual TrackPointer getTrack(const QModelIndex& index) const; |
1419 | |
1420 | virtual void search(const QString& searchText); |
1421 | @@ -30,6 +28,7 @@ |
1422 | virtual void removeTrack(const QModelIndex& index); |
1423 | virtual void removeTracks(const QModelIndexList& indices); |
1424 | virtual bool addTrack(const QModelIndex& index, QString location); |
1425 | + virtual bool appendTrack(int trackId); |
1426 | // Adding multiple tracks at one to a playlist. Returns the number of |
1427 | // successful additions. |
1428 | virtual int addTracks(const QModelIndex& index, QList<QString> locations); |
1429 | |
1430 | === modified file 'mixxx/src/library/preparefeature.cpp' |
1431 | --- mixxx/src/library/preparefeature.cpp 2011-03-26 12:29:21 +0000 |
1432 | +++ mixxx/src/library/preparefeature.cpp 2012-05-31 20:47:26 +0000 |
1433 | @@ -41,31 +41,35 @@ |
1434 | void PrepareFeature::bindWidget(WLibrarySidebar* sidebarWidget, |
1435 | WLibrary* libraryWidget, |
1436 | MixxxKeyboard* keyboard) { |
1437 | - DlgPrepare* pPrepareView = new DlgPrepare(libraryWidget, |
1438 | + m_pPrepareView = new DlgPrepare(libraryWidget, |
1439 | m_pConfig, |
1440 | m_pTrackCollection); |
1441 | - connect(pPrepareView, SIGNAL(loadTrack(TrackPointer)), |
1442 | + connect(m_pPrepareView, SIGNAL(loadTrack(TrackPointer)), |
1443 | this, SIGNAL(loadTrack(TrackPointer))); |
1444 | - connect(pPrepareView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)), |
1445 | + connect(m_pPrepareView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)), |
1446 | this, SIGNAL(loadTrackToPlayer(TrackPointer, QString))); |
1447 | - connect(pPrepareView, SIGNAL(analyzeTracks(QList<int>)), |
1448 | + connect(m_pPrepareView, SIGNAL(analyzeTracks(QList<int>)), |
1449 | this, SLOT(analyzeTracks(QList<int>))); |
1450 | - connect(pPrepareView, SIGNAL(stopAnalysis()), |
1451 | + connect(m_pPrepareView, SIGNAL(stopAnalysis()), |
1452 | this, SLOT(stopAnalysis())); |
1453 | |
1454 | connect(this, SIGNAL(analysisActive(bool)), |
1455 | - pPrepareView, SLOT(analysisActive(bool))); |
1456 | + m_pPrepareView, SLOT(analysisActive(bool))); |
1457 | connect(this, SIGNAL(trackAnalysisProgress(TrackPointer, int)), |
1458 | - pPrepareView, SLOT(trackAnalysisProgress(TrackPointer, int))); |
1459 | - connect(this, SIGNAL(trackAnalysisFinished(TrackPointer)), |
1460 | - pPrepareView, SLOT(trackAnalysisFinished(TrackPointer))); |
1461 | - pPrepareView->installEventFilter(keyboard); |
1462 | + m_pPrepareView, SLOT(trackAnalysisProgress(TrackPointer, int))); |
1463 | + connect(this, SIGNAL(trackAnalysisFinished(TrackPointer)), |
1464 | + m_pPrepareView, SLOT(trackAnalysisFinished(TrackPointer))); |
1465 | + |
1466 | + connect(this, SIGNAL(trackAnalysisFinished(TrackPointer)), |
1467 | + m_pPrepareView, SLOT(trackAnalysisFinished(TrackPointer))); |
1468 | + |
1469 | + m_pPrepareView->installEventFilter(keyboard); |
1470 | |
1471 | // Let the DlgPrepare know whether or not analysis is active. |
1472 | bool bAnalysisActive = m_pAnalyserQueue != NULL; |
1473 | emit(analysisActive(bAnalysisActive)); |
1474 | |
1475 | - libraryWidget->registerView(m_sPrepareViewName, pPrepareView); |
1476 | + libraryWidget->registerView(m_sPrepareViewName, m_pPrepareView); |
1477 | } |
1478 | |
1479 | TreeItemModel* PrepareFeature::getChildModel() { |
1480 | @@ -75,6 +79,7 @@ |
1481 | void PrepareFeature::activate() { |
1482 | //qDebug() << "PrepareFeature::activate()"; |
1483 | emit(switchToView(m_sPrepareViewName)); |
1484 | + emit(restoreSearch(m_pPrepareView->currentSearch())); |
1485 | } |
1486 | |
1487 | void PrepareFeature::activateChild(const QModelIndex& index) { |
1488 | |
1489 | === modified file 'mixxx/src/library/preparefeature.h' |
1490 | --- mixxx/src/library/preparefeature.h 2011-03-26 12:29:21 +0000 |
1491 | +++ mixxx/src/library/preparefeature.h 2012-05-31 20:47:26 +0000 |
1492 | @@ -9,6 +9,7 @@ |
1493 | #include "library/libraryfeature.h" |
1494 | #include "configobject.h" |
1495 | #include "treeitemmodel.h" |
1496 | +#include "dlgprepare.h" |
1497 | |
1498 | class AnalyserQueue; |
1499 | class LibraryTableModel; |
1500 | @@ -63,6 +64,7 @@ |
1501 | int m_iOldBpmEnabled; |
1502 | TreeItemModel m_childModel; |
1503 | const static QString m_sPrepareViewName; |
1504 | + DlgPrepare* m_pPrepareView; |
1505 | }; |
1506 | |
1507 | |
1508 | |
1509 | === modified file 'mixxx/src/library/proxytrackmodel.cpp' |
1510 | --- mixxx/src/library/proxytrackmodel.cpp 2011-09-25 08:08:35 +0000 |
1511 | +++ mixxx/src/library/proxytrackmodel.cpp 2012-05-31 20:47:26 +0000 |
1512 | @@ -11,7 +11,8 @@ |
1513 | // ProxyTrackModel proxies settings requests to the composed TrackModel, |
1514 | // don't initialize its TrackModel with valid parameters. |
1515 | : TrackModel(QSqlDatabase(), ""), |
1516 | - m_bHandleSearches(bHandleSearches) { |
1517 | + m_bHandleSearches(bHandleSearches), |
1518 | + m_currentSearch("") { |
1519 | m_pTrackModel = dynamic_cast<TrackModel*>(pTrackModel); |
1520 | Q_ASSERT(m_pTrackModel && pTrackModel); |
1521 | setSourceModel(pTrackModel); |
1522 | |
1523 | === modified file 'mixxx/src/library/recording/recordingfeature.cpp' |
1524 | --- mixxx/src/library/recording/recordingfeature.cpp 2011-04-10 18:23:52 +0000 |
1525 | +++ mixxx/src/library/recording/recordingfeature.cpp 2012-05-31 20:47:26 +0000 |
1526 | @@ -23,8 +23,9 @@ |
1527 | TrackCollection* pTrackCollection, |
1528 | RecordingManager* pRecordingManager) |
1529 | : LibraryFeature(parent), |
1530 | - m_pConfig(pConfig), m_pRecordingView(0), |
1531 | - m_pTrackCollection(pTrackCollection), |
1532 | + m_pConfig(pConfig), |
1533 | + m_pTrackCollection(pTrackCollection), |
1534 | + m_pRecordingView(0), |
1535 | m_pRecordingManager(pRecordingManager){ |
1536 | |
1537 | } |
1538 | @@ -48,6 +49,8 @@ |
1539 | WLibrary *libraryWidget, |
1540 | MixxxKeyboard *keyboard) |
1541 | { |
1542 | + Q_UNUSED(sidebarWidget); |
1543 | + |
1544 | //The view will be deleted by LibraryWidget |
1545 | m_pRecordingView = new DlgRecording(libraryWidget, |
1546 | m_pConfig, |
1547 | @@ -64,35 +67,47 @@ |
1548 | } |
1549 | |
1550 | bool RecordingFeature::dropAccept(QUrl url) { |
1551 | + Q_UNUSED(url); |
1552 | return false; |
1553 | } |
1554 | |
1555 | bool RecordingFeature::dropAcceptChild(const QModelIndex& index, QUrl url) { |
1556 | + Q_UNUSED(index); |
1557 | + Q_UNUSED(url); |
1558 | return false; |
1559 | } |
1560 | |
1561 | bool RecordingFeature::dragMoveAccept(QUrl url) { |
1562 | + Q_UNUSED(url); |
1563 | return false; |
1564 | } |
1565 | |
1566 | bool RecordingFeature::dragMoveAcceptChild(const QModelIndex& index, QUrl url) { |
1567 | + Q_UNUSED(index); |
1568 | + Q_UNUSED(url); |
1569 | return false; |
1570 | } |
1571 | |
1572 | void RecordingFeature::activate() { |
1573 | m_pRecordingView->refreshBrowseModel(); |
1574 | - emit(switchToView("Recording")); |
1575 | + emit(switchToView(m_sRecordingViewName)); |
1576 | + emit(restoreSearch(m_pRecordingView->currentSearch())); |
1577 | } |
1578 | |
1579 | void RecordingFeature::activateChild(const QModelIndex& index) { |
1580 | - |
1581 | + Q_UNUSED(index); |
1582 | } |
1583 | |
1584 | void RecordingFeature::onRightClick(const QPoint& globalPos) { |
1585 | + Q_UNUSED(globalPos); |
1586 | } |
1587 | |
1588 | void RecordingFeature::onRightClickChild(const QPoint& globalPos, QModelIndex index) { |
1589 | + Q_UNUSED(globalPos); |
1590 | + Q_UNUSED(index); |
1591 | } |
1592 | + |
1593 | void RecordingFeature::onLazyChildExpandation(const QModelIndex &index){ |
1594 | - //Nothing to do here since we have no child models |
1595 | + Q_UNUSED(index); |
1596 | + // Nothing to do here since we have no child models |
1597 | } |
1598 | |
1599 | === modified file 'mixxx/src/library/recording/recordingfeature.h' |
1600 | --- mixxx/src/library/recording/recordingfeature.h 2011-04-10 18:23:52 +0000 |
1601 | +++ mixxx/src/library/recording/recordingfeature.h 2012-05-31 20:47:26 +0000 |
1602 | @@ -53,7 +53,6 @@ |
1603 | ConfigObject<ConfigValue>* m_pConfig; |
1604 | TrackCollection* m_pTrackCollection; |
1605 | FolderTreeModel m_childModel; |
1606 | - QString m_currentSearch; |
1607 | const static QString m_sRecordingViewName; |
1608 | DlgRecording* m_pRecordingView; |
1609 | RecordingManager* m_pRecordingManager; |
1610 | |
1611 | === modified file 'mixxx/src/library/rhythmbox/rhythmboxfeature.cpp' |
1612 | --- mixxx/src/library/rhythmbox/rhythmboxfeature.cpp 2012-05-14 20:28:12 +0000 |
1613 | +++ mixxx/src/library/rhythmbox/rhythmboxfeature.cpp 2012-05-31 20:47:26 +0000 |
1614 | @@ -100,9 +100,8 @@ |
1615 | //calls a slot in the sidebar model such that 'Rhythmbox (isLoading)' is displayed. |
1616 | emit (featureIsLoading(this)); |
1617 | } |
1618 | - else |
1619 | - emit(showTrackModel(m_pRhythmboxTrackModel)); |
1620 | |
1621 | + emit(showTrackModel(m_pRhythmboxTrackModel)); |
1622 | } |
1623 | |
1624 | void RhythmboxFeature::activateChild(const QModelIndex& index) { |
1625 | |
1626 | === modified file 'mixxx/src/library/traktor/traktorfeature.cpp' |
1627 | --- mixxx/src/library/traktor/traktorfeature.cpp 2011-10-18 05:12:35 +0000 |
1628 | +++ mixxx/src/library/traktor/traktorfeature.cpp 2012-05-31 20:47:26 +0000 |
1629 | @@ -109,9 +109,9 @@ |
1630 | m_title = tr("(loading) Traktor"); |
1631 | //calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. |
1632 | emit (featureIsLoading(this)); |
1633 | - } else { |
1634 | - emit(showTrackModel(m_pTraktorTableModel)); |
1635 | } |
1636 | + |
1637 | + emit(showTrackModel(m_pTraktorTableModel)); |
1638 | } |
1639 | |
1640 | void TraktorFeature::activateChild(const QModelIndex& index) { |
1641 | |
1642 | === modified file 'mixxx/src/soundmanager.h' |
1643 | --- mixxx/src/soundmanager.h 2011-10-16 02:09:36 +0000 |
1644 | +++ mixxx/src/soundmanager.h 2012-05-31 20:47:26 +0000 |
1645 | @@ -92,7 +92,7 @@ |
1646 | #ifdef __PORTAUDIO__ |
1647 | bool m_paInitialized; |
1648 | unsigned int m_jackSampleRate; |
1649 | -#endif |
1650 | +#endif |
1651 | QHash<AudioOutput, const AudioSource*> m_registeredSources; |
1652 | QHash<AudioInput, AudioDestination*> m_registeredDestinations; |
1653 | |
1654 | |
1655 | === modified file 'mixxx/src/widget/wsearchlineedit.cpp' |
1656 | --- mixxx/src/widget/wsearchlineedit.cpp 2012-03-13 03:40:29 +0000 |
1657 | +++ mixxx/src/widget/wsearchlineedit.cpp 2012-05-31 20:47:26 +0000 |
1658 | @@ -117,7 +117,17 @@ |
1659 | } |
1660 | } |
1661 | |
1662 | +// slot |
1663 | void WSearchLineEdit::restoreSearch(const QString& text) { |
1664 | + if(text.isNull()) { |
1665 | + // disable |
1666 | + setEnabled(false); |
1667 | + blockSignals(true); |
1668 | + setText("- - -"); |
1669 | + blockSignals(false); |
1670 | + return; |
1671 | + } |
1672 | + setEnabled(true); |
1673 | qDebug() << "WSearchLineEdit::restoreSearch(" << text << ")"; |
1674 | blockSignals(true); |
1675 | setText(text); |
1676 | @@ -136,6 +146,7 @@ |
1677 | |
1678 | void WSearchLineEdit::slotSetupTimer(const QString& text) |
1679 | { |
1680 | + Q_UNUSED(text); |
1681 | m_searchTimer.stop(); |
1682 | //300 milliseconds timeout |
1683 | m_searchTimer.start(300); |
1684 | |
1685 | === modified file 'mixxx/src/widget/wtracktableview.cpp' |
1686 | --- mixxx/src/widget/wtracktableview.cpp 2012-05-04 05:38:59 +0000 |
1687 | +++ mixxx/src/widget/wtracktableview.cpp 2012-05-31 20:47:26 +0000 |
1688 | @@ -816,6 +816,15 @@ |
1689 | } |
1690 | |
1691 | void WTrackTableView::slotSendToAutoDJ() { |
1692 | + // append to auto DJ |
1693 | + sendToAutoDJ(false); // bTop = false |
1694 | +} |
1695 | + |
1696 | +void WTrackTableView::slotSendToAutoDJTop() { |
1697 | + sendToAutoDJ(true); // bTop = true |
1698 | +} |
1699 | + |
1700 | +void WTrackTableView::sendToAutoDJ(bool bTop) { |
1701 | if (!modelHasCapabilities(TrackModel::TRACKMODELCAPS_ADDTOAUTODJ)) { |
1702 | return; |
1703 | } |
1704 | |
1705 | === modified file 'mixxx/src/widget/wtracktableview.h' |
1706 | --- mixxx/src/widget/wtracktableview.h 2012-05-04 03:00:08 +0000 |
1707 | +++ mixxx/src/widget/wtracktableview.h 2012-05-31 20:47:26 +0000 |
1708 | @@ -46,6 +46,7 @@ |
1709 | void slotNextTrackInfo(); |
1710 | void slotPrevTrackInfo(); |
1711 | void slotSendToAutoDJ(); |
1712 | + void slotSendToAutoDJTop(); |
1713 | void slotReloadTrackMetadata(); |
1714 | void slotResetPlayed(); |
1715 | void addSelectionToPlaylist(int iPlaylistId); |
1716 | @@ -54,6 +55,7 @@ |
1717 | void doSortByColumn(int headerSection); |
1718 | |
1719 | private: |
1720 | + void sendToAutoDJ(bool bTop); |
1721 | void showTrackInfo(QModelIndex index); |
1722 | void createActions(); |
1723 | void dragMoveEvent(QDragMoveEvent * event); |
1724 | @@ -90,6 +92,7 @@ |
1725 | |
1726 | // Send to Auto-DJ Action |
1727 | QAction *m_pAutoDJAct; |
1728 | + QAction *m_pAutoDJTopAct; |
1729 | |
1730 | // Remove from table |
1731 | QAction *m_pRemoveAct; |
Looks good -- please merge!