Commit Graph

98 Commits

Author SHA1 Message Date
Martin Kleusberg
373bd5db5b Remove \r characters from table definitions while reading DB layout
Remove all \r characters from a table defintion when reading it. This
makes sure it doesn't appear as a invalid character in the UI.

This commit improves the displaying of EoD's database from issue #63.
2014-07-26 21:41:12 +02:00
Martin Kleusberg
b921fe58f3 Fix treatment of spaces when importing CSV files without quotes
When importing a CSV file without no quote characters no spaces were
imported. So this...
a,b b,c
...would become...
a,bb,c

Fix this by not checking for being in quote mode when not having
configured a quote char anyway.
2014-07-20 18:12:46 +02:00
Martin Kleusberg
13464f41d3 Fix spelling. 2014-07-12 16:26:53 +02:00
Martin Kleusberg
17cf2018ca Remove dependency to main window from DBBrowserDB class
Get rid of the dependency to the MainWindow class in the DBBrowserDB
class. It was only used for calling the log SQL and set database state
functions anyway. The same result can be achieved emitting Qt slots.
2014-07-12 16:13:32 +02:00
Martin Kleusberg
ad392fa662 Merge pull request #47 from TheVanDoom/master
Fixed a problem with the import of .csv-files

This fixes the import of CSV files with multi-byte UTF-8 characters in them. Also handle CSV files without a trailing line break better.
2014-07-10 17:32:08 +02:00
Peinthor Rene
00ae461dff add a getRow function to retrieve rowdata by rowid 2014-07-10 00:31:45 +02:00
moritzhader
37e195ad6f Fixed a problem with the csv-import.
During the import, the parser used to append blanks between quotes and separators as part of the cell-content.
Now blanks are detected and ignored, iff they are not used as separator or in between quotes.
2014-07-09 20:29:11 +02:00
moritzhader
e86e648124 Changed the read-line command
Previously, the read-line was performed using the stream-operator. Unfortunately, this approach limited the possible reading range to a word, causing problems when parsing files with blanks between the quotes and separators.
Instead, the readline is performed using the readLine() method of the QTextStream class.
2014-07-09 19:56:22 +02:00
Moritz Hader
d8bc658df7 Fixed a problem with the import of .csv-files
Up until now, the DBBrowserDB:decodeCSV used to load the csv-file character by character using the getChar() method of the QFile-class.
Unfortunatelly, this approach caused multibyte-chars as used for UTF-8 encoding to be split and displayed incorrectly.

The fix uses the QTextStream-class to load the file line by line.
Every line is then again iterated character by character, before the old algorithm is applied. Using this approach, the characters are loaded and encoded properly. Splitting multibyte-chars is thus prevented.
2014-07-08 16:08:12 +02:00
Martin Kleusberg
dca664270f MainWindow: Make it possible to cancel closing of database file
When closing the database, either by using the menu item or by closing
the window, the user is asked whether the changes he made shall be
saved or not. Add a third button to this message box which makes it
possible to cancel the action.
2014-06-20 13:03:23 +02:00
Martin Kleusberg
7139ad0086 Show temporary tables and views in Structure and Browse tabs
Also show temporary tables in the Database Structure and the Browse Data
tabs as well as in the export dialogs etc.
2014-06-07 13:38:24 +02:00
Martin Kleusberg
2aaf7345ff Reduce scope of some variables 2014-05-30 19:13:43 +02:00
Martin Kleusberg
a7110ea0fc Clear the tree widget in the Structure tab when after closing a DB
Clear the tree widget in the 'Database Structure' tab of the main window
after closing a database.
See issue #44.
2014-04-22 22:08:27 +02:00
Peinthor Rene
1bac11348f include cleanup 2013-09-19 22:55:35 +02:00
Martin Kleusberg
bc2511434e SqliteTableModel: Fix bug in last commit to support multiline strings
Fix a bug in the last commit to correctly remove comments on multi-line
queries.
2013-09-06 14:30:50 +02:00
Martin Kleusberg
7167129464 EditTableDialog: Add buttons to move a field up and down
Add two buttons to move the currently selected field up or down to allow
changing the field order of a table.

Extend the DBBrowserDB::renameColumn() method to support changing the
position of a field.
2013-06-13 20:37:19 +02:00
Martin Kleusberg
bd169e034f DBBrowserDB: Remove getTableSQL() function
Delete the getTableSQL() method in DBBrowserDB. Because we reload and
store the SQL statements for tables after every change to the DB layout
we can just use these strings instead of having an extra function doing
an extra DB query. This simplifies the code a bit and also reduces the
number of SQL statements executed by the application.
2013-06-13 18:11:18 +02:00
Martin Kleusberg
d7c9585982 DBBrowserDB: Don't export sqlite_sequence table
When creating an SQL dump don't export the sqlite_sequence table as it
is created internally by SQLite and it is not possible to import it
again.
2013-06-04 22:15:15 +02:00
Martin Kleusberg
324bb23193 DBBrowserDB: Merge renameColumn() and dropColumn()
Merge the renameColumn() and dropColumn() methods. They are just way too
long and complicated but also very similar that it makes no sense to
keep them separated.
This also simplifies the code of renameColumn() a bit while fixing the
trigger/view/index problem in dropColumn().
2013-06-04 17:36:14 +02:00
Martin Kleusberg
2463116976 DBBrowserDB: Use SQL grammar for getting fields of table
When reading in the DB layout use our SQL grammar parser to determine
the fields of a table. This simplifies the code a bit and might also
give more detailed information in some situations.
2013-06-04 17:13:27 +02:00
Martin Kleusberg
b07f0a5add DBBrowserDB: Clean up logSQL() method 2013-06-04 17:03:57 +02:00
Martin Kleusberg
db39e3e293 DBBrowserDB: Attempt to restore views, indices etc. in renameColumn()
Save views, triggers and indices before deleting the old table in
renameColumn() and try to create them again after renaming the new
table. This is likely to fail and we'd probably need a grammar for these
objects to make the appropriate changes, so in case it does fail this
just prints a warning with some ideas of what to do.
2013-06-04 16:42:31 +02:00
Martin Kleusberg
6bd114dca3 Merge branch 'feature-nologtruncate' of https://github.com/oysteinkrog/sqlitebrowser into oysteinkrog-feature-nologtruncate 2013-06-04 15:13:19 +02:00
Øystein Krog
da0ac6bc0d Don't truncate log messages unless they contain binary data (removes previous log limit of 300 characters)
Adapted from c4d253287f
2013-06-04 10:18:07 +02:00
Martin Kleusberg
3a85d96a6d DBBrowserDB: When reading DB layout also save not null and default value
Fix the updateSchemea() method to also read and save the not null flag
and the default value of each column.
This fixes a problem in renameColumn() which made it "forget" these
values. It is now possible to set the not null flag of multiple columns
in EditTableDialog.
2013-06-03 18:26:46 +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
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
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
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
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
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
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
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
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
33d3dcdc16 Fix extension loading 2013-05-03 16:11:35 +02:00
Martin Kleusberg
e36b17a485 Add support for SQLite extension loading
Enable the extension support in SQLite.

Add code to allow loading of extension.

Add menu entry for easy extension loading.
2013-05-03 15:26:34 +02:00
Martin Kleusberg
b9d0497c99 More cleanup in SqliteDB 2013-04-19 20:00:59 +02:00
Martin Kleusberg
b4a64d6208 Clean up SQLiteDB
Much of the code in there is not really needed anymore as quite a bit of
functionality has been moved to the SqliteTableModel.
2013-04-19 19:54:26 +02:00
Martin Kleusberg
1ba3169428 Fix CSV export to work with SqliteTableModel 2013-04-10 18:59:37 +02:00
Martin Kleusberg
f45b89b6c9 Fix SQL export to work with the SqliteTableModel 2013-04-10 18:51:18 +02:00
Martin Kleusberg
31bf07000b SqliteTableModel: Restore BLOB support and clean up DBSQLiteDB 2013-04-10 18:18:08 +02:00
Martin Kleusberg
77cf98fd53 SqliteTableModel: Inserting and deleting rows, clean up, bug fixes
Add some basic code to support inserting and deleting rows again.

Fix a few bugs here and there.

Do some general code clean up.
2013-04-07 19:08:40 +02:00
Martin Kleusberg
5d2139ce99 Kind of fix the find dialog when using the SqliteTableModel 2013-04-06 23:40:47 +02:00
Martin Kleusberg
00b9f40271 SqliteTableModel: Make editing of data possible again 2013-04-06 23:12:53 +02:00
Peinthor Rene
16a40ed349 it's now possible to specify the restore point name 2013-03-28 10:51:09 +01:00
Peinthor Rene
3d6b09ddb4 kill too long lines, no functional changes 2013-03-25 06:15:27 +01:00