mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 23:41:51 +02:00
Don't use the slower length/count methods when isEmpty does the job.
This commit is contained in:
parent
89cb984bb4
commit
e51ad04846
@ -337,7 +337,7 @@ DownloadJob::onDownloadProgress( qint64 rcvd, qint64 total )
|
||||
}
|
||||
|
||||
QByteArray data = m_reply->readAll();
|
||||
if ( data.length() == 0 )
|
||||
if ( data.isEmpty() )
|
||||
return;
|
||||
|
||||
if ( m_file->write( data ) < 0 )
|
||||
|
@ -586,7 +586,7 @@ void
|
||||
Playlist::setPlaylistRevisionFinished()
|
||||
{
|
||||
Q_D( Playlist );
|
||||
if ( d->queuedSetPlaylistRevisionCmds.length() > 0 )
|
||||
if ( !d->queuedSetPlaylistRevisionCmds.isEmpty() )
|
||||
{
|
||||
DatabaseCommand_SetPlaylistRevision* cmd = d->queuedSetPlaylistRevisionCmds.dequeue();
|
||||
// Update oldrev to currentRevision so that optimistic locking works correctly.
|
||||
|
@ -398,7 +398,7 @@ Source::addCollection( const collection_ptr& c )
|
||||
{
|
||||
Q_D( Source );
|
||||
|
||||
//Q_ASSERT( m_collections.length() == 0 ); // only 1 source supported atm
|
||||
//Q_ASSERT( m_collections.isEmpty() ); // only 1 source supported atm
|
||||
d->collections.append( c );
|
||||
emit collectionAdded( c );
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
||||
"track.id = file_join.track AND "
|
||||
"file.id = file_join.file AND "
|
||||
"%1" )
|
||||
.arg( trksl.length() > 0 ? trksToken : QString( "0" ) );
|
||||
.arg( !trksl.isEmpty() ? trksToken : QString( "0" ) );
|
||||
|
||||
files_query.prepare( sql );
|
||||
files_query.exec();
|
||||
|
@ -219,7 +219,7 @@ Tomahawk::DatabaseImpl::updateSchema( int oldVersion )
|
||||
foreach ( const QString& sl, statements )
|
||||
{
|
||||
QString s( sl.trimmed() );
|
||||
if ( s.length() == 0 )
|
||||
if ( s.isEmpty() )
|
||||
continue;
|
||||
|
||||
tLog() << "Executing:" << s;
|
||||
|
@ -268,7 +268,7 @@ DBSyncConnection::sendOpsData( QString sinceguid, QString lastguid, QList< dbop_
|
||||
ops.clear();
|
||||
|
||||
m_lastSentOp = lastguid;
|
||||
if ( ops.length() == 0 )
|
||||
if ( ops.isEmpty() )
|
||||
{
|
||||
tLog( LOGVERBOSE ) << "Sending ok" << m_source->id() << m_source->friendlyName();
|
||||
sendMsg( Msg::factory( "ok", Msg::DBOP ) );
|
||||
|
@ -423,7 +423,7 @@ Servent::getLocalSipInfos( const QString& nodeid, const QString& key )
|
||||
info.setNodeId( nodeid );
|
||||
sipInfos.append( info );
|
||||
}
|
||||
if ( d_func()->externalHostname.length() > 0)
|
||||
if ( !d_func()->externalHostname.isEmpty() )
|
||||
{
|
||||
SipInfo info = SipInfo();
|
||||
info.setHost( d_func()->externalHostname );
|
||||
@ -1047,7 +1047,7 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
|
||||
bool
|
||||
Servent::visibleExternally() const
|
||||
{
|
||||
return (!d_func()->externalHostname.isNull()) || (d_func()->externalAddresses.length() > 0);
|
||||
return !d_func()->externalHostname.isNull() || !d_func()->externalAddresses.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -328,7 +328,7 @@ ColumnView::startDrag( Qt::DropActions supportedActions )
|
||||
}
|
||||
}
|
||||
|
||||
if ( indexes.count() == 0 )
|
||||
if ( indexes.isEmpty() )
|
||||
return;
|
||||
|
||||
tDebug( LOGVERBOSE ) << "Dragging" << indexes.count() << "indexes";
|
||||
|
@ -386,7 +386,7 @@ GridView::startDrag( Qt::DropActions supportedActions )
|
||||
}
|
||||
}
|
||||
|
||||
if ( indexes.count() == 0 )
|
||||
if ( indexes.isEmpty() )
|
||||
return;
|
||||
|
||||
qDebug() << "Dragging" << indexes.count() << "indexes";
|
||||
|
@ -719,7 +719,7 @@ TrackView::startDrag( Qt::DropActions supportedActions )
|
||||
}
|
||||
}
|
||||
|
||||
if ( indexes.count() == 0 )
|
||||
if ( indexes.isEmpty() )
|
||||
return;
|
||||
|
||||
tDebug() << "Dragging" << indexes.count() << "indexes";
|
||||
|
@ -507,7 +507,7 @@ JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result )
|
||||
m_pendingAlbum = album;
|
||||
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
||||
SLOT( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ) );
|
||||
if ( album->tracks().count() > 0 )
|
||||
if ( !album->tracks().isEmpty() )
|
||||
{
|
||||
emit m_resolver->informationFound( url, album.objectCast<QObject>() );
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ ScriptCommandQueue::onCommandDone()
|
||||
disconnect( m_timer, SIGNAL( timeout() ),
|
||||
this, SLOT( onTimeout() ) );
|
||||
|
||||
if ( m_queue.count() > 0 )
|
||||
if ( !m_queue.isEmpty() )
|
||||
nextCommand();
|
||||
}
|
||||
|
||||
@ -102,6 +102,6 @@ ScriptCommandQueue::onTimeout()
|
||||
disconnect( m_timer, SIGNAL( timeout() ),
|
||||
this, SLOT( onTimeout() ) );
|
||||
|
||||
if ( m_queue.count() > 0 )
|
||||
if ( !m_queue.isEmpty() )
|
||||
nextCommand();
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ ScriptCommand_AllAlbums::onAlbumsJobDone(const QVariantMap& result)
|
||||
}
|
||||
|
||||
QList< Tomahawk::artist_ptr > resultArtists;
|
||||
if ( result["artists"].toList().length() > 0 )
|
||||
if ( !result["artists"].toList().isEmpty() )
|
||||
{
|
||||
resultArtists = ScriptCommand_AllArtists::parseArtistVariantList( result[ "artists" ].toList() );
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ SearchWidget::updateArtists()
|
||||
|
||||
qSort( floats.begin(), floats.end() );
|
||||
|
||||
while ( floats.count() > 0 )
|
||||
while ( !floats.isEmpty() )
|
||||
{
|
||||
float f = floats.takeLast();
|
||||
foreach ( const artist_ptr& a, artists )
|
||||
@ -469,7 +469,7 @@ SearchWidget::updateAlbums()
|
||||
|
||||
qSort( floats.begin(), floats.end() );
|
||||
|
||||
while ( floats.count() > 0 )
|
||||
while ( !floats.isEmpty() )
|
||||
{
|
||||
float f = floats.takeLast();
|
||||
foreach ( const album_ptr& a, albums )
|
||||
|
@ -125,7 +125,7 @@ Breadcrumb::updateButtons( const QModelIndex& updateFrom )
|
||||
btn->show();
|
||||
|
||||
// Animate all buttons except the first
|
||||
if ( m_buttons.count() > 0 && isVisible() )
|
||||
if ( !m_buttons.isEmpty() && isVisible() )
|
||||
{
|
||||
QPropertyAnimation* animation = new QPropertyAnimation( btn, "pos" );
|
||||
animation->setDuration( 300 );
|
||||
|
@ -257,7 +257,7 @@ QSize
|
||||
AccountsToolButton::sizeHint() const
|
||||
{
|
||||
QSize size = QToolButton::sizeHint();
|
||||
if ( m_factoryPixmaps.count() == 0 ) //no accounts enabled!
|
||||
if ( m_factoryPixmaps.isEmpty() ) //no accounts enabled!
|
||||
return size;
|
||||
|
||||
size.rwidth() *= m_factoryPixmaps.count();
|
||||
|
Loading…
x
Reference in New Issue
Block a user