Bug 471208 - In payee view, the default category displays with AccountNameRole instead of AccountFullNameRole
Summary: In payee view, the default category displays with AccountNameRole instead of ...
Status: REPORTED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: git (master)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-18 22:56 UTC by Cory F Cohen
Modified: 2023-06-18 22:56 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cory F Cohen 2023-06-18 22:56:19 UTC
In the payee view, the default category displays with AccountNameRole instead of AccountFullNameRole.   It should display the full "hierarchical" name because, without additional context, it can be difficult to tell which category is actually selected.

I'm opening a ticket for this issue because I choose poorly and this problem exceeded my ability to produce a clean fix to the problem. :-( I expected that I was hunting for a place where I would set something like "ui->comboDefaultCategory->displayFullName = true" and instead ended up over AccountDelegate changing how accounts are painted inside a ComboBox TreeView. :-| I'm happy to submit a merge request and work to finish fixing the problem if someone can tell me what to do, or for someone else to just correct this bug and I'll see what I can learn from the correct patch.

My solution involved: 1. In models/accountsproxymodel.h, return AccountFullNameRole for Qt::EditRole AND Qt:DisplayRole.  This causes the full name to display in the default category widget.  2. In views/accountdelegate.cpp, test if the parent is a ComboBox (instead of a view) and set opt.txt to the AccountNameRole (this causes the short name to display in the TreeView).  3. In views/kpayeesview_p.h call setItemDelegate() on ui->comboDefaultCategory to an instance of AccountDelegate.

This solution works in the payee view, but it also changes how the KMyMoneyAccountCombo renders in the transaction editor and split editor.  Specifically, it results in full names being shown inside the tree view.  I also tried marking the payee default category widget editable, which displayed the full name correctly, but that added a "split" widget to the default category control which was inappropriate in this context.  There appears to be logic for doing something similar in KMyMoneyAccountComboSplitHelper, but it also does much more.

In summary, I don't see how the problem can be easily fixed in the payee view without affecting the editing views, and the similarity of the issues raises concerns (at least to me) about whether a shared mechanism should be used in both places. My intuition is that the SplitHelper could probably use my fix by setting an AccountDelegate plus a few other changes and that this approach would make it easier to create category selection widgets that display a full name in the future.  But that's a bigger change than I had intended and would welcome some feedback.