Commit Graph

3750 Commits

Author SHA1 Message Date
Martin Kleusberg
a78dd0292f Save some screen space and reduce number of unnecessary borders
This slightly changes the window layout of the main window and its
docks by a) removing or reducing the margins around some widgets and b)
changing the style of some widgets to flat i.e. removing borders around
them. Via these changes we save a little screen space which should
especially help on smaller screens and hopefully also make the window
layout easier to read by not having as many parallel border lines in
some docks.
2022-08-07 18:26:45 +02:00
mgrojo
fb43e0677a Project files: prevent SQL tabs loss while closing the application
When a project file is loaded, changes are made, and the event close is
triggered, we lose the SQL file contents, because the project file is saved
when the tabs are close. Now the order is reversed, so the project saving
catches the correct state.

See issue #3007
2022-07-31 17:43:49 +02:00
mgrojo
0280d98a8f sqlite3 API: Prevent that busy DB are left open
If we follow the steps described in
https://github.com/sqlitebrowser/sqlitebrowser/issues/2910#issuecomment-1186259390
we get this warning:
"Database didn't close correctly, probably still busy"

The error has not been prevented, but by using sqlite3_close_v2 instead
of sqlite3_close, we can assure that the connection is eventually released.
2022-07-31 17:43:49 +02:00
mgrojo
f324729782 Project files: fix crash when tables does not match DB file
There are project files with settings saved for a table with empty schema
and name.

We let the user load a new DB file when the one referenced by the project
is not found, opening the door to load a DB with a different structure.

A final case for this inconsistencies can be that we let the user cancel
the opening dialog, and the project can be opened without a DB file.

See issue #3007
2022-07-31 17:43:49 +02:00
Martin Kleusberg
13b15ddc64 parser: Refactor parsing and handling of constraints
This commit refactors the handling of constraints and continues the work
started in 43107ea773. Instead of heavily
relying on runtime polymorphism with these changes we move towards more
compile-time polymorphism. Noticeable the constraint data types do not
have a type function any longer; instead they are differentiated by
their actual data type.

This has several benefits:
- More likely to catch errors at compile-time and therefore avoid them
  at runtime.
- The program runs faster. This should be most noticeable for databases
  with a very large amount of tables or other database objects.
- The code should be easier to read and maintain.

Additionally this should also prepare for even more refactoring in the
future.
2022-07-24 17:45:37 +02:00
Martin Kleusberg
dd62577818 Refactor the constraints tab in the Edit Table dialog
After moving both foreign keys and check constraints to different tabs
in the Edit Table dialog, the previous constraints tab now only shows
primary keys and unique constraints. To accomodate for this reduced
feature set, this commit renames their internal names and uses a
narrower data type for handling the constraints.
2022-07-24 14:22:14 +02:00
Martin Kleusberg
54d82eab44 Add an extra tab for editing check constraints to the Edit Table dialog
Just like before in 53b5493f2e which added
an extra tab for foreign keys, this adds an extra tab for editing check
constraints in the Edit Table dialog. Again, this makes the UI easier to
navigate and adds support for editing of check constraints to the
dialog.
2022-07-24 14:03:19 +02:00
Martin Kleusberg
53b5493f2e Add an extra tab for editing foreign keys to the Edit Table dialog
In the Edit Table dialog we had two separate tabs, one for table fields
and one for table constraints. The table constraints tab showed primary
keys, unique constraint, foreign keys, and some check constraints and at
least to some extent allows editing them.

This commit moves the foreign keys to a new third tab. Even though this
adds extra UI elements I feel like this might simplify finding and
editing exactly the items you are looking for and leads to a clearer UI.

This also adds support for fully editing foreign keys in the new tab.
Previously the references table and columns could not be edited in the
constraints tab. The only feature these changes remove is converting
other constraints to or from foreign keys which again simplifies the UI
and makes it less error-prone because this is not really a meaningful
thing to do.
2022-07-24 13:13:31 +02:00
Martin Kleusberg
6356e5dea2 Fix minor warnings by cppcheck 2022-07-23 21:14:04 +02:00
Martin Kleusberg
5c57622f58 parser: Add support for IS (NOT) DISTINCT FROM expressions
SQLite 3.39.0 introduced expressions of these forms:
expr IS DISTINCT FROM expr
expr IS NOT DISTINCT FROM expr

Since these can be used in indexes and check expression, we need need to
add support for these expressions to the SQL parser.
2022-07-23 18:26:31 +02:00
Manuel
b01a201569 Merge pull request #3068 from longnguyen2004/master
Refactor CMakeLists, targetify everything
2022-07-21 20:04:05 +02:00
mgrojo
2e39408f09 Associate copy table column menu entry to action.
This is a fix for PR #3051.

See issue #3059.
2022-07-08 22:23:46 +02:00
Manuel
bb6f633560 Merge pull request #3051 from ImTheTom/copy-column-name
Add copy column name action to data browser.
2022-06-28 22:15:51 +02:00
mgrojo
a1f6d2c7ea Fixes for hiding the title bar of the single Table Browser
- Do not hide the title bar if the dock is floating when the second one is
closed.

- Fix the number of docs for hiding the title bar when it is opened.

Related to issue #2283.
2022-06-27 00:01:26 +02:00
mgrojo
c40fb07b87 Do not show the titlebar for the Table Browser dock when there is only one
This saves space and avoids redundancy in the different places where the
table name appears.

A new toolbar button for adding a new dock is included, so the
functionality is still visible (it might be more discoverable now, indeed).

Related to issue #2283.

See comment in:
 https://github.com/sqlitebrowser/sqlitebrowser/issues/2918#issuecomment-1003108299
2022-06-25 01:11:16 +02:00
mgrojo
f18611ae17 Change mouse cursor to the pointing hand when Ctrl+Shift are pressed
This will make the functionality of opening a URL or foreign key more
visible.

See comment in:
 https://github.com/sqlitebrowser/sqlitebrowser/issues/3057#issuecomment-1165841123
2022-06-25 01:06:52 +02:00
mgrojo
8bb16d1dd0 DB Schema: drag & drop SELECT queries
New check option in the contextual menu of the DB schema dock to allow
drag & drop of SELECT queries, provided that only a table or fields of
the same table are dragged from the DB Schema tree.
2022-06-20 17:40:24 +02:00
mgrojo
f5e074528d Fix possible crash when opening a project without SQL tabs
If there is no SQL tab in the project (cannot reproduce that any longer,
only after manual editing of the project file), the first query and
selection of a column index greater than the number of columns in the
default table browsed in the Data Browser will cause a crash, because
m_currentTabTableModel will still be associated to the table in the
Data Browser main tab.
2022-06-20 13:21:15 +02:00
mgrojo
8f5c17e2a7 Edit Database Cell: fixed potential for data loss and better feedback
Remaining detected case for a potential data loss in the cell editor have
been fixed:
- Switching to another main tab.
- Start a filter.

In both cases a dialog for saving or discarding is open.

Additionally, the cell editor shows the cell coordinates currently open.
And the NULL text in margin is reset when the user types in the editor.

See issue #2488
2022-06-19 23:52:15 +02:00
mgrojo
974954f1a1 Plot Dock: use more precision for small numbers and less for big numbers
See issue #2498
2022-06-17 20:12:28 +02:00
Justin Clift
00d258f5fa Merge pull request #3071 from eltociear/patch-1
fix typo in extension-functions.c
2022-06-17 20:52:30 +10:00
Ikko Ashimine
27f5fede84 fix typo in extension-functions.c
begining -> beginning
2022-06-17 18:46:06 +09:00
mgrojo
13b372caa3 Fix repositioning of filter widgets after the second click on the header
This happened only for the custom dark/light styles.

The new connects fixes the issue for me. This was discovered by trial and
error, because I don't know what is really causing the problem (seems
some bug relating with event ordering and maybe a race condition).

Second change is irrelevant for the issue, just for optimization of the
loop.

See comment:
https://github.com/sqlitebrowser/sqlitebrowser/issues/2558#issuecomment-1003773910
2022-06-15 21:28:58 +02:00
Long Nguyen
cdb6b35a53 Always link libdl 2022-06-12 11:27:11 +07:00
Long Nguyen
9e9df7cc87 Properly build static-only SQLite 2022-06-12 11:05:23 +07:00
Long Nguyen
5fcf2a5066 Update comment 2022-06-12 11:03:30 +07:00
Long Nguyen
1dd16017a7 Stop adding /usr/local/lib, CMake already adds it by itself 2022-06-12 10:40:20 +07:00
Long Nguyen
471ca89d24 Remove LOCAL_SQLITE, it's not actually needed 2022-06-12 10:38:26 +07:00
Long Nguyen
18de6db149 Refactor CMakeLists, targetify everything 2022-06-12 10:26:21 +07:00
Martin Kleusberg
179d8c5280 cmake: Add a compile time option to statically link the SQLite library
Also use this option in the AppImage workflow to make sure to actually
include the intended version of SQLite.

Note this probably only works fine on Unix-like systems.
2022-06-11 18:02:37 +02:00
Justin Clift
158e32b84e Merge pull request #3067 from atriwidada/master
typo fix
2022-06-11 15:20:56 +10:00
Andika Triwidada
6f21c2a56a typo fix 2022-06-11 11:25:56 +07:00
Justin Clift
21aef5218c Merge pull request #3001 from Biswa96/windres-fix
Fix resource compilation for mingw
2022-06-11 12:11:36 +10:00
Martin Kleusberg
738ecd6feb AppImage: Link against locally built SQLite library 2022-06-10 19:20:02 +02:00
Martin Kleusberg
cc58853b3a build: Add cmake option for using custom built SQLite library 2022-06-10 19:18:04 +02:00
Martin Kleusberg
0ab1cd45ea build: Remove Travis file
Remove the remaining travis.yml file as it is not used any longer.
2022-06-10 18:27:28 +02:00
Łukasz Wojniłowicz
957de60519 Update Polish translation 2022-06-10 14:31:12 +02:00
Werner Mollentze
345750dff3 Updated the packages to build on Ubuntu / Debian
Updated the required package list to build successfully on recent Ubuntu / Debian versions - `qt5-default` was removed in the `qtbase-opensource-src` source package in Debian's version `5.15.1+dfsg-2`.
2022-06-10 14:23:23 +02:00
Martin Kleusberg
f068c2a466 AppImage: Build own version of SQLite to have a more recent version
This downloads and build SQLite from source, currently using version
3.38.5, for building the AppImage file. This way we can include a more
recent version of SQLite instead of shipping the version from Ubuntu
20.04.

See issue #3064.
2022-06-10 14:17:54 +02:00
Martin Kleusberg
e655658597 Respect the sqlite_sequence table when generating PK value for new rows
If there is a record in the sqlite_sequence table for a table we want to
insert into, use that sequence value to generate the next primary key
instead of using the maximum value plus one.

See issue #3026.
2022-06-10 13:38:19 +02:00
Martin Kleusberg
594aa02088 parser: Fix string literals used as column ids in indexed columns
This fixes indexed columns as e.g. used in primary key constraints which
are quoted using single quotes. Because you would never index a string
literal it is safe to assume that text in single quotes actually is a
column identifier.

See issue #3047.
2022-06-05 16:00:58 +02:00
Martin Kleusberg
42c5de7234 Use a separate enum for table constraint types in the Edit Table dialog
This adds a enum of table constraint types to the Edit Table dialog
instead of reusing the enum provided by the sqlb::Constraint class. This
way changes to the sqlb namespace do not affect the Edit Table dialog as
much and in the long term I would like to get rid of the enum in the
sqlb::Constraint class anyway.
2022-06-05 15:21:47 +02:00
Tom Bowyer
32c99f0f4d Add copy column name to table viewer 2022-05-30 16:36:50 +10:00
Justin Clift
a14e6eb607 Merge pull request #3034 from Mailaender/patch-1
Added version 3.12.2
2022-05-09 02:12:22 +10:00
Matthias Mailänder
b9f4f2be65 Add version 3.12.2 2022-05-08 11:22:23 +02:00
Biswapriyo Nath
638948ed77 Fix resource compilation for mingw
* Include CMAKE_CURRENT_BINARY_DIR for version.h file in winapp.rc.
  Because version.h is now generated by cmake and put in build dir.
* Quote default BUILD_VERSION value, else windres shows syntax error.
2022-04-01 00:30:50 +05:30
Martin Kleusberg
43107ea773 Refactor data structures for table constraints
This is a long overdue continuation of some previous refactoring effort.
Before this we used to store the columns a table constraint belongs to
within the constraint object itself. So for example, a foreign key
constraint object would store the referencing as well as the referenced
column names. While initially simple, this approach has the downside of
duplicating certain data, thus breaking ownership and complicating
matters later on. This becomes obvious when renaming the referencing
column. The column name clearly is a feature of the table but in the
previous approach it also needs to be changed in the foreign key object
as well as in any other constraint for this field even though the
constraint itself has not been touched. This illustrates how a
constraint is not only a property of a table but the field names (a
property of the table) are also a property of the constraint, creating a
circular ownership. This makes the code hard to maintain. It also
invalidates references to constraints in the program needlessly, e.g.
when only changing a column name.

With this commit the column names are removed from the constraint types.
Instead they are now solely a property of the table. This, however,
raised another issue. For unique constraints and primary keys it is
possible to use expressions and/or sorted keys whereas for foreign keys
this is not possible. Additionally check constraints have no columns at
all. So when not storing the used columns inside the constraint objects
we need to have different storage types for each of them. So in a second
step this commit moves the code from a single data structure for storing
all table constraints to three data structures, one for PK and unique,
one for foreign keys, and one for check constraints.

By doing all this, this commit also changes the interface for handling
quite a bit. The new interface tends to use more explicit types which
makes the usage code easier to read.

Please note that this is still far from finished. But future development
on this should be a lot easier now.
2022-03-24 21:37:43 +01:00
Nikolay Zlatev
e55fed2473 SqliteTableModel::headerData skip FontRole for Vertical orientation
This is a performance optimization for TableBrowser

For more info look b6c5024de0
2022-03-22 15:27:07 +02:00
Nikolay Zlatev
18e6a6f703 Icon cleanup
Clean some bad (deprecated) SVG properties, so Qt stop complaints

:/icons/foreground_color:1:1594: Could not parse node: radialGradient
:/icons/foreground_color:1:2684: Could not resolve property: #h
:/icons/background_color:61:31: Could not parse node: radialGradient
:/icons/background_color:86:6: Could not resolve property: #white
2022-03-22 14:11:23 +02:00
Nikolay Zlatev
ad370f693d MainWindow: SqliteTableModel::finishedFetch skip callback for chunk load
Now SqliteTableModel::finishedFetch is active only for row count.
SqlExecutionArea should display proper value for "row count", not
"Prefetch Block Size" when "actual row count" > "Prefetch Block Size"

This should fix #2595
2022-03-22 13:09:15 +02:00