Add loading sub images

This commit is contained in:
2025-03-23 13:32:35 +01:00
parent 45c368bbbb
commit 0047607c1d
10 changed files with 115 additions and 35 deletions
+43 -12
View File
@@ -23,13 +23,16 @@ Image::Image(const QString name, int number, ImageRingList *ringList) :
{
}
void Image::load(QThreadPool *pool)
void Image::load(int index, QThreadPool *pool)
{
if(index != m_info.index && !m_loading)
m_rawImage.reset();
if(!m_rawImage && !m_loading)
{
m_loading = true;
m_released = false;
pool->start(new LoadRunable(m_name, this, m_ringList->analyzeLevel()));
pool->start(new LoadRunable(m_name, this, m_ringList->analyzeLevel(), index));
}
if(!m_loading && m_rawImage)
emit pixmapLoaded(this);
@@ -38,7 +41,7 @@ void Image::load(QThreadPool *pool)
void Image::loadThumbnail(QThreadPool *pool)
{
if(!m_thumbnail)
pool->start(new LoadRunable(m_name, this, AnalyzeLevel::None, true));
pool->start(new LoadRunable(m_name, this, AnalyzeLevel::None, 0, true));
else
emit thumbnailLoaded(this);
}
@@ -230,9 +233,9 @@ void ImageRingList::increment()
(*m_firstImage)->release();
m_firstImage = increment(m_firstImage);
m_currImage = increment(m_currImage);
(*m_currImage)->load(m_loadPool);
(*m_currImage)->load(0, m_loadPool);
m_lastImage = increment(m_lastImage);
(*m_lastImage)->load(m_loadPool);
(*m_lastImage)->load(0, m_loadPool);
}
}
@@ -247,9 +250,37 @@ void ImageRingList::decrement()
(*m_lastImage)->release();
m_firstImage = decrement(m_firstImage);
m_currImage = decrement(m_currImage);
(*m_currImage)->load(m_loadPool);
(*m_currImage)->load(0, m_loadPool);
m_lastImage = decrement(m_lastImage);
(*m_firstImage)->load(m_loadPool);
(*m_firstImage)->load(0, m_loadPool);
}
}
void ImageRingList::prevSubImage()
{
if(m_images.size())
{
if((*m_currImage)->isLoading())
return;
int index = (*m_currImage)->info().index;
int num = (*m_currImage)->info().num;
if(num > 1)
(*m_currImage)->load(index == 1 ? num - 1 : index - 1, m_loadPool);
}
}
void ImageRingList::nextSubImage()
{
if(m_images.size())
{
if((*m_currImage)->isLoading())
return;
int index = (*m_currImage)->info().index;
int num = (*m_currImage)->info().num;
if(num > 1)
(*m_currImage)->load((index + 1) % num, m_loadPool);
}
}
@@ -303,7 +334,7 @@ void ImageRingList::loadFile(int row)
if(m_images.empty())
return;
(*m_currImage)->load(m_loadPool);
(*m_currImage)->load(0, m_loadPool);
m_width = DEFAULT_WIDTH<m_images.size()/2 ? DEFAULT_WIDTH : m_images.size()/2;
if(m_liveMode)
@@ -312,9 +343,9 @@ void ImageRingList::loadFile(int row)
for(int i=0; i<m_width; i++)
{
m_firstImage = decrement(m_firstImage);
(*m_firstImage)->load(m_loadPool);
(*m_firstImage)->load(0, m_loadPool);
m_lastImage = increment(m_lastImage);
(*m_lastImage)->load(m_loadPool);
(*m_lastImage)->load(0, m_loadPool);
}
if(m_lastImage != m_firstImage)
{
@@ -438,9 +469,9 @@ void ImageRingList::setPreload(int width)
for(int i = newWidth - m_width; i>0; i--)
{
m_firstImage = decrement(m_firstImage);
(*m_firstImage)->load(m_loadPool);
(*m_firstImage)->load(0, m_loadPool);
m_lastImage = increment(m_lastImage);
(*m_lastImage)->load(m_loadPool);
(*m_lastImage)->load(0, m_loadPool);
}
}
if(newWidth < m_width)