Commit Graph

497 Commits

Author SHA1 Message Date
Martin Kleusberg
928a957e70 SqliteTypes: Allow non-numeric default values
Fix the sqlb::Field class to support non-numeric default values by
putting them in quotes.
2013-06-02 17:16:35 +02:00
Martin Kleusberg
13c3963651 SqliteTableModel: Support EXPLAIN and PRAGMA queries again
Change the approach to count the total number of rows returned by an SQL
query to also support EXPLAIN and PRAGMA statements. These failed before
because you are not allowed to put them into a COUNT query. This commit
adds the code needed to count the number of rows manually when one of
these queries is executed.
2013-06-01 14:41:25 +02:00
Martin Kleusberg
40f8a28fad SqliteTableModel: Don't crash when query contains ';'
Fix a bug in SqliteTableModel that caused the application to crash when
the SQL query contained a semicolon somewhere in the middle of the
string. This was caused by an error in the rtrimChar function which
returned everything left of the first semicolon. The new implementation
only removed trailing characters.
2013-06-01 12:58:07 +02:00
Martin Kleusberg
ebadc180ce EditTableDialog: Remove unused function 2013-06-01 12:50:19 +02:00
Martin Kleusberg
fa2589c829 DBBrowserDB: Use sqlb::Field for createTable()
When creating a new table specify the table structure using the
sqlb::Field type instead of just a plain string list.
2013-06-01 12:43:43 +02:00
Martin Kleusberg
c0b3506ede EditTableDialog: Fix bug when renaming column
Store the old column name to be able to address it by its current name
when renameColumn is called.
2013-06-01 12:42:36 +02:00
Martin Kleusberg
cbd81de88b Remove the DBBrowserField class
Remove the DBBrowserField class and change all parts of the program
which used to use this class to work with sqlb::Field instead.
2013-05-31 16:50:13 +02:00
Martin Kleusberg
b9afbe2aea EditTableDialog: Allow some more changes to existing tables
Allow setting the default value, the check values and under some
circumstances the not null flag when editing existing tables.

This required some changes to DBBrowserDB::renameColumn() which is now
using some more features of sqlitetypes.cpp but could still be improved.
2013-05-31 16:13:58 +02:00
Martin Kleusberg
82d78384e0 EditTableDialog: Some minor code clean up 2013-05-31 14:29:45 +02:00
Martin Kleusberg
7e319bd80f EditTableDialog: Fix adding new fields to table
Fix the function to add new columns to an existing table to work
properly with the recent changes.
2013-05-31 14:21:11 +02:00
Martin Kleusberg
b1333c90c7 EditTableDialog: Make it possible to change the type of existing columns
Restore the possibility to change the data type of a column of an
existing table - a feature we lost some time ago.

Also change the updateTypes() method to not actually update the types of
all columns when only one can be changed at a time.
2013-05-31 14:14:30 +02:00
Martin Kleusberg
23331ea181 DBBrowserDB: Always update internal variables after changing the DB layout
Make sure to always replace the old DB layout representation in
DBBrowserDB after making changes to the database.
2013-05-31 14:12:10 +02:00
Martin Kleusberg
8063502def EditTableDialog: Allow renaming columns of existing tables
Make it possible to rename the columns of already existing tables using
the EditTableDialog. This is a feature we lost somewhere around commit
b36800ea02.
2013-05-30 15:35:25 +02:00
Martin Kleusberg
8c86a01faf EditTableDialog: Don't change the cursor when renaming the table
Renaming a table doesn't take a lot of time hence no need to change the
cursor.
2013-05-25 17:22:20 +02:00
Martin Kleusberg
f3ae25572d DBBrowserDB: Remove the dirty flag
Remove the dirty flag as it is no longer needed. Because we track the
savepoints currently held open we can just use that list to see wether
there are changes to be committed. So there is no need to track this in
a separate variable.
2013-05-23 18:16:58 +02:00
Martin Kleusberg
6de8425985 VacuumDialog: Fix dialog after savepoint change
Call saveAll() in the VacuumDialog to make sure to release all savepoints.

Also cancel the dialog when no object was select but the OK button
clicked. This avoids an unnecessary DB reload in the main window.
2013-05-23 18:09:09 +02:00
Martin Kleusberg
7f03e01a86 ImportCsvDialog: Also use the new savepoint logic in this dialog
Do just the same in the ImportCsvDialog as before in the
EditTableDialog, i.e. using a unique savepoint name which is not
released when the import was successfull.
2013-05-23 18:04:27 +02:00
Martin Kleusberg
a1b72c5eef Extend the entire savepoint logic to allow multiple active savepoints
Allow multiple savepoints in DBBrowserDB, i.e. setRestorePoint() doesn't
simply return if the DB is already set to dirty but creates an
additional savepoint.

Track the names of all savepoints which have not been either saved or
reverted yet.

Finally, and that's the whole point of this commit, change the savepoint
logic of the EditTableDialog. We used to have a transaction started when
opening a database which was only committed when the file was closed
again. This way the EditFileDialog could savely create a savepoint when
being opened and just release it when OK was clicked or revert to it
when cancel was clicked. Getting rid of the transaction broke this
logic. The dialog still worked but as the savepoint was released when
the changes were applied all changes made via the dialog were
immediately committed to the database. So clicking the revert button had
no effect on those changes. This is at best an unexpected behaviour but
could also be a problem when some changes are reverted while others
aren't. So, having the option now of keeping multiple savepoints opened
this problem can be fixed by just creating a new savepoint every time
the dialog is opened, reverting to it when it is cancelled and _not_
releasing it when OK is clicked.

I hope this works!
2013-05-23 17:41:16 +02:00
Martin Kleusberg
4dfabe4a78 VacuumDialog: Add dialog to allow compacting single objects individually
Add a new dialog which is shown when compacting the database. This
dialog allows selecting single objects individually to avoid vacuuming
the entire database.

It also shows a new warning if the database is dirty as changes are
going to be saved before vacuuming.
2013-05-21 22:32:05 +02:00
Martin Kleusberg
6f8e988f10 Also enable extension loading when creating a new database 2013-05-21 21:01:19 +02:00
Martin Kleusberg
929bb9026d SqlTextEdit: Support opening files by drag and drop
When dropping a file on the editor widget try to open and read it.
2013-05-17 15:05:21 +02:00
Martin Kleusberg
c0e6d251d5 MainWindow: Show execution time in SQL tab
Show the time needed for executing a statement in the result box.

Generally fix some minor problems with the result view.
2013-05-17 14:56:58 +02:00
Martin Kleusberg
c251a001a1 DBBrowserDB: Fix transaction logic in execute{Multi}SQL
Create a restore point in executeSQL and executeMultiSQL instead of just
setting the dirty flag. This way the changes made using these functions
are not applied immediately when no restore point was created yet.
2013-05-17 14:39:42 +02:00
Martin Kleusberg
606b5bd953 SqlExecutionArea: Show status messages in text edit instead of label 2013-05-17 14:35:20 +02:00
Martin Kleusberg
5a3cfda826 SyntaxHighlighter: Add SQLite functions
Also highlight the names of functions supported by SQLite such as COUNT.
2013-05-16 21:16:37 +02:00
Martin Kleusberg
d2f1db8457 SyntaxHighlighter: Make keyword list a bit easier to read 2013-05-16 21:05:06 +02:00
Martin Kleusberg
04b431d3f1 Add rough implementation of some command line options
Support some additional command line options for opening and running SQL
scripts directly.

Don't just take the first argument as a SQLite database to open as it
could be a command line option - Qt and X11 have some default ones.
2013-05-14 18:12:11 +02:00
Martin Kleusberg
6ba0cd76c0 Open database correctly when importing into a new file
When doing a SQL import into a new database file open this file
correctly after the import.
2013-05-10 13:29:49 +02:00
Martin Kleusberg
11a2d321d8 Don't set dirty flag after SQL import to new DB file
When creating a new database to import a SQL file into don't set the
dirty flag.
2013-05-10 13:21:52 +02:00
Martin Kleusberg
729773d345 Fix SQL import file name logic
Don't ask the user wether to create a new DB or use the current one if
no database is opened anyway.

Don't start the import when the save dialog was cancelled.
2013-05-10 13:15:06 +02:00
Martin Kleusberg
5a3658cad2 DBBrowserDB: Show progress dialog in executeMultiSQL()
Show a progress dialog when executing multiple SQL statements. This
mainly affects the SQL import.
2013-05-10 12:58:46 +02:00
Martin Kleusberg
5536c13a06 DBBrowserDB: Export BLOBs correctly
When creating an SQL dump also export BLOB data correctly.
2013-05-09 18:47:32 +02:00
Martin Kleusberg
cf0a0339eb MainWindow: Replace icon for the SQL log window
Replace the icon used in the action for toggling the SQL log
dock/window.
You might need to delete your makefiles before building this.
2013-05-09 18:34:33 +02:00
Martin Kleusberg
90d423c66f DBBrowserDB: Don't export sqlite_stat1 table when dumping DB
When creating a SQL dump of the database don't export the sqlite_stat1
table as it's impossible to import it later because SQLite generates it
automatically.
2013-05-09 18:18:18 +02:00
Martin Kleusberg
1c19defbe9 ExtendedTableWidget: Always scroll per pixel horizonzally
Always use per pixel scrolling when scrolling in horizontal direction.
This changes the scrolling in the SqlExecutionArea and makes some
settings in the MainWindow dispensable.
2013-05-09 18:05:25 +02:00
Martin Kleusberg
1e89d1914e Update .desktop file 2013-05-09 14:19:20 +02:00
Martin Kleusberg
5b9d5cc40b Remove some debug messages. Change some error messages..
Remove some useless debug messages, e.g. because they just print an SQL
string which you can see in the SQL log window anyway.

Change some "critical" errors messages to just warning. No sense in
printing a critical error message when the program can handle the
problem by itself.
2013-05-08 22:03:04 +02:00
Martin Kleusberg
cf72bfbb1c MainWindow: Improve SQL tab behaviour
Don't allow opening and saving when no database file is opened.

Close all tabs when the database is closed.
2013-05-08 21:50:35 +02:00
Martin Kleusberg
f3f340f83e Add single step execution to the SQL tab
Add a new action to allow the execution of the SQL statement in the
current line. This also supports multi-line SQL statement.
2013-05-08 21:44:08 +02:00
Martin Kleusberg
a39325830c MainWindow: Don't use bold print for write and revert actions
At least for me it looks a bit odd to use a bold font for these actions.
They are not that much more important than the other ones.
2013-05-08 21:19:02 +02:00
Martin Kleusberg
74bdfee384 SqliteTableModel: Return from setData() if value hasn't changed
Don't do any changes to the database if the value hasn't actually
changed. This avoids settings the dirty flag when there is no need to.
2013-05-07 20:51:07 +02:00
Martin Kleusberg
ea31c8023b SqliteTableModel: Don't show binary data in table widgets
Don't show BLOBs as binary data in table widgets, instead put a "BLOB"
text in that cell.

Also make BLOBs not editable unless you use the edit dialog.
2013-05-07 20:47:16 +02:00
Martin Kleusberg
09afe637c6 MainWindow: Don't open new SQL tab when the current one is empty
When opening an SQL file don't open a new tab for it when the current
one is completely empty and could be used just as well.
2013-05-07 20:33:04 +02:00
Martin Kleusberg
d6ed7e932f Show error message when changing table data fails
Give the user an error message when setting new data for a cell fails.
This is especially useful when the problem is caused by foreign key
constraints.
2013-05-07 20:25:35 +02:00
Martin Kleusberg
432180ec03 SqlTextEdit: Show line numbers
Show line numbers in the SqlTextEdit widget. This code is based on the
CodeEditor example from the Qt documentation.
2013-05-07 20:16:17 +02:00
Martin Kleusberg
61ee8b4871 MainWindow: Fix menu entry for log dock widget
Simplify the log window handling a little bit.

Fix a bug that caused the log window to disappear when the window was
minimised.
2013-05-06 19:11:06 +02:00
Martin Kleusberg
ef5f88cc70 SqlExecutionArea: Implement save as view function
Add a menu item to allow saving the results of a query a new view.
2013-05-06 18:59:46 +02:00
Martin Kleusberg
9536e7a095 SqlExecutionArea: Support exporting result to CSV file
Add a button which allows the user to save the query results to a CSV
file.

Add some basic preparations for saving the result as a view.
2013-05-06 18:44:58 +02:00
Martin Kleusberg
e548becda1 SqlExecutionArea: Use Qt Designer for layout design 2013-05-06 18:17:59 +02:00
Martin Kleusberg
16d533999d Make result table in SQL tab non-editable 2013-05-06 17:35:39 +02:00