From 94d4fe762c7311dc0c90615159ec9bc3917f5a19 Mon Sep 17 00:00:00 2001 From: Agel Date: Mon, 20 Apr 2026 11:54:57 +0200 Subject: [PATCH] Add format text to history view --- src/backend/HistoryBookModel.cpp | 5 +++++ src/backend/HistoryBookModel.h | 2 ++ src/backend/HistoryModel.cpp | 3 +++ src/backend/HistoryModel.h | 1 + src/qml/pages/HistoryPage.qml | 9 +++++++++ 5 files changed, 20 insertions(+) diff --git a/src/backend/HistoryBookModel.cpp b/src/backend/HistoryBookModel.cpp index e8fe43c..ce16986 100644 --- a/src/backend/HistoryBookModel.cpp +++ b/src/backend/HistoryBookModel.cpp @@ -70,6 +70,11 @@ QString HistoryBookModel::author() const return m_author; } +QString HistoryBookModel::format() const +{ + return m_filePath.section('.', -1).toUpper(); +} + QString HistoryBookModel::coverImageUrl() const { return m_coverImageUrl; diff --git a/src/backend/HistoryBookModel.h b/src/backend/HistoryBookModel.h index c1e9d2e..671e2a0 100644 --- a/src/backend/HistoryBookModel.h +++ b/src/backend/HistoryBookModel.h @@ -17,6 +17,7 @@ class HistoryBookModel : public QObject { Q_PROPERTY(QString lastOpened READ lastOpened WRITE setLastOpened NOTIFY lastOpenedChanged) Q_PROPERTY(QString title READ title NOTIFY metadataLoaded) Q_PROPERTY(QString author READ author NOTIFY metadataLoaded) + Q_PROPERTY(QString format READ format NOTIFY metadataLoaded) Q_PROPERTY(QString coverImageUrl READ coverImageUrl NOTIFY coverImageLoaded) public: @@ -33,6 +34,7 @@ public: QString title() const; QString author() const; + QString format() const; QString coverImageUrl() const; void loadMetadata(); diff --git a/src/backend/HistoryModel.cpp b/src/backend/HistoryModel.cpp index 2d66bec..8caa22f 100644 --- a/src/backend/HistoryModel.cpp +++ b/src/backend/HistoryModel.cpp @@ -10,6 +10,7 @@ HistoryModel::HistoryModel(ReaderFactory &factory, QObject *parent) m_roleNames[FilePathRole] = "filePath"; m_roleNames[TitleRole] = "title"; m_roleNames[AuthorRole] = "author"; + m_roleNames[FormatRole] = "format"; m_roleNames[ProgressRole] = "progress"; m_roleNames[LastOpenedRole] = "lastOpened"; m_roleNames[CoverImageUrlRole] = "coverImageUrl"; @@ -43,6 +44,8 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const return book->title(); case AuthorRole: return book->author(); + case FormatRole: + return book->format(); case ProgressRole: return book->progress(); case LastOpenedRole: diff --git a/src/backend/HistoryModel.h b/src/backend/HistoryModel.h index 9b927df..b666215 100644 --- a/src/backend/HistoryModel.h +++ b/src/backend/HistoryModel.h @@ -19,6 +19,7 @@ public: FilePathRole = Qt::UserRole + 1, TitleRole, AuthorRole, + FormatRole, ProgressRole, LastOpenedRole, CoverImageUrlRole diff --git a/src/qml/pages/HistoryPage.qml b/src/qml/pages/HistoryPage.qml index ddc2163..eca458a 100644 --- a/src/qml/pages/HistoryPage.qml +++ b/src/qml/pages/HistoryPage.qml @@ -76,6 +76,15 @@ Rectangle { elide: Text.ElideRight } + Text { + visible: format !== "" + width: parent.width + text: format + color: ThemeManager.currentTheme.dimText + font.pixelSize: 12 + elide: Text.ElideRight + } + Text { visible: author !== "" width: parent.width