Commit Graph

3032 Commits

Author SHA1 Message Date
mgrojo
1ec502ae9b Added font and point size selection to conditional formats
Added font combo box and spin box for selecting font and font point size
of a conditional format. The default for a new conditional format is the
corresponding setting.

Minor dialog adjustments for better display.

See issues #1976 and #1815.
2019-09-21 18:17:16 +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
6ddd6e99ff Fix issue with inserting rows into single-column PK tables
After inserting an empty row into a table using the Browse Data tab, we
read the row back from the database to find out whether any (and which)
default values were inserted by SQLite. For tables with a single primary
key column the SQL statement for doing so was broken and failed every
time. So these values were only shown when refreshing the view.

This problem was introduced in a615c7b5a0.

See issue #1870.
2019-09-19 12:29:36 +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
402ea9f359 tests: Add more test cases for the SQLite parser 2019-09-13 14:22:12 +02:00
Martin Kleusberg
ce66c1da20 Remove the Antlr parser and the Antlr runtime library
Both are fully replaced by our new parser and are no longer needed.

See issue #1990.
2019-09-13 14:22:12 +02:00
Martin Kleusberg
ec0ebed697 grammar: Replace Antlr parser for CREATE TABLE statements by new parser
This extends our new Bison-generated parser to also parse CREATE TABLE
statements and replaces the last parts of the Antlr-generated parser by
doing so.

Also adjust the unit tests to match the new style of parsed expressions.
They have better formatting now and identifiers are always correctly
quoted. This could not be done before and so the tests expected the old
look of expression statements.

See issue #1990.
2019-09-13 14:22:04 +02:00
Martin Kleusberg
7477ec341b grammar: Add CREATE VIRTUAL TABLE support to the new parser
Add support for parsing CREATE VIRTUAL TABLE statements to the new
bison-generated parser. Also remove support for this from the Antlr
parser. Parsing virtual tables is far from complete but good enough for
our purposes. It is also not worse than with the old parser.

See issue #1990.
2019-09-12 11:25:59 +02:00
Martin Kleusberg
9e8cb6e2fb grammar: Replace the Antlr parser for CREATE INDEX statements
Replace the Antlr lexer and parser for CREATE INDEX statements a new
lexer and parser generated with flex and bison. This commit is a first
step towards replacing all Antlr-realted parts of the parser. Until then
the new bison-generated parser is only used for CREATE INDEX statements
and the old Antlr-generated parser is used for CREATE TABLE statements.

These are the main reasons for replacing all of the Antlr parser:
- Getting rid of the Antlr runtime library as a dependency.
- Not depending on an old piece of sotware (we are depending on Antlr2
  while Antlr4 is available at the moment. However, migrating to Antlr4
  is as bad as migrating to bison).
- Better handling of expressions in statements. This proved to be a
  consistent source of problems over the last couple of years.
- Somewhat better Unicode support.
- Reentrant code / multithreading support.
- I can finally uninstall Java from my computer.

See #1990.
2019-09-12 11:25:41 +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
3f7b108860 grammar: Add missing SLASH definition
This was missing from the first day of our SQLite parser. I have no idea
how nobody could notice this before. Without this SLASH definition no
table and no index could be parsed which had a "/" inside an expression.
2019-09-04 10:04:46 +02:00
Martin Kleusberg
147d2a4b72 Fix tests
Fix issue introduced in 0bf323ffc0 which
did only break the tests.
2019-09-04 09:50:04 +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
fc3248554d Do not roll back when importing CSV file without final line break
When importing a CSV file which uses quotes to escape characters we
would throw an error if the very last character in the file is the end
quote character. This commit changes it to only error when ending in the
middle of a quoted field but not at the end anymore.

See issue #1986.
2019-09-04 09:16:20 +02:00
Martin Kleusberg
64d83568ec Remove leftover debug code 2019-09-04 09:00:32 +02:00
Martin Kleusberg
0bf323ffc0 grammar: Simplify grammar parser
Remove the stub for parsing CREATE TABLE ... AS SELECT statements. This
provides no extra value because we never come across these statements in
our context and this is not remotely implemented in a useful way.

Also remove the statement and statement list structures as they are not
used either.
2019-09-04 08:58:12 +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
2045a4d48f Fix a warning and a build error on macOS
See issue #1979.
2019-08-27 21:55:20 +02:00
Martin Kleusberg
ad2aa8ca88 Remove unnecessary checks and message boxes
This removes a couple of checks whether the database is opened. They
are not really necessary because the respective buttons are disabled
anyway in case no database is loaded. This was inconsistent anyway since
not all functions were checking for this. It also gets rid of a string
which translators have to deal with even though it is never going to be
displayed.
2019-08-27 21:55:19 +02:00
mgrojo
6d9b8418ce Set gaps when the x axis is NULL
Gaps are requested to QCustomPlot when one of the coordinates of a point
is NaN. We were using that feature for the y axis, but not for the x axis
where null values where being converted to 0, which makes less sense than
making a gap, at least for consistency.

See issue #1977
2019-08-26 23:19:33 +02:00
Martin Kleusberg
1a0786c409 Restore status bar calculations in Browse Data tab
This fixes a regression introduced in commit
3f0832f449 which lead to the calculation
of numbers like sum, average, and count in the status bar not being
displayed.
2019-08-23 16:12:32 +02:00
Martin Kleusberg
d9fbdb4bfc Fix collation combo box for newly added fields in Edit Table dialog
This fixes a regression which was introduced by the changes in Commit
0768ccd1db. The newly added combo box for
setting the collation of a field was not created for fields which were
newly added to the table. This broke the setting of the data type for
these fields.

See issue #1973.
2019-08-23 15:12:26 +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
0768ccd1db Add column for editing collations to Edit Table dialog
Add a new column to the field table of the Edit Table dialog which
allows you to set, remove, and modify the collation of each field. This
is done by showing a combo box which lists all currently available
collations.

See issue #1973.
2019-08-21 23:37:16 +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
Martin Kleusberg
7f051f8926 Some progress towards less usage of SIGNAL and SLOT macros
This is in no way complete but since it is a routine task and I got
bored of it I am going to stop here.
2019-08-21 11:58:31 +02:00
Martin Kleusberg
df291aa286 grammar: Fix whitespace problems
When using a "x IS NOT NULL" expression in a statement our parser was
generating something like "xIS NOTNULL". This was especially a problem
because the table looked like it parsed correctly but actually contained
a faulty expression. So when modifying the table you would get
unexpected error messages, or worse silent errors introduced into your
table.

Also add a test case for this and for commit e7ba79f478.

See issue #1969.
2019-08-20 10:05:03 +02:00
Martin Kleusberg
e7ba79f478 grammar: Fix parsing of some recursive expressions
Fix the parsing of complex, recursive expressions as they can be
especially used in CHECK constraints. This also improves the handling of
row value expressions which were somewhat in conflict with recursive
expressions. So with this commit we should be back to a more stable
expression parser in general.

See issue #1969.
2019-08-20 10:02:33 +02:00
mgrojo
b37b444e04 Remove no longer needed call to processEvents
After cf631a0222 this call is no longer
needed to work around the problem described in #1649.

See discussion in issue #1943.
2019-08-18 15:16:04 +02:00
Martin Kleusberg
ed4c252dbb Add comment to avoid future problems 2019-08-18 14:22:35 +02:00
Martin Kleusberg
cf631a0222 Make updating of database structure always happen in the main thread
Make sure the updating of the database structure always happens in the
main thread so it is in sync with the GUI updates. This way we know for
sure that the list of tables has been completely updated before we try
to (re-)select a table in the Browse Data tab after the DB structure
changed.

See issue #1701.
2019-08-18 14:09:12 +02:00
Martin Kleusberg
f515c0473c Better naming of duplicated SQL tabs
See issue #1964.
2019-08-18 13:45:53 +02:00
mgrojo
aae2d4dea5 Restore current table and applied filters from project
Restoring the current table and applied filters from project was not
working due to some interference with other applied changes.

Now it is done at the end of the load project function and after having
processed events. applyBrowseTableSettings is also called, otherwise
filters are applied but not visible in their input boxes.

See issue #1573
2019-08-17 20:48:00 +02:00
mgrojo
fefbe37c29 Prompt user for options after dropping files
If no DB is open, DB4S tries to open the dropped file as formerly.
Otherwise, the user is prompted for the action:
- Open Database or Project
- Attach Database...
- Import CSV file(s)...

See issue #1883
2019-08-17 14:05:14 +02:00
Martin Kleusberg
6f81e89ec1 Add context menu and Duplicate tab feature to Execute SQL tabs
Add a new right click context menu to the tab bar of the Execute SQL tab
in the main window. This menu contains actions for renaming and closing
tabs. Especially the renaming feature was hard to find before.

Add a third, new action to the context menu for duplicating the tab.
Duplicating opens a new tan and copies the title and SQL text from the
selected tab.

See issue #1964.
2019-08-15 16:24:35 +02:00
mgrojo
732cda89fd Button for clearing the sorting columns
A new button in the "Browse Data" toolbar for clearing the sorting columns
and returning to the default table order.

New icon created as a composition of icons from the Silk icon set.

See issue  #1761
2019-08-15 15:43:13 +02:00
mgrojo
e40271f042 Set a minimum size for the Browse Table combo-box
See issue #1965
2019-08-12 21:45:37 +02:00
Martin Kleusberg
622ef9dfc1 dbhub: Fix size for very large databases in remote dock
Fix the size value in the database list of the Remote Dock for very
large databases. This was showing a negative value due to an overlow.
2019-08-10 15:41:25 +02:00
Martin Kleusberg
a9e6fe4ecb Support adding custom constraints in Edit Table dialog
This adds support for adding custom constraint in the Edit Table dialog,
e.g. for adding multi-column unique constraints.
2019-08-10 13:18:18 +02:00
Martin Kleusberg
99c7523849 Fix warning when browsing views
When browsing a view we were constructing a query which looked like
this because the rowid column was empty:
SELECT "",* FROM "view_name";
This worked because there isn't really any rowid column for views anyway
and SQLite was interpreting the first bit as an empty string literal.
However using double quotes for string literals triggers a warning in
the error log. This commit aims to avoid this warning.
2019-08-10 11:51:12 +02:00
Martin Kleusberg
5221a66182 Fix floating point detection for 64bit values
I forgot to add this file in 7d85d7a41b.
2019-08-05 13:40:50 +02:00
mgrojo
9327d512a9 Avoid displaying sort indicators in plot dock and "Copy with headers"
headerData() now returns column name plus sort indicator in the display
role and only the column name in the edit role. This allows to use the
edit role for the plot and the copy-with-headers features, so they do not
show the sort indicator as part of the column name.

See related issue #1409 and PR #1810
2019-08-04 18:00:31 +02:00
mgrojo
32efd8f19f Avoid flickering while sorting or filtering
Flickering was produced in the table header, due to the fact that the
the filter boxes were displayed first at the rightmost side while the
table is reset and then they are repainted when the rows appear, in order
to leave space to the vertical header with the row numbers.

Setting the minimum width of the vertical header to the current width
before any filtering or sorting avoids the issue. The minimum width is
set to the default when changing the current table.

See issues #1763 and #1941
2019-08-04 01:11:13 +02:00
mgrojo
bef856ef45 Fixes some problems reported by Coverity
- Unchecked dynamic_cast
- Uninitialized scalar field
- Uninitialized pointer field
- Big parameter passed by value
2019-08-02 17:19:28 +02:00
mgrojo
12c6a66375 New shortcuts for menu entries: open read-only and wiki
Ctrl+Shift+O for "Open DB Read Only" (see issue #1904)
F1 for "Help > Wiki" (our online help page)
2019-08-01 21:39:17 +02:00
Martin Kleusberg
7d85d7a41b Correctly detect numbers up to 64 bits when detecting data type
This fixes commit 74e0df376a for integers
and floats of more than 32 bits length.

See comment by @mgrojo here:
74e0df376a (r34532732)
2019-08-01 14:07:47 +02:00
Martin Kleusberg
74e0df376a When updating a field try to respect the affinity data type if possible
When modifying the value of a field in the Browse Data tab, we used to
always hand over the new value to SQLite as text. This works most of the
time but can cause problems e.g. when a CHECK constraint checks the data
type of the value and expects something other than text. It is also a
pretty lazy approach in general.

This commit checks if the new value matches the affinity data type of
the column, and if it does hands over the new value as the correct data
type.

See issue #1952.
2019-08-01 13:30:01 +02:00
Martin Kleusberg
05181df8b8 grammar: Fix parsing of more complex expressions
See issue #1950.
2019-08-01 11:14:30 +02:00
Martin Kleusberg
263c28e6f4 grammar: Correctly parse the modulo operator
This adds a missing definition for the % character in order to make the
modulo operator work correctly in expressions.

See issue #1950.
2019-08-01 11:06:59 +02:00
Martin Kleusberg
55b3f6378f grammar: Correctly parse subexpressions in parentheses
This fixes parsing for table definitions like this:

CREATE TABLE a(
    x INT DEFAULT(5 + (1))
);

See issue #1950.
2019-08-01 11:06:08 +02:00