From 2f591f89d2b9c194cbcd18af3e5304fffee8d51b Mon Sep 17 00:00:00 2001 From: Stefan Derkits Date: Sat, 1 Dec 2012 14:43:04 +0100 Subject: [PATCH] First Implementation of SongType support in Playlists (needs libechonest from https://github.com/Horrendus/libechonest) --- .../dynamic/echonest/EchonestControl.cpp | 39 +++++++++++++++++++ .../dynamic/echonest/EchonestGenerator.cpp | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp index d9983b846..e199c6cc9 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp @@ -441,6 +441,28 @@ Tomahawk::EchonestControl::updateWidgets() m_input = QWeakPointer< QWidget >( combo ); insertMoodsAndStyles(); + } else if( selectedType() == "Song Type" ) { + m_currentType = Echonest::DynamicPlaylist::SongType; + + QComboBox* match = new QComboBox(); + match->addItem( tr( "is" ), 1 ); + match->addItem( tr( "is not" ), 0 ); + + QComboBox* combo = new QComboBox(); + combo->addItem( tr( "Christmas" ), "christmas" ); + combo->addItem( tr( "Studio" ), "studio" ); + combo->addItem( tr( "Live" ), "live" ); + + connect( match, SIGNAL( activated( int ) ), this, SLOT( updateData() ) ); + connect( match, SIGNAL( activated( int ) ), this, SLOT( editingFinished() ) ); + connect( combo, SIGNAL( activated( int ) ), this, SLOT( updateData() ) ); + connect( combo, SIGNAL( activated( int ) ), this, SLOT( editingFinished() ) ); + + m_matchString = match->currentText(); + m_matchData = match->currentText(); + + m_match = QWeakPointer< QWidget >( match ); + m_input = QWeakPointer< QWidget >( combo ); } else { m_match = QWeakPointer( new QWidget ); m_input = QWeakPointer( new QWidget ); @@ -522,6 +544,23 @@ Tomahawk::EchonestControl::updateData() m_data.second = enumVal; // qDebug() << "SAVING" << input->currentIndex() << "AS" << enumVal << "(" << input->itemData( input->currentIndex() ).toInt() << "+" << m_matchData.toInt() << ")"; } + } else if( selectedType() == "Song Type" ) { + QComboBox* match = qobject_cast( m_match.data() ); + QComboBox* input = qobject_cast< QComboBox* >( m_input.data() ); + if ( match && input ) { + m_matchString = match->currentText(); + m_matchData = match->itemData( match->currentIndex() ).toString(); + + QString songType = input->currentText().toLower(); + if ( match->currentText() == "is not" ) + songType.append(":false"); + + qDebug() << "ST: " << songType; + + m_data.first = Echonest::DynamicPlaylist::SongType; + m_data.second = songType; + } + } calculateSummary(); diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp index e581d7aff..61e648188 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestGenerator.cpp @@ -65,7 +65,7 @@ EchonestFactory::typeSelectors() const { QStringList types = QStringList() << "Artist" << "Artist Description" << "User Radio" << "Song" << "Mood" << "Style" << "Adventurousness" << "Variety" << "Tempo" << "Duration" << "Loudness" << "Danceability" << "Energy" << "Artist Familiarity" << "Artist Hotttnesss" << "Song Hotttnesss" - << "Longitude" << "Latitude" << "Mode" << "Key" << "Sorting"; + << "Longitude" << "Latitude" << "Mode" << "Key" << "Sorting" << "Song Type"; return types; }