kexi
keximigrate.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00192
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
00212
00213
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 }
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
|