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
00104 bool isSourceAndDestinationDataSourceTheSame() const;
00105
00107 bool performImport(Kexi::ObjectStatus* result = 0);
00108
00110 bool performExport(Kexi::ObjectStatus* result = 0);
00111
00113 inline bool progressSupported() { return drv_progressSupported(); }
00114
00115 virtual int versionMajor() const = 0;
00116 virtual int versionMinor() const = 0;
00117
00121 virtual QVariant propertyValue( const QCString& propName );
00122
00124 void setPropertyValue( const QCString& propName, const QVariant& value );
00125
00129 QString propertyCaption( const QCString& propName ) const;
00130
00133 QValueList<QCString> propertyNames() const;
00134
00138 virtual bool isValid();
00139
00140 signals:
00141 void progressPercent(int percent);
00142
00143 protected:
00145 KexiMigrate(QObject *parent, const char *name, const QStringList &args = QStringList());
00146
00148 virtual bool drv_connect() = 0;
00150 virtual bool drv_disconnect() = 0;
00151
00153 virtual bool drv_tableNames(QStringList& tablenames) = 0;
00154
00156 virtual bool drv_readTableSchema(
00157 const QString& originalName, KexiDB::TableSchema& tableSchema) = 0;
00158
00160 virtual bool drv_copyTable(const QString& srcTable, KexiDB::Connection *destConn,
00161 KexiDB::TableSchema* dstTable) = 0;
00162
00163 virtual bool drv_progressSupported() { return false; }
00164
00182 virtual bool drv_getTableSize(const QString&, Q_ULLONG&)
00183 { return false; }
00184
00185 void updateProgress(Q_ULLONG step = 1ULL);
00186
00189 KexiDB::Field::Type userType(const QString& fname);
00190
00193 KexiMigration::Data* m_migrateData;
00194
00195
00196
00197
00201 QMap<QCString,QVariant> m_properties;
00202
00206 QMap<QCString,QString> m_propertyCaptions;
00207
00208 private:
00210 bool tableNames(QStringList& tablenames);
00211
00213 KexiProject* createProject(Kexi::ObjectStatus* result);
00214
00215
00216
00217
00218
00220 QPtrList<KexiDB::TableSchema> m_tableSchemas;
00221
00223
00226 bool progressInitialise();
00227
00228 KexiProject *m_destPrj;
00229
00231 Q_ULLONG m_progressTotal;
00233 Q_ULLONG m_progressDone;
00235 Q_ULLONG m_progressNextReport;
00236
00237 friend class MigrateManager;
00238 };
00239
00240 }
00241
00244 #define KEXIMIGRATE_DRIVER_INFO( class_name, internal_name ) \
00245 int class_name::versionMajor() const { return KEXI_MIGRATION_VERSION_MAJOR; } \
00246 int class_name::versionMinor() const { return KEXI_MIGRATION_VERSION_MINOR; } \
00247 K_EXPORT_COMPONENT_FACTORY(keximigrate_ ## internal_name, \
00248 KGenericFactory<KexiMigration::class_name>( "keximigrate_" #internal_name ))
00249
00252 #define KEXIMIGRATION_DRIVER \
00253 public: \
00254 virtual int versionMajor() const; \
00255 virtual int versionMinor() const;
00256
00257 #endif
00258
|