mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Merge pull request #147 from tomahawk-player/songtype
add Echonest SongType Support
This commit is contained in:
@@ -441,6 +441,28 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_input = QPointer< QWidget >( combo );
|
m_input = QPointer< QWidget >( combo );
|
||||||
|
|
||||||
insertMoodsAndStyles();
|
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 {
|
} else {
|
||||||
m_match = QPointer<QWidget>( new QWidget );
|
m_match = QPointer<QWidget>( new QWidget );
|
||||||
m_input = QPointer<QWidget>( new QWidget );
|
m_input = QPointer<QWidget>( new QWidget );
|
||||||
@@ -522,6 +544,21 @@ Tomahawk::EchonestControl::updateData()
|
|||||||
m_data.second = enumVal;
|
m_data.second = enumVal;
|
||||||
// qDebug() << "SAVING" << input->currentIndex() << "AS" << enumVal << "(" << input->itemData( input->currentIndex() ).toInt() << "+" << m_matchData.toInt() << ")";
|
// 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();
|
calculateSummary();
|
||||||
@@ -611,6 +648,15 @@ Tomahawk::EchonestControl::updateWidgetsFromData()
|
|||||||
input->setCurrentIndex( val );
|
input->setCurrentIndex( val );
|
||||||
// qDebug() << "LOADING" << m_data.second.toInt() << "AS" << 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();
|
calculateSummary();
|
||||||
}
|
}
|
||||||
@@ -850,6 +896,19 @@ Tomahawk::EchonestControl::calculateSummary()
|
|||||||
Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) );
|
Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) );
|
||||||
QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower();
|
QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower();
|
||||||
summary = tr( "in a %1 style" ).arg( text );
|
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;
|
m_summary = summary;
|
||||||
|
@@ -65,7 +65,7 @@ EchonestFactory::typeSelectors() const
|
|||||||
{
|
{
|
||||||
QStringList types = QStringList() << "Artist" << "Artist Description" << "User Radio" << "Song" << "Mood" << "Style" << "Adventurousness" << "Variety" << "Tempo" << "Duration" << "Loudness"
|
QStringList types = QStringList() << "Artist" << "Artist Description" << "User Radio" << "Song" << "Mood" << "Style" << "Adventurousness" << "Variety" << "Tempo" << "Duration" << "Loudness"
|
||||||
<< "Danceability" << "Energy" << "Artist Familiarity" << "Artist Hotttnesss" << "Song Hotttnesss"
|
<< "Danceability" << "Energy" << "Artist Familiarity" << "Artist Hotttnesss" << "Song Hotttnesss"
|
||||||
<< "Longitude" << "Latitude" << "Mode" << "Key" << "Sorting";
|
<< "Longitude" << "Latitude" << "Mode" << "Key" << "Sorting" << "Song Type";
|
||||||
|
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user