diff options
Diffstat (limited to 'kexi/migration/mysql/mysqlmigrate.cpp')
-rw-r--r-- | kexi/migration/mysql/mysqlmigrate.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/kexi/migration/mysql/mysqlmigrate.cpp b/kexi/migration/mysql/mysqlmigrate.cpp index a2c62dd5..013613ea 100644 --- a/kexi/migration/mysql/mysqlmigrate.cpp +++ b/kexi/migration/mysql/mysqlmigrate.cpp @@ -20,11 +20,11 @@ #include "mysqlmigrate.h" -#include <qstring.h> -#include <qregexp.h> -#include <qfile.h> -#include <qvariant.h> -#include <qvaluelist.h> +#include <tqstring.h> +#include <tqregexp.h> +#include <tqfile.h> +#include <tqvariant.h> +#include <tqvaluelist.h> #include <kdebug.h> #include <mysql_version.h> @@ -52,9 +52,9 @@ KEXIMIGRATE_DRIVER_INFO( MySQLMigrate, mysql ) }*/ //! Constructor (needed for trading interface) -MySQLMigrate::MySQLMigrate(QObject *parent, const char *name, - const QStringList &args) : - KexiMigrate(parent, name, args) +MySQLMigrate::MySQLMigrate(TQObject *tqparent, const char *name, + const TQStringList &args) : + KexiMigrate(tqparent, name, args) ,d(new MySqlConnectionInternal(0)) ,m_mysqlres(0) { @@ -92,7 +92,7 @@ bool MySQLMigrate::drv_disconnect() /* ************************************************************************** */ /*! Get the types and properties for each column. */ bool MySQLMigrate::drv_readTableSchema( - const QString& originalName, KexiDB::TableSchema& tableSchema) + const TQString& originalName, KexiDB::TableSchema& tableSchema) { // m_table = new KexiDB::TableSchema(table); @@ -100,7 +100,7 @@ bool MySQLMigrate::drv_readTableSchema( // tableSchema.setCaption(table + " table"); //Perform a query on the table to get some data - QString query = QString("SELECT * FROM `") + drv_escapeIdentifier(originalName) + "` LIMIT 0"; + TQString query = TQString("SELECT * FROM `") + drv_escapeIdentifier(originalName) + "` LIMIT 0"; if(d->executeSQL(query)) { MYSQL_RES *res = mysql_store_result(d->mysql); if (res != NULL) { @@ -109,14 +109,14 @@ bool MySQLMigrate::drv_readTableSchema( MYSQL_FIELD *fields = mysql_fetch_fields(res); for(unsigned int i = 0; i < numFlds; i++) { - QString fldName(fields[i].name); - QString fldID( KexiUtils::string2Identifier(fldName) ); + TQString fldName(fields[i].name); + TQString fldID( KexiUtils::string2Identifier(fldName) ); KexiDB::Field *fld = new KexiDB::Field(fldID, type(originalName, &fields[i])); if(fld->type() == KexiDB::Field::Enum) { - QStringList values = examineEnumField(originalName, &fields[i]); + TQStringList values = examineEnumField(originalName, &fields[i]); } fld->setCaption(fldName); @@ -136,14 +136,14 @@ bool MySQLMigrate::drv_readTableSchema( /*! Get a list of tables and put into the supplied string list */ -bool MySQLMigrate::drv_tableNames(QStringList& tableNames) +bool MySQLMigrate::drv_tableNames(TQStringList& tableNames) { if(d->executeSQL("SHOW TABLES")) { MYSQL_RES *res = mysql_store_result(d->mysql); if (res != NULL) { MYSQL_ROW row; while ((row = mysql_fetch_row(res)) != NULL) { - tableNames << QString::fromUtf8(row[0]); //utf8.. ok? + tableNames << TQString::fromUtf8(row[0]); //utf8.. ok? } mysql_free_result(res); } else { @@ -160,7 +160,7 @@ bool MySQLMigrate::drv_tableNames(QStringList& tableNames) On success the result is stored in \a stringList and true is returned. \return cancelled if there are no records available. */ tristate MySQLMigrate::drv_queryStringListFromSQL( - const QString& sqlStatement, uint columnNumber, QStringList& stringList, int numRecords) + const TQString& sqlStatement, uint columnNumber, TQStringList& stringList, int numRecords) { stringList.clear(); if (d->executeSQL(sqlStatement)) { @@ -190,7 +190,7 @@ tristate MySQLMigrate::drv_queryStringListFromSQL( mysql_free_result(res); return false; } - stringList.append( QString::fromUtf8(row[columnNumber], lengths[columnNumber]) ); //ok? utf8? + stringList.append( TQString::fromUtf8(row[columnNumber], lengths[columnNumber]) ); //ok? utf8? } mysql_free_result(res); } else { @@ -204,7 +204,7 @@ tristate MySQLMigrate::drv_queryStringListFromSQL( /*! Fetches single record from result obtained by running \a sqlStatement. */ -tristate MySQLMigrate::drv_fetchRecordFromSQL(const QString& sqlStatement, +tristate MySQLMigrate::drv_fetchRecordFromSQL(const TQString& sqlStatement, KexiDB::RowData& data, bool &firstRecord) { if (firstRecord || !m_mysqlres) { @@ -235,12 +235,12 @@ tristate MySQLMigrate::drv_fetchRecordFromSQL(const QString& sqlStatement, } data.resize(numFields); for (int i=0; i < numFields; i++) - data[i] = QString::fromUtf8(row[i], lengths[i] ); //ok? utf8? + data[i] = TQString::fromUtf8(row[i], lengths[i] ); //ok? utf8? return true; } /*! Copy MySQL table to KexiDB database */ -bool MySQLMigrate::drv_copyTable(const QString& srcTable, KexiDB::Connection *destConn, +bool MySQLMigrate::drv_copyTable(const TQString& srcTable, KexiDB::Connection *destConn, KexiDB::TableSchema* dstTable) { if(d->executeSQL("SELECT * FROM `" + drv_escapeIdentifier(srcTable)) + "`") { @@ -249,8 +249,8 @@ bool MySQLMigrate::drv_copyTable(const QString& srcTable, KexiDB::Connection *de MYSQL_ROW row; const KexiDB::QueryColumnInfo::Vector fieldsExpanded( dstTable->query()->fieldsExpanded() ); while ((row = mysql_fetch_row(res)) != NULL) { - const int numFields = QMIN((int)fieldsExpanded.count(), (int)mysql_num_fields(res)); - QValueList<QVariant> vals; + const int numFields = TQMIN((int)fieldsExpanded.count(), (int)mysql_num_fields(res)); + TQValueList<TQVariant> vals; unsigned long *lengths = mysql_fetch_lengths(res); if (!lengths) { mysql_free_result(res); @@ -280,14 +280,14 @@ bool MySQLMigrate::drv_copyTable(const QString& srcTable, KexiDB::Connection *de } -bool MySQLMigrate::drv_getTableSize(const QString& table, Q_ULLONG& size) { +bool MySQLMigrate::drv_getTableSize(const TQString& table, TQ_ULLONG& size) { if(d->executeSQL("SELECT COUNT(*) FROM `" + drv_escapeIdentifier(table)) + "`") { MYSQL_RES *res = mysql_store_result(d->mysql); if (res != NULL) { MYSQL_ROW row; while ((row = mysql_fetch_row(res)) != NULL) { //! @todo check result valid - size = QString(row[0]).toULongLong(); + size = TQString(row[0]).toULongLong(); } mysql_free_result(res); } else { @@ -300,7 +300,7 @@ bool MySQLMigrate::drv_getTableSize(const QString& table, Q_ULLONG& size) { } //! Convert a MySQL type to a KexiDB type, prompting user if necessary. -KexiDB::Field::Type MySQLMigrate::type(const QString& table, +KexiDB::Field::Type MySQLMigrate::type(const TQString& table, const MYSQL_FIELD *fld) { // Field type @@ -391,12 +391,12 @@ KexiDB::Field::Type MySQLMigrate::type(const QString& table, Assumes fld is a CHAR, VARCHAR, one of the BLOBs or TEXTs. \return KexiDB::Field::Text, KexiDB::Field::LongText or KexiDB::Field::BLOB */ -KexiDB::Field::Type MySQLMigrate::examineBlobField(const QString& table, +KexiDB::Field::Type MySQLMigrate::examineBlobField(const TQString& table, const MYSQL_FIELD* fld) { - QString mysqlType; + TQString mysqlType; KexiDB::Field::Type kexiType; - QString query = "SHOW COLUMNS FROM `" + drv_escapeIdentifier(table) + - "` LIKE '" + QString::fromLatin1(fld->name) + "'"; + TQString query = "SHOW COLUMNS FROM `" + drv_escapeIdentifier(table) + + "` LIKE '" + TQString::tqfromLatin1(fld->name) + "'"; if(d->executeSQL(query)) { MYSQL_RES *res = mysql_store_result(d->mysql); @@ -404,7 +404,7 @@ KexiDB::Field::Type MySQLMigrate::examineBlobField(const QString& table, if (res != NULL) { MYSQL_ROW row; while ((row = mysql_fetch_row(res)) != NULL) { - mysqlType = QString(row[1]); + mysqlType = TQString(row[1]); } mysql_free_result(res); } else { @@ -417,10 +417,10 @@ KexiDB::Field::Type MySQLMigrate::examineBlobField(const QString& table, kdDebug() << "MySQLMigrate::examineBlobField: considering " << mysqlType << endl; - if(mysqlType.contains("blob", false) != 0) { + if(mysqlType.tqcontains("blob", false) != 0) { // Doesn't matter how big it is, it's binary kexiType = KexiDB::Field::BLOB; - } else if(mysqlType.contains("text", false) != 0) { + } else if(mysqlType.tqcontains("text", false) != 0) { // All the TEXT types are too big for Kexi text. kexiType = KexiDB::Field::BLOB; } else if(fld->length < 200) { @@ -440,11 +440,11 @@ KexiDB::Field::Type MySQLMigrate::examineBlobField(const QString& table, strings, "option1", "option2". \return list of possible values the field can take */ -QStringList MySQLMigrate::examineEnumField(const QString& table, +TQStringList MySQLMigrate::examineEnumField(const TQString& table, const MYSQL_FIELD* fld) { - QString vals; - QString query = "SHOW COLUMNS FROM `" + drv_escapeIdentifier(table) + - "` LIKE '" + QString::fromLatin1(fld->name) + "'"; + TQString vals; + TQString query = "SHOW COLUMNS FROM `" + drv_escapeIdentifier(table) + + "` LIKE '" + TQString::tqfromLatin1(fld->name) + "'"; if(d->executeSQL(query)) { MYSQL_RES *res = mysql_store_result(d->mysql); @@ -452,7 +452,7 @@ QStringList MySQLMigrate::examineEnumField(const QString& table, if (res != NULL) { MYSQL_ROW row; while ((row = mysql_fetch_row(res)) != NULL) { - vals = QString(row[1]); + vals = TQString(row[1]); } mysql_free_result(res); } else { @@ -460,7 +460,7 @@ QStringList MySQLMigrate::examineEnumField(const QString& table, } } else { // Huh? MySQL wont tell us what values it can take. - return QStringList(); + return TQStringList(); } kdDebug() << "MySQLMigrate::examineEnumField: considering " @@ -470,22 +470,22 @@ QStringList MySQLMigrate::examineEnumField(const QString& table, if(!vals.startsWith("enum(")) { // Huh? We're supposed to be parsing an enum! kdDebug() << "MySQLMigrate::examineEnumField:1 not an enum!" << endl; - return QStringList(); + return TQStringList(); } if(!vals.endsWith(")")) { kdDebug() << "MySQLMigrate::examineEnumField:2 not an enum!" << endl; - return QStringList(); + return TQStringList(); } - // It'd be nice to use QString.section or QStringList.split, but we need + // It'd be nice to use TQString.section or TQStringList.split, but we need // to be careful as enum values can have commas and quote marks in them // e.g. CREATE TABLE t(f enum('option,''') gives one option: "option,'" vals = vals.remove(0,5); - QRegExp rx = QRegExp("^'((?:[^,']|,|'')*)'"); - QStringList values = QStringList(); + TQRegExp rx = TQRegExp("^'((?:[^,']|,|'')*)'"); + TQStringList values = TQStringList(); int index = 0; - while ((index = rx.search(vals, index, QRegExp::CaretAtOffset)) != -1) { + while ((index = rx.search(vals, index, TQRegExp::CaretAtOffset)) != -1) { int len = rx.matchedLength(); if (len != -1) { kdDebug() << "MySQLMigrate::examineEnumField:3 " << rx.cap(1) << endl; @@ -494,8 +494,8 @@ QStringList MySQLMigrate::examineEnumField(const QString& table, kdDebug() << "MySQLMigrate::examineEnumField:4 lost" << endl; } - QChar next = vals[index + len]; - if (next != QChar(',') && next != QChar(')')) { + TQChar next = vals[index + len]; + if (next != TQChar(',') && next != TQChar(')')) { kdDebug() << "MySQLMigrate::examineEnumField:5 " << (char)next << endl; } index += len + 1; @@ -509,7 +509,7 @@ void MySQLMigrate::getConstraints(int flags, KexiDB::Field* fld) { fld->setPrimaryKey(flags & PRI_KEY_FLAG); fld->setAutoIncrement(flags & AUTO_INCREMENT_FLAG); fld->setNotNull(flags & NOT_NULL_FLAG); - fld->setUniqueKey(flags & UNIQUE_KEY_FLAG); + fld->setUniqueKey(flags & UNITQUE_KEY_FLAG); //! @todo: Keys and uniqueness } |