Initial implementation of "conditional formatting" (#1503)

After setting a filter, the user can select from the context menu in the
filter line a new option "Use for Conditional Format", that assigns
automatically a colour to the background of cells fulfilling that
condition.

The formatting is preserved after the user has removed the filter. Several
conditional formats can be successively added to a column using different
filters.

The conditional formats of a column can be cleared when the filter is empty
selecting "Clear All Conditional Formats" from the filter line context
menu.

The conditional formats are saved and loaded in project files as other
browse table settings.

A new class Palette has been added for reusing the automatic colour
assignment of the Plot Dock. It takes into account the theme kind of the
application (dark, light) for the colour selection.

A new class CondFormat for using the conditional formatting settings from
several classes. The conversion of a filter string from our format to an
SQL condition has been moved here for reuse in filters and conditional
formatting.

Whether the conditional format applies is resolved by SQLite, so filters
and conditional formats give the same exact results.

Code for getting a pragma value has been reused for getting the condition
result, and consequently renamed to selectSingleCell.

Possible future improvement:
- New dialog for editing the conditional formatting (at least colour and
application order of conditions, but maybe too: adding new conditions and
editing the condition itself).
This commit is contained in:
Manuel
2018-10-30 21:22:14 +01:00
committed by Martin Kleusberg
parent 4031a165fa
commit abb6f686a3
21 changed files with 466 additions and 165 deletions

View File

@@ -36,6 +36,8 @@ void FilterTableHeader::generateFilters(int number, bool showFirst)
else
l->setVisible(true);
connect(l, SIGNAL(delayedTextChanged(QString)), this, SLOT(inputChanged(QString)));
connect(l, SIGNAL(addFilterAsCondFormat(QString)), this, SLOT(addFilterAsCondFormat(QString)));
connect(l, SIGNAL(clearAllCondFormats()), this, SLOT(clearAllCondFormats()));
filterWidgets.push_back(l);
}
@@ -86,6 +88,18 @@ void FilterTableHeader::inputChanged(const QString& new_value)
emit filterChanged(sender()->property("column").toInt(), new_value);
}
void FilterTableHeader::addFilterAsCondFormat(const QString& filter)
{
// Just get the column number and the new value and send them to anybody interested in new conditional formatting
emit addCondFormat(sender()->property("column").toInt(), filter);
}
void FilterTableHeader::clearAllCondFormats()
{
// Just get the column number and send it to anybody responsible or interested in clearing conditional formatting
emit clearAllCondFormats(sender()->property("column").toInt());
}
void FilterTableHeader::clearFilters()
{
for(FilterLineEdit* filterLineEdit : filterWidgets)