Commit Graph

24 Commits

Author SHA1 Message Date
Martin Kleusberg
ca682b2067 Fix some warnings 2019-11-06 20:25:39 +01:00
Martin Kleusberg
ba1270cedb Clean up the code and make some more minor optimisations
This also includes replacing some more Qt containers by their STL
counterparts.
2019-11-06 20:25:18 +01:00
mgrojo
b3b1ac6946 Disable entire toolbars and frames in Table Browser
The Show/Hide Style Toolbar button and the find bar buttons were not
being disabled when the database was closed. The Find Next button even made
the application crashed in that state.

This change ensures we don't forget to disable new buttons in the toolbars
and frames of the Table Browser.

The layout where the navigation buttons are inserted does not, apparently,
disable the children widget, so cannot be used in the same way.

See related issues #1976 and #1608.
2019-11-03 20:22:27 +01:00
mgrojo
01378367a6 Easy way of selecting columns (and rows)
Add shortcuts for selection of entire columns ("Ctrl+Space") or rows
("Shift+Space") from the current cell selection.

A new menu entry in the column header is also added, including the shortcut
legend for selecting the column.

This addresses #1717 and complements #1976 for quick formatting of entire
columns or rows.
2019-10-27 23:35:48 +01:00
mgrojo
5aeca230fc Formats conditioned to row-id values to allow free cell formatting
The conditional formatting is extended to cover free single-cell
formatting. The row-id formats have precedence over regular conditional
formats.

In the styling toolbar, when single cells are selected, row-id formats are
created or updated. When entire columns are selected, regular conditional
formats are instead. Clearing formats for entire columns, remove both. For
single cells, only corresponding row-id formats.

New row-id formats are also saved to project files and loaded.

See issue #1976
2019-10-27 01:25:04 +02:00
Martin Kleusberg
a43e6a93e4 Store settings in SqliteTableModel
Store the relevant settings in SqliteTableModel and only update them
when they have changed. This avoids a lot of querying and converting of
variables in the data() function which is called very often and
therefore is somewhat critical for the overall performance.
2019-10-04 18:40:22 +02:00
Martin Kleusberg
be06bf2ac9 More consistent use of size_t for indexing table columns
Especially when we can remove the code for loading the binary bits of
the old project file format, this should allow us to get rid of a ton of
static_casts.
2019-10-04 17:58:42 +02:00
Martin Kleusberg
6252124a69 Simplify some names
This is only changing internal function and variable names. Since we
have a separate class for the code from the Browse Data tab now, there
is no point to have the function names contain some sort of string like
"browseData" or similar.
2019-10-03 21:14:11 +02:00
mgrojo
7ca90e0f7e Fix problem with cursor navigation in table browser
This was causing that cursor navigation in table browser did not move the
scroll or that find bar required an additional scrollTo call.

Problem was introduced in 63aabb9601

See comments in PR #2013
2019-09-30 23:41:58 +02:00
mgrojo
b7f6bef398 Fix compilation error with Qt version used by Travis
This is another way to solve the overload.
2019-09-29 22:36:15 +02:00
mgrojo
9b1561afd0 Merge branch 'browser_formats' 2019-09-29 20:12:03 +02:00
mgrojo
fbf1de1e4b Merge branch 'master' into browser_formats
Necessary changes:

- Added function `ExtendedTableWidget::colsInSelection` to emulate former
behaviour of `ExtendedTableWidget::selectedCols`, which is needed by the
format toolbar.

- Added call to `ui->dataTable->scrollTo(match);` in TableBrowser::find,
otherwise the scroll was not advancing to the current index.

# Conflicts:
#	src/TableBrowser.cpp
#	src/TableBrowser.ui
#	src/icons/icons.qrc
#	src/sqlitetablemodel.cpp
2019-09-29 19:39:11 +02:00
mgrojo
6affb875cf Improvements for text alignment
The requested text alignment is always combined with AlignVCenter, which is
the value used before conditional formatting was implemented and gives
better display result.

When creating a new conditional formatting while applying a format from the
toolbar to a column which does not already have one, the alignment flag
of the format is taken from the current cell. In this way, the default text
alignment for numbers is preserved.

See issue #1976 and PR #2013
2019-09-29 13:54:18 +02:00
mgrojo
63aabb9601 Added toolbar for direct formatting of columns in Data Browser
The new toolbar is hidden by default and can be toggled using a button in
the main Data Browser toolbar. Margins and spacing have been updated to
improve appearance of the two toolbars.

These tool buttons apply the format to the columns which are contained in
the selection. This is done by updating or adding a new condition-less
format to the list of conditional formats of those columns.

New style icons from the Silk icon set. Changed existent ones for
coherence.

See issue #1976.
2019-09-29 12:33:34 +02:00
Martin Kleusberg
671cc6d6c6 Add a find tool bar to the Browse Data tab
This adds a find tool bar to the Browse Data tab which allows the user
to search for values in the current table view. It only looks in
non-filtered rows and in non-hidden columns. It respected display
formats and sort order, too. The idea is to provide an additional level
of searching: the first one is done by using the filters and actually
reduces the number of rows in the view; the second level is done by
using the new find tool bar and allows you to look for values in the
remaining rows (or all rows if there is no filter).

See issue #1608.
2019-09-26 16:07:18 +02:00
mgrojo
5b73cd1481 Fixes when adding new conditional format
Font point size preference is taken into account when creating a new
default conditional format.

New conditional formats in dialog are resized to contents.

See issues #1976 and #1815.
2019-09-21 23:30:28 +02:00
mgrojo
c27002c301 Added text alignment to conditional formats
Combo box for selecting the desired text alignment for a conditional
format.

The default alignment in the browser has been adjusted for numbers, which
are now aligned to the right as in spreadsheets.

Project file format updated.

See issues #1976 and #1815.
2019-09-21 23:28:35 +02:00
mgrojo
412c239366 More conditional formats: font style
The conditional format manager allows now to set the font style: bold,
italic and underline.

The project format has been updated. This is also the base for setting
other font formats without further changing the project schema.

New icons form the Silk icon set.

See issue #1976 and #1815.
2019-09-21 12:33:16 +02:00
Martin Kleusberg
80fb3707c6 Add global filter field to Browse Data tab
This adds a new field to the toolbar of the Browse Data tab which allows
filtering the current table just as the other filters. With the new
field however all columns of a row are checked and only one has to
match. This provides in effect a "global" filter which works on all
columns instead of just one.

See issues #1608 and #1662.
2019-09-16 22:36:14 +02:00
Martin Kleusberg
3237e9d2f5 grammar: Rework how PK and unique constraints work
This commit changes the class hierarchy to make primary key constraints
a type of unique constraints. This fits nicely with reality because
primary key columns do not allow duplicate values. It also makes our
life easier as the other changes which are introduced here add some code
required by both unique and primary key constraints and which now can be
shared.

Move the auto increment flag from the field class to the primary key
class. This changes how auto increment fields work and look and might be
a bit unfamiliar but it simplifies things a lot for us because an auto
increment field is always a primary key. So before we had to maintain
two places: the field with the auto increment flag and the primary key
which belongs to it. Now it is all in one place in the primary key.

Add support for storing and manipulating sort order for columns in
primary key and unique constraints. It does not add support for them to
the grammar parser though.

Finally add a way to store and manipulate on conflict clauses for unique
and primary key constraints. Again, parser support for them is not added.
2019-09-11 15:09:23 +02:00
Martin Kleusberg
13155e5f71 Make view settings in TableBrowser class static
See issue #1972.
2019-09-04 09:40:51 +02:00
Martin Kleusberg
2958e5acba Silence some warnings and fix bug with RTL editor
This silences a couple of compiler warnings. The changes in the grammar
parser serve the same purpose: they silence at least some of the
warnings Antlr prints while generating the parser code.

In the Edit Dialog a missing break is added to a switch statement. This
seems like it actually was an unintended fallthrough for once, setting
the focus to the hex editor instead of the RTL editor.
2019-08-28 19:08:27 +02:00
Martin Kleusberg
c3c6e42dfb Make new TableBrowser class a bit more robust against misuse 2019-08-23 12:16:15 +02:00
Martin Kleusberg
3f0832f449 Move form data and code for Browse Data tab into a separate widget class
This adds a new widget called TableBrowser which does everything the
Browse Data tab did before. All the UI data and all the code related to
this tab is moved into the new widget class. The main window now simply
uses the new widget instead of implementing all this stuff itself.

I mainly see three benefits from this change:
1) The main window class becomes smaller and starts looking less like a
master class which manages all of the application. This should make it
easier for new developers to find their way around the code.
2) A better separation of the table browser and the remaining main
window makes it clearer which class class is responsible for what. Again
this makes it easier to maintain the code when it grows.
3) If we ever want to have split views, multiple Browse Data tabs, or
something similar this is an absolute prerequisite.

This commit obviously changes a lot of code. So be prepared for
unintended changes and consider doing some extra testing.

See issue #1972.
2019-08-21 20:47:27 +02:00