Commit Graph

17 Commits

Author SHA1 Message Date
Martin Kleusberg
b63f1520bc Simplify code and fix useless-conversion warnings 2018-11-15 14:15:36 +01:00
Martin Kleusberg
bf505edf66 Code refactoring
This commit refactors vast parts of the sqlitetypes.h interface. Its
main goals are: less code, easier code, a more modern interface, reduced
likelihood for strange errors and more flexibility for future
extensions.

The main reason why the sqlitetypes.h functions were working so well in
DB4S was not because they were that stable but because they were
extremely interlinked with the rest of the code. This is fine because we
do not plan to ship them as a separate library. But it makes it hard to
find the obvious spot to fix an issue or to put a new function. It can
always be done in the sqlitetypes function or in the rest of the DB4S
code because it is just not clear what the interface between the two
should look like. This is supposed to be improved by this commit. One
main thing here is to make ownership of objects a bit clearer.

In theory the new code should be faster too but that difference will be
neglectable from a user POV.

This commit also fixes a hidden bug which caused all table constraints
to be removed in the Edit Table dialog when a single field was removed
from the table.

This is all still WIP and more work is needed to be done here.
2018-09-05 22:24:46 +02:00
Martin Kleusberg
7a9f310778 Don't allow editing the SQL preview in the Edit Index dialog
Don't allow the user to edit the SQL preview in the Edit Index dialog
because it's just supposed to be a preview.
2018-07-15 23:39:40 +02:00
Martin Kleusberg
a5d36694db Simplify code 2018-05-16 18:26:48 +02:00
Martin Kleusberg
39a5460500 Fix crashes in Edit Index dialog when database has no tables
Fix some crashes in the Edit Index dialog which happen if you try to add
a new index when there are no tables in the database yet.

See issue #1293.
2018-01-15 22:38:10 +01: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
df8219de09 In Edit Index dialog don't remove expression columns by accident
Don't allow removing expression columns by double clicking as this it
too error-prone. Instead require a button click for removal and only
start editing the expression when double clicking.

See issue #1012.
2017-06-28 16:56:26 +02:00
Martin Kleusberg
8cc3154c72 Add button for adding expression columns in Edit Index dialog
Add a button for adding new expression columns to the Edit Index dialog.

Allow the user to edit the 'name' of existing expression columns in the
Edit Index dialog.
2017-05-14 21:37:11 +02:00
Martin Kleusberg
6321d14dd6 Add buttons for changing the column order in Edit Index dialog
Add two buttons for moving index columns up or down in the Edit Index
dialog.
2017-05-14 20:48:43 +02:00
Martin Kleusberg
f06b63bc66 Use savepoint in Edit Index dialog
Create a save point when opening the Edit Index dialog. This allows us
to revert back to the last version when pressing the Cancel button.
2017-05-14 20:48:42 +02:00
Martin Kleusberg
e61d7d9fa7 Allow setting the partial index clause in the Edit Index dialog
This adds a new field to the Edit Index dialog that allows the user to
change the partial index expression for an index.

Example:
CREATE INDEX i ON a(
     col1 ASC,
     col2 DESC
) WHERE id < 1000;	-- This bit here
2017-05-14 20:48:42 +02:00
Martin Kleusberg
58996f1345 Rework the Edit Index dialog
Change the layout of the dialog entirely. Instead of having checkboxes
that, if activated, move a column into the index, use two separate table
views, one for available columns and one for used columns. This makes it
easier to see the index structure on first sight. It also makes it
possible to see the order of the different index columns from the table
views. Additionally, now expression columns that are used in the index
are shown in the table views, even allowing them to be removed from the
index.
2017-05-14 17:01:00 +02:00
Martin Kleusberg
036e4349e0 Fix crash when clicking Create Index in empty database
This fixes a crash that would happen if you click the Create Index
button while having opened an empty database file, i.e. without any
table to create an index on yet.
2017-01-31 18:56:42 +01:00
Martin Kleusberg
38144bbcad Finish main part of the recent refactoring effort
This finally gets rid of the DBBrowserObject class entirely and moves
all its functionality to the newer classes in the sqlb namespace.

I'm still not entirely happy with this but at least things should be a
little more consistent now.
2017-01-23 20:59:12 +01:00
Martin Kleusberg
e5a79ec0fa Code refactoring
This changes the class structure in the sqlb namespace as well as the
DBBrowserObject class. The rest of the commit are changes that are
required by the modifications in sqlb and DBBrowserObject.

The idea behind this refactoring is this: we currently have the
DBBrowserObject class which holds some basic information about the
database object (name, type, SQL string, etc.). It also contains a
sqlb::Table and a sqlb::Index object. Those are used if the type of
the object is table or index and they contain a whole lot more
information on the object than the DBBrowserObject class, including the
name, the type, the SQL string, etc.

So we have a duplication here. There are two class structures for
storing the same information. This has historic reasons but other than
that there is no point in keeping it this way. With this commit I start
the work of consolidating the sqlb classes in order to get rid of the
DBBrowserObject class entirely.

This commit only starts this task, it doesn't finish it. This is why it
is a little messy here and there, but then again the old structure was a
little messy, too. We will need at least a very basic trigger and view
parser before finishing this is even possible. When this is done, I hope
the ode will be much easier to read and understand. But even in the
current state there already is some progress: we save a little bit of
memory, don't copy big objects all the time anymore, and replace a lot
of unnecessary string comparisons with integer comparisons.
2017-01-20 17:42:15 +01:00
Martin Kleusberg
2c7f32c699 Rename Create Index dialog to Edit Index dialog
Just like the Edit Table dialog, this dialog handles both creating and
editing. For consistency's sake this dialog is therefore renamed to Edit
Index dialog.
2017-01-20 12:35:07 +01:00