diff options
Diffstat (limited to 'src/threadlistmodel.h')
| -rw-r--r-- | src/threadlistmodel.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/threadlistmodel.h b/src/threadlistmodel.h index eb1a7ff..7ed8fef 100644 --- a/src/threadlistmodel.h +++ b/src/threadlistmodel.h @@ -19,8 +19,10 @@ #pragma once #include <QAbstractTableModel> +#include <QColor> #include <QVector> +#include "tagcolors.h" #include "types.h" /// Table model over query results, filled in batches so a large query paints @@ -29,11 +31,14 @@ class ThreadListModel : public QAbstractTableModel { Q_OBJECT public: + /// No tags column: spelling out a dozen tags per row cost most of the + /// list's width and was unreadable. Functional tags moved to a chip strip + /// under the message pane, and the account tag renders as a chip in front + /// of the subject. enum Column { DateColumn = 0, AuthorsColumn, SubjectColumn, - TagsColumn, ColumnCount, }; @@ -42,10 +47,32 @@ public: /// worker speaks thread ids, so the mapping belongs on the model /// rather than in every caller. ThreadIdRole = Qt::UserRole + 1, + + /// The account tag on this thread without its "account-" prefix, for + /// the chip drawn in front of the subject. Empty when the thread + /// carries none. + AccountLabelRole, + + /// Fill colour for that chip. + AccountColourRole, + + /// Every tag on the thread, for the strip under the message pane. + TagsRole, }; + /// Row fill for a thread tagged `deleted`, and for one tagged `spam`. + /// Muted rather than saturated: a bulk delete paints every selected row, + /// and a wall of pure red is harder to read than the list it replaces. + /// Exposed so a test names the same colour the model uses. + static QColor deletedColour(); + static QColor spamColour(); + explicit ThreadListModel(QObject *parent = nullptr); + /// Supplies the account chip colours. Not owned; must outlive the model. + /// Without one, chips fall back to a colour generated from the tag name. + void setTagColors(const TagColors *colours) { m_tagColors = colours; } + int rowCount(const QModelIndex &parent = {}) const override; int columnCount(const QModelIndex &parent = {}) const override; QVariant data(const QModelIndex &index, int role) const override; @@ -65,4 +92,5 @@ public: private: QVector<ThreadSummary> m_threads; + const TagColors *m_tagColors = nullptr; }; |
