diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp index 158087b55..61d25aaa1 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 = QPointer< 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( "Studio" ), "studio" ); + combo->addItem( tr( "Live" ), "live" ); + combo->addItem( tr( "Christmas" ), "christmas" ); + + 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 = "is"; + m_matchData = 1; + + m_match = QPointer< QWidget >( match ); + m_input = QPointer< QWidget >( combo ); } else { m_match = QPointer( new QWidget ); m_input = QPointer( new QWidget ); @@ -522,6 +544,21 @@ 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* combo = qobject_cast< QComboBox* >( m_input.data() ); + if ( match && combo ) { + m_matchString = match->currentText(); + m_matchData = match->itemData( match->currentIndex() ).toString(); + + QString songType = combo->itemData( combo->currentIndex() ).toString(); + if ( match->currentIndex() == 1 ) + songType.append( ":false" ); + + m_data.first = Echonest::DynamicPlaylist::SongType; + m_data.second = songType; + } + } calculateSummary(); @@ -611,6 +648,15 @@ Tomahawk::EchonestControl::updateWidgetsFromData() input->setCurrentIndex( val ); // qDebug() << "LOADING" << m_data.second.toInt() << "AS" << val; } + } else if( selectedType() == "Song Type" ) { + QComboBox* match = qobject_cast( m_match.data() ); + QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() ); + if ( match && combo ) { + match->setCurrentIndex( match->findData( m_matchData )); + + QString songType = m_data.second.toString().split( ":" ).at( 0 ); + combo->setCurrentIndex( combo->findData( songType ) ); + } } calculateSummary(); } @@ -850,6 +896,19 @@ Tomahawk::EchonestControl::calculateSummary() Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); summary = tr( "in a %1 style" ).arg( text ); + } else if( selectedType() == "Song Type" ) { + Q_ASSERT( !m_input.isNull() ); + Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); + QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText(); + + + Q_ASSERT( !m_match.isNull() ); + Q_ASSERT( qobject_cast< QComboBox* >( m_match.data() ) ); + QComboBox* combo = qobject_cast< QComboBox* >( m_match.data() ); + if ( combo->currentIndex() == 0 ) + summary = tr( "where song type is %1" ).arg( text ); + else + summary = tr( "where song type is not %1" ).arg( text ); } m_summary = summary; 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; }