Commit Graph

2474 Commits

Author SHA1 Message Date
Martin Kleusberg
d16970d7c9 Replace foreach macro by range-based for loop 2018-09-05 22:53:00 +02:00
Martin Kleusberg
bf505edf66 Code refactoring
This commit refactors vast parts of the sqlitetypes.h interface. Its
main goals are: less code, easier code, a more modern interface, reduced
likelihood for strange errors and more flexibility for future
extensions.

The main reason why the sqlitetypes.h functions were working so well in
DB4S was not because they were that stable but because they were
extremely interlinked with the rest of the code. This is fine because we
do not plan to ship them as a separate library. But it makes it hard to
find the obvious spot to fix an issue or to put a new function. It can
always be done in the sqlitetypes function or in the rest of the DB4S
code because it is just not clear what the interface between the two
should look like. This is supposed to be improved by this commit. One
main thing here is to make ownership of objects a bit clearer.

In theory the new code should be faster too but that difference will be
neglectable from a user POV.

This commit also fixes a hidden bug which caused all table constraints
to be removed in the Edit Table dialog when a single field was removed
from the table.

This is all still WIP and more work is needed to be done here.
2018-09-05 22:24:46 +02:00
Martin Kleusberg
f3e6aec57d Load SQLite extensions earlier
In the Preferences dialog we allow the user to configure a list of
SQLite extensions which should be loaded whenever a new database file is
create or an existing database file is loaded. This commit changes the
order of actions after creating or opening a file so that the extensions
are loaded significantly earlier. This way they are already loaded for
most of the time during the process.

This fixes some subtle bugs. One of the more prominent ones was
triggered when there is a view which uses some function which is
defined in such an extension. After loading the file, parsing would fail
and you couldn't see the fields of the view. Browsing it would work but
trying to edit the display format crashed the application.
2018-09-04 22:06:12 +02:00
mgrojo
60195c78ed New shortcut key for copying cell value from above
Ctrl+' is used by spreadsheets for copying formula/value from the cell
above.

Our shortcut copies the value inside the inline editor when it is text.
That mimics the behaviour of LibreOffice Calc. For binary data that cannot
be edited inline, the BLOB is just copied from the above cell to the
current one.

See discussion in PR #1516.
2018-09-02 22:05:12 +02:00
Martin Kleusberg
effb4e0ac6 Fix typo
Thanks to @mgrojo for spotting this before any user or any translator
could see it.
2018-08-28 23:07:00 +02:00
Martin Kleusberg
4a3273b359 Add some PRAGMA which are only connection persistent to the project file
The temp_store, wal_autocheckpoint and synchronous PRAGMAs are only
stored for the current database connection but not saved in the database
file. So to fully restore the working environment after closing a
database, this commit adds these three PRAGMAs to the project file
format.

See issue #1518.
2018-08-28 21:45:43 +02:00
Martin Kleusberg
b94e988e2e Run VACUUM after changing the auto_vacuum PRAMGA
Changing the auto_vacuum PRAGMA requires us to run VACUUM most of the
time. So to be safe we just do that for every change to the PRAGMA now.

See issue #1518.
2018-08-28 21:33:28 +02:00
Martin Kleusberg
049d4ba76f Fix foreign key check after editing a table
After editing a table we perform a foreign key check to see if the
modifications caused any problems. This check doesn't seem to work
because it expected that in case of a problem the PRAGMA would fail.
This however isn't the case - it just doesn't return any results but it
doesn't fail. This commit fixes the check and only shows rolls back if
the PRAGMA returned any data.
2018-08-28 21:17:14 +02:00
Martin Kleusberg
406734a2c9 Defer foreign keys during SQL import
When importing an SQL file, defer foreign keys until the import is
finished. This is necessary if there are foreign key constraints in the
imported table and the order of the INSERT statements doesn't match the
hierarchy of the constraints.

Also perform an integrity check at the end of the import.

See issue #1519.
2018-08-28 21:14:09 +02:00
Martin Kleusberg
ee736eb2dd Show better error messages when executing SQL scripts
This commit fixed wrong error messages in the code we use whenever
multiple SQL statements are executed at once programmatically, most
noticeably in the SQL import. In the case of an error we would first
clean up and rollback and only then recover the error message which
usually would be lost by then. With the changes in this commit the first
thing we do is to recover the error message and only then clean up.

See issue #1519.
2018-08-27 22:36:02 +02:00
mgrojo
14106de34c Issue #1511: failed deletion in the DB still deletes the rows from model
If the deletion of a record is rejected by the SQLite3, for example, due to
the presence of Foreign Key constraints, the corresponding rows must not
be deleted from the model.
2018-08-27 21:47:09 +02:00
Manuel
ce032d95e6 Issue #530: constraints on table prevents new record being added (#1477)
* Issue #530: constraints on table prevents new record being added

This adds a new dialog for adding records to a table. The current approach
is broken for several cases where foreign keys and check constraints are
impeding the insertion of an empty record. With the dialog, the user can
inspect the constraints (tooltip) and type of fields and add values
consistent with the requirements. The data is only inserted when the user
presses the Save button.

The dialog is modelled after the Edit Table or Edit Index dialog. An upper
frame allows entering the data using widgets. The lower frame previews the
SQL statement that will be used.

The old approach for adding records is still accessible pressing Tab on
the last cell of the table.

* Fix build problem introduced in previous commit on this branch

* Dialog as fallback for failure after empty row insertion and read only text

The insertion of an empty row is always tried. When it fails due to
constraints and foreign keys, the Add Record Dialog is open so the user
can enter values for the new record considering the constraints.

When the table has not constraints, or the row insertion provides valid
values, the user is still able to insert rows using the simple approach.

SQL preview in dialog is now read-only.

* Visual improvements for the Add Record dialog

QLineEdit as item delegate for the value, so it is more visible that we
are supposed to edit the value.

Remove last end-of-line in tool-tip.

* Improvements in the "Add Record" dialog

Display of NULL values using DisplayRole (no focus) or place holder text
(when focus).

Set value to NULL through a context menu and shortcut in the value line
edit.

Take text type affinity into account for quoting or not entered numbers.
New isType and affinity functions in sqlitetypes.

Clarify wording of constraints in tooltip for value. Added the same tooltip
for the type.

Escape quotes inside string values.

Removed unused parameters warnings.

Other wording or code improvements based on the pull-request review: #1477.

* User access to the Add Record dialog

The Add Record dialog is now accessible for the user. The New Record button
is converted to a QToolButton and a new pop-up menu is added to it for
invoking the in-line table insertion (New Record) or the Add Record dialog
(Insert Values...). What's This information for the button updated.
2018-08-27 21:35:09 +02:00
Martin Kleusberg
d5a049062d Fix crash when browsing a view
This was introduced by 2b6153d9b8.
2018-08-21 20:28:58 +02:00
seigneurfuo
b7dbfc84c9 Add French translation to .desktop 2018-08-20 12:18:03 +01:00
Martin Kleusberg
c4109e6a10 Fix plot from disappearing when refreshing the view
The plot and all plot settings disappear when you click the Refresh
button in the Browse Data tab. This problem was introduced in the
multithreading patch.
2018-08-16 18:35:44 +02:00
Justin Clift
06363f8083 Retrieve the currentrelease file from our new download servers
In theory this should "just work", without any weirdness.  Only
one way to find out for sure though. :)
2018-08-13 01:18:16 +01:00
Martin Kleusberg
1a780ebddc Add menu item for our Patreon page
See issue #1425.
2018-08-12 22:25:02 +02:00
Martin Kleusberg
b717140fe9 Fix editing table with custom display formats set
Since PR #1436 we allow configuration of the identifier quotes instead
of always using backticks. But in the code for detecting a custom
display format on a column the assumption still was that normal columns
without a custom display format are always surrounded in backticks. The
result of this was that even if there is only a single display format
configured for a table, no field of no column can be edited anymore.
This commit restores the original state which would only disable editing
for the columns with a custom display format.
2018-08-12 14:07:53 +02:00
Martin Kleusberg
b219edbbfb Fix hidden columns being unhidden in Browse Data tab when sorting
This is required for Qt version < 5.10. For Qt versions >= 5.10 the
unhiding of all columns before rehiding the desired ones does nothing
because there the table view doesn't store its state anymore. And when
it does nothing we don't change the state of our view settings which in
turn triggers the mentioned problem.

See issue #1475.
2018-08-12 13:48:48 +02:00
Navdeep Singh Sidhu
96ca599479 Fix for snap package error "QXcbConnection: Could not connect to display :0" (#1501) 2018-08-11 00:58:33 +01:00
Justin Clift
d1a637bb33 Fix some trivial capitalisation problems in user visible strings 2018-08-10 23:42:37 +01:00
Navdeep Singh Sidhu
bfc261cfff Added CD (Continuous Deployment) snap packaging support (#1500)
* Added CD (Continuous Deployment) snap packaging support

* Added required files to create a snap package. Launchpad account will automate the build whenever code is committed to git repo

# What is a snap?

A snap :
* is a squashFS filesystem containing your app code and a snap.yaml file containing specific metadata. It has a read-only file-system and, once installed, a writable area.
* is self-contained. It bundles most of the libraries and run-times it needs and can be updated and reverted without affecting the rest of the system.
* is confined from the OS and other apps through security mechanisms, but can exchange content and functions with other snaps according to fine-grained policies controlled by the user and the OS defaults.

# Notes on improvements squashed into this PR

* Reduced the snap size by removing files from prime stage.
* Fixed typo in snap summary, thanks @justinclift for pointing out
* Reduced the size of snap package by removing big files from the package
* Added revno to the version script
* Added long description of snap package from deb package
* Borrowed some code from vlc snap script to fix fall back UI (need further research to fix issue)
* Added echo message to request users to report issues with snap package

Signed-off-by: Navdeep Singh Sidhu <deepsidhu1313@users.noreply.github.com>
2018-08-10 23:35:11 +01:00
Martin Kleusberg
060c406549 Include SQLite/SQLCipher and Qt version in bug report body 2018-08-10 19:18:00 +02:00
Martin Kleusberg
f3f6662978 Fix memory leak
This was introduced in 75e4c32bc4.
2018-08-10 19:17:59 +02:00
Martin Kleusberg
b28d0f63ec Show SQLite and SQLCipher version in About dialog when using SQLCipher
See issue #1474.
2018-08-10 19:17:59 +02:00
Justin Clift
a1c982c158 CentOS 7 provides CMake 2.8.12.2, so this commit moves the min version to that
For #1488.
2018-08-10 15:01:06 +01:00
Martin Kleusberg
c8899ec0c1 Avoid confusion in the About dialog about the SQLCipher version
SQLCipher reports in its SQLITE_VERSION macro the version of the
underlying SQLite version. Because we cannot easily get any other
version from SQLCipher and because the reported version is not identical
to the SQLCipher version we need to rephrase the wording in the dialog a
bit to keep the two versions separated.

See issue #1474.
2018-08-10 15:40:17 +02:00
Martin Kleusberg
75e4c32bc4 Don't use the SqliteTableModel class for querying row counts in export
When exporting a database to an SQL file we need to query the row count
of each table to calculate the progress later in the actual export. This
commit replaces the SqliteTableModel class which was used for this
purpose by a simple query function. This might be slightly faster here
but more importantly avoids a progress window being shown for each table
before finally seeing the one for the actual export.

See issue #1476.
2018-08-10 14:26:00 +02:00
Martin Kleusberg
2b6153d9b8 Fix browse table settings not being reapplied correctly
We have already fixed the rowid column from appearing after almost every
action in the Browse Data tab, for example in commit
39302f5b60.

This didn't fix every issue related to this problem though. Hidden
columns are shown too and modified column widths are reset. Also this
happens for different actions, for example the column widths are also
reset when sorting the view or when changing the filters. All these
problems are hopefully fixed by this commit.

See issue #1475.
2018-08-10 13:52:39 +02:00
mgrojo
d3d9d10ecd Untranslatable message in SQL Log 2018-08-09 22:23:16 +02:00
Martin Kleusberg
8a07f0e655 Change page_size PRAGMA from spin box to combo box
Change the control of the page_size PRAGMA from a spin box to a combo
box in the Edit Pragma tab. This makes sure no values are entered which
aren't a power of two. The same change was done in the Cipher dialog a
while ago for the same reasons.
2018-08-09 14:39:34 +02:00
Martin Kleusberg
8f7fc07604 Order PRAGMAs in the Edit Pragma tab alphabetically
Also add tab stops.
2018-08-09 14:16:34 +02:00
Martin Kleusberg
a23c0a0852 Fix PRAGMA view when loading a project file
When loading a project file which changes the foreign_keys or the
case_sensitive_like PRAGMAs while being in the Edit Pragma tab didn't
update the UI accordingly. Only after changing the tab and returning to
the Edit Pragma tab updated the controls.
2018-08-09 14:08:09 +02:00
Martin Kleusberg
c9d651c7b2 Add value of the case_sensitive_like PRAGMA to the project files
We allow the user to edit the case_senstive_like PRAGMA via the UI. But
because its state is not saved in the database - just like with the
foreign_key PRAGMA - we should save it in the project file for users who
want to restore the entire environment.
2018-08-09 14:04:47 +02:00
Manuel
4f1256cc5f Allow "getting" and setting case_sensitive_like pragma (#1494)
* Allow "getting" and setting case_sensitive_like pragma

In order to allow case insensitive filtering, the pragma
case_sensitive_like is added to the GUI. Given that this pragma cannot be
read, a special SELECT request is made in DBBrowserDB::getPragma for
inferring its value.

See issue #1489.

* Warning in the pragma case_sensitive_like

This pragma has some peculiarities, so it is convenient to warn the user
about it through a tool-tip in the value.
2018-08-09 14:00:21 +02:00
mgrojo
282e6739d9 Prevent data loss when editing table with foreign keys enabled
Our procedure for editing tables may involve a drop of the old table
definition. This will trigger the "ON DELETE CASCADE" clauses of the
child tables, leading to unexpected and silent data loss.

Following the procedure described in:
https://www.sqlite.org/lang_altertable.html
we can guarantee that no data is deleted, but at the cost of opening a
new transaction specific for the table modification. The possible pending
changes must be saved before. This is only done when the foreign_keys
pragma is enabled.

See issue #1481
2018-08-09 13:28:49 +02:00
mgrojo
7b660338ed Standard use of title case and ellipsis in menu actions
Menu actions that take the user to a dialog, where the action is completed
with some interaction and that could be cancelled, now have ellipsis.

Actions that only open an informative window do no longer have ellipsis.

Title case used in all menu entries.

See issue #1434
2018-08-09 12:45:41 +02:00
mgrojo
732c322181 Menu bar restructured so it follows a more standard layout
- Some actions not directly related to file operations over databases or
projects have been moved from "File" to a new "Tools" top-level menu entry.
Future tools can be added here.
- Preferences moved from "View" to "Edit" (MacOS is supposed to still have
it in the application menu).

See issue #1434
2018-08-09 12:45:41 +02:00
Martin Kleusberg
9a30e6cbb0 Don't translate PRAGMAs in the UI editor
This disables translation for PRAGMA names and values in the Edit Pragma
tab. The values must not be translated when using the current
implementation because they are used as shown for reading and writing
the PRAGMA values. The names could be translated but probably should not
be because they are more fixed name than description of their function.

See issue #1489.
2018-08-09 12:35:44 +02:00
Justin Clift
2f1a012933 Removing mailing list entry
The mailing list server will likely be offline for an extended period.
2018-08-08 14:24:09 +01:00
Manuel
d343a55286 Merge pull request #1473 from sqlitebrowser/filter_strings
Support for operator filters for strings
2018-08-08 14:39:02 +02:00
Martin Kleusberg
c46081c137 Fix typo in Readme 2018-08-08 14:01:20 +02:00
mgrojo
636136a775 Use official Qt translation for Shift key
The translation of key sequences must be empty or follow the official Qt
translated names, otherwise the key sequence is not recognised and it will
not work.

The official translation for Shift key is "May" (not "Mayús" or "Mayús.")

See possibly related issue #1491
2018-08-06 21:31:05 +02:00
mgrojo
b6f47f91de Use standard SQL quotes for string literals 2018-08-06 19:46:13 +02:00
mgrojo
f977534a1b Improper use of no-translation (notr) attribute
"Preview only (N/A)" must be translated
"toolBar1" although it's a window title it will never show up, so better
not request translation.
2018-08-06 19:24:46 +02:00
Martin Kleusberg
6db6a4d327 Add link to the Wiki to the Readme file
See issue #1464.
2018-08-05 16:32:54 +02:00
Martin Kleusberg
cdbed71905 Replace Patreon badge in Readme file
Use a shields.io image for the Patreon link for better consistency with
the other badges.
2018-08-05 16:26:26 +02:00
Martin Kleusberg
9a8f223b88 Add support for in-memory databases
Add a new menu option for opening an in-memory database. When working on
an in-memory database some menu options are disabled because they only
make sense when the database is also written to disk. I have left the
Write Changes button enabled though because for some actions the current
transaction needs to be committed - even though it's only committed to
memory then.

See issues #335 and #1492.
2018-08-05 15:45:50 +02:00
Martin Kleusberg
52de8c3099 Fix a crash when opening another database after adding some records
The application crashed for me when I opeend a database, then switched
to Browse Data tab, added some records there, then created a new empty
database.
2018-08-05 15:32:36 +02:00
mgrojo
aa82b52d5c Result of spell checker in Spanish translation
- Spelling errors fixed
- Mayús as proper translation for Shift key
- Fixed misinterpretation of "Displayed text"
2018-08-04 13:57:23 +02:00