mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
ignore artists with no input when generating the summary
This commit is contained in:
@@ -97,6 +97,9 @@ Tomahawk::EchonestControl::matchString() const
|
|||||||
QString
|
QString
|
||||||
Tomahawk::EchonestControl::summary() const
|
Tomahawk::EchonestControl::summary() const
|
||||||
{
|
{
|
||||||
|
if( m_summary.isEmpty() )
|
||||||
|
const_cast< EchonestControl* >( this )->calculateSummary();
|
||||||
|
|
||||||
return m_summary;
|
return m_summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -264,6 +264,7 @@ EchonestGenerator::sentenceSummary()
|
|||||||
* - Separate phrases by comma, and before last phrase
|
* - Separate phrases by comma, and before last phrase
|
||||||
* - sorting always at end
|
* - sorting always at end
|
||||||
* - collapse artists. "Like X, like Y, like Z, ..." -> "Like X, Y, and Z"
|
* - collapse artists. "Like X, like Y, like Z, ..." -> "Like X, Y, and Z"
|
||||||
|
* - skip empty artist entries
|
||||||
*
|
*
|
||||||
* NOTE / TODO: In order for the sentence to be grammatically correct, we must follow the EN API rules. That means we can't have multiple of some types of filters,
|
* NOTE / TODO: In order for the sentence to be grammatically correct, we must follow the EN API rules. That means we can't have multiple of some types of filters,
|
||||||
* and all Artist types must be the same. The filters aren't checked at the moment until Generate / Play is pressed. Consider doing a check on hide as well.
|
* and all Artist types must be the same. The filters aren't checked at the moment until Generate / Play is pressed. Consider doing a check on hide as well.
|
||||||
@@ -283,7 +284,19 @@ EchonestGenerator::sentenceSummary()
|
|||||||
}
|
}
|
||||||
if( !sorting.isNull() )
|
if( !sorting.isNull() )
|
||||||
allcontrols.removeAll( sorting );
|
allcontrols.removeAll( sorting );
|
||||||
|
|
||||||
|
/// Skip empty artists
|
||||||
|
QList< dyncontrol_ptr > empty;
|
||||||
|
foreach( const dyncontrol_ptr& artist, artists ) {
|
||||||
|
QString summary = artist.dynamicCast< EchonestControl >()->summary();
|
||||||
|
if( summary.lastIndexOf( "~" ) == summary.length() - 1 )
|
||||||
|
empty << artist;
|
||||||
|
}
|
||||||
|
foreach( const dyncontrol_ptr& toremove, empty ) {
|
||||||
|
artists.removeAll( toremove );
|
||||||
|
allcontrols.removeAll( toremove );
|
||||||
|
}
|
||||||
|
|
||||||
/// Do the assembling. Start with the artists if there are any, then do all the rest.
|
/// Do the assembling. Start with the artists if there are any, then do all the rest.
|
||||||
for( int i = 0; i < artists.size(); i++ ) {
|
for( int i = 0; i < artists.size(); i++ ) {
|
||||||
dyncontrol_ptr artist = artists.value( i );
|
dyncontrol_ptr artist = artists.value( i );
|
||||||
@@ -292,6 +305,7 @@ EchonestGenerator::sentenceSummary()
|
|||||||
/// Collapse artist lists
|
/// Collapse artist lists
|
||||||
QString center, suffix;
|
QString center, suffix;
|
||||||
QString summary = artist.dynamicCast< EchonestControl >()->summary();
|
QString summary = artist.dynamicCast< EchonestControl >()->summary();
|
||||||
|
|
||||||
if( i == 0 ) { // if it's the first and only one
|
if( i == 0 ) { // if it's the first and only one
|
||||||
center = summary.remove( "~" );
|
center = summary.remove( "~" );
|
||||||
if( artists.size() == 2 ) // special case for 2, no comma. ( X and Y )
|
if( artists.size() == 2 ) // special case for 2, no comma. ( X and Y )
|
||||||
|
@@ -156,6 +156,8 @@ CollapsibleControls::onAnimationFinished()
|
|||||||
|
|
||||||
if( m_collapseAnimation && m_layout->currentWidget() == m_controls && m_timeline->direction() == QTimeLine::Backward ) {
|
if( m_collapseAnimation && m_layout->currentWidget() == m_controls && m_timeline->direction() == QTimeLine::Backward ) {
|
||||||
m_layout->setCurrentWidget( m_summaryWidget );
|
m_layout->setCurrentWidget( m_summaryWidget );
|
||||||
|
} else {
|
||||||
|
setMaximumHeight( QWIDGETSIZE_MAX );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user