Commit Graph

117 Commits

Author SHA1 Message Date
Martin Kleusberg a4552152af cipher: Fix opening SQLCipher DBs using page size 1024
No idea how this fixes that inconsistency bug described here but it does:
https://discuss.zetetic.net/t/sqlcipher-support-being-added-to-db-browser-for-sqlite/243/6
2014-11-10 22:52:33 +01:00
Martin Kleusberg 8fb9176f99 cipher: Show encryption status in the main window statusbar
Add a note to the status bar of the main window when an encrpyted
database is opened.

Also make some methods in the CipherDialog class const.
2014-11-02 18:15:13 +01:00
Martin Kleusberg 167d8cbd74 cipher: Fix build option and use a dialog for entering the password
Fix the sqlcipher build option in the qmake project to actually enable
the SQLCipher support.

Add a new dialog called CipherDialog which is used to ask the user for
the password and other encryption details instead of using standard Qt
input dialogs.
2014-11-02 13:12:31 +01:00
Martin Kleusberg 9ba36d02b2 Add initial SQLCipher support
Add some basic initial support for SQLCipher. Note that this is more of
a POC than a final implementation.

This commit adds an option called 'sqlcipher' to the cmake and qmake
projects which - when enabled - replaces the default SQLite3 include and
library files by their SQLCipher counter-parts. Especially on MacOS X
there might be some more work required in finding the correct include
paths. The SQLCipher library supports unencrypted databases, too, so
even if the option is enabled the program behaves like before. You can
see the difference, though, in the About Dialog where the SQLite version
string will say 'SQLCipher version xy'.

When the sqlcipher option is enabled and you try to open a file which is
neither a project file nor a normal SQLite3 database it is assumed now
that the file is an encypted database. There is no way to tell between
an invalid file and an encypted file, so in both cases a password dialog
pops up. When the correct password and page size are entered the file is
opened and can be edited like any other database before.

Creating encrypted databases isn't supported yet. So for testing you
need to fall back to the sqlcipher command line tool.

See issue #12.
2014-11-01 12:56:53 +01:00
Peinthor Rene 8c5dfbb977 sqlexport: rewrite "to sql file" export to use streaming 2014-10-23 20:56:09 +02:00
Peinthor Rene 594ea38420 Fix insert on integer PK fields with not null
Moved the emptyinsertstmt into DBBrowserDB class
to be able to query the database for values.
2014-09-21 20:45:12 +02:00
Martin Kleusberg 75487111ba Silence some warning
Closes #102.
2014-09-16 19:20:43 +02:00
Peinthor Rene cf33f3054e sqlite: Allow opening of databases with custom collations 2014-09-13 20:43:32 +02:00
Martin Kleusberg c0d48604f8 Small optimisation when inserting rows 2014-09-07 12:32:16 +02:00
Peinthor Rene 97e2025cc9 cvsparser: Newly implemented CSV Parser
Moved parser into it's own class
This parser now proper supports new lines in quoted text
and returns a QVector<QStringList> result.
2014-09-02 18:05:04 +02:00
Martin Kleusberg b87992c8fb Clean up the DBBrowserDB class a bit 2014-08-31 16:10:01 +02:00
Martin Kleusberg 03879d93f0 ImportCsvDialog: Allow other file encoding than UTF-8
Add a combobox and a text field for choosing a different encoding of the
input file than the default UTF-8.
2014-08-31 13:10:25 +02:00
Martin Kleusberg c7de94cb77 Make it possible to add rows to a WITHOUT rowid table
This commit allows you to add new rows to a table without rowid column.
The main problem here is that SQLite won't create the next value for the
primary key column itself, so we have to do that instead.

See issue #51.
2014-08-26 18:38:04 +02:00
Martin Kleusberg e37df8658c Improve support for 'WITHOUT rowid' tables
This adds support for editing and deleting rows from tables without
rowid. It also fixes a check in the EditTableDialog when activating the
not null constraint as well as making some progress when it comes to
adding new rows.

Also see issue #51.
2014-08-26 17:58:33 +02:00
Martin Kleusberg 7d4248ecb4 Keep field information in sqlb::Table object rather than DBBrowserObject
Keep all the table and field information in a sqlb::Table object (which
itself is stored in DBBrowserObject) rather than storing field
information in DBBrowserObject and sqlb::Table objects at the same time.
2014-08-26 17:52:15 +02:00
Peinthor Rene 55678bb945 sql: use _rowid_ instead of rowid
This doesn't really solve the problem, but reduces the chance
to have a nameclash with rowid, until we come up with something better
we can't fully support tables with a column name _rowid_ but that should
be very seldom
2014-08-22 23:21:44 +02:00
Peinthor Rene 3b907df8e3 tablemodel: fix crash if rowdata couldn't be fetched 2014-08-22 23:13:39 +02:00
Peinthor Rene 9aa73915c3 sqliteparsing: add a flag to indicate if we support modifying in our dlg
This flag should indicate if we can fully handle this table definition
in our edit table dialog. if not we should do one of these things:
* disable the edit table dialog to modify the table
* display a warning message that modifying this table may remove constraints
* ??
2014-08-18 19:41:49 +02:00
Peinthor Rene 32ef063d11 sqlite3: workaround to prevent creating 0 byte sqlite3 database files 2014-08-17 13:05:49 +02:00
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 https://github.com/dwarburt/SQLITE-Browser/commit/c4d253287faab37e8a749932c6c988aad4735cd5
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