From a7872cf56b7f313881f0d5e50d548ffdb5ba68b9 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 13 Aug 2026 20:07:31 +0200 Subject: feat(queries): edit, pin and delete a saved query from the UI Item 82. Saving a query worked and nothing else did: changing one field meant retyping the whole query under the same name, and deleting one meant editing the file by hand. An action that creates something the UI cannot then change or remove is incomplete, and the user hit it within minutes of the first hand test. Right-clicking a saved query, on its button or its menu entry, now offers Edit, Move to menu / Show as a button, and Delete. Every path funnels through one replaceSavedQuery(), which matches on the name the dialog was OPENED with rather than the one it returns, so a rename replaces the entry instead of leaving the original behind beside a new one, and which merges the stored entry's unknown fields in a single place rather than in three. Delete confirms first: the rule against confirmation dialogs covers tag mutations, which the undo stack can take back, and this writes user config that it cannot. Two cases the item did not anticipate. A generated entry has no query to edit, so the dialog shows its composed query read-only rather than offering a field that changes nothing, and carries `generated` and `flat` through an edit rather than letting it decay into a plain entry holding a snapshot of what it resolved to today. And the overwrite notice had to learn to ignore the entry being edited, since warning that "Inbox" already exists while editing Inbox is noise. This also fixes a defect that predated it and was already reachable from the save path. rebuildSavedQueryRow() called deleteLater() on the old row, which defers destruction to the event loop, so the stale row went on answering findChild() and every lookup after a rebuild reported the state from before the edit. Nothing looked wrong on screen, which is why it surfaced only as three tests failing against a row that had in fact been rebuilt correctly. Five tests, three mutations. Matching on the returned name fails two, never writing the file fails three, and dropping the unknown-field merge fails one. That last one initially proved nothing: it drove UNPIN, which copies the stored entry and so carries `unknown` along by itself, and passed with the merge deleted. It now goes through the edit path with a replacement that has none, which is what the dialog actually returns. Co-Authored-By: Claude Opus 5 --- src/savequerydialog.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/savequerydialog.h') diff --git a/src/savequerydialog.h b/src/savequerydialog.h index be5a2af..d859254 100644 --- a/src/savequerydialog.h +++ b/src/savequerydialog.h @@ -42,6 +42,11 @@ public: SaveQueryDialog(const Config &config, const QString &query, const QString &accountKey, QWidget *parent = nullptr); + /// Edits an entry that already exists, prefilled from it rather than from + /// the query bar. + SaveQueryDialog(const Config &config, const SavedQuery &existing, + QWidget *parent = nullptr); + /// The query as edited. Only meaningful after exec() returned Accepted. SavedQuery savedQuery() const; @@ -51,8 +56,19 @@ public: static bool namesAnExistingQuery(const Config &config, const QString &name); private: + void build(const SavedQuery &initial); void updateOkState(); + /// The name the dialog was opened on, empty when creating. The caller + /// matches on this rather than on the returned name, so a rename replaces + /// the entry instead of adding a second one beside it. + QString m_originalName; + + /// Set for a generated entry, whose query is composed from the accounts + /// and cannot be edited here. + QString m_generated; + bool m_flat = false; + const Config &m_config; QLineEdit *m_name = nullptr; QLineEdit *m_query = nullptr; -- cgit v1.2.3