Commit Graph

2139 Commits

Author SHA1 Message Date
mgrojo
baaeea8844 Fix table header issues in a more portable way
This undoes 9e2f8e5ede and try to solve the
issues present in Linux with Qt 5.9 and the one in Windows with the Dark
Style at the same time.

I think both issues come from using the filter box height as y offset. The
real offset has to be the original table header height. In Windows+Dark the
box is apparently shorter, so after moving, part of the header is clipped.
In Linux+Qt5.9, the original header height is shorter than the filter box,
so moving by the filter box height clips the filter box at the bottom.

The new height increment for the table header is also reduced to 4, so the
margin is 2 in both the bottom and the top of the filter boxes.
See issue #1493
2019-03-03 20:29:59 +01:00
mgrojo
4b5b5c6238 Detect data with embedded zeros as binary also for ISO-8859
See issues #1772 and #1773
2019-03-03 14:26:16 +01:00
Martin Kleusberg
bede43f76c Fix in-memory databases bein read only
This problem was introduced in 5c727e8b70.
2019-03-03 12:18:28 +01:00
Martin Kleusberg
fa203c4c61 Fix multiple problems in 0f6946c19d
Fix multiple problems which were introduced in commit
0f6946c19d. They all are about detection
of transaction statements. First it turned out that the commit slightly
changed the behaviour of the dirty parameter which, although there did
not seem to be any consequences of this, was turned back into the old
behaviour. Then the detection of transaction statements depended on the
structure updated flag which is totally wrong and needed to be fixed.
Next, it turned out that SQLite executed ";COMMIT;" as one statement
instead of two. This means we need to skip until after the first
semicolon and not until before it. And finally, after skipping until
after the semicolon we should perform the check for transaction
statements again before blindly giving the next statement to SQLite.

See issue #1777.
2019-03-03 12:04:56 +01:00
mgrojo
9e2f8e5ede Fix for table header filters under Ubuntu Linux 18.04 and Qt 5.9.5
The filter box was clipped one or two pixels for both the follow-desktop
mode and the dark-style mode. This fixes it, but not sure if it will fix
the problem reported in issue #1493 in Windows.
2019-03-02 19:05:24 +01:00
mgrojo
0adb0af133 Fix text detection for blobs containing bytes in ASCII range up to a zero
Despite we provide a length for toUnicode() the validity/decode is being
performed only up to the first null character, so it passes as text blobs
containing bytes in the ASCII range, followed by a zero and anything else
after.

See issue #1772
2019-03-02 13:51:31 +01:00
mgrojo
230c40e8ee New setting allowing to set a dark style using a style-sheet
A new setting allows to follow the system style or set a new dark style
based on a the style-sheet provided by
https://github.com/ColinDuquesnoy/QDarkStyleSheet
The style-sheet is licensed under the MIT license. Images contained in
that project are licensed under CC-BY license.

* Set colours using style-sheet in Data Browser tab of Preferences

The colours of the frame and text-lines previewing the settings in Data
Browser tab need to have being set using a style-sheet, otherwise they
are eclipsed by the dark style-sheet when in use.

* Update preference colours when the application style is changed

In order to have matching colours in all the preferences, the individual
colour settings in Data Browser and SQL tabs are reset to default values
matching the corresponding style setting (dark stylesheet or follow desktop,
which could be dark or light as always).

Additionally, several problems with colour settings in QScintilla have
been fixed:
- We don't use indentation guides
- both sets of lexer colour settings must be used, otherwise the result is
inconsistant and unpredictable:
    * lexer->setDefaultColor|Paper and lexer->setColor|Paper

See issues #1751 #1493 and #1738
2019-03-01 21:07:44 +01:00
mgrojo
1a90acc52f Add license of ColinDuquesnoy/QDarkStyleSheet 2019-03-01 20:45:23 +01:00
Martin Kleusberg
85cdb59e08 Fix crash in f3a54e4c71
Also add a new helper function which makes the code a bit easier
understand.
2019-03-01 16:26:29 +01:00
Martin Kleusberg
f3a54e4c71 Add support for sorting by multiple columns in the Browse Data tab
This allows sorting by multiple columns (as in ORDER BY Field1, Field2)
by holding the Control key while clicking on another column header in
the Browse Data tab.

See issue #1761.
2019-03-01 11:32:38 +01:00
Martin Kleusberg
00bc7db5c0 Always set sort direction to ascending when sorting a new column
When changing the sort column in the Browse Data tab we always toggled
the sort direction too. So when Field1 was sorted in ascending order,
clicking on Field2 would sort it in descending order. If Field1 was
sorted in descending order, clicking on Field2 would sort it in
ascending order. Now in both cases Field2 is sorted in ascending order
first.
2019-03-01 10:34:55 +01:00
mgrojo
cc67969d73 Update preference colours when the application style is changed
In order to have matching colours in all the preferences, the individual
colour settings in Data Browser and SQL tabs are reset to default values
matching the corresponding style setting (dark stylesheet or follow desktop,
which could be dark or light as always).

Additionally, several problems with colour settings in QScintilla have
been fixed:
- We don't use indentation guides
- both sets of lexer colour settings must be used, otherwise the result is
inconsistant and unpredictable:
    * lexer->setDefaultColor|Paper and lexer->setColor|Paper
2019-02-28 00:02:47 +01:00
Martin Kleusberg
e52f2054f2 grammar: Fix keywords as table name and keywords as column name
SQLite allows some keywords to be used for table names and some other
keywords to be used for column names without using any quotes. Our
grammar parser needs to know which keywords are allowed and which are
not. In the two lists (one for table names and one for column names)
there were a few errors and omissions. This commit should fix them.

This was pointed out in #1716.
2019-02-27 12:24:44 +01:00
Martin Kleusberg
fcdcfbdc79 Fix bug in 0f6946c19d
Fix a stupid mistake in commit 0f6946c19d.
Apparently I wasn't able to count to 6.
2019-02-27 11:57:38 +01:00
Cristian Lupascu
ff455c7038 Enable 'Edit Database Cell' when view is editable (#1756) 2019-02-25 19:38:54 +01:00
Martin Kleusberg
0f6946c19d Fix transaction detection in SQL import
Fix a couple of problems in the detection of transaction statements
during the SQL import. Before this the detection was case-dependent as
well as dependent on the number of spaces you use. Also it did not
detect 'END TRANSACTION', 'COMMIT TRANSACTION', or 'BEGIN <qualifier>
TRANSACTION' at all. Finally, it could modify your statements if you
embed string in them which look like transaction statements. All of this
is, hopefully, fixed in this commit.

See issue #1764.
2019-02-25 19:30:49 +01:00
mgrojo
e436cb2516 Move query in results panel of Execute SQL to the bottom
This gives precedence to the results of the query. It also removes the
comment characters that only made sense in the SQL User log. The text is
splitted so the texts are only translated once. The output of a multi-query
execution is also improved, because the results and line are constant
while the query part is quickly changing.

After the execution of a multi-query text, the final text is not separated
by a blank line so the result message is visible in the second.

For users wanting more space in the editor and query table, the results
panel is now collapsible, since the SQL Log can be used instead.

See issues #1709 and #1670.
2019-02-23 21:22:12 +01:00
mgrojo
dfb7974d27 Reduce (and unify) margins in the main tabs and in Execute SQL widgets
The margins have been set to 3 for the layouts of all the main tabs. It has
been generally reduced from the default (9), except for the DB Structure
which was set to 0 and now has been increased to 3 for uniformity with the
other tabs.

The margins of interior widgets in Execute SQL tab has also been reduced to
3 from the default.

See issues #1762 and #620.
2019-02-23 17:08:54 +01:00
mgrojo
e84589b12e Reduce (and unify) margins in the main tabs and in Execute SQL widgets
The margins have been set to 3 for the layouts of all the main tabs. It has
been generally reduced from the default (9), except for the DB Structure
which was set to 0 and now has been increased to 3 for uniformity with the
other tabs.

The margins of interior widgets in Execute SQL tab has also been reduced to
3 from the default.

See issues #1762 and #620.
2019-02-23 16:58:23 +01:00
Justin Clift
c7dd272ec6 Force DB4S to be displayed in light mode on macOS
We don't yet support Dark Mode on macOS Mojave (or above), so need
to keep in light mode.  Without this, DB4S is unusable.

Thanks to @jsejcksn for pointing us in the right direction. :)

See #1751 for for more details.
2019-02-23 18:28:51 +11:00
mgrojo
20c3e9d97d Set colours using style-sheet in Data Browser tab of Preferences
The colours of the frame and text-lines previewing the settings in Data
Browser tab need to have being set using a style-sheet, otherwise they
are eclipsed by the dark style-sheet when in use.
2019-02-23 00:23:12 +01:00
mgrojo
ed178689a4 New setting allowing to set a dark style using a style-sheet
A new setting allows to follow the system style or set a new dark style
based on a the style-sheet provided by
https://github.com/ColinDuquesnoy/QDarkStyleSheet
The style-sheet is licensed under the MIT license. Images contained in
that project are licensed under CC-BY license.

Pending issues:

- Use of stylesheets is incompatible to QPalette. Some colours for
previewing settings in the Preferences dialog are eclipsed by the style-
sheet
See https://github.com/ColinDuquesnoy/QDarkStyleSheet/issues/48

- Changing the style should select matching background and foreground
colours for the Browse Data and SQL tabs in Preferences.

See issues #1751 #1493 and #1738
2019-02-22 22:15:19 +01:00
Martin Kleusberg
a7a50c5e4c Fix crash when attaching an unencrypted database in the SQLCipher build
In builds with SQLCipher support enabled, attaching an unencrypted
database crashed the application.

See issue #1758.
2019-02-21 15:25:27 +01:00
Martin Kleusberg
5c727e8b70 Use the same code for creating new DBs as for opening existing DBs
We didn't install all the collations and callbacks we have when creating
a new database. They were only installed when opening an existing
database.

To avoid issues like this the code for creating a new database is
stripped down to a bare minimum. After the database is created, we
immediately close it now and open it again through the standard open
code.
2019-02-21 14:19:48 +01:00
Martin Kleusberg
282387ced7 Add new logging section for SQLite's error log
Add a new logging section to the SQL log panel called "Error Log".
Register a callback to receive errors and warnings from SQLite and add
them to the new error log section.

See issue #1754.
2019-02-21 14:19:47 +01:00
Martin Kleusberg
042e925f9f Make ExtendedScintilla widget run without a lexer
When using an ExtendedScintilla widget without setting a lexer, the
application would easily crash. This is improved by this commit.
2019-02-21 14:19:47 +01:00
mgrojo
8ddfa75929 Disable word wrapping in the Browse Data table when using Qt 5.2.x
In order to work around #1658 (QTBUG-73721) the word wrapping is disabled
when compiling with Qt 5.12.x. This workaround will also allow compiling
with better macOS dark theme support by using Qt 5.12 (see issues #1493 and
#1751 and Qt bug reports: QTBUG-68891 and QTBUG-71020) without affecting
builds using previous versions of Qt.
2019-02-20 23:26:43 +01:00
Martin Kleusberg
fbe4f167be Simplify code 2019-02-20 10:14:41 +01:00
Martin Kleusberg
a75acc01ef Move the automatic update check back into the main window class
See issue #1595.
2019-02-18 17:54:02 +01:00
Martin Kleusberg
abac190e76 Make early network accesses more reliable when using WLAN
The automatic update check is performed early during the application
start. It turns out that, when using a Wifi connection, the Qt
networking code is not ready yet at this point which leads to an
"Network inaccessible" error. This commit delays the automatic update
check until the network configuration is loaded completely.

See issue #1595.
2019-02-17 13:45:10 +01:00
Manuel
3b455afccf Allow custom display formats (#1720)
Allow user to define their own display formats. The SQL code is editable
and the combo box changes automatically to custom if the user edits one
of the predefined formats.

The display format (either custom or predefined) is validated with a 
case-insensitive regex so at least it contains a function applied to the column
name. 

Added a new callback for executeSQL following the model of sqlite3_exec.
Using this, the number of columns is got from a checking query execution. If
it is not one, the custom display format is also rejected.

Note that these validations might still be fooled in some unforeseen way, but
the users should know what they're doing.

See issue #573
2019-02-15 20:10:52 +01:00
Martin Kleusberg
14c82ea817 Fix alterTable() function
Fix a few issues in the alterTable() code. One type of issue would
happen if there are any keys or constraints in the table. Because the
check whether more changes are needed did not work as expected, we would
try to edit the table again, even though it is already correct. The
second type of issue (which can be triggered independently but which can
also be a follow-up issue to the first one) tries to access the table by
its old name even though it might already have been renamed.

See issue #1725.
2019-02-15 17:05:53 +01:00
Martin Kleusberg
a840a43161 Don't ask for saving changes when importing a SQL file
When importing a SQL file into a new database, we would create a
database file, import everything, then close the database and open it in
the GUI. While closing, however, the application asks you whether you
want to save the changes you made which can be confusing. This is solved
by creating an empty database, then closing it immediately without any
changes just to then open it in the GUI. Only then the import takes
place.

See comment in issue #1045.
2019-02-15 10:55:31 +01:00
Martin Kleusberg
d783d36dbd Further performance improvements in the SQL import
This eliminates some unneeded conversions in the SQL import code which
should speed up the import and reduce its memory consumption.

See issue #1045.
2019-02-14 18:01:20 +01:00
Martin Kleusberg
b6ec525da7 Fix build on some platforms
Fix build issues caused by 13a8a1f282.
2019-02-14 17:35:12 +01:00
Martin Kleusberg
13a8a1f282 Speed up the SQL import a bit
This commit attempts to speed up the SQL import a bit by removing
unnecessary conversions and counting of characters. It's still far from
perfect though.

See issue #1045.
2019-02-14 13:45:18 +01:00
Martin Kleusberg
c224d04607 sqlcipher: Fix editing the encryption for SQLCipher4
With SQLCipher4 the encryption was not working as expected because the
KDF and HMAC algorithms were not set properly. This is fixed in this
commit so it should work now with SQLCipher4 as well as SQLCipher3.

See issues #1690 and #1732.
2019-02-12 10:42:51 +01:00
mgrojo
4a728bd4f9 Class 'NullLineEdit' lacks Q_OBJECT macro
Qt Creator and lupdate are giving warnings about this class lacking the
Q_OBJECT macro. Although it seems to not be needed, adding it will silence
the warnings without drawbacks.

See issue #1740.
2019-02-11 23:04:42 +01:00
Iulian Onofrei
1ebd9955ca Fix static analyzer issues (#1727)
* Fix `barsGroup` memory leak

* Remove unused values
2019-02-09 21:01:55 +01:00
mgrojo
3eebffd7c6 Detect XML data starting with a declaration
Checking for "<?xml" at the beginning of a text is a quick and simple test
that will detect most of the XML cases.

This fills an obvious gap in #1537.
2019-02-09 20:01:22 +01:00
mgrojo
e2443d685f Fix text detection check
Truncating the text in bytes boundaries for the quick test was breaking
the text detection for Russian and probably any script encoded in more than
one byte. The problem occurred probably when a multibyte character was
truncated at the 512 boundary. This is a bit improbable in latin-based
languages like German or Spanish, whose most characters are a byte, but
very easy in other scripts, like Cyrillic, whose characters are encoded in
more than one.

The new approach is based in QTextCodec finding invalid characters using
the current encoding, which seems immune to the truncation problem.
According to callgrind, it has also better performance, probably because it
does not involve memory comparison.

See issue #1731
2019-02-09 19:03:42 +01:00
Martin Kleusberg
0089802177 Make Add Record button work again with a single click
In 5f4d0ee7ff the Add Record button in the
Browse Table tab was inadvertently changed to only open a popup menu
after a long click but not triggering the Add Record action after a
normal click. This restores the old behaviour.
2019-02-09 18:42:53 +01:00
Martin Kleusberg
7468bb2139 tests: Add test case for ee70a34ead
Add a test case for the bug which motivated disabling the window
function rules in ee70a34ead.

See issue #1733.
2019-02-09 13:33:56 +01:00
Martin Kleusberg
ee70a34ead grammar: Disable window function parsing
Remove the window function grammar rules. I think they are not needed
anyway as long as we only parse CREATE TABLE and CREATE INDEX
statements and unexpectedly they do seem to cause problems. It it still
worth investigating how this is possible but for now removing them seems
like the best option.

See issue #1733.
2019-02-09 13:26:21 +01:00
Manuel
5f4d0ee7ff Improve the size policy (toolbars and improved icons) (#1684)
* Improve the size policy (and more and better icons)

These changes improve the size policy for translations having long texts
in some buttons by:

* Converting the text buttons in the Edit Database Cell to icons
* Making the "Type of data" label wrappable and expandable
* Converting the text buttons in the Browse Data tab to icons
* Allowing the Plot combo-boxes to shrunk

All this allows both the Browse Data and the docks to grow and shrink with
more freedom.

New icons for buttons are reused when appropriate in context menus.

Added icon for filter and improve icon for docks (has been mirrored so it
matches the actual dock position).

Added Print icon in Edit Database Cell using the extra free space, so the
print action there is more visible.

This continues the effort started in #1324.

* Convert the embedded buttons to actual toolbars

This provides more flexibility, like the way how toolbars are compacted
when they have not enough space.

The QToolButtons in Browse Data tab and in Edit Cell dialog are converted
to QActions and inserted in new toolbars embedded in the same place as
the old buttons. Everything else should stay the same (shortcuts, tool-tips
and what's-this information).

* Set style for all toolbars in Preferences and minor adjustments

The combo-box used for the main toolbar is replicated for all the toolbars
in application. In this way, users with high resolutions can use the styles
with both icons and text, while users with lower resolutions can leave the
default styles, which should be better for them.

Some icon texts has been abbreviated from their default values, so they fit
better in the toolbars when they are visible.

The print icon in Edit Cell has been moved to the right, where it would be
the first to be collapsed.

The original what's-this info for Set as NULL in Edit Cell toolbar has been
restored.

* Remove no longer used overloaded function

The addShortcutsTooltip function applying to QWidget was no longer used
after having converted all the buttons to actions, so it is removed.
2019-02-08 21:45:50 +01:00
mgrojo
9fc6eeb3c6 Fix ambiguous shortcut for Ctrl+/
The shortcut was ambiguous because it was active in the button and in the
SQL editor itself. In the button was only documentation and was made
ambiguous when enabling the feature and fixing the shortcut in
6425fb177e

Now its scope is reduced to widget like similar button shortcuts so it can
be unambiguous in the editor.

See issue #1614
2019-02-04 20:30:29 +01:00
mgrojo
5383ede3d8 Enable/disable "Save All" button
The  "Save All" button is now disabled and enabled with the same criteria
than the save project buttons.

See issues #871 and #1706
2019-02-02 21:40:14 +01:00
mgrojo
8162c96c15 Double click a column for selecting it
Since the mouse release triggers the sorting, we were unable to select
only one column. Connecting the double click over the header to a column
selection, we are able to select that column. However, we cannot select
one column without sorting by it, since the sorting is triggered before,
on the first mouse click.

See issue #1717
2019-01-26 21:11:49 +01:00
mgrojo
03e75af3f1 Rectify the sort indicator after multiple column selection
When more than one column is selected we abort the sorting, but Qt has
already assigned the sort indicator to the last selected column, so we
have to restore the saved settings to fix the sort indicator column.

See issue #1717
2019-01-26 20:51:02 +01:00
mgrojo
e22966ec23 Fix override warning in selectAll
This change fixes a cmpile warning on Mac OS: (10.12.6) + Clang

warning: 'selectAll' overrides a member function but is not marked
'override'

Fixes #1718
2019-01-24 23:20:20 +01:00