Commit Graph

2255 Commits

Author SHA1 Message Date
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
Martin Kleusberg
05e2defe33 Add possibility to change the type of table constraints in Edit Table
Enable the combo box in the Edit Table dialog to change the type of a
table constraint and add the code to try to transform a constraint from
one type into another as best as possible.
2019-07-28 22:33:36 +02:00
Martin Kleusberg
cb694dd2c6 grammar: Change the way the table constraints are stored
This changes the way we store the constraints associated with a table
from using a map to using a set. The map was mapping from the list of
field names to the constraint applied on these fields. Now the field
list is stored inside the constraint and we can store the constraints in
a simple set. This turns out to simplify the code noticeably.
2019-07-28 14:52:03 +02:00
Martin Kleusberg
9d654a19ba Support modifying the column list of a constraint in Edit Table dialog
This adds support for modifying the columns a constraint is applied on
in the Constraints tab of the Edit Table dialog. This is a major step
towards full constraint editing capabilities (adding new constraints,
modifying constraint type, and editing constraint type-dependent
parameters are the other missing pieces).

The reasoning behind the popup dialog is to not introduce another full
dialog on top of the Edit Table dialog. After opening the Edit Table
dialog, then switching to the Constraints tab, then opening another
modal dialog, I felt like losing track of what I am currently editing.
The popup dialog is certainly not great but feels a bit less intrusive.
Any suggestions regarding this are appreciated.
2019-07-27 18:26:01 +02:00
Martin Kleusberg
3f60142abc Support deleting table constraints in Edit Table dialog
This adds support for deleting table constraints in the Edit Table
dialog.
2019-07-27 12:36:46 +02:00
mgrojo
48a8481b85 Allow using extended regular expressions in the find dialogs
This adds support for searching "this|that" to find either "this" or "that"
or using quantifiers like "{number}". The change applies to the
Find/Replace dialog and the search bar.

See https://en.cppreference.com/w/cpp/regex/ecmascript for details of the
syntax.

This raises the requirement for an external version of QScintilla to v2.11.

See issue #1625
2019-07-26 19:47:02 +02:00
Martin Kleusberg
cd748d07ab Support changing constraint names in the Edit Table dialog
This adds support for changing the names of existing constraints in the
Edit Table dialog. It should be possible to extend the code to allow
further modifications of the constraints.

As a minor change, this commit makes the SQL column of the constraints
table read only.
2019-07-26 18:44:34 +02:00
Martin Kleusberg
335999e4bd Remember read-only flag for recent files list
When opening a file in read-only mode, remember that read-only flag when
adding it to the list of recently opened files. The next time it is
opened it will be again in read-only mode.

The way this is implemented (by adding a "[ro]" to the start of the path
to indicate when to open in read-only mode) was chosen in order to be
fully backwards compatible with the previous data format for the file
list.

See issue #1913.
2019-07-26 16:22:28 +02:00
Martin Kleusberg
97d77d557b Fix build for Qt version < 5.6
This fixes 8a4e363483.
2019-07-26 15:34:01 +02:00
Martin Kleusberg
b32351e7b6 Try to avoid automatic column resizing in Browse Data tab
See issue #1941.
2019-07-26 15:10:32 +02:00
Martin Kleusberg
8a4e363483 Add "Browse Table" action to the context menu of the DB Structure dock
Add a "Browse Table" action to the right-click menu of the table and
view items in the Database Structure dock.

See issue #1943.
2019-07-26 14:51:26 +02:00
Martin Kleusberg
6cfac1b0f1 Fix right click action "Browse Table" for tables with whitespace
Fix a crash when using the "Browse Table" action in the right click menu
in the Database Structure tab. It crashed whenever the table name or the
schema name started or ended with a space character.
2019-07-26 14:26:00 +02:00
Martin Kleusberg
ec4e0dc5cc Don't treat numbers as JSON data in Edit Cell dialog
When detecting the data type in the Edit Cell dialog, don't treat
simple numbers as a JSON document. They should be handled as text
instead.

Thanks to @mgrojo for pointing this out here.
d344f396b2 (r34132706)
2019-07-26 14:18:53 +02:00
mgrojo
9fe529752b Allow to change sort order for any column in the multi-column sort list
A second Ctrl+Click over an already added column changes the direction of
any column.

Before this change, the effect was only applied to the last selected column
and a second Ctrl+Click on the other columns triggered a requery without
having changed anything.

This was mentioned in PR #1810. See also issue #1761.
2019-07-13 17:42:50 +02:00
mgrojo
592fa91e25 New function for detecting mixed RTL-LTR texts
Qt's isRightToLeft() returns true only for all left-to-right characters
in the string. That prevents the automatic switch to LTR Text mode, when
the text contains one or more left-to-right characters.

See #1793 and #1929
2019-07-11 22:10:24 +02:00
mgrojo
5e965b1a20 Restore QTextEdit widget for RTL text in the Cell Editor
This restores the Qt text widget that was replaced by a QScintilla one in
45c1e2abfd

QScintilla does not support right-to-left scripts like Arabic, so QTextEdit
is still needed for these languages. Since the QScintilla editor has other
advantages already explained, it is preserved for general text edition.

RTL texts are detected when data is loaded and the Qt editor is
automatically selected. This is done both when loading data from the cell
and when interactively typing RTL characters in the Cell Editor.

All these changes can be undone if a new QScintilla editor supports RTL
texts.

See comments in issue #1793
2019-07-11 22:10:24 +02:00
GortiZ
786fac033a Updated Italian translation (#1931)
* [CHG] Updated italian translations
2019-07-10 21:05:27 +02:00
Martin Kleusberg
9594115ef3 Send the fetched signal in RowLoader even when no rows where fetched
Always send the fetched() signal when a RowLoader thread has finished a
fetch task. Before this the signal was only sent when some data was
actually retrieved from the task. This fixes some rare problems in the
Execute SQL tab where the query for determining the row count of a
SELECT statement changes something, so the subsequent row loading task
does not return any rows after all.

The only case I know of is when loading an extension using the
'SELECT load_extension()' function. The load_extension function is
actually called twice when SQLite for some reason reports that rows
where returned from this statement. These calls are:
SELECT COUNT(*) FROM (SELECT load_extension('...'));
SELECT load_extension('...');
After the first call is executed, the extension is loaded. So the second
call does not return any rows and we indefinitely wait for the rows we
expect. Strangely enough this only happens for some extensions.

The change here should have no side effects becaue the signal is only
connected to one slot which skips most steps when no rows where fetched.

See issue #1932.
2019-07-06 23:05:57 +02:00
Martin Kleusberg
b17755c46a Only register error log callback once at start of application
Instead of registering the error log callback function every time a
database file is opened, we now register it only once when the
application is first started. This way we can avoid calling
sqlite_shutdown which can have unintended side effects.

See issue #1932.
2019-07-05 22:13:46 +02:00
Martin Kleusberg
5589bd9da4 Speed up the loading of the database structure
While testing the original database from issue #1892 which contains
hundreds of tables and fields, I noticed how long the loading of the
database structure takes. This is especially problematic since it needs
to be reloaded on various occasions, e.g. running most statements in the
Execute SQL tab, which stalls the application every time.

According to a profiler it is the QIcon constructor which requires most
of the time. By introducing this small icon cache class we can reduce
the time for loading icons to almost nothing.

While still not perfect the UI already feels much more responsive with
this patch.
2019-06-28 14:58:50 +02:00
Martin Kleusberg
237b1fd9b8 Simplify code 2019-06-28 13:25:46 +02:00
Mercury233
028242160f minor fix zh-cn translation 2019-06-17 00:24:17 +08:00
Martin Kleusberg
ccae4af6d1 Fix off-by-one error 2019-06-13 16:12:47 +02:00
Scott Furry
cf05e7a462 Centralize File Filter and Resolve End CSV Import Message
Matter came up WRT #1880. In reviewing, several other instances
were found where same file filter as a string literal was repreated.
This commit centralizes	these file filters to one location. Filters
are declared `static const` to prevent accidental modification.

Also applied is a fix to #1881. QMessage at end of Import CSV is removed.
2019-05-29 15:54:27 +02:00
mgrojo
09944739cc Log transaction and savepoints statements executed by application
These statements have implications for the user, so it is better to log
them.

See #1859 and #1901
2019-05-29 15:37:23 +02:00
mgrojo
1df647b0df Fix copy-paste-edit error in SqlExecutionArea::saveState()
The error was introduced in 59b55ac436

Indentation level also fixed.

Thanks to @scottfurry for pointing this out. See issue #1889.
2019-05-19 19:41:27 +02:00
mgrojo
512f7eeeab Save splitter sizes of the Execute SQL areas to disk under request
Saving cannot be done in the class destructor, since it seems that the
sizes have already change in that moment. Now they are saved under request
of the Main Window at the same time when the Main Window state is saved.

See issue #1889.
2019-05-19 13:45:56 +02:00
mgrojo
59b55ac436 Save splitter sizes in the Execute SQL areas
Whenever the splitters between the SQL editor, the table result and the
last execution results panes are moved, the sizes are saved to memory (for
performance) so the next SQL tab to be opened restores them. When an area
is destroyed the last saved settings are saved to disk, so they are ready
for the next execution without much impact in disk utilisation.

Issue #1889
2019-05-17 23:18:00 +02:00
mgrojo
30d0b183a5 Fix crash when opening project file
When opening a project file the following exception is raised in
src/sqlitedb.h:208

terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

This is related to 64a596a887
2019-05-12 00:15:35 +02:00
Martin Kleusberg
6bbf401abd Fix build for Qt < 5.10 2019-05-11 16:28:48 +02:00
Martin Kleusberg
e2f3186d19 Fix saving/restoring of settings in Import CSV dialog
Saving and restoring of quote and separator characters did not work as
expected in the Import CSV dialog since the last commits. A missing
"else" made us try to save the string "Other" as the quote character
when a custom quote character was selected. Also the translation from
and to the saved format on disk had its problems.

See issue #1860.
2019-05-11 16:10:31 +02:00
Martin Kleusberg
2d12330783 dbhub: Set window title of new Proxy dialog
Forgot that in the last commit.
2019-05-09 15:25:10 +02:00
Martin Kleusberg
38ece2ea42 dbhub: Add proxy configuration support
This adds a new dialog, accessible from the Remote tab in the Preferences
Dialog, which allows the user to configure the proxy to use for all
network connections.

The new default is to use the system-wide proxy settings.

See issue #979.
2019-05-09 15:11:44 +02:00
Martin Kleusberg
4cf6cb7c2a dbhub: Set last modified date of file during initial cloning
The dbhub.io server provides us the last modified date of the database
when cloning it. Because we send the last modified date back to the
server when trying to push a database, it makes sense to initially set
the last modified date of the local file to the date provided by the
server.

See issue https://github.com/sqlitebrowser/dbhub.io/issues/101.
2019-05-09 13:50:39 +02:00
Martin Kleusberg
afee3ca79e Support more field separators and quote chars in the CSV import
This adds support for more characters as field separator and for quoting
in the CSV import. Before this we only supported ASCII characters, with
this we support all characters which when UTF-8 encoded require up to
16 bits.

See issue #1860.
2019-05-08 23:54:06 +02:00
Martin Kleusberg
cec6b82561 Fix loading of last used settings in Import CSV dialog
Fix the loading of the last used import settings in the Import CSV
dialog when the "Other" option has been used in one of the dropdown
boxes.
2019-05-07 23:16:09 +02:00
mgrojo
c70a1fc56f Close version range to apply workaround for QTBUG-73721
It appeared in Qt version 5.12.0 and it is supposed to be fixed in 5.12.3.

See issue #1658
2019-05-07 22:52:52 +02:00
Martin Kleusberg
d1621e31b8 Fix qmake build 2019-05-07 22:17:27 +02:00
Scott Furry
f877f8a10c Resolve Github Issue #1867 - Spurious Empty Filename message.
Problem traced to QFile::exist() producing message when passed an empty QString.
Fix is to test QString length before any QFile::exist() usage with that string.
2019-05-07 22:14:13 +02:00
Scott Furry
d54b820fb2 Shadowed Variable Warnings (#1864)
Compile with ALL_WARNINGS using GCC 8.2.1.
Encountered approximately dozen warnings with this pattern:

    [path to sqlitebrowser root]/src/[somesourcefile]:line:cursor: warning: declaration
	of ‘data’ shadows a member of ‘ClassName’ [-Wshadow]
            OtherDataType data = ....line of code at line given above...
                          ^~~~
    In file included from /usr/include/qt5/QtWidgets/qdialog.h:44,
                     from /usr/include/qt5/QtWidgets/QDialog:1,
                     ...other sources in project
    /usr/include/qt5/QtWidgets/qwidget.h:733:18: note: shadowed declaration is here
         QWidgetData *data;
                      ^~~~

It appears there is a variable named 'data' within Qt global scope. Using 'data`
as a variable name, even one limited in scope to small lamda expressions, causes
compiler some grief.

Commit resolves the warnings in affected files. No problems apparent during execution.
Requires CSV stress-testing.
2019-05-07 22:09:21 +02:00
Scott Furry
800a8daf11 Normalize qhexedit.h include path
Include path used for QHexEdit in EditDialog.cpp is "implementation specific"
to how DB4S uses the QHexEdit library. Change is to make usage of library
more generic.
2019-05-07 21:56:06 +02:00
Martin Kleusberg
c61e172afe Attempt to fix the build on some platforms - again
See issue #1879.
2019-05-07 21:53:09 +02:00
Martin Kleusberg
64a596a887 Use even less Qt containers 2019-05-06 18:50:05 +02:00
Martin Kleusberg
37aaa4c7f2 Avoid using std::regex for now
It turned out that on some platforms we still aim to support the stdlib
had not yet implemented std::regex. For this reason we want to avoid
using it for now.

In the particular use cases here it was also not the best solution. It
was faster to write using a regular expression instead of a hand coded
loop but clearly a simple loop should be more efficient here.

See issue #1873.
2019-05-05 15:35:50 +02:00
Martin Kleusberg
d87f253940 Attempt to fix build error on some platforms
See issue #1873.
2019-05-03 17:59:11 +02:00
Martin Kleusberg
16768d5474 dbhub: Respect the order of the licence list and remove "Unspecified"
Respect the suggested order of the licences as provided by the dbhub.io
server instead of sorting them alphabetically by their internal key.

Also remove the hard-coded "Unspecified" licence option because the
dbhub.io server provided its own "No licence specified" option.
2019-05-03 15:28:02 +02:00
Martin Kleusberg
5e90d90ac6 Replace all typedefs by usings
This is just a matter of code style, no functional change whatsoever.
2019-05-03 15:06:48 +02:00
Martin Kleusberg
40aff11086 Use even less Qt containers 2019-05-03 15:04:15 +02:00
Martin Kleusberg
b70e25c786 dbhub: Add a built-in certificate for read-only access to dbhub.io
This adds a built-in, default certificate which enables read-only access
to dbhub.io. This should make it easier to try out the remote features.
When trying to open the Push Database dialog, a message with more
details and all required links is displayed.
2019-05-03 13:27:07 +02:00