Commit Graph

35 Commits

Author SHA1 Message Date
Martin Kleusberg
37a5645bf5 Fix some shadow warnings 2018-11-15 15:24:00 +01:00
Martin Kleusberg
c91009c7f3 Fix old-style-cast warnings 2018-11-15 15:11:09 +01:00
Manuel
abb6f686a3 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).
2018-10-30 21:22:14 +01:00
Iulian Onofrei
d526fa0b64 Add last location saving and loading per action type (#1587)
* Fixed code style

* Added last location saving and loading per action type

This saves and loads different paths per action type when presenting the
native file dialog popup.
2018-10-27 22:24:01 +02:00
mgr
79983e25cf Printing support #1525: plot printing using preview dialog
Add shortcut and entry in context menu for printing a plot.
2018-09-29 23:54:51 +02:00
Martin Kleusberg
28b8652ad6 Improve loading of all data
The multithreading patch didn't properly load all data into the cache
when this was necessary. It would only do so if the chunk size was
sufficiently high. This is fixed in this commit.

Show a progress dialog while loading all data which can be cancelled by
the user.

When cancelling the loading of all data in those cases which require all
data to be loaded, stop whatever process needs the data too.
2018-06-08 22:46:47 +02:00
Martin Kleusberg
3da520cdd1 Clean up multi threading patch, fix build and some bugs
Make strings translatable, remove some more debug code, fix tests,
reduce size of patch slightly, remove weird tooltip, don't crash when
closing database, simplify code, fix filters, don't link agains pthread
on Windows.
2018-06-08 22:46:47 +02:00
Martin Kleusberg
51dbe72e23 Multi-threading patch
This was done by Michael Krause.
https://lists.sqlitebrowser.org/pipermail/db4s-dev/2018-February/000305.html

In this commit I only fixed two compiler warnings, some whitespace
issues and removed some debug messages.
2018-06-08 22:46:47 +02:00
mgrojo
5dbb7ff645 Ensure the Escape key doesn't make Plot and Remote docks go away
Override reject() as done in other dock dialogs.

Fixes #1310
2018-01-30 20:33:15 +01:00
mgrojo
42bb1c0d65 Translatable strings and default case branch
This addresses review comments by @MKleusberg in PR #1302.
2018-01-26 18:13:20 +01:00
mgrojo
c5ec23e92e Stacked or grouped bars and plot legend
Two new options added to the context menu of the plot:

- Stacked bars: switches between stacked bars or grouped bars. The former
overlapped layout is avoided since it doesn't make much sense.

- Show legend: toggles the display of a plot legend with a translucent
background. Possible future improvement is dragging the legend with the
mouse.
2018-01-21 17:00:45 +01:00
mgrojo
175407645b Simplify the axis type storing, translucent additional bars and What's This
Now that we have a proper type column in the plot selection widget, the
internal type storing can be simplified.

If the plot has more than one Y selections for one X of label type (bar
charts) the first bar is opaque, but the additional are translucent in
order to be seen, since they will overlap.

What's This information added to explain all the possible selections for
plotting.
2018-01-20 18:28:03 +01:00
mgrojo
aa680622c0 Bar charts and Axis Type column in Plot Dock
String type columns are now selectable as X axis. In that case a bar chart
is plotted where the column values are used as bar labels.

A new Axis Type column is added to the axis selection table, so the user
knows before-hand how the plot will be drawn.

Line type and point shape combo-boxes are not enabled for bar charts, since
they don't make sense.

Columns that make no sense for the Y axis as strings and date/times are not
selectable for that axis.
2018-01-20 18:08:31 +01:00
mgrojo
33801d5285 Synchronize PlotDock with 'Execute SQL' table. Continuation of PR #1271
Make use of signals to connect the selection in plot to the associated
table widget. Every time that the plot is updated from the Main Window
the table widget associated to the table or query is connected to the plot
and the previous widget is disconnected. This allows the selection of the
correct table widget.

Line selection methods moved to the Extended Table Widget to be used as
slots for this connection.

The destroyed signal is also connected for resetting the plot. This fixes
a crash that already existed before this PR, when closing a SQL tab while
the plot is still associated to the table results model.
2018-01-16 00:37:42 +01:00
mgrojo
b2fbf45012 Plot: detect dates with time, pure dates and times data types
Three different date/time data types are detected and appropriately
displayed in the axis:
- DateTime: "yyyy-MM-dd\nhh:mm:ss"
- Date: "yyyy-MM-dd"
- Time: "hh:mm:ss"
2018-01-11 21:07:06 +01:00
mgrojo
ce2b33ab6d Use the correct function for checking the count of plotted items
Now that the plot may contain graphs and curves, the plottableCount()
function must be used instead of graphCount() for checking whether the plot
has any plotted items.

This had the effect reported in issue #821 of breaking the enable check for
the fetch-all button.
2018-01-08 23:30:55 +01:00
mgrojo
b08960f504 Plot: Respect the "Order by" clause when plotting
The tables/queries sorted by X are drawn using QCPGraph as before.

Since QCPGraph does automatically sort by X, we change to QCPCurve that
requires a third data vector to reflect the order. We get that from the
current row order.

In the case of curves, only None and Line is supported as line style.

Since the order is now important for the plot, it is automatically updated
whenever the user sorts by another column in the browsed table.

This addresses issue #821 and indirectly fixes the problem of incorrect
point->row selection link when the table is not sorted by X, reported in
issue #838.
2018-01-07 14:54:29 +01:00
mgrojo
05559d4727 Avoid inheriting the style sheet in child widgets
Avoid inheriting the style sheet in child widgets by naming the widget
type where it is set.

This had the effect, reported in issue #838, of setting an unwanted style
in child widgets, like the tool-tip of the "Load all data" button, the
tool-tip of the SQL results pane or the context menu of the search-bar
edit line.
2017-12-15 17:58:28 +01:00
mgrojo
982a88b5e2 Avoid crash performing the correct check to know if the plot has graphs
This crash was introduced in 6d3228a0e3. It
happened when no previous settings were saved for the plot.

Additionally the plot interaction are set once for the plot widget.

This was reported at issue #838.
2017-12-14 23:38:33 +01:00
mgrojo
6d3228a0e3 Visual warning when plotting if not all data has been fetched
Warn user if not all data has been fetched and hint about the button for
loading all the data. The attention to this button is attracted changing
its background to a reddish colour and showing a warning in its tool-tip,
which is automatically shown for its default duration.

Default message is simplified and the button is only enabled when it is
useful (users of non-big databases would never be distracted about the
fetching mechanism).

Since this button is also useful for resetting the zoom and axis range,
it is also enabled if the user performs one of these interactions over the
plot.

See discussion at issue #838.
2017-12-13 23:05:56 +01:00
mgrojo
e34d36085d Copy plot to clipboard
New context menu and shortcut (context restricted to widget) for copying
the current plot to the clipboard as a pixmap.
2017-12-13 00:14:27 +01:00
mgrojo
bfb607c4b7 Crash when running query with columns selected for plot
The model was still changing when the plot was being drawn. Now the plot
waits for the fetching to be finished.

See issue #1262
2017-12-11 23:57:25 +01:00
mgrojo
5807c0be6b Allow zooming and dragging only in one orientation
By selecting the axis or the labels associated to the axis,the user can
restrict the subsequent zoom or drag operation to that orientation.

The possible user interactions are documented in the Whats's This
information.

See issue #1258
2017-12-08 20:12:07 +01:00
Martin Kleusberg
409d02f9ea plot: Remove axis labels when there is no plot
See issue #950.
2017-12-07 16:14:15 +01:00
mgrojo
cef1e9020b Improve the user interactions over plot: zooming and range dragging.
The rectangle selection is no longer possible. Control+click can be used
for selecting a range of items.

This allows more freedom for performing customisations as requested in
issue "Change axis limits #838".

The "Load all data" button tool-tip and icon have been readjusted so they
hint the additional use pattern of resetting the plot to the original
zoom and range limits.

New and more appropriate icon for the "Save Plot" button. Icon from the
Silk set from famfamfam.com.
2017-12-02 17:41:41 +01:00
Martin Kleusberg
16263452c8 plot: Correctly restore Y axis check states
When restoring the plot state we always checked set the use-on-y-axis
checkbox when a colour was defined for a field. This is correct most of
the times because a field doesn't have a colour as long as it's not used
in the plot. However, when you uncheck a field it keeps its colour which
starts causing issues as soon these settings are reloaded.

The solution is to not only store the colour but also the check state
independently. This changes the project files format though, so the code
needs to support loading old and new file formats.

See issue #1245.
2017-12-01 13:03:48 +01:00
mgr
ade562769a Minor improvements in Plot Dock columns
The Column Field is resized to the content.

The dummy column has been removed and the header no longer stretches the
last section property.

The table has alternating row colors for easy following of the field
checks.
2017-11-13 23:59:36 +01:00
mgr
e8e5671588 Range of plot points can be selected in graph and in table
The user is now able of selecting a range of contiguous points in any of
the graphs of the plot, through rectangle selection or click in single
point. This selection triggers automatically the selection of the
corresponding lines in the browsed table. In this way the user can analyse
the plot in detail.

Two other minor improvements: spelling error fixed and the dummy column in
the plot selection table has now transparent foreground (intends to avoid
wondering of the user about what functionality provides this column).
2017-11-11 23:10:11 +01:00
Martin Kleusberg
ee32b3e4e1 Use nullptr where possible 2017-10-30 21:20:02 +01:00
Martin Kleusberg
4f18de856d plot: Fix labels for 'Row #' columns
See issue #950.
2017-05-08 13:19:59 +02:00
Martin Kleusberg
4706dd7dd7 plot: Correctly disable signals when needed
In the plot code use the blockSignals() method instead of connecting and
disconnecting signals and slots every time. The disconnects didn't
really work using the new C++11 connection code, so this commit restored
the functionality as it was intended.

This means that *a ton* of calls to updatePlot() are eliminated which
improves the performance.

It also avoid messing up the graph selection table in the Plot Dock in
certain cases.

See issue #950.
2017-05-08 13:05:30 +02:00
Martin Kleusberg
8c5650a63f libs: Update qcustomplot to version 2.0-beta 2017-05-04 21:51:43 +02:00
Martin Kleusberg
f1194d845e Rename all the settings accessor functions
Rename the settings accessor functions from Settings::getSettingsValue()
(and similar) to Settings::getValue() (and similar). The 'Settings' bit
seems a bit redundant and costs a lot of screen space.
2017-03-20 23:16:52 +01:00
Oleg Prutz
84a5030d9e Fix plotting with datetimes on x axis (#738)
Use QDateTime::toMSecsSinceEpoch() instead of
deprecated QDateTime::toTime_t() which does not
correctly convert datetimes which do not exist
due to switch to Daylight Saving Time
2017-03-05 16:28:11 +03:00
Martin Kleusberg
a6f2a7d9a0 Move plot code into a separate set of files
This cleans up the main window class a bit which was getting quite large
and a bit harder to maintain than necessary.

This commit also includes two minor fixes to the plot system:
- The plot widgets are now disabled when no database file is opened.
- The progress bar shown when fetching all data is now initialised with
the correct row numbers.

Other than that this commit should in theory not change any
functionality.
2017-01-13 18:00:39 +01:00