Skip to content

Commit

Permalink
Make sure index cache is updated and used.
Browse files Browse the repository at this point in the history
  • Loading branch information
astifter committed Dec 11, 2015
1 parent 1882b2e commit fef00a2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions ThumbnailView/ThumbnailModel.cpp
Expand Up @@ -174,13 +174,22 @@ void ThumbnailView::ThumbnailModel::imagesDeletedFromDB( const DB::FileNameList&
}


int ThumbnailView::ThumbnailModel::indexOf(const DB::FileName& fileName)
{
Q_ASSERT( !fileName.isNull() );
if ( !m_fileNameToIndex.contains(fileName) )
m_fileNameToIndex.insert(fileName, m_displayList.indexOf(fileName));

return m_fileNameToIndex[fileName];
}

int ThumbnailView::ThumbnailModel::indexOf(const DB::FileName& fileName) const
{
Q_ASSERT( !fileName.isNull() );
if ( !m_fileNameToIndex.contains(fileName))
if ( !m_fileNameToIndex.contains(fileName) )
return -1;
else
return m_fileNameToIndex[fileName];

return m_fileNameToIndex[fileName];
}

void ThumbnailView::ThumbnailModel::updateIndexCache()
Expand Down Expand Up @@ -282,8 +291,9 @@ void ThumbnailView::ThumbnailModel::requestThumbnail( const DB::FileName& fileNa
// request the thumbnail in the size that is set in the settings, not in the current grid size:
const QSize cellSize = cellGeometryInfo()->baseIconSize();
const int angle = imageInfo->angle();
const int row = indexOf(fileName);
ThumbnailRequest* request
= new ThumbnailRequest( m_displayList.indexOf(fileName), fileName, cellSize, angle, this );
= new ThumbnailRequest( row, fileName, cellSize, angle, this );
request->setPriority( priority );
ImageManager::AsyncLoader::instance()->load( request );
}
Expand Down Expand Up @@ -311,12 +321,6 @@ void ThumbnailView::ThumbnailModel::reset()
QAbstractItemModel::reset();
}

int ThumbnailView::ThumbnailModel::indexOf(const DB::FileName& fileName)
{
return m_displayList.indexOf(fileName);
}


QString ThumbnailView::ThumbnailModel::thumbnailText( const QModelIndex& index ) const
{
const DB::FileName fileName = imageAt( index.row() );
Expand Down

0 comments on commit fef00a2

Please sign in to comment.