Commit Graph

2175 Commits

Author SHA1 Message Date
mgrojo
25715bb590 Add min & max in selection to the status bar and always show rows & columns
Now number of rows and columns is always showed, independent of the number
of cells threshold. Plural forms are used in translations (Spanish and
British English updated for testing).

Min and Max have also been added to the status bar message.
2019-04-03 11:51:35 +02:00
mgrojo
4d5e841813 Show info in status bar when a selection is made in Data Browser
When a selection is made in the Data Browser, the status bar shows:
number of rows, number of columns, sum and average of numeric values (other
data types count as 0) in the selection.

For avoiding expensive computations when the selection is very big
(selecting all cells or an entire column) the threshold setting for the
completion is reused.

This was inspired by #1791, but does not implement the proposed feature.
2019-04-03 11:51:35 +02:00
Justin Clift
5de6adeb42 Added Korean translation updates from PR #1600 2019-04-03 15:56:41 +11:00
Martin Kleusberg
70d5ec08eb Fix two warnings
See issue #1828.
2019-04-02 20:59:20 +02:00
Martin Kleusberg
20724ee139 Use a custom extension function instead of the json_array function
For multi-column PKs in WITHOUT ROWID tables the first implementation
added a dependency on the JSON extension by using the json_array
function. To make sure DB4S works even without this extension, this
commit adds and makes use of a custom extension function which
essentially does the same thing as json_array.
2019-04-02 17:56:22 +02:00
Martin Kleusberg
726db220d1 Fix inserting into tables with multiple primary key columns
See issue #1834.
2019-04-02 16:19:07 +02:00
Martin Kleusberg
d1adac0a3b Activate one more test
Looks like we forgot about this when closing #1270.
2019-04-01 21:56:29 +02:00
Martin Kleusberg
e42b1e0716 Fix tests 2019-04-01 21:54:14 +02:00
Martin Kleusberg
a615c7b5a0 Initial support for multiple primary key columns in WITHOUT ROWID tables
This add initial and mostly untested support for WITHOUT ROWID tables
with multiple primary key columns. It should now be possible to update
and to delete records in these tables.

This commit also improves the overall handling of multiple primary key
columns in preparation for better support of them in general.

Note that this makes us depend on an SQLite version with a built-in JSON
extension.

See issues #516, #1075, and #1834.
2019-04-01 21:43:00 +02:00
Martin Kleusberg
b788e2ddc8 Fix deleting from without rowid tables 2019-04-01 19:28:09 +02:00
Giuseppe Zizza
ee5f9165d3 Italian translation 2019-04-02 00:02:16 +11:00
Justin Clift
7fd3901534 Regenerate translation files for the master branch 2019-04-02 00:00:37 +11:00
Martin Kleusberg
2352943988 Fix editing encryption when using SQLCipher 4
It seems like we need to explicitly detach the newly encrypted database
when changing the encryption settings and using SQLCipher 4.

See issue #1829.
2019-03-30 13:30:35 +01:00
Paul Jarvis
8ce0b0071f Rename 'errno' as Windows appears to reserve it 2019-03-30 18:11:11 +11:00
apjarvis
c44286bc2b Corrections to base64 encoding and decoding functions (#1804)
* Allow base64 encoding of blobs

* Fix typo error on base64 encoding resulting in unterminated string being returned.

* Limit padding characters to maximum of two

* Tidy up padding characters

* Add detection of UTF8 format when decoding base64
2019-03-28 23:38:22 +01:00
Manuel
ea2aa495b3 Visual sort indicators for multi-column sorting (#1810)
This adds visual sort indicators to the already working multi-column
sorting. Qt sort indicator is disabled, so only one indicator per column
is visible.

Unicode characters are used to indicate direction (triangles) and sort
column order (superscript numbers).

See issue #1761
2019-03-28 15:05:27 +11:00
Martin Kleusberg
564d54ec5e Use cipher_default_* PRAGMAs when attaching an encrypted database
When attaching an SQLCipher encrypted database we need to set the page
size, KDF iterations, and HMAC and KDF algorithms. This needs to be done
before actually attaching the database but we tried to do it afterwards
which silently fails until the first statement is executed on the
attached database. This commit modifies the "default" values for these
pragmas in order to make sure SQLCipher uses the correct values right at
the beginning.

See issue #1799.
2019-03-25 18:49:19 +01:00
Martin Kleusberg
05cb45d1f7 Fix attaching an unencrypted database to an encrypted database
When opening a plain database and trying to attach an unencrypted
database we need to explicitly specify that there is no key for the
attached database. Otherwise SQLCipher is going to use the same key as
for the main database which results in an error.

See issue #1814.
2019-03-25 18:02:44 +01:00
mgrojo
217563fd47 Dialog and foreground configuration for conditional formats
A new dialog for editing conditional formats that can be invoked from the
filter line editor or from the data browser contextual menus. The dialog
allows adding and removing conditional formats, changing the priority order
and editing foreground colour, background colour and filter condition.

The conditional formats have been expanded to allow defining the foreground
colour. By default is the setting configured by user.

This is a continuation of the functionality introduced in PR #1503.
2019-03-23 22:14:18 +01:00
mgrojo
2d35206313 Remove syntax highlighting for tables when DB is closed
See issue #1800
2019-03-23 12:50:55 +01:00
Justin Clift
77a9dd394d Add the development docker CA chain 2019-03-21 22:48:28 +11:00
mgrojo
29bfcc4922 Add option for word wrapping in Edit Database Cell
A new option, in the toolbar of the Edit Database Cell, is added for
setting word wrapping for the text editor modes. It is now independent of
the SQL preference. The configuration reading the editor/wrap_lines setting
is moved to the particular SQL editor class.

Added icon from the Silk icon set.

See issue #1796
2019-03-17 19:23:02 +01:00
mgrojo
fa66937827 Highlight all the SQLite keywords and only those
Some SQLite keywords were not highlighted and QScintilla included a lot
of words that were not keywords for SQLite. This redefines the keyword
list for highlighting to match the list that we already prepare for
completion.

The list has been updated with some missing cases from the current SQLite
keyword list: https://www.sqlite.org/lang_keywords.html
2019-03-16 19:45:15 +01:00
mgrojo
780ff3f65d Proper SQL Execution behaviour when DB is closed
Remove completion for identifiers when closing DB.

Do not enable the execute SQL actions when the DB is closed.

See issue #1800
2019-03-16 16:38:18 +01:00
mgrojo
d4ef409711 Restore correct font after the Cell Edit dock is set to plain text
QScintilla seems to reset many settings when setLexer is called, so we
need to restore the font when switching from the lexer modes to the mode
without lexer (plain text).

See issue #1793.
2019-03-10 23:51:43 +01:00
mgrojo
3e92ec2b3b New argument for saving settings
Added new argument to command line for saving a value for a setting and
not only running it temporarily: -O/--save-option

Fix string lists settings so they are saved as an actual QStringList and
not a string. This assumes these settings are always named "*list".
Currently they, and only they, are.

Together with --quit, this argument allows saving the extensions/list and
other settings after an installation depending on options selected by user
in the installer. For example, running (Linux syntax):

./sqlitebrowser --save-option extensions/list=/path/to/libsqlitefunctions.so,/path/to/libsqlite-formats.so --quit

will save the two extensions to the preferences and they will be
automatically loaded every time DB4S is loaded.

See issue #1224 and PR #1716.
2019-03-10 13:42:41 +01:00
mgrojo
45c1e2abfd Drop the QTextEdit widget in the Edit Database Cell dock
Use the QScintilla widget for all the text modes of the Edit Database Cell
dock. All the features are believed to be preserved.

- The plain text mode is materialised removing the lexer.

- Null values are indicated now in the margin instead of using a
placeholder. The same pattern is also used for the Image and BLOB data
cases when the editor is switched to a text mode. In the dark mode, the
line number margin matches now the style-sheet and instead of the
configurable editor colours.

- Read-only state in the editor is hinted by the caret not blinking, but
the text is still selectable by keyboard or mouse.

Features and fixes added by using this widget:

- Find/Replace dialog for the plain text editor. See issue #1746
- The QScintilla widget does not strip CR characters. See issue #1793
- Line numbers and visible caret line in the text mode.
2019-03-10 01:01:07 +01:00
Martin Kleusberg
e59100f297 Use Niels Lohmann's JSON library instead of Qt's
Replace Qt's own JSON library functions by Niels Lohmann's JSON library
in the Export JSON dialog. This was necessary because for very large
JSON objects Qt's library functions generated incomplete JSON exports.

See issue #1789.
2019-03-08 12:26:17 +01:00
mgrojo
fc73ff4e5c Make clear we are counting characters and not bytes or C char(s)
Update translations with source texts.

Update en_GB translation to include plural forms (and some colour
instances+automatic removal of duplicate messages done by linguist).

See issue #1772
2019-03-08 00:02:44 +01:00
mgrojo
ef90d30cf1 Give appropriate compilation instruction for extension-formats
See PR #1716
2019-03-06 21:30:53 +01:00
apjarvis
c8318a17ec New extension for decoding base64 and plist data (#1716)
Added an SQLite extension for data format conversions with the current features:

* encode and decode of base64
* decode 'plist' data structures.

Decoding of base64 checks whether it is entirely ascii and if so create
a text object otherwise create a blob.

It can be loaded as an SQLite extension and be invoked via a custom
'Edit display format'. 

The extension provides the following SQL functions:
- plist
- unBase64
- toBase64
2019-03-06 20:43:53 +01:00
Martin Kleusberg
61e13aec03 Fix possible crash when sorted column does not exist anymore
When sorting a table or a view by a column, then removing enough columns
from that table, that view, or the underlying table of the view so that
the column index get out of bound, and then going back to browse that
table the application crashes. This commit makes sure to ignore such
columns which would cause a crash.

See issue #1774.
2019-03-06 12:01:39 +01:00
Cristian Lupascu
db17cd9e4f Add Insert for Views using AddRecordDialog (#141) 2019-03-06 11:13:56 +01:00
Scott Furry
caff4bd683 Supress libpng warning messages
Warning messages from libpng are printed when running SQLiteBrowser.
Messages state:

libpng warning: iCCP: known incorrect sRGB profile

Five messages are printed at once during execution and were isolated
to when preferences dialog was called. Problem was isolated to the
select flag images.

Opening ./src/translations/flags/{cn,de,fr,ru,us}.png images in GIMP
a warning about the iccp profile was produced. Profile was ID'd as:

sRGB IEC61966-2.1
IEC 61966-2.1 Default RGB colour space - sRGB
Manufacturer: IEC http://www.iec.ch
Copyright: Copyright (c) 1998 Hewlett-Packard Company

Opening ./images/sqlitebrowser.png image in GIMP also produced a
warning about the iccp profile. Profile was ID'd as:

HD 709-A
Copyright: Copyright Apple Computer, Inc., 2010

Pull Request corrects these images. Each affected image was run through
imagemagic convert command (convert <file.png> --strip <file.png>).

Images appear normal during program execution.
2019-03-04 19:48:57 -07:00
mgrojo
1b414b7e35 Avoid style-sheet inheritance in colour chooser boxes in Preferences
This avoid propagating the style-sheet to other widgets. For example, to
the tool-tip shown in the frame. But it could also fixed the problem
reported for Windows in issue #1493:
"Editing color preferences dialog background takes the last chosen color."
"Color dialog becomes obscured by the changing color patterns of each
selection."
2019-03-04 21:17:02 +01:00
mgrojo
e9d8af6059 Removed code for changing the default Qt behaviour for read-only+selectable
This code was added for #1123 but it isn't working well, some times the
read-only style is used when the cell is writable and vice versa. It has
also problems in the Dark Style mode.

So it is better to remove this code, the read-only characteristic is
hinted by the non-blinking caret. The same should be done for the
QScintilla editors, but it does not have such method.

See issue #1493
2019-03-04 20:42:53 +01:00
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