mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-01-17 14:28:24 +01:00
Reduce variable scopes
This commit is contained in:
parent
46239947f5
commit
69653c4934
@ -235,9 +235,6 @@ Source::friendlyNamesLessThan( const QString& first, const QString& second )
|
||||
favored.append( QRegExp( "\\b([A-Z][a-z']* ?){2,10}" ) ); //properly capitalized person's name
|
||||
favored.append( QRegExp( "[a-zA-Z ']+" ) ); //kind of person's name
|
||||
|
||||
bool matchFirst = false;
|
||||
bool matchSecond = false;
|
||||
|
||||
//We check if the strings match the regexps. The regexps represent friendly name patterns we do
|
||||
//*not* want (penalties) or want (favored), prioritized. If none of the strings match a regexp,
|
||||
//we go to the next regexp. If one of the strings matches, and we're matching penalties, we say
|
||||
@ -261,8 +258,8 @@ Source::friendlyNamesLessThan( const QString& first, const QString& second )
|
||||
isPenalty = false;
|
||||
}
|
||||
|
||||
matchFirst = rx.exactMatch( first );
|
||||
matchSecond = rx.exactMatch( second );
|
||||
bool matchFirst = rx.exactMatch( first );
|
||||
bool matchSecond = rx.exactMatch( second );
|
||||
|
||||
if ( matchFirst == false && matchSecond == false )
|
||||
continue;
|
||||
|
@ -144,10 +144,9 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
|
||||
|
||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
||||
|
||||
PlayableItem* albumitem;
|
||||
foreach( const album_ptr& album, trimmedAlbums )
|
||||
{
|
||||
albumitem = new PlayableItem( album, rootItem() );
|
||||
PlayableItem* albumitem = new PlayableItem( album, rootItem() );
|
||||
albumitem->index = createIndex( rootItem()->children.count() - 1, 0, albumitem );
|
||||
|
||||
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
@ -190,10 +189,9 @@ AlbumModel::addArtists( const QList<Tomahawk::artist_ptr>& artists )
|
||||
|
||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
||||
|
||||
PlayableItem* albumitem;
|
||||
foreach ( const artist_ptr& artist, trimmedArtists )
|
||||
{
|
||||
albumitem = new PlayableItem( artist, rootItem() );
|
||||
PlayableItem* albumitem = new PlayableItem( artist, rootItem() );
|
||||
albumitem->index = createIndex( rootItem()->children.count() - 1, 0, albumitem );
|
||||
|
||||
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
@ -219,10 +217,9 @@ AlbumModel::addQueries( const QList<Tomahawk::query_ptr>& queries )
|
||||
|
||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
||||
|
||||
PlayableItem* albumitem;
|
||||
foreach ( const query_ptr& query, queries )
|
||||
{
|
||||
albumitem = new PlayableItem( query, rootItem() );
|
||||
PlayableItem* albumitem = new PlayableItem( query, rootItem() );
|
||||
albumitem->index = createIndex( rootItem()->children.count() - 1, 0, albumitem );
|
||||
|
||||
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
|
@ -679,11 +679,10 @@ PlayableModel::insertInternal( const QList< T >& items, int row, const QList< To
|
||||
emit beginInsertRows( parent, crows.first, crows.second );
|
||||
|
||||
int i = 0;
|
||||
PlayableItem* plitem;
|
||||
foreach ( const T& item, items )
|
||||
{
|
||||
PlayableItem* pItem = itemFromIndex( parent );
|
||||
plitem = new PlayableItem( item, pItem, row + i );
|
||||
PlayableItem* plitem = new PlayableItem( item, pItem, row + i );
|
||||
plitem->index = createIndex( row + i, 0, plitem );
|
||||
|
||||
if ( plitem->query() )
|
||||
|
@ -290,11 +290,10 @@ PlaylistModel::insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int
|
||||
|
||||
QList< Tomahawk::query_ptr > queries;
|
||||
int i = 0;
|
||||
PlayableItem* plitem;
|
||||
foreach( const plentry_ptr& entry, entries )
|
||||
{
|
||||
PlayableItem* pItem = itemFromIndex( parent );
|
||||
plitem = new PlayableItem( entry, pItem, row + i );
|
||||
PlayableItem* plitem = new PlayableItem( entry, pItem, row + i );
|
||||
plitem->index = createIndex( row + i, 0, plitem );
|
||||
|
||||
if ( logs.count() > i )
|
||||
|
@ -193,10 +193,9 @@ TreeModel::addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr
|
||||
|
||||
emit beginInsertRows( parent, crows.first, crows.second );
|
||||
|
||||
PlayableItem* albumitem = 0;
|
||||
foreach( const album_ptr& album, albums )
|
||||
{
|
||||
albumitem = new PlayableItem( album, parentItem );
|
||||
PlayableItem* albumitem = new PlayableItem( album, parentItem );
|
||||
albumitem->index = createIndex( parentItem->children.count() - 1, 0, albumitem );
|
||||
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
|
||||
@ -283,10 +282,9 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
|
||||
|
||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
||||
|
||||
PlayableItem* artistitem;
|
||||
foreach( const artist_ptr& artist, artists )
|
||||
{
|
||||
artistitem = new PlayableItem( artist, rootItem() );
|
||||
PlayableItem* artistitem = new PlayableItem( artist, rootItem() );
|
||||
artistitem->index = createIndex( rootItem()->children.count() - 1, 0, artistitem );
|
||||
connect( artistitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
}
|
||||
@ -312,10 +310,9 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModel
|
||||
|
||||
emit beginInsertRows( parent, crows.first, crows.second );
|
||||
|
||||
PlayableItem* item = 0;
|
||||
foreach( const query_ptr& query, tracks )
|
||||
{
|
||||
item = new PlayableItem( query, parentItem );
|
||||
PlayableItem* item = new PlayableItem( query, parentItem );
|
||||
item->index = createIndex( parentItem->children.count() - 1, 0, item );
|
||||
|
||||
connect( item, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
|
@ -846,12 +846,11 @@ JSResolver::loadCollections()
|
||||
|
||||
if ( collectionInfo.contains( "iconfile" ) )
|
||||
{
|
||||
bool ok = false;
|
||||
QString iconPath = QFileInfo( filePath() ).path() + "/"
|
||||
+ collectionInfo.value( "iconfile" ).toString();
|
||||
|
||||
QPixmap iconPixmap;
|
||||
ok = iconPixmap.load( iconPath );
|
||||
bool ok = iconPixmap.load( iconPath );
|
||||
if ( ok && !iconPixmap.isNull() )
|
||||
sc->setIcon( QIcon( iconPixmap ) );
|
||||
}
|
||||
|
@ -74,7 +74,6 @@ ScriptEngine::sslErrorHandler( QNetworkReply* qnr, const QList<QSslError>& errli
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
||||
QByteArray digest = errlist.first().certificate().digest();
|
||||
int result = -1;
|
||||
|
||||
if ( !TomahawkSettings::instance()->isSslCertKnown( digest ) )
|
||||
{
|
||||
@ -92,7 +91,7 @@ ScriptEngine::sslErrorHandler( QNetworkReply* qnr, const QList<QSslError>& errli
|
||||
question.setStandardButtons( QMessageBox::No );
|
||||
question.addButton( tr( "Trust certificate" ), QMessageBox::AcceptRole );
|
||||
|
||||
result = question.exec();
|
||||
int result = question.exec();
|
||||
|
||||
//FIXME: discuss whether we want to store rejects, too (needs settings management to remove the decision?)
|
||||
if ( result == QMessageBox::AcceptRole )
|
||||
|
Loading…
x
Reference in New Issue
Block a user