1 /* This file is part of the KDE project 2 Copyright (C) 2008 Sharan Rao <sharanrao@gmail.com> 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this program; see the file COPYING. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef XBASEMIGRATE_H 21 #define XBASEMIGRATE_H 22 23 #include <QHash> 24 25 #include <migration/keximigrate.h> 26 #include "xbase.h" 27 28 namespace KexiMigration 29 { 30 31 class xBaseMigrate : public KexiMigrate, protected xbXBase 32 { 33 Q_OBJECT 34 35 public: 36 xBaseMigrate(QObject *parent, const QVariantList& args = QVariantList()); 37 virtual ~xBaseMigrate(); 38 39 protected: 40 //! Driver specific function to return table names 41 virtual bool drv_tableNames(QStringList *tablenames); 42 43 //! Driver specific implementation to read a table schema 44 virtual bool drv_readTableSchema( 45 const QString& originalName, KDbTableSchema *tableSchema); 46 47 //! Driver specific connection implementation 48 virtual bool drv_connect(); 49 50 virtual bool drv_disconnect(); 51 52 virtual bool drv_copyTable(const QString& srcTable, 53 KDbConnection *destConn, KDbTableSchema* dstTable, 54 const RecordFilter *recordFilter = nullptr); 55 56 //! @todo move this somewhere to low level class (MIGRATION?) virtual bool drv_getTablesList( QStringList &list ); 57 //! @todo move this somewhere to low level class (MIGRATION?) virtual bool drv_containsTable( const QString &tableName ); 58 59 private: 60 KDbField::Type type(char xBaseColumnType); 61 62 //! Sets and existing constraints on the field 63 void getConstraints(const QString& tableName, KDbField* fld); 64 65 //! Returns a list of index files corresponding to the specific fieldName 66 QStringList getIndexFileNames(const QString& tableName, const QString& fieldName); 67 68 //! Mapping tableNames to actual absoolute file name paths 69 //! XBase only deals with absolute names ( with the .dbf extension ) which is pretty cumbersome 70 QHash<QString,QString> m_tableNamePathMap; 71 }; 72 } 73 74 #endif 75