1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 01:09:42 +01:00

Merge pull request #147 from tomahawk-player/songtype

add Echonest SongType Support
This commit is contained in:
Stefan Derkits 2013-01-09 12:45:03 -08:00
commit 7d94b0b575
2 changed files with 60 additions and 1 deletions

View File

@ -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<QWidget>( new QWidget );
m_input = QPointer<QWidget>( 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<QComboBox*>( 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<QComboBox*>( 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;

View File

@ -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;
}