kexi

keximigrate.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Adam Pigg <adam@piggz.co.uk>
00003    Copyright (C) 2004-2005 Jaroslaw Staniek <js@iidea.pl>
00004    Copyright (C) 2005 Martin Ellis <martin.ellis@kdemail.net>
00005 
00006    This program is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this program; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KEXI_MIGRATE_H
00023 #define KEXI_MIGRATE_H
00024 
00025 
00026 #include "kexidb/tableschema.h"
00027 #include "keximigratedata.h"
00028 
00029 #include <kgenericfactory.h>
00030 #include <qstringlist.h>
00031 
00032 class KexiProject;
00033 namespace Kexi
00034 {
00035     class ObjectStatus;
00036 }
00037 
00045 #define KEXI_MIGRATION_VERSION_MAJOR 1
00046 #define KEXI_MIGRATION_VERSION_MINOR 1
00047 
00052 namespace KexiMigration 
00053 {
00054 
00056 KEXIMIGR_EXPORT int versionMajor();
00057 
00059 KEXIMIGR_EXPORT int versionMinor();
00060 
00061 
00063 
00076 class KEXIMIGR_EXPORT KexiMigrate : public QObject, public KexiDB::Object
00077 {
00078     Q_OBJECT
00079 
00080     public:
00081         virtual ~KexiMigrate();
00082 
00084         KexiMigration::Data* data() const { return m_migrateData; }
00085 
00088         void setData(KexiMigration::Data* migrateData);
00089 
00099         bool checkIfDestinationDatabaseOverwritingNeedsAccepting(Kexi::ObjectStatus* result,
00100             bool& acceptingNeeded);
00101 
00103         bool performImport(Kexi::ObjectStatus* result = 0);
00104 
00106         bool performExport(Kexi::ObjectStatus* result = 0);
00107 
00109         inline bool progressSupported() { return drv_progressSupported(); }
00110 
00111         virtual int versionMajor() const = 0;
00112         virtual int versionMinor() const = 0;
00113 
00117         virtual QVariant propertyValue( const QCString& propName );
00118 
00120         void setPropertyValue( const QCString& propName, const QVariant& value );
00121 
00125         QString propertyCaption( const QCString& propName ) const;
00126 
00129         QValueList<QCString> propertyNames() const;
00130 
00134         virtual bool isValid();
00135 
00136     signals:
00137         void progressPercent(int percent);
00138 
00139     protected:
00141         KexiMigrate(QObject *parent, const char *name, const QStringList &args = QStringList());
00142 
00144         virtual bool drv_connect() = 0;
00146         virtual bool drv_disconnect() = 0;
00147 
00149         virtual bool drv_tableNames(QStringList& tablenames) = 0;
00150 
00152         virtual bool drv_readTableSchema(
00153             const QString& originalName, KexiDB::TableSchema& tableSchema) = 0;
00154 
00156         virtual bool drv_copyTable(const QString& srcTable, KexiDB::Connection *destConn, 
00157             KexiDB::TableSchema* dstTable) = 0;
00158 
00159         virtual bool drv_progressSupported() { return false; }
00160 
00178         virtual bool drv_getTableSize(const QString&, Q_ULLONG&)
00179         { return false; }
00180 
00181         void updateProgress(Q_ULLONG step = 1ULL);
00182 
00185         KexiDB::Field::Type userType(const QString& fname);
00186 
00189         KexiMigration::Data* m_migrateData;
00190 
00191 //          // Temporary values used during import (set by driver specific methods)
00192 //          KexiDB::Field* m_f;
00193 
00197         QMap<QCString,QVariant> m_properties;
00198 
00202         QMap<QCString,QString> m_propertyCaptions;
00203 
00204     private:
00206         bool tableNames(QStringList& tablenames);
00207 
00209         KexiProject* createProject(Kexi::ObjectStatus* result);
00210 
00211 //      //Private data members
00212 //      //! Flag indicating whether data should be copied
00213 //      bool m_keepData;
00214 
00216         QPtrList<KexiDB::TableSchema> m_tableSchemas;
00217 
00219 
00222         bool progressInitialise();
00223 
00224         KexiProject *m_destPrj;
00225 
00227         Q_ULLONG m_progressTotal;
00229         Q_ULLONG m_progressDone;
00231         Q_ULLONG m_progressNextReport;
00232 
00233         friend class MigrateManager;
00234 };
00235 
00236 } //namespace KexiMigration
00237 
00240 #define KEXIMIGRATE_DRIVER_INFO( class_name, internal_name ) \
00241     int class_name::versionMajor() const { return KEXI_MIGRATION_VERSION_MAJOR; } \
00242     int class_name::versionMinor() const { return KEXI_MIGRATION_VERSION_MINOR; } \
00243     K_EXPORT_COMPONENT_FACTORY(keximigrate_ ## internal_name, \
00244       KGenericFactory<KexiMigration::class_name>( "keximigrate_" #internal_name ))
00245 
00248 #define KEXIMIGRATION_DRIVER \
00249     public: \
00250     virtual int versionMajor() const; \
00251     virtual int versionMinor() const;
00252 
00253 #endif
00254 
KDE Home | KDE Accessibility Home | Description of Access Keys