From 35ab3f4502c0b37f2b320b3c8dcec542cc61aed0 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 5 Apr 2015 03:25:08 +0200 Subject: [PATCH] Don't count items when we really just need to know if a list is empty or not. --- src/accounts/zeroconf/TomahawkZeroconf.h | 4 +-- src/libtomahawk/Album.cpp | 4 +-- src/libtomahawk/Artist.cpp | 6 ++--- src/libtomahawk/AtticaManager.cpp | 2 +- src/libtomahawk/ContextMenu.cpp | 14 +++++----- src/libtomahawk/DownloadManager.cpp | 8 +++--- src/libtomahawk/MetaPlaylistInterface.cpp | 26 +++++++++---------- src/libtomahawk/Pipeline.cpp | 2 +- src/libtomahawk/Playlist.cpp | 4 +-- src/libtomahawk/Query.h | 2 +- src/libtomahawk/Source.cpp | 6 ++--- src/libtomahawk/TomahawkSettings.cpp | 2 +- src/libtomahawk/ViewManager.cpp | 10 +++---- .../accounts/lastfm/LastFmInfoPlugin.cpp | 4 +-- src/libtomahawk/audio/AudioEngine.cpp | 6 ++--- .../database/DatabaseCommand_DeleteFiles.cpp | 6 ++--- .../DatabaseCommand_LoadPlaylistEntries.cpp | 4 +-- .../filemetadata/MetadataEditor.cpp | 4 +-- src/libtomahawk/filemetadata/MusicScanner.cpp | 8 +++--- src/libtomahawk/network/ConnectionManager.cpp | 4 +-- src/libtomahawk/network/Servent.cpp | 2 +- src/libtomahawk/playlist/AlbumModel.cpp | 10 +++---- src/libtomahawk/playlist/ColumnView.cpp | 4 +-- src/libtomahawk/playlist/GridView.cpp | 4 +-- src/libtomahawk/playlist/PlayableModel.cpp | 4 +-- src/libtomahawk/playlist/PlaylistModel.cpp | 6 ++--- src/libtomahawk/playlist/TrackView.cpp | 8 +++--- src/libtomahawk/playlist/TreeModel.cpp | 6 ++--- src/libtomahawk/playlist/ViewHeader.cpp | 2 +- .../dynamic/database/DatabaseGenerator.cpp | 2 +- src/libtomahawk/widgets/BreadcrumbButton.cpp | 2 +- src/tomahawk/sourcetree/SourcesProxyModel.cpp | 4 +-- .../sourcetree/items/PlaylistItems.cpp | 6 ++--- src/tomahawk/sourcetree/items/QueueItem.cpp | 4 +-- 34 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/accounts/zeroconf/TomahawkZeroconf.h b/src/accounts/zeroconf/TomahawkZeroconf.h index 97884023c..c623f6d06 100644 --- a/src/accounts/zeroconf/TomahawkZeroconf.h +++ b/src/accounts/zeroconf/TomahawkZeroconf.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2013, Uwe L. Korn * * Tomahawk is free software: you can redistribute it and/or modify @@ -58,7 +58,7 @@ public slots: void resolved( QHostInfo i ) { qDebug() << Q_FUNC_INFO << "zeroconf-derived IP has resolved to name " << i.hostName(); - if ( i.hostName().length() ) + if ( !i.hostName().isEmpty() ) emit tomahawkHostFound( ip, port, i.hostName(), nid ); else emit tomahawkHostFound( ip, port, "Unknown", nid ); diff --git a/src/libtomahawk/Album.cpp b/src/libtomahawk/Album.cpp index 1baa89fb3..34dc14aed 100644 --- a/src/libtomahawk/Album.cpp +++ b/src/libtomahawk/Album.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * * Tomahawk is free software: you can redistribute it and/or modify @@ -332,7 +332,7 @@ Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, { QVariantMap returnedData = output.value< QVariantMap >(); const QByteArray ba = returnedData["imgbytes"].toByteArray(); - if ( ba.length() ) + if ( !ba.isEmpty() ) { d->coverBuffer = ba; } diff --git a/src/libtomahawk/Artist.cpp b/src/libtomahawk/Artist.cpp index 1f930c60e..c340fea68 100644 --- a/src/libtomahawk/Artist.cpp +++ b/src/libtomahawk/Artist.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2013, Teo Mrnjavac * @@ -500,7 +500,7 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari } m_albumsLoaded.insert( InfoSystemMode, true ); - if ( m_officialAlbums.count() ) + if ( !m_officialAlbums.isEmpty() ) emit albumsAdded( albums, InfoSystemMode ); break; @@ -515,7 +515,7 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari else if ( output.isValid() ) { const QByteArray ba = returnedData["imgbytes"].toByteArray(); - if ( ba.length() ) + if ( !ba.isEmpty() ) { m_coverBuffer = ba; } diff --git a/src/libtomahawk/AtticaManager.cpp b/src/libtomahawk/AtticaManager.cpp index 0f58de669..23144163c 100644 --- a/src/libtomahawk/AtticaManager.cpp +++ b/src/libtomahawk/AtticaManager.cpp @@ -591,7 +591,7 @@ AtticaManager::resolverDownloadFinished ( QNetworkReply *j ) doc.setContent( j ); const QDomNodeList nodes = doc.documentElement().elementsByTagName( "downloadlink" ); - if ( nodes.length() < 1 ) + if ( nodes.isEmpty() ) { tLog() << "Found no download link for resolver:" << doc.toString(); return; diff --git a/src/libtomahawk/ContextMenu.cpp b/src/libtomahawk/ContextMenu.cpp index 7c1cb471f..59332f9b9 100644 --- a/src/libtomahawk/ContextMenu.cpp +++ b/src/libtomahawk/ContextMenu.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2013, Teo Mrnjavac * * Tomahawk is free software: you can redistribute it and/or modify @@ -419,15 +419,15 @@ ContextMenu::addToQueue() void ContextMenu::copyLink() { - if ( m_queries.count() ) + if ( !m_queries.isEmpty() ) { Utils::LinkGenerator::instance()->copyOpenLink( m_queries.first() ); } - else if ( m_albums.count() ) + else if ( !m_albums.isEmpty() ) { Utils::LinkGenerator::instance()->copyOpenLink( m_albums.first() ); } - else if ( m_artists.count() ) + else if ( !m_artists.isEmpty() ) { Utils::LinkGenerator::instance()->copyOpenLink( m_artists.first() ); } @@ -437,7 +437,7 @@ ContextMenu::copyLink() void ContextMenu::openPage( MenuActions action ) { - if ( m_queries.count() ) + if ( !m_queries.isEmpty() ) { if ( action == ActionTrackPage ) { @@ -455,7 +455,7 @@ ContextMenu::openPage( MenuActions action ) } } } - else if ( m_albums.count() ) + else if ( !m_albums.isEmpty() ) { if ( action == ActionArtistPage ) { @@ -466,7 +466,7 @@ ContextMenu::openPage( MenuActions action ) ViewManager::instance()->show( m_albums.first() ); } } - else if ( m_artists.count() ) + else if ( !m_artists.isEmpty() ) { ViewManager::instance()->show( m_artists.first() ); } diff --git a/src/libtomahawk/DownloadManager.cpp b/src/libtomahawk/DownloadManager.cpp index d366d8836..0ac573dcb 100644 --- a/src/libtomahawk/DownloadManager.cpp +++ b/src/libtomahawk/DownloadManager.cpp @@ -194,15 +194,15 @@ downloadjob_ptr DownloadManager::currentJob() const { QList j = jobs( DownloadJob::Running ); - if ( j.count() ) + if ( !j.isEmpty() ) return j.first(); j = jobs( DownloadJob::Paused ); - if ( j.count() ) + if ( !j.isEmpty() ) return j.first(); j = jobs( DownloadJob::Waiting ); - if ( j.count() ) + if ( !j.isEmpty() ) return j.first(); return downloadjob_ptr(); @@ -282,7 +282,7 @@ DownloadManager::resume() m_globalState = true; - if ( jobs( DownloadJob::Paused ).count() ) + if ( !jobs( DownloadJob::Paused ).isEmpty() ) { foreach ( const downloadjob_ptr& job, jobs( DownloadJob::Paused ) ) { diff --git a/src/libtomahawk/MetaPlaylistInterface.cpp b/src/libtomahawk/MetaPlaylistInterface.cpp index 6cd93d1fa..6712f223d 100644 --- a/src/libtomahawk/MetaPlaylistInterface.cpp +++ b/src/libtomahawk/MetaPlaylistInterface.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2012, Christian Muehlhaeuser + * Copyright 2012-2015, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,7 +62,7 @@ MetaPlaylistInterface::removeChildInterface( const Tomahawk::playlistinterface_p QList< Tomahawk::query_ptr > MetaPlaylistInterface::tracks() const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->tracks(); else return QList< Tomahawk::query_ptr >(); @@ -72,7 +72,7 @@ MetaPlaylistInterface::tracks() const int MetaPlaylistInterface::trackCount() const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->trackCount(); else return 0; @@ -82,7 +82,7 @@ MetaPlaylistInterface::trackCount() const result_ptr MetaPlaylistInterface::currentItem() const { - if ( m_childInterfaces.count() && m_childInterfaces.first() ) + if ( !m_childInterfaces.isEmpty() && m_childInterfaces.first() ) return m_childInterfaces.first()->currentItem(); else return Tomahawk::result_ptr(); @@ -92,7 +92,7 @@ MetaPlaylistInterface::currentItem() const qint64 MetaPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->siblingIndex( itemsAway, rootIndex ); else return -1; @@ -102,7 +102,7 @@ MetaPlaylistInterface::siblingIndex( int itemsAway, qint64 rootIndex ) const Tomahawk::query_ptr MetaPlaylistInterface::queryAt( qint64 index ) const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->queryAt( index ); else return Tomahawk::query_ptr(); @@ -112,7 +112,7 @@ MetaPlaylistInterface::queryAt( qint64 index ) const Tomahawk::result_ptr MetaPlaylistInterface::resultAt( qint64 index ) const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->resultAt( index ); else return Tomahawk::result_ptr(); @@ -122,7 +122,7 @@ MetaPlaylistInterface::resultAt( qint64 index ) const qint64 MetaPlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->indexOfResult( result ); else return -1; @@ -132,7 +132,7 @@ MetaPlaylistInterface::indexOfResult( const Tomahawk::result_ptr& result ) const qint64 MetaPlaylistInterface::indexOfQuery( const Tomahawk::query_ptr& query ) const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->indexOfQuery( query ); else return -1; @@ -142,7 +142,7 @@ MetaPlaylistInterface::indexOfQuery( const Tomahawk::query_ptr& query ) const PlaylistModes::RepeatMode MetaPlaylistInterface::repeatMode() const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->repeatMode(); else return PlaylistModes::NoRepeat; @@ -152,7 +152,7 @@ MetaPlaylistInterface::repeatMode() const bool MetaPlaylistInterface::shuffled() const { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->shuffled(); else return false; @@ -175,7 +175,7 @@ MetaPlaylistInterface::hasChildInterface( const Tomahawk::playlistinterface_ptr& void MetaPlaylistInterface::setRepeatMode( PlaylistModes::RepeatMode mode ) { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->setRepeatMode( mode ); } @@ -183,6 +183,6 @@ MetaPlaylistInterface::setRepeatMode( PlaylistModes::RepeatMode mode ) void MetaPlaylistInterface::setShuffled( bool enabled ) { - if ( m_childInterfaces.count() ) + if ( !m_childInterfaces.isEmpty() ) return m_childInterfaces.first()->setShuffled( enabled ); } diff --git a/src/libtomahawk/Pipeline.cpp b/src/libtomahawk/Pipeline.cpp index 4d3496f5d..af81d7167 100644 --- a/src/libtomahawk/Pipeline.cpp +++ b/src/libtomahawk/Pipeline.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2013, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libtomahawk/Playlist.cpp b/src/libtomahawk/Playlist.cpp index 06eb216a3..cdc124bf1 100644 --- a/src/libtomahawk/Playlist.cpp +++ b/src/libtomahawk/Playlist.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2011, Leo Franchi * Copyright 2010-2012, Jeff Mitchell * @@ -455,7 +455,7 @@ Playlist::setRevision( const QString& rev, setBusy( false ); setLoaded( true ); - if ( d->initEntries.count() && currentrevision().isEmpty() ) + if ( !d->initEntries.isEmpty() && currentrevision().isEmpty() ) { // add initial tracks createNewRevision( uuid(), currentrevision(), d->initEntries ); diff --git a/src/libtomahawk/Query.h b/src/libtomahawk/Query.h index c24d27f1e..365e0c4e2 100644 --- a/src/libtomahawk/Query.h +++ b/src/libtomahawk/Query.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2013, Uwe L. Korn * diff --git a/src/libtomahawk/Source.cpp b/src/libtomahawk/Source.cpp index 06fd159f7..5c63caa56 100644 --- a/src/libtomahawk/Source.cpp +++ b/src/libtomahawk/Source.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2013, Uwe L. Korn * @@ -151,7 +151,7 @@ collection_ptr Source::dbCollection() const { Q_D( const Source ); - if ( d->collections.length() ) + if ( !d->collections.isEmpty() ) { foreach ( const collection_ptr& collection, d->collections ) { @@ -722,7 +722,7 @@ Source::executeCommands() // return here when the last command finished connect( cmd.data(), SIGNAL( finished() ), SLOT( executeCommands() ) ); - if ( cmdGroup.count() ) + if ( !cmdGroup.isEmpty() ) { Database::instance()->enqueue( cmdGroup ); } diff --git a/src/libtomahawk/TomahawkSettings.cpp b/src/libtomahawk/TomahawkSettings.cpp index d127bde35..98f0a032b 100644 --- a/src/libtomahawk/TomahawkSettings.cpp +++ b/src/libtomahawk/TomahawkSettings.cpp @@ -817,7 +817,7 @@ QString TomahawkSettings::downloadsPath() const { QString musicLocation; - if ( scannerPaths().count() ) + if ( !scannerPaths().isEmpty() ) musicLocation = scannerPaths().first(); return value( "downloadmanager/path", musicLocation ).toString(); diff --git a/src/libtomahawk/ViewManager.cpp b/src/libtomahawk/ViewManager.cpp index dc68c6d74..372beea21 100644 --- a/src/libtomahawk/ViewManager.cpp +++ b/src/libtomahawk/ViewManager.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2011, Jeff Mitchell * Copyright 2010-2012, Leo Franchi * Copyright 2013, Teo Mrnjavac @@ -348,7 +348,7 @@ ViewManager::showInboxPage() void ViewManager::historyBack() { - if ( !m_pageHistoryBack.count() ) + if ( m_pageHistoryBack.isEmpty() ) return; ViewPage* page = m_pageHistoryBack.takeLast(); @@ -367,7 +367,7 @@ ViewManager::historyBack() void ViewManager::historyForward() { - if ( !m_pageHistoryFwd.count() ) + if ( m_pageHistoryFwd.isEmpty() ) return; ViewPage* page = m_pageHistoryFwd.takeLast(); @@ -413,8 +413,8 @@ ViewManager::destroyPage( ViewPage* page ) m_pageHistoryBack.removeAll( page ); m_pageHistoryFwd.removeAll( page ); - emit historyBackAvailable( m_pageHistoryBack.count() ); - emit historyForwardAvailable( m_pageHistoryFwd.count() ); + emit historyBackAvailable( !m_pageHistoryBack.isEmpty() ); + emit historyForwardAvailable( !m_pageHistoryFwd.isEmpty() ); } if ( m_currentPage == page ) diff --git a/src/libtomahawk/accounts/lastfm/LastFmInfoPlugin.cpp b/src/libtomahawk/accounts/lastfm/LastFmInfoPlugin.cpp index 3ca1d6af4..d1c897dec 100644 --- a/src/libtomahawk/accounts/lastfm/LastFmInfoPlugin.cpp +++ b/src/libtomahawk/accounts/lastfm/LastFmInfoPlugin.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify @@ -809,7 +809,7 @@ LastFmInfoPlugin::coverArtReturned() Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>(); QByteArray ba = reply->readAll(); - if ( ba.isNull() || !ba.length() ) + if ( ba.isNull() || ba.isEmpty() ) { tLog() << Q_FUNC_INFO << "Null byte array for cover of" << origData["artist"] << origData["album"]; emit info( requestData, QVariant() ); diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index 9877d6adf..3c572ab1a 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2013, Teo Mrnjavac * @@ -942,7 +942,7 @@ AudioEngine::playItem( const Tomahawk::artist_ptr& artist ) playlistinterface_ptr pli = artist->playlistInterface( Mixed ); if ( pli->isFinished() ) { - if ( !pli->tracks().count() ) + if ( pli->tracks().isEmpty() ) { JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the artist '%1'" ).arg( artist->name() ), 15 ) ); @@ -968,7 +968,7 @@ AudioEngine::playItem( const Tomahawk::album_ptr& album ) playlistinterface_ptr pli = album->playlistInterface( Mixed ); if ( pli->isFinished() ) { - if ( !pli->tracks().count() ) + if ( pli->tracks().isEmpty() ) { JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the album '%1' by %2" ).arg( album->name() ).arg( album->artist()->name() ), 15 ) ); diff --git a/src/libtomahawk/database/DatabaseCommand_DeleteFiles.cpp b/src/libtomahawk/database/DatabaseCommand_DeleteFiles.cpp index 8cf1dcbf4..f30e00ecc 100644 --- a/src/libtomahawk/database/DatabaseCommand_DeleteFiles.cpp +++ b/src/libtomahawk/database/DatabaseCommand_DeleteFiles.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * * Tomahawk is free software: you can redistribute it and/or modify @@ -40,7 +40,7 @@ using namespace Tomahawk; void DatabaseCommand_DeleteFiles::postCommitHook() { - if ( !m_idList.count() ) + if ( m_idList.isEmpty() ) return; // make the collection object emit its tracksAdded signal, so the @@ -135,7 +135,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi ) delquery.exec(); } - if ( m_idList.count() ) + if ( !m_idList.isEmpty() ) source()->updateIndexWhenSynced(); emit done( m_idList, source()->dbCollection() ); diff --git a/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp b/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp index 01606b7af..3048b427a 100644 --- a/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp +++ b/src/libtomahawk/database/DatabaseCommand_LoadPlaylistEntries.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -104,7 +104,7 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi ) // qDebug() << "Playlist has no current revision data"; } - if ( prevrev.length() ) + if ( !prevrev.isEmpty() ) { TomahawkSqlQuery query_entries_old = dbi->newquery(); query_entries_old.prepare( "SELECT entries, " diff --git a/src/libtomahawk/filemetadata/MetadataEditor.cpp b/src/libtomahawk/filemetadata/MetadataEditor.cpp index c0f1da109..87ff5b16a 100644 --- a/src/libtomahawk/filemetadata/MetadataEditor.cpp +++ b/src/libtomahawk/filemetadata/MetadataEditor.cpp @@ -1,7 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2012, Christopher Reichert - * Copyright 2012, Christian Muehlhaeuser + * Copyright 2012-2015, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -186,7 +186,7 @@ MetadataEditor::writeMetadata( bool closeDlg ) } else if ( closeDlg ) { - if ( m_editFiles.count() ) + if ( !m_editFiles.isEmpty() ) ScanManager::instance()->runFileScan( m_editFiles, false ); close(); diff --git a/src/libtomahawk/filemetadata/MusicScanner.cpp b/src/libtomahawk/filemetadata/MusicScanner.cpp index 6b86ecc2a..f57da456c 100644 --- a/src/libtomahawk/filemetadata/MusicScanner.cpp +++ b/src/libtomahawk/filemetadata/MusicScanner.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * * Tomahawk is free software: you can redistribute it and/or modify @@ -274,7 +274,7 @@ MusicScanner::postOps() foreach ( const QString& s, m_skippedFiles ) tDebug( LOGEXTRA ) << s; - if ( m_filesToDelete.length() || m_scannedfiles.length() ) + if ( !m_filesToDelete.isEmpty() || !m_scannedfiles.isEmpty() ) { if ( !m_dryRun ) { @@ -312,13 +312,13 @@ MusicScanner::cleanup() void MusicScanner::commitBatch( const QVariantList& tracks, const QVariantList& deletethese ) { - if ( deletethese.length() ) + if ( !deletethese.isEmpty() ) { tDebug( LOGINFO ) << Q_FUNC_INFO << "deleting" << deletethese.length() << "tracks"; executeCommand( dbcmd_ptr( new DatabaseCommand_DeleteFiles( deletethese, SourceList::instance()->getLocal() ) ) ); } - if ( tracks.length() ) + if ( !tracks.isEmpty() ) { tDebug( LOGINFO ) << Q_FUNC_INFO << "adding" << tracks.length() << "tracks"; executeCommand( dbcmd_ptr( new DatabaseCommand_AddFiles( tracks, SourceList::instance()->getLocal() ) ) ); diff --git a/src/libtomahawk/network/ConnectionManager.cpp b/src/libtomahawk/network/ConnectionManager.cpp index 478c04859..afd49d1e6 100644 --- a/src/libtomahawk/network/ConnectionManager.cpp +++ b/src/libtomahawk/network/ConnectionManager.cpp @@ -203,9 +203,9 @@ ConnectionManager::newControlConnection( const Tomahawk::peerinfo_ptr& peerInfo d->controlConnection->addPeerInfo( peerInfo ); d->controlConnection->setFirstMessage( m ); - if ( peerInfo->id().length() ) + if ( !peerInfo->id().isEmpty() ) d->controlConnection->setName( peerInfo->contactId() ); - if ( peerInfo->nodeId().length() ) + if ( !peerInfo->nodeId().isEmpty() ) d->controlConnection->setId( peerInfo->nodeId() ); d->controlConnection->setNodeId( peerInfo->nodeId() ); diff --git a/src/libtomahawk/network/Servent.cpp b/src/libtomahawk/network/Servent.cpp index a213bdd4e..7b7ab0cec 100644 --- a/src/libtomahawk/network/Servent.cpp +++ b/src/libtomahawk/network/Servent.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2013, Teo Mrnjavac * Copyright 2013-2014, Uwe L. Korn diff --git a/src/libtomahawk/playlist/AlbumModel.cpp b/src/libtomahawk/playlist/AlbumModel.cpp index abc237a96..02cc390b0 100644 --- a/src/libtomahawk/playlist/AlbumModel.cpp +++ b/src/libtomahawk/playlist/AlbumModel.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2011, Jeff Mitchell * * Tomahawk is free software: you can redistribute it and/or modify @@ -114,7 +114,7 @@ AlbumModel::addAlbums( const QList& albums ) QList trimmedAlbums; foreach ( const album_ptr& album, albums ) { - if ( !album.isNull() && album->name().length() ) + if ( !album.isNull() && !album->name().isEmpty() ) { if ( findItem( album ) || trimmedAlbums.contains( album ) ) continue; @@ -122,7 +122,7 @@ AlbumModel::addAlbums( const QList& albums ) } } - if ( !trimmedAlbums.count() ) + if ( trimmedAlbums.isEmpty() ) { emit itemCountChanged( rowCount( QModelIndex() ) ); return; @@ -159,7 +159,7 @@ AlbumModel::addArtists( const QList& artists ) QList trimmedArtists; foreach ( const artist_ptr& artist, artists ) { - if ( !artist.isNull() && artist->name().length() ) + if ( !artist.isNull() && !artist->name().isEmpty() ) { if ( findItem( artist ) || trimmedArtists.contains( artist ) ) continue; @@ -167,7 +167,7 @@ AlbumModel::addArtists( const QList& artists ) } } - if ( !trimmedArtists.count() ) + if ( trimmedArtists.isEmpty() ) { emit itemCountChanged( rowCount( QModelIndex() ) ); return; diff --git a/src/libtomahawk/playlist/ColumnView.cpp b/src/libtomahawk/playlist/ColumnView.cpp index b2c685ea9..0fd3fa010 100644 --- a/src/libtomahawk/playlist/ColumnView.cpp +++ b/src/libtomahawk/playlist/ColumnView.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2014, Teo Mrnjavac * * Tomahawk is free software: you can redistribute it and/or modify @@ -283,7 +283,7 @@ ColumnView::wheelEvent( QWheelEvent* event ) void ColumnView::onFilterChangeFinished() { - if ( selectedIndexes().count() ) + if ( !selectedIndexes().isEmpty() ) scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter ); if ( !proxyModel()->filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() ) diff --git a/src/libtomahawk/playlist/GridView.cpp b/src/libtomahawk/playlist/GridView.cpp index e9b621b04..579d87ad8 100644 --- a/src/libtomahawk/playlist/GridView.cpp +++ b/src/libtomahawk/playlist/GridView.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2011, Jeff Mitchell * * Tomahawk is free software: you can redistribute it and/or modify @@ -365,7 +365,7 @@ GridView::onDelegateStopped( const QPersistentModelIndex& index ) void GridView::onFilterChanged( const QString& ) { - if ( selectedIndexes().count() ) + if ( !selectedIndexes().isEmpty() ) scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter ); onViewChanged(); diff --git a/src/libtomahawk/playlist/PlayableModel.cpp b/src/libtomahawk/playlist/PlayableModel.cpp index 732aad5c2..4a2494dd0 100644 --- a/src/libtomahawk/playlist/PlayableModel.cpp +++ b/src/libtomahawk/playlist/PlayableModel.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2011 Leo Franchi * Copyright 2010-2011, Jeff Mitchell * @@ -666,7 +666,7 @@ void PlayableModel::insertInternal( const QList< T >& items, int row, const QList< Tomahawk::PlaybackLog >& logs, const QModelIndex& parent ) { Q_D( PlayableModel ); - if ( !items.count() ) + if ( items.isEmpty() ) { emit itemCountChanged( rowCount( QModelIndex() ) ); diff --git a/src/libtomahawk/playlist/PlaylistModel.cpp b/src/libtomahawk/playlist/PlaylistModel.cpp index 983e9890e..f315c4ecd 100644 --- a/src/libtomahawk/playlist/PlaylistModel.cpp +++ b/src/libtomahawk/playlist/PlaylistModel.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2010-2012, Leo Franchi * @@ -268,7 +268,7 @@ void PlaylistModel::insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int row, const QModelIndex& parent, const QList< Tomahawk::PlaybackLog >& logs ) { Q_D( PlaylistModel ); - if ( !entries.count() ) + if ( entries.isEmpty() ) { emit itemCountChanged( rowCount( QModelIndex() ) ); finishLoading(); @@ -456,7 +456,7 @@ PlaylistModel::parsedDroppedTracks( QList< query_ptr > tracks ) else beginRow = rowCount( QModelIndex() ); - if ( tracks.count() ) + if ( !tracks.isEmpty() ) { bool update = ( d->dropStorage.action & Qt::CopyAction || d->dropStorage.action & Qt::MoveAction ); if ( update ) diff --git a/src/libtomahawk/playlist/TrackView.cpp b/src/libtomahawk/playlist/TrackView.cpp index 0e1088092..196bf7e79 100644 --- a/src/libtomahawk/playlist/TrackView.cpp +++ b/src/libtomahawk/playlist/TrackView.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * * Tomahawk is free software: you can redistribute it and/or modify @@ -682,7 +682,7 @@ TrackView::wheelEvent( QWheelEvent* event ) void TrackView::onFilterChanged( const QString& ) { - if ( selectedIndexes().count() ) + if ( !selectedIndexes().isEmpty() ) scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter ); if ( !filter().isEmpty() && !proxyModel()->playlistInterface()->trackCount() && model()->trackCount() ) @@ -912,7 +912,7 @@ TrackView::expand( const QPersistentModelIndex& idx ) void TrackView::select( const QPersistentModelIndex& idx ) { - if ( selectedIndexes().count() ) + if ( !selectedIndexes().isEmpty() ) return; // selectionModel()->select( idx, QItemSelectionModel::SelectCurrent ); @@ -925,7 +925,7 @@ TrackView::selectFirstTrack() { if ( !m_proxyModel->rowCount() ) return; - if ( selectedIndexes().count() ) + if ( !selectedIndexes().isEmpty() ) return; QModelIndex idx = m_proxyModel->index( 0, 0, QModelIndex() ); diff --git a/src/libtomahawk/playlist/TreeModel.cpp b/src/libtomahawk/playlist/TreeModel.cpp index 397af44a9..1484dc70b 100644 --- a/src/libtomahawk/playlist/TreeModel.cpp +++ b/src/libtomahawk/playlist/TreeModel.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2011, Jeff Mitchell * Copyright 2012, Leo Franchi * Copyright 2013, Teo Mrnjavac @@ -182,7 +182,7 @@ void TreeModel::addAlbums( const QModelIndex& parent, const QList& albums ) { finishLoading(); - if ( !albums.count() ) + if ( albums.isEmpty() ) return; PlayableItem* parentItem = itemFromIndex( parent ); @@ -291,7 +291,7 @@ TreeModel::onTracksAdded( const QList& tracks, const QModel { finishLoading(); - if ( !tracks.count() ) + if ( tracks.isEmpty() ) return; PlayableItem* parentItem = itemFromIndex( parent ); diff --git a/src/libtomahawk/playlist/ViewHeader.cpp b/src/libtomahawk/playlist/ViewHeader.cpp index 1693a24ec..59b93cfef 100644 --- a/src/libtomahawk/playlist/ViewHeader.cpp +++ b/src/libtomahawk/playlist/ViewHeader.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/libtomahawk/playlist/dynamic/database/DatabaseGenerator.cpp b/src/libtomahawk/playlist/dynamic/database/DatabaseGenerator.cpp index 28ed50be0..b5f28f274 100644 --- a/src/libtomahawk/playlist/dynamic/database/DatabaseGenerator.cpp +++ b/src/libtomahawk/playlist/dynamic/database/DatabaseGenerator.cpp @@ -177,7 +177,7 @@ DatabaseGenerator::fetchNext( int /* rating */ ) QString DatabaseGenerator::sentenceSummary() { - if( m_controls.count() && m_controls.first()->type() == "SQL" ) + if ( !m_controls.isEmpty() && m_controls.first()->type() == "SQL" ) return m_controls.first()->summary(); // TODO diff --git a/src/libtomahawk/widgets/BreadcrumbButton.cpp b/src/libtomahawk/widgets/BreadcrumbButton.cpp index 774649d0f..4df316aae 100644 --- a/src/libtomahawk/widgets/BreadcrumbButton.cpp +++ b/src/libtomahawk/widgets/BreadcrumbButton.cpp @@ -143,7 +143,7 @@ BreadcrumbButton::setParentIndex( const QModelIndex& idx ) } } - if ( m_combo->count() && list.count() ) + if ( m_combo->count() && !list.isEmpty() ) { // Check if it's the same, Don't change if it is, as it'll cause flickering QStringList old; diff --git a/src/tomahawk/sourcetree/SourcesProxyModel.cpp b/src/tomahawk/sourcetree/SourcesProxyModel.cpp index 541a6afbb..b93a9c38d 100644 --- a/src/tomahawk/sourcetree/SourcesProxyModel.cpp +++ b/src/tomahawk/sourcetree/SourcesProxyModel.cpp @@ -1,7 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2011, Leo Franchi - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * * Tomahawk is free software: you can redistribute it and/or modify @@ -65,7 +65,7 @@ SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePar // always filter empty top-level groups SourceTreeItem* item = m_model->data( sourceModel()->index( sourceRow, 0, sourceParent ), SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >(); - if ( item && item->type() != SourcesModel::Divider && item->parent()->parent() == 0 && !item->children().count() ) + if ( item && item->type() != SourcesModel::Divider && item->parent()->parent() == 0 && item->children().isEmpty() ) return false; if ( !m_filtered ) diff --git a/src/tomahawk/sourcetree/items/PlaylistItems.cpp b/src/tomahawk/sourcetree/items/PlaylistItems.cpp index d68d404c4..9f3209d63 100644 --- a/src/tomahawk/sourcetree/items/PlaylistItems.cpp +++ b/src/tomahawk/sourcetree/items/PlaylistItems.cpp @@ -1,7 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2012, Leo Franchi - * Copyright 2010-2014, Christian Muehlhaeuser + * Copyright 2010-2015, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -265,9 +265,9 @@ PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action ) void PlaylistItem::parsedDroppedTracks( const QList< query_ptr >& tracks ) { - if ( tracks.count() && m_playlist && m_playlist->author()->isLocal() ) + if ( !tracks.isEmpty() && m_playlist && m_playlist->author()->isLocal() ) { - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding" << tracks.count() << "tracks on playlist:" << m_playlist->title() << m_playlist->guid() << m_playlist->currentrevision(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding" << tracks.count() << "tracks to playlist:" << m_playlist->title() << m_playlist->guid() << m_playlist->currentrevision(); m_playlist->addEntries( tracks ); } diff --git a/src/tomahawk/sourcetree/items/QueueItem.cpp b/src/tomahawk/sourcetree/items/QueueItem.cpp index 90d3848ac..acecf3b37 100644 --- a/src/tomahawk/sourcetree/items/QueueItem.cpp +++ b/src/tomahawk/sourcetree/items/QueueItem.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2014, Christian Muehlhaeuser + * Copyright 2014-2015, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -169,7 +169,7 @@ QueueItem::dropMimeData( const QMimeData* data, Qt::DropAction action ) void QueueItem::parsedDroppedTracks( const QList< Tomahawk::query_ptr >& tracks ) { - if ( tracks.count() ) + if ( !tracks.isEmpty() ) { ViewManager::instance()->queue()->view()->trackView()->model()->appendQueries( tracks ); }