Simplify handling item-data-source property in elements
ClosedPublic

Authored by staniek on Jan 17 2018, 9:29 AM.

Details

Summary

They are all the same, let's remove copy-pasted code.

This also makes the property editable for all elements supporting data source, so also completer works there.

+ Remove unnecessary and unused support of static text with $ prefix

FIXED-IN:3.1.0

Test Plan

Try data source properties of elements in KReportExample and KEXI Reports

Diff Detail

Repository
R14 KReport
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
staniek created this revision.Jan 17 2018, 9:29 AM
Restricted Application added a project: KReport. · View Herald TranscriptJan 17 2018, 9:29 AM
staniek requested review of this revision.Jan 17 2018, 9:29 AM
piggz added a comment.Jan 17 2018, 9:18 PM

Not all item types allow 'extra value' to be specified for the data source. Are you happy allowing the property for all item types?

I see, do you remember what was the actual rule?

I would say we want the combos to be editable so the completion works and mouse-less operations are easy. This is different option though, that we lack in KProperty but it's wasy to add. It can be called "editable" so we would have:

KPropertyComboBoxEditor::KPropertyComboBoxEditor(const KPropertyListData &listData,
                                                 const KPropertyComboBoxEditorOptions &options,
                                                 QWidget *parent)
   : QComboBox(parent), d(new Private)
{
 ....
   setEditable(d->options.extraValueAllowed || d->options.editable);
   setInsertPolicy(QComboBox::NoInsert);
piggz added a comment.Jan 18 2018, 8:01 AM

eg, field datasource can contain =<Complex js > or $<literal string>

Thanks for the reminder Adam.

  1. Now I wonder if there's room for a cleanup before we release. Is the '$' prefix used (documented) somewhere?

We have KProperty("value", QString(), tr("Value"), tr("Value used if not bound to a field")) IIRC per my request long ago to simplify the logic.
Special cases: it's called "static-image" for images for backward-compatibility, and for maps we have 3 properties long/lat/zoom.

What do you think about removing the support for the '$' prefix?
If we no longer have the prefix we do not worry about it having no sense e.g. for image elements.

  1. The '=' prefix. Looks like it's working, has no equivalent elsewhere in reports and has users already.

Do you see any reason why we would not support the '=' for element types that were not supported before?
That is, for image, text, barcode, maps, web. This patch currently does it.

PS: Maybe in the future we would display invalid column names in some special way on the report. That is, as long as we don't support the '$' prefix, datasource string not having '=' prefix and not leading to existing field is an error worth emphasizing.

Regarding lat/long/zoom, does the map element show you the map for statically provided values (i.e. when is data source is empty)?

staniek updated this revision to Diff 25617.Jan 19 2018, 12:40 AM
staniek edited the summary of this revision. (Show Details)
  • GIT_SILENT dataSourceProperty()->setValue -> setItemDataSource
  • Remove unnecessary and unused support of static text with $ prefix
  • GIT_SILENT Update API for source and format
  • GIT_SILENT For docs for loadFromFile
  • GIT_SILENT dataSourceProperty()->setValue -> setItemDataSource
  • Remove unnecessary and unused support of static text with $ prefix
  • GIT_SILENT Update API for source and format
  • GIT_SILENT For docs for loadFromFile

@piggz Please see the changes, I also updated the loadFromFile() which now sets the "value" property.

piggz accepted this revision.Jan 19 2018, 5:38 PM
This revision is now accepted and ready to land.Jan 19 2018, 5:38 PM
This revision was automatically updated to reflect the committed changes.