Project

General

Profile

Actions

Feature #1111

closed

WSuggestionPopup: allow setting the TextFormat

Added by Rob Van Dyck almost 13 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
12/29/2011
Due date:
% Done:

0%

Estimated time:

Description

I wanted to show an 'empty' suggestion (see attached screenshot).

I accomplished this by adding a suggestion with contents " ", which would be escaped to  

Therefor I needed to change the textformat used in the method WSuggestionPopup::modelRowsInserted from

WText *value = new WText(asString(d), PlainText);

to

WText *value = new WText(asString(d), XHTMLText);

The request is to be able to set this textformat on a WSuggestionPopup.

For testing purposes you can run the attached code, in case the textFormat has been set to XHTMLText it should show the contents of the screenshot.

This feature request is related to [1].

[1] <URL:http://redmine.webtoolkit.eu/boards/2/topics/3455>

Thanx!

Rob.


Files

main.cpp (3.34 KB) main.cpp Rob Van Dyck, 12/29/2011 10:54 AM
empty_suggestion.png (13 KB) empty_suggestion.png Rob Van Dyck, 12/29/2011 10:54 AM
Actions #1

Updated by Rob Van Dyck almost 13 years ago

edit:

I accomplished this by adding a suggestion with contents "& n b s p;", which would be escaped to "& a m p ; n b s p;".

Actions #2

Updated by Koen Deforche almost 13 years ago

  • Status changed from New to Resolved
  • Assignee set to Koen Deforche
  • Target version set to 3.2.1

Hey Rob,

Happy 2012, btw!

Actually, WAbstractItemModel already has a way to indicate that an item's display role is XHMLText: the ItemIsXHTMLText flag. The problem is that the WSuggestionPopup does not take it into account.

I've fixed this in my git copy and will push these changes later.

Regards,

koen

Actions #3

Updated by Rob Van Dyck almost 13 years ago

Great! Thanx Koen!

A happy 2012 to you, your colleagues and your family as well!

Regards!

Rob.

Actions #4

Updated by Rob Van Dyck almost 13 years ago

Hi Koen,

Sorry it took me a while to start using this (I continued working with my old modified version of wt untill now), but I have a small remark on its usage.

In my code I use a WStandardItemModel within the WSuggestionPopup.

My first thought:

[1] use the WSuggestionPopup::addSuggestion() and then set the flags on the model.

When [1] didn't work:

[2] manually add a WStandardItem with the correct flags to the model, so don't use WSuggestionPopup::addSuggestion()

That worked because the flags are only taken into account when you add something to the model

To make [1] work you could take the flags also into account when the data of the model is changed in the method 'WSuggestionPopup::modelDataChanged'.



// right under value->setText(asString(d));

WModelIndex index = model*->index(i, modelColumn*);

TextFormat format = index.flags() & ItemIsXHTMLText ? XHTMLText : PlainText;

value->setTextFormat(format);

So now I can use your feature in the following way as well (example use of [1]):

int row = popup_logic~~model()>rowCount();

popup_logic->addSuggestion(content*.first, content*.second);

WStandardItemModel model = dynamic_cast<WStandardItemModel>(popup_logic->model());

WModelIndex index = model*->index(row*, 0);

model
itemFromIndex(index)~~>setFlags(ItemIsXHTMLText);

Next to what allready worked (example use of [2]):

WStandardItem *item = new WStandardItem();

item*->setData(boost::any(content*.first), DisplayRole);

item*->setData(boost::any(content*.second), UserRole);

item~~setFlags(item~~>flags() | ItemFlag::ItemIsXHTMLText);

model*->appendRow(item*);

Kind regards,

Rob.

Actions #5

Updated by Koen Deforche almost 13 years ago

Hey Rob,

Good suggestion, I've incorporated it.

Regards,

koen

Actions #6

Updated by Koen Deforche over 12 years ago

  • Status changed from Resolved to Closed

Fixed in 3.2.1

Actions

Also available in: Atom PDF