Skip to content

Commit

Permalink
Add Result::isLocal helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Apr 14, 2016
1 parent bf28f68 commit c87b139
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/libtomahawk/ContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
if ( m_supportedActions & ActionOpenFileManager &&
queries.length() == 1 &&
queries.first()->numResults() &&
queries.first()->results().first()->resolvedByCollection() &&
queries.first()->results().first()->resolvedByCollection()->isLocal() )
queries.first()->results().first()->isLocal() )
{
m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/folder.svg" ),
tr( "Open Folder in File Manager..." ) ), ActionOpenFileManager );
Expand Down
2 changes: 1 addition & 1 deletion src/libtomahawk/DropJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ DropJob::removeRemoteSources()

foreach ( const Tomahawk::result_ptr& result, item->results() )
{
if ( !result->resolvedByCollection().isNull() && !result->resolvedByCollection()->isLocal() )
if ( !result->isLocal() )
{
list.append( item );
break;
Expand Down
2 changes: 1 addition & 1 deletion src/libtomahawk/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ Query::resultSorter( const result_ptr& left, const result_ptr& right )

if ( ls == rs )
{
if ( right->resolvedByCollection() && right->resolvedByCollection()->isLocal() )
if ( right->isLocal() )
{
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions src/libtomahawk/Result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ Result::playable() const
}


bool
Result::isLocal() const
{
return resolvedByCollection().isNull() ? false : resolvedByCollection()->isLocal();
}


QVariant
Result::toVariant() const
{
Expand Down
6 changes: 6 additions & 0 deletions src/libtomahawk/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ friend class ::MetadataEditor;
bool isOnline() const;
bool playable() const;

/**
* @brief whether this result isLocal, i.e. resolved by a local collection
* @return isLocal
*/
bool isLocal() const;

QString url() const;
/**
* Has the given url been checked that it is accessible/valid.
Expand Down
4 changes: 2 additions & 2 deletions src/libtomahawk/filemetadata/MetadataEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result )
return;

m_result = result;
setEditable( result->resolvedByCollection() && result->resolvedByCollection()->isLocal() );
setEditable( result->isLocal() );

setTitle( result->track()->track() );
setArtist( result->track()->artist() );
Expand All @@ -250,7 +250,7 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result )
setYear( result->track()->year() );
setBitrate( result->bitrate() );

if ( result->resolvedByCollection() && result->resolvedByCollection()->isLocal() )
if ( result->isLocal() )
{
QString furl = m_result->url();
if ( furl.startsWith( "file://" ) )
Expand Down
4 changes: 2 additions & 2 deletions src/libtomahawk/playlist/TreeProxyModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
if ( !item->result()->isOnline() && ti->result()->isOnline() )
return false;

if ( ( item->result()->resolvedByCollection().isNull() || !item->result()->resolvedByCollection()->isLocal() ) &&
!ti->result()->resolvedByCollection().isNull() && ti->result()->resolvedByCollection()->isLocal() )
if ( ( !item->result()->isLocal() ) &&
!ti->result()->isLocal() )
{
return false;
}
Expand Down

0 comments on commit c87b139

Please sign in to comment.