Project

General

Profile

Bug #4495 ยป 0001-Enabled-additional-tooltips-updatable.patch

Bruce Toll, 10/04/2015 08:31 PM

View differences:

examples/charts/ChartsExample.C
};
/*
* Handler to update tooltips on model changes
*/
void updateToolTip(WStandardItemModel *model, WStandardItem *item)
{
WString old_tip = item->toolTip();
WString new_tip = asString(model->headerData(item->column())) + ": "
+ asString(item->data(DisplayRole), "%.f");
if (old_tip != new_tip) {
item->setToolTip(new_tip);
}
}
/*
* Reads a CSV file as an (editable) standard item model.
*/
WAbstractItemModel *readCsvFile(const std::string &fname,
......
for (int col = 0; col < model->columnCount(); ++col) {
model->item(row, col)->setFlags(ItemIsSelectable | ItemIsEditable);
/*
Example of tool tips (disabled here because they are not updated
when editing data)
*/
/*
WString toolTip = asString(model->headerData(col)) + ": "
+ asString(model->item(row, col)->data(DisplayRole), "%.f");
model->item(row, col)->setToolTip(toolTip);
*/
}
model->itemChanged().connect(boost::bind(updateToolTip, model, _1));
return model;
} else {
WString error(WString::tr("error-missing-data"));
......
model->setData(i, 0, x);
model->setData(i, 1, sin(x));
WString toolTip = asString(model->item(i, 1)->data(DisplayRole), "%.2f");
model->item(i, 1)->setToolTip(toolTip);
}
/*
    (1-1/1)