From 0dacb5c4c61818088efb5bf513f15d2b715491e3 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 3 Aug 2026 15:41:16 +0200 Subject: feat: render tags as chips instead of a text column Spelled out per row, tags ran to 500 pixels of largely repeated text and took most of the thread list's width. The column is gone; tags render as coloured chips split by what they actually mean. An account tag says which mailbox a thread arrived in, and draws as a chip in front of the subject. A functional tag says what state a thread is in, and those fill one row under the message pane. One row keeps the message area from shifting between threads with different tag counts, so whatever does not fit collapses into a +N chip that names the rest in its tooltip. TagColors resolves a colour by exact tag first, then by top-level prefix, so a single "shopping" entry covers shopping/amazon and shopping/nike while shopping/amazon can still override its own. That matters at 96 tags. Built-in defaults cover the usual state tags, and anything left unconfigured falls back to a hash of the name, stable so a chip does not change colour as the list scrolls. --- src/threadlistmodel.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/threadlistmodel.h') diff --git a/src/threadlistmodel.h b/src/threadlistmodel.h index 01fd241..7ed8fef 100644 --- a/src/threadlistmodel.h +++ b/src/threadlistmodel.h @@ -22,6 +22,7 @@ #include #include +#include "tagcolors.h" #include "types.h" /// Table model over query results, filled in batches so a large query paints @@ -30,12 +31,12 @@ class ThreadListModel : public QAbstractTableModel { Q_OBJECT public: - /// Subject stretches to fill the view, so it must come last: anything - /// after it is pushed out of sight. Tags leads, being the column that - /// changes when the user acts on a thread. + /// 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 { - TagsColumn = 0, - DateColumn, + DateColumn = 0, AuthorsColumn, SubjectColumn, ColumnCount, @@ -46,6 +47,17 @@ 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`. @@ -57,6 +69,10 @@ public: 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; @@ -76,4 +92,5 @@ public: private: QVector m_threads; + const TagColors *m_tagColors = nullptr; }; -- cgit v1.2.3