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);
|
QDir dir(path);
|
||||||
|
|
||||||
@@ -87,13 +87,13 @@ bool ImageRingList::setDir(const QString path)
|
|||||||
{
|
{
|
||||||
absolutePaths.append(dir.absoluteFilePath(file));
|
absolutePaths.append(dir.absoluteFilePath(file));
|
||||||
}
|
}
|
||||||
setFiles(absolutePaths);
|
setFiles(absolutePaths, currentFile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageRingList::setFiles(const QStringList files)
|
void ImageRingList::setFiles(const QStringList files, const QString ¤tFile)
|
||||||
{
|
{
|
||||||
m_images.clear();
|
m_images.clear();
|
||||||
foreach(const QString &file, files)
|
foreach(const QString &file, files)
|
||||||
@@ -103,7 +103,11 @@ void ImageRingList::setFiles(const QStringList files)
|
|||||||
m_images.append(ptr);
|
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_currImage)->load();
|
||||||
|
|
||||||
m_width = DEFAULT_WIDTH<m_images.size()/2 ? DEFAULT_WIDTH : m_images.size()/2;
|
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()
|
ImagePtr ImageRingList::currentImage()
|
||||||
{
|
{
|
||||||
if(m_images.size())
|
if(m_images.size())
|
||||||
|
|||||||
+3
-2
@@ -38,8 +38,9 @@ class ImageRingList : public QObject
|
|||||||
QList<ImagePtr>::iterator m_lastImage;
|
QList<ImagePtr>::iterator m_lastImage;
|
||||||
public:
|
public:
|
||||||
explicit ImageRingList(QObject *parent = 0);
|
explicit ImageRingList(QObject *parent = 0);
|
||||||
bool setDir(const QString path);
|
bool setDir(const QString path, const QString ¤tFile = QString());
|
||||||
void setFiles(const QStringList files);
|
void setFiles(const QStringList files, const QString ¤tFile = QString());
|
||||||
|
void setFile(const QString &file);
|
||||||
ImagePtr currentImage();
|
ImagePtr currentImage();
|
||||||
void increment();
|
void increment();
|
||||||
void decrement();
|
void decrement();
|
||||||
|
|||||||
+1
-1
@@ -94,7 +94,7 @@ void MainWindow::openFile()
|
|||||||
if(!file.isEmpty())
|
if(!file.isEmpty())
|
||||||
{
|
{
|
||||||
QFileInfo info(file);
|
QFileInfo info(file);
|
||||||
m_ringList->setDir(info.dir().absolutePath());
|
m_ringList->setFile(info.canonicalFilePath());
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user