Project

General

Profile

Actions

Bug #713

closed

WTableView and WStandardItem UrlRole bug

Added by Marios Hadjieleftheriou over 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
02/07/2011
Due date:
% Done:

0%

Estimated time:

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

Table.C (1.86 KB) Table.C Pieter Libin, 02/16/2011 10:17 AM
Actions #1

Updated by Koen Deforche over 13 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

Actions #2

Updated by Pieter Libin about 13 years ago

add an example to reproduce the problem (provided by marioh@research.att.com)

Actions #3

Updated by Koen Deforche about 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

Actions #4

Updated by Koen Deforche about 13 years ago

  • Status changed from Resolved to Closed

Available in Wt 3.1.9

Actions

Also available in: Atom PDF