mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
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:
@@ -186,9 +186,9 @@ void ImportCsvDialog::accept()
|
||||
objectMap objects = pdb->getBrowsableObjects();
|
||||
for(auto it=objects.constBegin();it!=objects.constEnd();++it)
|
||||
{
|
||||
if(it.value().gettype() == "table" && it.value().getname() == ui->editName->text())
|
||||
if(it.value().gettype() == sqlb::Object::ObjectTypes::Table && it.value().getname() == ui->editName->text())
|
||||
{
|
||||
if((size_t)it.value().table.fields().size() != csv.columns())
|
||||
if((size_t)it.value().object.dynamicCast<sqlb::Table>()->fields().size() != csv.columns())
|
||||
{
|
||||
QMessageBox::warning(this, QApplication::applicationName(),
|
||||
tr("There is already a table of that name and an import into an existing table is only possible if the number of columns match."));
|
||||
|
||||
Reference in New Issue
Block a user