[Kexi-devel] Simple improvements of importtablewizard and friends

Jaroslaw Staniek staniek at kde.org
Mon Feb 16 20:47:21 UTC 2015

 Hi Roman, Adam,
Just noticed these (not your) issues (in calligra/2.9 without your patches):

KexiDB::TableSchema* AlterSchemaWidget::newSchema()
    m_newSchema->setName(m_tableNameWidget->nameText()); // [1]
    return m_newSchema;

Why the [1] line is here? On importing large data sets it's called for
every record.

2. Ownership/memory leak issue:
AlterSchemaWidget::setTableSchema(KexiDB::TableSchema* ts, const
QString& suggestedCaption)
is used only in ImportTableWizard::arriveAlterTablePage().
AlterSchemaWidget::m_originalSchema makes no sense I think.
It's enough if we pass `ts' to AlterSchemaWidget.

Then since we want to update the schema's name prior to import, do it
in ImportTableWizard::doImport() just after this code:

    if (!m_alterSchemaWidget->newSchema()) {
        msg.showErrorMessage(i18n("No table was selected to import."));
        return false;

i.e. m_alterSchemaWidget->newSchema()->setName(m_alterSchemaWidget->nameWidget()->nameText());

I guess we need to update schema's caption too:
and m_alterSchemaWidget->newSchema()->setCaption(m_alterSchemaWidget->nameWidget()->captionText());

3. This may be needed because we need to explicitly set auto increment
for the column declared as pkey. We do the same in table designer and
csv import, BTW.

--- kexi/migration/AlterSchemaWidget.cpp
+++ kexi/migration/AlterSchemaWidget.cpp
@@ -135,8 +135,10 @@ void AlterSchemaWidget::typeActivated(int typ)

-void AlterSchemaWidget::pkeyClicked(bool pkey){
+void AlterSchemaWidget::pkeyClicked(bool pkey)
+    m_newSchema->field(m_selectedColumn)->setAutoIncrement(pkey);

Until now imported tables had no autonumber set.

4. Performance: Compute m_alterSchemaWidget->newSchema()->fieldCount()
once and keep before "do  { }".

5. Naming: replace m_currentDatabase with m_connection.

regards, Jaroslaw Staniek

: A world-wide network of software engineers, artists, writers, translators
: and facilitators committed to Free Software development - http://kde.org
Calligra Suite:
: A graphic art and office suite - http://calligra.org
: A visual database apps builder - http://calligra.org/kexi
Qt Certified Specialist:
: http://www.linkedin.com/in/jstaniek

More information about the Kexi-devel mailing list