Show marked files in file list bold

This commit is contained in:
2022-06-04 15:59:51 +02:00
parent dbb533176c
commit c8a70d22f8
3 changed files with 31 additions and 3 deletions
+19 -1
View File
@@ -3,6 +3,7 @@
#include <QDir>
#include "loadrunable.h"
#include "rawimage.h"
#include "database.h"
using namespace std;
@@ -97,9 +98,10 @@ void Image::thumbnailLoadFinish(void *rawImage)
emit thumbnailLoaded(this);
}
ImageRingList::ImageRingList(QObject *parent) : QAbstractItemModel(parent)
ImageRingList::ImageRingList(Database *database, QObject *parent) : QAbstractItemModel(parent)
, m_liveMode(false)
, m_analyzeLevel(None)
, m_database(database)
{
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
m_thumbPool = new QThreadPool(this);
@@ -273,6 +275,15 @@ QStringList ImageRingList::imageNames() const
return ret;
}
void ImageRingList::updateMark()
{
if(m_images.size())
{
QModelIndex idx = index(m_currImage - m_images.begin(), 0);
emit dataChanged(idx, idx, {Qt::FontRole});
}
}
QModelIndex ImageRingList::index(int row, int column, const QModelIndex &parent) const
{
return createIndex(row, column, m_images.at(row).get());
@@ -305,6 +316,13 @@ QVariant ImageRingList::data(const QModelIndex &index, int role) const
QFileInfo info(m_images.at(index.row())->name());
return info.fileName();
}
case Qt::FontRole:
{
bool marked = m_database->isMarked(m_images.at(index.row())->name());
QFont font;
font.setBold(marked);
return font;
}
default:
return QVariant();
}
+5 -1
View File
@@ -45,6 +45,8 @@ protected slots:
typedef std::shared_ptr<Image> ImagePtr;
class Database;
class ImageRingList : public QAbstractItemModel
{
Q_OBJECT
@@ -57,8 +59,9 @@ class ImageRingList : public QAbstractItemModel
bool m_liveMode;
AnalyzeLevel m_analyzeLevel;
QThreadPool *m_thumbPool;
Database *m_database;
public:
explicit ImageRingList(QObject *parent = 0);
explicit ImageRingList(Database *database, QObject *parent = 0);
~ImageRingList() override;
bool setDir(const QString path, const QString &currentFile = QString());
void setFile(const QString &file);
@@ -75,6 +78,7 @@ public:
void stopLoading();
int imageCount() const;
QStringList imageNames() const;
void updateMark();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;
+7 -1
View File
@@ -55,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
connect(m_stretchPanel, &StretchToolbar::invert, m_imageGL->imageWidget(), &ImageWidget::invert);
connect(m_stretchPanel, &StretchToolbar::superPixel, m_imageGL->imageWidget(), &ImageWidget::superPixel);
m_ringList = new ImageRingList(this);
m_ringList = new ImageRingList(m_database, this);
m_filesystem = new FilesystemWidget(m_ringList, this);
connect(m_filesystem, SIGNAL(fileSelected(int)), this, SLOT(loadFile(int)));
@@ -437,7 +437,10 @@ void MainWindow::markImage()
{
QString file = ptr->name();
if(!file.isEmpty())
{
m_database->mark(file);
m_ringList->updateMark();
}
updateWindowTitle();
}
@@ -450,7 +453,10 @@ void MainWindow::unmarkImage()
{
QString file = ptr->name();
if(!file.isEmpty())
{
m_database->unmark(file);
m_ringList->updateMark();
}
updateWindowTitle();
}