Bug #713
closedWTableView and WStandardItem UrlRole bug
0%
Description
When using a WTableView with a WStandardItemModel, setting the UrlRole of a WStandardItem results in the table view rendering the URL without any text (it results in an empty cell that is clickable and links to the specified URL, but there is no label).
The problem seems to be in WItemDelegate::update. When a WAnchor is created for the specific item, WAnchor::setRef is called, but WAnchor::setText is never called, which leaves the anchor text empty.
Adding in line 132 of WItemDelegate.C:
132: std::string s = asString(index.data(UserRole)).toUTF8();
133: a->setText(s);
fixes the issue
It would be preferable to be able to directly add a WAnchor through WStandardItemModel::setData. That way the user would be able to also customize the anchor (e.g., the setTarget functionality). Currently, passing a WAnchor to WTableView results in an unsupported exception.
Files
Updated by Koen Deforche almost 14 years ago
- Status changed from New to Feedback
Hey Marios,
The text itself should be set inside a WText that is a child of the anchor. If somehow this is not the case then that must be a bug. Can you reproduce it in a small test case, or, share the code that you use to set the data ?
In principle, we do not specify data as widgets in the models, in order to have a clean separation between model and view. Of course, nothing prevents you from doing that using a customized ItemDelegate. You need to set the anchor then as user role data (otherwise you get the unsupported exception). In your case, however, I would prefer to add an AnchorTargetRole and suppor that in the WItemDelegate.
Regards,
koen
Updated by Pieter Libin almost 14 years ago
add an example to reproduce the problem (provided by marioh@research.att.com)
Updated by Koen Deforche over 13 years ago
- Status changed from Feedback to Resolved
Hey,
You need to set the label as DisplayRole, not as UserRole. With that modification, the test case behaves correctly.
Regards,
koen
Updated by Koen Deforche over 13 years ago
- Status changed from Resolved to Closed
Available in Wt 3.1.9