Add ImageRingList::setFile()
This commit is contained in:
+14
-4
@@ -72,7 +72,7 @@ ImageRingList::ImageRingList(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool ImageRingList::setDir(const QString path)
|
||||
bool ImageRingList::setDir(const QString path, const QString ¤tFile)
|
||||
{
|
||||
QDir dir(path);
|
||||
|
||||
@@ -87,13 +87,13 @@ bool ImageRingList::setDir(const QString path)
|
||||
{
|
||||
absolutePaths.append(dir.absoluteFilePath(file));
|
||||
}
|
||||
setFiles(absolutePaths);
|
||||
setFiles(absolutePaths, currentFile);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ImageRingList::setFiles(const QStringList files)
|
||||
void ImageRingList::setFiles(const QStringList files, const QString ¤tFile)
|
||||
{
|
||||
m_images.clear();
|
||||
foreach(const QString &file, files)
|
||||
@@ -103,7 +103,11 @@ void ImageRingList::setFiles(const QStringList files)
|
||||
m_images.append(ptr);
|
||||
}
|
||||
|
||||
m_firstImage = m_currImage = m_lastImage = m_images.begin();
|
||||
int index = files.indexOf(currentFile);
|
||||
if(index < 0)
|
||||
index = 0;
|
||||
|
||||
m_firstImage = m_currImage = m_lastImage = m_images.begin()+index;
|
||||
(*m_currImage)->load();
|
||||
|
||||
m_width = DEFAULT_WIDTH<m_images.size()/2 ? DEFAULT_WIDTH : m_images.size()/2;
|
||||
@@ -117,6 +121,12 @@ void ImageRingList::setFiles(const QStringList files)
|
||||
}
|
||||
}
|
||||
|
||||
void ImageRingList::setFile(const QString &file)
|
||||
{
|
||||
QFileInfo info(file);
|
||||
setDir(info.absolutePath(), file);
|
||||
}
|
||||
|
||||
ImagePtr ImageRingList::currentImage()
|
||||
{
|
||||
if(m_images.size())
|
||||
|
||||
Reference in New Issue
Block a user