Compare commits

...

2 Commits

Author SHA1 Message Date
nou 3448f62f31 Try to fix crash in ImageRingList 2026-01-19 20:57:13 +01:00
nou 567e66acb5 Update libXISF 2025-11-02 23:17:10 +01:00
3 changed files with 29 additions and 25 deletions
+1 -1
Submodule libXISF updated: 2e74d94641...7b70b6a081
+24 -20
View File
@@ -111,7 +111,7 @@ void Image::thumbnailLoadFinish(std::shared_ptr<RawImage> rawImage)
emit thumbnailLoaded(this); emit thumbnailLoaded(this);
} }
ImageRingList::ImageRingList(Database *database, const QStringList &nameFilter, QObject *parent) : QAbstractItemModel(parent) ImageRingList::ImageRingList(Database *database, const QStringList &nameFilter, QObject *parent) : QAbstractListModel(parent)
, m_liveMode(false) , m_liveMode(false)
, m_analyzeLevel(None) , m_analyzeLevel(None)
, m_database(database) , m_database(database)
@@ -412,7 +412,7 @@ void ImageRingList::clearThumbnails()
img->clearThumbnail(); img->clearThumbnail();
} }
QModelIndex ImageRingList::index(int row, int column, const QModelIndex &parent) const /*QModelIndex ImageRingList::index(int row, int column, const QModelIndex &parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
return createIndex(row, column, m_images.at(row).get()); return createIndex(row, column, m_images.at(row).get());
@@ -422,7 +422,7 @@ QModelIndex ImageRingList::parent(const QModelIndex &child) const
{ {
Q_UNUSED(child); Q_UNUSED(child);
return QModelIndex(); return QModelIndex();
} }*/
int ImageRingList::rowCount(const QModelIndex &parent) const int ImageRingList::rowCount(const QModelIndex &parent) const
{ {
@@ -432,31 +432,35 @@ int ImageRingList::rowCount(const QModelIndex &parent) const
return 0; return 0;
} }
int ImageRingList::columnCount(const QModelIndex &parent) const /*int ImageRingList::columnCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
return 1; return 1;
} }*/
QVariant ImageRingList::data(const QModelIndex &index, int role) const QVariant ImageRingList::data(const QModelIndex &index, int role) const
{ {
switch(role) if(index.isValid() && index.row() >= 0 && index.row() < m_images.size())
{ {
case Qt::DisplayRole: switch(role)
{ {
QFileInfo info(m_images.at(index.row())->name()); case Qt::DisplayRole:
return info.fileName(); {
} QFileInfo info(m_images.at(index.row())->name());
case Qt::FontRole: return info.fileName();
{ }
bool marked = m_database->isMarked(m_images.at(index.row())->name()); case Qt::FontRole:
QFont font; {
font.setBold(marked); bool marked = m_database->isMarked(m_images.at(index.row())->name());
return font; QFont font;
} font.setBold(marked);
default: return font;
return QVariant(); }
default:
return QVariant();
}
} }
return QVariant();
} }
QVariant ImageRingList::headerData(int section, Qt::Orientation orientation, int role) const QVariant ImageRingList::headerData(int section, Qt::Orientation orientation, int role) const
+4 -4
View File
@@ -51,7 +51,7 @@ typedef std::shared_ptr<Image> ImagePtr;
class Database; class Database;
class ImageRingList : public QAbstractItemModel class ImageRingList : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
int m_width; int m_width;
@@ -93,10 +93,10 @@ public:
void updateMark(); void updateMark();
void clearThumbnails(); void clearThumbnails();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; //QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override; //QModelIndex parent(const QModelIndex &child) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; //int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
public slots: public slots: