Commit Graph

623 Commits

Author SHA1 Message Date
Martin Kleusberg
97d77d557b Fix build for Qt version < 5.6
This fixes 8a4e363483.
2019-07-26 15:34:01 +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
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
Martin Kleusberg
237b1fd9b8 Simplify code 2019-06-28 13:25:46 +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
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
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
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
Martin Kleusberg
64a596a887 Use even less Qt containers 2019-05-06 18:50:05 +02:00
Martin Kleusberg
40aff11086 Use even less Qt containers 2019-05-03 15:04:15 +02:00
Martin Kleusberg
b803e3c49f Use more STL containers instead of Qt containers 2019-05-02 17:02:59 +02:00
Martin Kleusberg
e16537dd9a Use emplace_back some more 2019-05-02 12:05:27 +02:00
Martin Kleusberg
f821fbb1a8 Silence a couple of warnings 2019-04-29 19:14:10 +02:00
Martin Kleusberg
15c23bb0d3 Use some more SQL containers instead of their Qt equivalents 2019-04-29 18:11:19 +02:00
Martin Kleusberg
f59a2453a2 Fix some warning and other code style changes 2019-04-26 14:48:24 +02:00
Scott Furry
5c1cf8a0a8 Resolve sign conversion warnings - prefetch preference
Resolve warnings that occur when building w/ ALL_WARNINGS enabled. Source tree
examined to enusre prefetch size is handled as type std::size_t. Also, tree was
modified correcting handling of the chunkSize variable in sqlitetablemodel that
uses the prefetch preference setting.

Also, some minor editing of sources was taken to improve readability
as well as consistency.
2019-04-25 15:51:25 +02:00
mgrojo
cb3ac2aa2a Prompt to save changes in project when closing DB or application
The following changes set the project as modified in order to ask to save
changes in project file when closing DB or application:

The main database file and any attached database file.
* PRAGMA values
* Show Row Id option
* Encoding
* Unlock View Primary Key option
* Sort columns and sort directions
* Column widths
* Applied Filters
* Display Formats
* Hidden columns

See issue #1706
2019-04-06 20:15:05 +02:00
mgrojo
9e6bd05f35 Avoid ambiguity for Ctrl+F in the Execute SQL tab
When the Ctrl+F was used in the Scintilla widgets of the SQL Log or Edit
Database Cell docks, the shortcut was ambiguous with the search find bar
action, which had window context. Now the later has widget context and a
new widget-context shortcut is explicitly connected to the action in the
editors of each new SQL tab.

See issue #1746
2019-04-05 20:54:09 +02:00
mgrojo
5ca95a57bc Find dialog based on the Find/Replace dialog for the Scintilla widgets
A new find dialog, bound to Ctrl+F, has been added to all the Scintilla
editors. The dialog is basically the Find/Replace dialog, whose replace
related controls have been set to invisible.

This shortcut and the new menu contextual entry are disabled for the
Execute SQL editors, since there the shortcut is already assigned to the
search bar and it would also be redundant.

See issue #1746
2019-04-04 23:49:35 +02:00
Martin Kleusberg
1aa7bbef87 Move code for opening and saving SQL files to the SqlExecutionArea
Move the code for opening and saving SQL files in the Execute SQL tab
from the main window to the SqlExecutionAtra class.

Also fix some warnings in the code for opening new SQL tabs.
2019-04-04 19:18:39 +02:00
Martin Kleusberg
fcac61da64 Simplify the WITHOUT ROWID code a bit
In the Table class we need to store whether this is a WITHOUT ROWID
table or now. Instead of just storing a boolean flag for that we were
storing a list of the rowid column(s). This is not just more complicated
to handle than a simple flag but also more error-prone because the list
must always be kept equal to the list of primary key columns. Failing to
keep them equal would result in an invalid SQL statement.
2019-04-03 12:19:53 +02:00
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
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
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
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
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
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
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
Cristian Lupascu
db17cd9e4f Add Insert for Views using AddRecordDialog (#141) 2019-03-06 11:13:56 +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
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
Cristian Lupascu
ff455c7038 Enable 'Edit Database Cell' when view is editable (#1756) 2019-02-25 19:38:54 +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
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
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
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
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
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
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
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