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.
This commit is contained in:
Martin Kleusberg
2017-01-20 17:31:54 +01:00
parent e3ef13a916
commit e5a79ec0fa
12 changed files with 252 additions and 164 deletions

View File

@@ -81,9 +81,9 @@ ForeignKeyEditorDelegate::ForeignKeyEditorDelegate(const DBBrowserDB& db, sqlb::
{
const auto objects = m_db.getBrowsableObjects();
for (auto& obj : objects) {
if ("table" == obj.gettype()) {
QString tableName = obj.table.name();
m_tablesIds.insert(tableName, obj.table.fieldNames());
if (obj.gettype() == sqlb::Object::ObjectTypes::Table) {
QString tableName = obj.object->name();
m_tablesIds.insert(tableName, obj.object.dynamicCast<sqlb::Table>()->fieldNames());
}
}
}