aboutsummaryrefslogtreecommitdiffstats
path: root/src/threadlistview.h
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-07 16:26:22 +0200
committerDanilo M. <danix@danix.xyz>2026-08-07 16:26:22 +0200
commit39cbde74a560407e24b05e171df883421aa2153e (patch)
treea7390b036f57507b17aa4291511ce33d3f297f81 /src/threadlistview.h
parentde884b036689b253d10ff48daa3a05cca20ba61d (diff)
downloadqtmaildir-39cbde74a560407e24b05e171df883421aa2153e.tar.gz
qtmaildir-39cbde74a560407e24b05e171df883421aa2153e.zip
feat(ui): show each thread's tags under its row
The thread list was uniform and cramped: every row one line tall, with nothing to say what a thread was about before opening it. Rows are now roughly double height, carrying a strip of tag chips beneath the text, with alternating row colours and a star column for flagged threads beside the existing paperclip. The strip is painted by the VIEW rather than by a delegate, which is why ThreadListView exists. A delegate is handed one cell's rectangle and cannot paint outside its column, so a strip drawn from the subject column stops at that column's edge, losing the last tags of a well-tagged thread, and starts at its left edge, putting the chips under the subject instead of under the row. Tags the row already shows another way are left out: inbox as structure, unread as the dimming, flagged as the star, attachment as the paperclip, and the account as the chip in the subject cell. Sorted, since notmuch's order is not guaranteed stable and a row whose chips reordered between repaints would flicker. Six defects were introduced and fixed on the way here, all of them one consequence: a QTableView paints per cell, and a row-wide strip is not a cell. SubjectDelegate installed view-wide drew the account chip into every column, since AccountLabelRole belongs to the row; it is split into RowStyleDelegate for every column and SubjectDelegate for the subject alone, with a Q_ASSERT guarding that. Row height returned from sizeHint did nothing, because a table takes one height per row. The strip painted from x=0 over the marker columns, via a protected viewportMargins() that returns 0. Measuring the text band and the strip with one font put the pills over the date. Alternating colours and the selection are per-cell too, so the band showed bare viewport background until the view filled it, honouring the model's own BackgroundRole first so a deleted row is not cut in half. And that fill spanned the full width, cutting the centred marker glyphs at their midpoint. Closes item 5. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/threadlistview.h')
-rw-r--r--src/threadlistview.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/threadlistview.h b/src/threadlistview.h
new file mode 100644
index 0000000..0b4eafc
--- /dev/null
+++ b/src/threadlistview.h
@@ -0,0 +1,47 @@
+/*
+ * qtmaildir - a Qt6 mail client for notmuch-indexed Maildirs
+ * Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#pragma once
+
+#include <QTableView>
+
+/// The thread list, with a row-wide strip of tag chips under each row's cells.
+///
+/// The strip is painted by the VIEW rather than by a delegate, and that is the
+/// whole reason this class exists. A delegate is handed one cell's rectangle
+/// and cannot paint outside its column, so pills drawn from the subject
+/// column's delegate stop at that column's edge, losing the last tags of a
+/// well-tagged thread, and start at that column's left edge, which puts them
+/// under the subject instead of under the row. Painting after the cells lets
+/// the strip run the full width, which is what the layout asks for:
+///
+/// [ date ][ from ][ subject ...................... ]
+/// [ pill ][ pill ][ pill ]
+///
+/// The cells confine themselves to the upper band so the lower one is free;
+/// SubjectDelegate::kRowPadding and rowHeightFor() are the shared measurements
+/// that keep the two halves agreeing.
+class ThreadListView : public QTableView
+{
+ Q_OBJECT
+public:
+ using QTableView::QTableView;
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+};