Commit Graph

462 Commits

Author SHA1 Message Date
Martin Kleusberg
ee32b3e4e1 Use nullptr where possible 2017-10-30 21:20:02 +01:00
Martin Kleusberg
1ca92cdde3 Use our Settings class everywhere
Don't use the QSettings class directly. This keeps the code more
consistent and makes it a bit easier to read. It also means that all
parts of the code profit from the settings cache that we have
implemented in the Settings class.
2017-10-30 13:37:34 +01:00
Martin Kleusberg
3bd2dc3bc1 Replace 'foreach' by range-based for loop from C++11 2017-10-30 13:10:08 +01:00
Martin Kleusberg
18b781495c Simplify code 2017-10-27 18:36:39 +02:00
Martin Kleusberg
955848f957 Improve detection of query vs. modify statements in Execute SQL tab
This should improve the detection of read-only query statements vs.
modifiying statements in the Execute SQL tab. The idea is to stop
looking for the SELECT keyword at the beginning of the statement and
instead fully rely on whether SQLite returns any data for this
statement.

See issue #1185.
2017-10-27 18:36:39 +02:00
Martin Kleusberg
b9595b9b7e Remove the valid flag from the SqliteTableModel class
Remove the valid flag from the SqliteTableModel class and remove its
usage in the Execute SQL tab of the main window. I believe this hasn't
been used for some time now because the main sources of error should
really be noticed before the query is even handed over to the model.
Additionally the valid flag wasn't as realible either anymore because of
the multi-threaded execution of the model queries.
2017-10-27 18:36:39 +02:00
mgrojo
9fd4ebe0e0 Fixed crashed when editing the display format and the currently browsed table name is actually a view.
Now it is checked the object type before the cast. This avoids the crash and the field name is obtained for each case.
2017-10-27 11:50:38 +02:00
Martin Kleusberg
c69314f566 Fix ampersand not showing up in dialog when renaming SQL tabs
This didn't work on Windows as pointed out by Chris Locke.
2017-10-27 11:30:59 +02:00
Martin Kleusberg
66fa44497d Try to fix build on Windows
See issue #1193.
2017-10-26 23:24:04 +02:00
Martin Kleusberg
bc91126b2c Allow renaming SQL tabs by double clicking them
See issue #1186.
2017-10-22 14:08:52 +02:00
Martin Kleusberg
37e5b62842 Make code easier to read 2017-10-20 17:47:04 +02:00
Martin Kleusberg
32da4de94d Fix collate warning after addition of multi-threaded loading
The no collate function warning is triggered in a thread which is used
for loading data. However, the warning is a message box and GUI elements
can only be drawn in the main thread. So the old code would crash. This
is fixed here by jumping to the main thread for showing the message box.
2017-10-16 21:58:30 +02:00
Martin Kleusberg
973f97c1eb Move row count query into a separate thread
In the SqliteTableModel class we need to know the total number of rows
in the table or returned by the query. This takes a considerable amount
of time and can be moved into a separate thread. I haven't done any
performance measurements with this but it might speed up switching
between large tables a bit.
2017-10-15 11:46:47 +02:00
kehugter
c4c4cf62a2 Remove activateWindow() when EditDock is toggled
There's no need to set sqlitebrowser as active window when updating
the main application window. The `activateWindow()` call prevents
switching workspaces in GNOME and Cinnamon desktops.

Fixes #934
2017-10-11 22:54:06 +02:00
Martin Kleusberg
5ea6b1a76d Fix recordset label in Browse Data tab 2017-10-11 09:21:41 +02:00
Martin Kleusberg
8f82f26d4f Visual optimisation for the CSV import process
When importing multiple CSV files at once, remove each entry from the
list of CSV files as its import completes. This way people can see the
list shrink visibly onscreen.

Also don't close the window if there are still files left to be
imported. This allows the user to import unchecked files, too, probably
using different settings.

See issue #1072.
2017-09-19 21:43:30 +02:00
Martin Kleusberg
d4e228d4b5 Make hidden columns persistent
With this commit the main window keeps track of the hidden columns and
re-hides them when the table is selected again. It also saves the hidden
status to the project file and restores it from there.
2017-09-18 20:41:27 +02:00
Peter Hyatt
c5c3d2366e Added hide selected columns and show all columns to tableview context menu.
Added a fix for building with MingW on Windows.
2017-09-18 19:47:27 +02:00
Oleg Prutz
ae8df56d9e Clear column filters after table modification
Fixes #1020. Clear values in the filter boxes
on the `Data` tab every time the table structure
changes.
2017-09-10 23:58:31 +02:00
Martin Kleusberg
fb6ea5ac60 Make text selectable in Edit dock even if db is opened as read only
Instead of disabling the entire edit dock when the database is opened in
read only mode, only disable all buttons for making changes to the
field. This way the data can still be read using the edit dock.

See issue #1123.
2017-09-10 15:19:03 +02:00
Martin Kleusberg
e9d4b3912a Move button for saving Execute SQL results to the toolbar
In the Execute SQL tab, move the button for saving the results of a
query as either a CSV file or a view from the bottom of the results view
to the toolbar at the top.

See issue #1122.
2017-09-10 15:00:31 +02:00
Martin Kleusberg
ea1659e1d0 Support schemata other than main in the Browse Data tab
Similar to commit 44eb2d4f99 this commit
makes use of the backend code improvements introduced in commit
532fcd3f6b.

It adds support for database schemata other than "main" to the Browse
Data tab. With this it's possible again to browse and edit data of
temporary tables using the Browse Data tab. This time, however, they are
separated logically from "main" tables. So handling temporary tables
should be a lot less error prone now, plus it's easier to tell for the
user what tables goes in what schema.

This commit changes the project file format. There is some code included
which allows loading of project files in the old format. However,
project files generated using versions after this commit can't be loaded
by older versions of DB4S.
2017-09-04 12:27:52 +02:00
Martin Kleusberg
1a3e3d3c40 Support SQL auto-completion for tables from different schemata
This improves commit 44eb2d4f99 by adding
support for auto completion in the SQL editors for all tables that are
not in the "main" schema.
2017-09-04 10:25:05 +02:00
Martin Kleusberg
44eb2d4f99 Add better handling of multiple schemata in the Database Structure tab
Commit 532fcd3f6b added support for
multiple database schemata to the backend code. While doing this, it
removed support for showing temporary database objects in the user
interface.

This functionally is partially reimplemented by this commit. With this
commit temporary database objects are shown in the Database Structure
tab and in the Db Structure dock. Unlike before however, they are
visually separated from 'normal' database objects. Also this commit
tries to make use of the new schema handling code wherever possible to
also separate temporary objects programatically from the normal ones.
This wasn't done in earlier versions and effectively was a source of
all sorts of errors.

This commit still lacks support for temporary tables in the foreign key
editor and in the Browse Data tab. Also a substantial amount of testing
is still required.
2017-09-03 21:36:06 +02:00
Martin Kleusberg
532fcd3f6b Add initial support for multiple database schemata
This adds initial basic support for handling different database schemata
at once to the backend code. This is still far from working properly but
shouldn't break much either - mostly because it's not really used yet in
the user interface code.
2017-09-03 13:22:21 +02:00
Martin Kleusberg
c3ab20b6b5 Fix indentation 2017-08-15 11:13:30 +02:00
Martin Kleusberg
d1f90994fb Activate attach menu item right after opening a database
The 'attach database' menu item was only activated after making changes
to the database and saving them. With this commit it's activated right
after opening a database, too.
2017-08-15 11:13:29 +02:00
Martin Kleusberg
b0c3d973ce Improve detection of PRAGMA and VACUUM statements in Execute SQL tab
In the Execute SQL tab we need to detect PRAGMA and VACUUM statements
before executing them in order to now execute them inside a transaction
which isn't supported by SQLite. If such a statement followed any other
statement however, the detection would fail, e.g.
pragma user_version=1;	-- this works
pragma app_version=2;	-- this fails

This should be fixed by this commit.
2017-08-11 18:18:55 +02:00
Martin Kleusberg
c636a505c8 Allow VACUUM command in Execute SQL tab
This allows the user to execute VACUUM commands in the Execute SQL by
detecting them and not creating a transaction for them.

See issue #1021.
2017-08-11 18:17:55 +02:00
Martin Kleusberg
5ae5241b95 Don't allow query execution when no database is opened
Some time ago we changed the Execute SQL tab to allow open SQL files
even if no database is loaded in order to provide an SQL editor without
needing a database.

If no database file is opened the Execute buttons were greyed out but
the F5/Ctrl+R shortcut would still work, causing an "out of memory"
error. That error doesn't cause any harm but is a bit confusing. So this
commit disables the keyboard shortcuts too.
2017-08-11 17:19:42 +02:00
Jonathan Oakley
e3a7d9aa75 Fix for comment problems in Execute Query tab
See issue #1004.
2017-08-10 20:51:30 +02:00
Martin Kleusberg
d14fb1fbb1 dbhub: Remove remote menu, add push button to remote dock
This commit removes the File -> Remote menu entirely. The only menu item
that was left was the Save to Remote item which is replaces by a button
in the remote dock.

The button is only enabled when a database file is opened and the user
has logged in using a certificate.

Clicking the button opens the same dialog and performs the same actions
as before. The only difference is that we don't use the first client
certificate - no matter which one it is - but instead use the client
certificate that was used for logging in.
2017-08-03 17:35:36 +02:00
Martin Kleusberg
26ddcf2c04 Allow setting PRAGMAs from the Execute SQL tab
As per popular request, this adds support for setting PRAGMAs from the
Execute SQL tab. Since most PRAGMAs won't work inside a transaction we
make sure that we're not in one while the PRAGMA statement is executed.
If this means we need to commit any pending changes, the user get a
message box.

See issues #1021, #980, #966.
2017-06-30 21:59:47 +02:00
Martin Kleusberg
3c40a12103 Rework the Execute SQL tab handling
Allow opening new tabs, opening SQL files, and saving SQL files even
when no database is opened. Execution of SQL statements obviously is
still not allowed. But this should make it possible to use DB4S as a
simple SQL text editor if no better alternative is available on the
system.

Don't close SQL tabs when closing the databse.

When opening a database only close empty tabs, keep all non-empty tabs
opened. This should make sure that no SQL statements are accidentally
lost when opening a new database or simply closing the old one.

When opening a project file, close all tabs and load the new tabs from
the project file.

See issue #1035.
2017-06-28 22:17:38 +02:00
Martin Kleusberg
4f676ae206 Check for errors when reading or writing sQL files
See issue #1036.
2017-06-28 15:35:30 +02:00
Martin Kleusberg
f4fad4afcf Fix possible crash when loading project files
This fixes a crash when loading project files that haven't set the
current tab to the Browse Data tab.

See issue #1019.
2017-06-26 12:39:50 +02:00
iKlsR
b0eb9acae2 Allow for interactive CSV file import
- Tweak input checker
- Preserve old file import as not to cause any unforeseen breaks
- Allow ignoring file name when importing multiple files to tables
- Mass toggle several files for import
2017-06-16 17:35:36 +02:00
Martin Kleusberg
462c252656 Add selecting fields in Execute SQL tab for Edit Cell dock via keyboard
See issue #481.
2017-05-19 15:13:57 +02:00
Martin Kleusberg
57c4e582c7 Don't show "Show rowid" menu item for views
Don't show the "Show rowid column" context menu item for views because
views don't really have a rowid column (it's always NULL). So showing
the column doesn't really make a lot of sense and might even confuse
some users.

Also change the order of the menu items a little to be more consistent
for views and tables.
2017-05-12 18:31:58 +02:00
Martin Kleusberg
21ee1f2703 Allow updating views
This adds a new context menu option that allows unlocking views for
updating. This requires appropriate triggers to be in place and the user
to type in a column name that can be used as a 'primary key' for the
view. By default views are still locked from editing.

Inserting into and deleting from views isn't supported yet.

See issue #141.
2017-05-12 18:17:50 +02:00
Martin Kleusberg
e404b22205 Fix wording in encoding message box 2017-05-12 16:22:39 +02:00
Martin Kleusberg
ef0ae8d549 Implement page-wise scrolling in Browse Data tab
Don't scroll by 100 records when using the scroll buttons but scroll by
one screen page.

See issue #232.
2017-05-08 12:06:56 +02:00
Martin Kleusberg
e205f77e6a Use platform specific path separators in window caption
For displaying the path to the currently opened database file use
platform specific path separators.

See issue #735.
2017-05-05 14:19:50 +02:00
Martin Kleusberg
9a171e0621 Avoid sorting twice in Browse Data tab
When browsing a table and changing the sort order, then switching to
another table, and then switching back, we would sort the table twice:
once using the default sort order and then again using the previously
used sort order. This results in four instead of two queries for those
tables (including the COUNT queries). This commit fixes this so that
only two queries are executed which should cut the run time for these
cases in half.

See issue #1007.
2017-05-04 19:54:03 +02:00
Martin Kleusberg
478ddc6da4 Simplify code 2017-05-04 19:21:17 +02:00
Martin Kleusberg
b5651d8b4d Keep the UI responsive when executing many statements in Execute SQL tab 2017-05-04 19:08:38 +02:00
Martin Kleusberg
3ff686d96f Show consistent slashes in recent files menu actions
See issue #735.
2017-05-03 21:11:29 +02:00
Martin Kleusberg
f7421a9d62 Fix messed up table browser
This is to work around a Qt bug which is present in at least version
5.7.1. The problem is this: when you browse a table/view with n
colums, then switch to a table/view with less than n columns, you'll be
able to resize the first (hidden!) column by resizing the section to the
left of the first visible column. By doing so the table view gets messed
up. But even when not resizing the first hidden column, tab-ing through
the fields will stop at the not-so-much-hidden rowid column, too. All
this an be fixed by this line. I haven't managed to find another
workaround or way to fix this yet.

If anybody knows more about this issue please let me know.
2017-05-03 20:43:31 +02:00
Martin Kleusberg
760ef092cd Try setting a saner default row height in the data browser
Maybe this helps with issue #419.
2017-04-10 15:07:51 +02:00
Justin Clift
8b2e93d547 Ensure 'File → Export → Table(s) to JSON' is enabled/disabled along with its siblings 2017-04-04 14:07:44 +01:00