Hello Adam, Garth, Albert and all the others...

here's the working, renamed, commented patch for playlist control via MIDI. In my setup this works fine. But I have made no tests with Windows or with other controllers. You can test this by assigning MIDI keys to [Playlist] SelectNextTrack, [Playlist] SelectPrevTrack, and [Channel1,2] LoadSelectedTrack.

If there are any problems, please contact me. I'm optimistic this is good to commit, though. Any responsible developer, feel free to rename the XML tags. I just put in something similar to the C++ identifiers.

- Ján

Index: mixxx/src/wtracktableview.cpp
===================================================================
--- mixxx/src/wtracktableview.cpp	(revision 1674)
+++ mixxx/src/wtracktableview.cpp	(working copy)
@@ -421,6 +421,35 @@
     m_pTrack = pTrack;
 }
 
+/* Move the cursor to the next track. */
+void WTrackTableView::selectNext()
+{
+    QModelIndex c = currentIndex();
+
+    // Create a row selection if none exists
+    if (c.row() == -1) {
+	selectRow(0);
+	c = currentIndex();
+    }
+    // Advance to next position
+    setCurrentIndex(c.child(c.row()+1, c.column()));
+    // Roll back to previous position if on last row
+    if (currentIndex().row() == -1) setCurrentIndex(c);
+    selectRow(currentIndex().row());
+}
+
+/* Move the cursor to the previous track. */
+void WTrackTableView::selectPrevious()
+{
+    QModelIndex c = currentIndex();
+
+    // Move to the previous row
+    setCurrentIndex(c.child(c.row()-1, c.column()));
+    // Roll back to previous position if on first row
+    if (currentIndex().row() == -1) setCurrentIndex(c);
+    selectRow(currentIndex().row());
+}
+
 void WTrackTableView::slotLoadPlayer1()
 {
     if (!m_pTable) //Browse mode
Index: mixxx/src/track.h
===================================================================
--- mixxx/src/track.h	(revision 1674)
+++ mixxx/src/track.h	(working copy)
@@ -99,6 +99,14 @@
     void slotNextTrackPlayer2(double);
     /** Slot for loading previous track in player 1 */
     void slotPrevTrackPlayer2(double);
+
+    /** Slots for loading the selected track into players */
+    void slotLoadSelectedTrackCh1(double);
+    void slotLoadSelectedTrackCh2(double);
+    /** Slots for moving the selection cursor in the track list */
+    void slotSelectNextTrack(double);
+    void slotSelectPrevTrack(double);
+
     /** Returns pointer to active playlist */
     TrackPlaylist *getActivePlaylist();
     /** Slot for sending track to Play Queue */
@@ -147,6 +155,8 @@
     ControlObjectThreadMain *m_pPlayButtonCh1, *m_pPlayButtonCh2;
     /** Pointer to ControlObject for next/prev buttons */
     ControlObjectThreadMain *m_pNextTrackCh1, *m_pNextTrackCh2, *m_pPrevTrackCh1, *m_pPrevTrackCh2;
+    /** Pointer to ControlObject for playlist navigation/loading into Players */
+    ControlObjectThreadMain *m_pLoadSelectedTrackCh1, *m_pLoadSelectedTrackCh2, *m_pSelectNextTrack, *m_pSelectPrevTrack;
     /** Pointer to ControlObject for play position */
     ControlObjectThreadMain *m_pPlayPositionCh1, *m_pPlayPositionCh2;
     /** Pointer to waveform summary generator */
Index: mixxx/src/wtracktableview.h
===================================================================
--- mixxx/src/wtracktableview.h	(revision 1674)
+++ mixxx/src/wtracktableview.h	(working copy)
@@ -77,6 +77,10 @@
     /**Current WTrackTableModel**/
     WTrackTableModel *m_pTable;
 
+    /* Helper functions to move the row selection */
+    void selectNext();
+    void selectPrevious();
+
 private:
     /** Config object*/
     ConfigObject<ConfigValue> *m_pConfig;
Index: mixxx/src/track.cpp
===================================================================
--- mixxx/src/track.cpp	(revision 1674)
+++ mixxx/src/track.cpp	(working copy)
@@ -157,6 +157,16 @@
     connect(m_pNextTrackCh2, SIGNAL(valueChanged(double)), this, SLOT(slotNextTrackPlayer2(double)));
     connect(m_pPrevTrackCh2, SIGNAL(valueChanged(double)), this, SLOT(slotPrevTrackPlayer2(double)));
 
+    // Make controls for tracklist navigation and current track loading
+    m_pLoadSelectedTrackCh1 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel1]","LoadSelectedTrack")));
+    m_pLoadSelectedTrackCh2 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel2]","LoadSelectedTrack")));
+    m_pSelectNextTrack = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Playlist]","SelectNextTrack")));
+    m_pSelectPrevTrack = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Playlist]","SelectPrevTrack")));
+    connect(m_pLoadSelectedTrackCh1, SIGNAL(valueChanged(double)), this, SLOT(slotLoadSelectedTrackCh1(double)));
+    connect(m_pLoadSelectedTrackCh2, SIGNAL(valueChanged(double)), this, SLOT(slotLoadSelectedTrackCh2(double)));
+    connect(m_pSelectNextTrack, SIGNAL(valueChanged(double)), this, SLOT(slotSelectNextTrack(double)));
+    connect(m_pSelectPrevTrack, SIGNAL(valueChanged(double)), this, SLOT(slotSelectPrevTrack(double)));
+
     TrackPlaylist::setTrack(this);
 
 	m_pView->m_pTrackTableView->repaintEverything();
@@ -764,6 +774,47 @@
     //m_pEndOfTrackCh2->slotSet(0.);
 }
 
+void Track::slotLoadSelectedTrackCh1(double v)
+{
+    QModelIndex index;
+    TrackInfoObject *pTrack;
+    // Only load on key presses and if we're not in browse mode
+    if (v && m_pView->m_pTrackTableView->m_pTable)
+    {
+        // Fetch the currently selected track 
+        index = m_pView->m_pTrackTableView->currentIndex();
+        pTrack = m_pView->m_pTrackTableView->m_pTable->m_pTrackPlaylist->getTrackAt(index.row());
+	// If there is one, load it
+	if (pTrack) slotLoadPlayer1(pTrack);
+    }
+}
+
+void Track::slotLoadSelectedTrackCh2(double v)
+{
+    QModelIndex index;
+    TrackInfoObject *pTrack;
+    // Only load on key presses and if we're not in browse mode
+    if (v && m_pView->m_pTrackTableView->m_pTable) {
+        // Fetch the currently selected track 
+        index = m_pView->m_pTrackTableView->currentIndex();
+        pTrack = m_pView->m_pTrackTableView->m_pTable->m_pTrackPlaylist->getTrackAt(index.row());
+	// If there is one, load it
+        if (pTrack) slotLoadPlayer2(pTrack);
+    }
+}
+
+void Track::slotSelectNextTrack(double v)
+{
+    // Only move on key presses
+    if (v) m_pView->m_pTrackTableView->selectNext();
+}
+
+void Track::slotSelectPrevTrack(double v)
+{
+    // Only move on key presses
+    if (v) m_pView->m_pTrackTableView->selectPrevious();
+}
+
 void Track::slotNextTrackPlayer1(double v)
 {
     if (v && m_pTrackPlayer1)
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to