diff options
Diffstat (limited to 'kexi/tests/altertable/altertable.cpp')
-rw-r--r-- | kexi/tests/altertable/altertable.cpp | 238 |
1 files changed, 119 insertions, 119 deletions
diff --git a/kexi/tests/altertable/altertable.cpp b/kexi/tests/altertable/altertable.cpp index bf14bc00..1c5589c4 100644 --- a/kexi/tests/altertable/altertable.cpp +++ b/kexi/tests/altertable/altertable.cpp @@ -21,11 +21,11 @@ #include <unistd.h> -#include <qapplication.h> -#include <qfile.h> -#include <qdir.h> -#include <qregexp.h> -#include <qclipboard.h> +#include <tqapplication.h> +#include <tqfile.h> +#include <tqdir.h> +#include <tqregexp.h> +#include <tqclipboard.h> #include <kdebug.h> @@ -41,22 +41,22 @@ #include <kexidb/connection.h> #include <kexidb/utils.h> -QString testFilename; -QFile testFile; -QTextStream testFileStream; -QStringList testFileLine; +TQString testFilename; +TQFile testFile; +TQTextStream testFileStream; +TQStringList testFileLine; uint testLineNumber = 0; -QString origDbFilename, dbFilename; +TQString origDbFilename, dbFilename; int variableI = 1; // simple variable 'i' support int newArgc; char** newArgv; KexiMainWindowImpl* win = 0; KexiProject* prj = 0; -void showError(const QString& msg) +void showError(const TQString& msg) { - QString msg_(msg); - msg_.prepend(QString("Error at line %1: ").arg(testLineNumber)); + TQString msg_(msg); + msg_.prepend(TQString("Error at line %1: ").tqarg(testLineNumber)); kdDebug() << msg_ << endl; } @@ -64,9 +64,9 @@ void showError(const QString& msg) text in quotes is extracted, e.g. \"ab c\" is treat as one item "ab c" Returns flas on failure (e.g. end of file). Empty lines and lines or parts of lines with # (comments) are omitted. */ -tristate readLineFromTestFile(const QString& expectedCommandName = QString::null) +tristate readLineFromTestFile(const TQString& expectedCommandName = TQString()) { - QString s; + TQString s; bool blockComment = false; while (true) { if (testFileStream.atEnd()) @@ -88,12 +88,12 @@ tristate readLineFromTestFile(const QString& expectedCommandName = QString::null break; } s.append(" "); //sentinel - QString item; + TQString item; testFileLine.clear(); const int len = s.length(); bool skipWhiteSpace = true, quoted = false; for (int i=0; i<len; i++) { - const QChar ch( s.ref(i) ); + const TQChar ch( s.ref(i) ); if (skipWhiteSpace) { if (ch=='#') break; //eoln @@ -111,15 +111,15 @@ tristate readLineFromTestFile(const QString& expectedCommandName = QString::null skipWhiteSpace = true; quoted = false; testFileLine.append( item ); - item = QString::null; + item = TQString(); continue; } item.append(ch); } } if (!expectedCommandName.isEmpty() && testFileLine[0]!=expectedCommandName) { - showError( QString("Invalid command '%1', expected '%2'") - .arg(testFileLine[0]).arg(expectedCommandName)); + showError( TQString("Invalid command '%1', expected '%2'") + .tqarg(testFileLine[0]).tqarg(expectedCommandName)); return false; } if (quoted) { @@ -135,54 +135,54 @@ bool checkItemsNumber(int expectedNumberOfItems, int optionalNumberOfItems = -1) if (optionalNumberOfItems>0) ok = ok || optionalNumberOfItems==(int)testFileLine.count(); if (!ok) { - QString msg = QString("Invalid number of args (%1) for command '%2', expected: %3") - .arg(testFileLine.count()).arg(testFileLine[0]).arg(expectedNumberOfItems); + TQString msg = TQString("Invalid number of args (%1) for command '%2', expected: %3") + .tqarg(testFileLine.count()).tqarg(testFileLine[0]).tqarg(expectedNumberOfItems); if (optionalNumberOfItems>0) - msg.append( QString(" or %1").arg(optionalNumberOfItems) ); + msg.append( TQString(" or %1").tqarg(optionalNumberOfItems) ); showError( msg ); return false; } return true; } -QVariant::Type typeNameToQVariantType(const QCString& name_) +TQVariant::Type typeNameToTQVariantType(const TQCString& name_) { - QCString name( name_.lower() ); + TQCString name( name_.lower() ); if (name=="string") - return QVariant::String; + return TQVariant::String; if (name=="int") - return QVariant::Int; + return TQVariant::Int; if (name=="bool" || name=="boolean") - return QVariant::Bool; + return TQVariant::Bool; if (name=="double" || name=="float") - return QVariant::Double; + return TQVariant::Double; if (name=="date") - return QVariant::Date; + return TQVariant::Date; if (name=="datetime") - return QVariant::DateTime; + return TQVariant::DateTime; if (name=="time") - return QVariant::Time; + return TQVariant::Time; if (name=="bytearray") - return QVariant::ByteArray; + return TQVariant::ByteArray; if (name=="longlong") - return QVariant::LongLong; + return TQVariant::LongLong; //todo more types - showError(QString("Invalid type '%1'").arg(name_)); - return QVariant::Invalid; + showError(TQString("Invalid type '%1'").tqarg(name_)); + return TQVariant::Invalid; } -// casts string to QVariant -bool castStringToQVariant( const QString& string, const QCString& type, QVariant& result ) +// casts string to TQVariant +bool castStringToTQVariant( const TQString& string, const TQCString& type, TQVariant& result ) { if (string.lower()=="<null>") { - result = QVariant(); + result = TQVariant(); return true; } if (string=="\"\"") { - result = QString(""); + result = TQString(""); return true; } - const QVariant::Type vtype = typeNameToQVariantType( type ); + const TQVariant::Type vtype = typeNameToTQVariantType( type ); bool ok; result = KexiDB::stringToVariant( string, vtype, ok ); return ok; @@ -190,7 +190,7 @@ bool castStringToQVariant( const QString& string, const QCString& type, QVariant // returns a number parsed from argument; if argument is i or i++, variableI is used // 'ok' is set to false on failure -static int getNumber(const QString& argument, bool& ok) +static int getNumber(const TQString& argument, bool& ok) { int result; ok = true; @@ -202,7 +202,7 @@ static int getNumber(const QString& argument, bool& ok) else { result = argument.toInt(&ok); if (!ok) { - showError(QString("Invalid value '%1'").arg(argument)); + showError(TQString("Invalid value '%1'").tqarg(argument)); return -1; } } @@ -212,26 +212,26 @@ static int getNumber(const QString& argument, bool& ok) //--------------------------------------- AlterTableTester::AlterTableTester() - : QObject() + : TQObject() , m_finishedCopying(false) { //copy the db file to a temp file qInitNetworkProtocols(); - QPtrList<QNetworkOperation> list = m_copyOperator.copy( - "file://" + QDir::current().path() + "/" + origDbFilename, - "file://" + QDir::current().path() + "/" + dbFilename, false, false ); - connect(&m_copyOperator, SIGNAL(finished(QNetworkOperation*)), - this, SLOT(slotFinishedCopying(QNetworkOperation*))); + TQPtrList<TQNetworkOperation> list = m_copyOperator.copy( + "file://" + TQDir::current().path() + "/" + origDbFilename, + "file://" + TQDir::current().path() + "/" + dbFilename, false, false ); + connect(&m_copyOperator, TQT_SIGNAL(finished(TQNetworkOperation*)), + this, TQT_SLOT(slotFinishedCopying(TQNetworkOperation*))); } AlterTableTester::~AlterTableTester() { - QFile(dbFilename).remove(); + TQFile(dbFilename).remove(); } -void AlterTableTester::slotFinishedCopying(QNetworkOperation* oper) +void AlterTableTester::slotFinishedCopying(TQNetworkOperation* oper) { - if (oper->operation()==QNetworkProtocol::OpPut) + if (oper->operation()==TQNetworkProtocol::OpPut) m_finishedCopying = true; } @@ -239,16 +239,16 @@ bool AlterTableTester::changeFieldProperty(KexiTableDesignerInterface* designerI { if (!checkItemsNumber(5)) return false; - QVariant newValue; - QCString propertyName( testFileLine[2].latin1() ); - QCString propertyType( testFileLine[3].latin1() ); - QString propertyValueString(testFileLine[4]); + TQVariant newValue; + TQCString propertyName( testFileLine[2].latin1() ); + TQCString propertyType( testFileLine[3].latin1() ); + TQString propertyValueString(testFileLine[4]); if (propertyName=="type") newValue = (int)KexiDB::Field::typeForString(testFileLine[4]); else { - if (!castStringToQVariant(propertyValueString, propertyType, newValue)) { - showError( QString("Could not set property '%1' value '%2' of type '%3'") - .arg(propertyName).arg(propertyValueString).arg(propertyType) ); + if (!castStringToTQVariant(propertyValueString, propertyType, newValue)) { + showError( TQString("Could not set property '%1' value '%2' of type '%3'") + .tqarg(propertyName).tqarg(propertyValueString).tqarg(propertyType) ); return false; } } @@ -259,7 +259,7 @@ bool AlterTableTester::changeFieldProperty(KexiTableDesignerInterface* designerI designerIface->changeFieldPropertyForRow( row, propertyName, newValue, 0, true ); if (propertyName=="type") { //clean subtype name, e.g. from "longText" to "LongText", because dropdown list is case-sensitive - QString realSubTypeName; + TQString realSubTypeName; if (KexiDB::Field::BLOB == KexiDB::Field::typeForString(testFileLine[4])) //! @todo hardcoded! realSubTypeName = "image"; @@ -271,7 +271,7 @@ bool AlterTableTester::changeFieldProperty(KexiTableDesignerInterface* designerI } //helper -bool AlterTableTester::getSchemaDump(KexiDialogBase* dlg, QString& schemaDebugString) +bool AlterTableTester::getSchemaDump(KexiDialogBase* dlg, TQString& schemaDebugString) { KexiTableDesignerInterface* designerIface = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() ); @@ -282,34 +282,34 @@ bool AlterTableTester::getSchemaDump(KexiDialogBase* dlg, QString& schemaDebugSt tristate result; schemaDebugString = designerIface->debugStringForCurrentTableSchema(result); if (true!=result) { - showError( QString("Loading modified schema failed. Result: %1") - .arg(~result ? "cancelled" : "false") ); + showError( TQString("Loading modified schema failed. Result: %1") + .tqarg(~result ? "cancelled" : "false") ); return false; } - schemaDebugString.remove(QRegExp(",$")); //no need to have "," at the end of lines + schemaDebugString.remove(TQRegExp(",$")); //no need to have "," at the end of lines return true; } bool AlterTableTester::showSchema(KexiDialogBase* dlg, bool copyToClipboard) { - QString schemaDebugString; + TQString schemaDebugString; if (!getSchemaDump(dlg, schemaDebugString)) return false; if (copyToClipboard) - QApplication::clipboard()->setText( schemaDebugString ); + TQApplication::tqclipboard()->setText( schemaDebugString ); else - kdDebug() << QString("Schema for '%1' table:\n").arg(dlg->partItem()->name()) + kdDebug() << TQString("Schema for '%1' table:\n").tqarg(dlg->partItem()->name()) + schemaDebugString + "\nendSchema" << endl; return true; } bool AlterTableTester::checkInternal(KexiDialogBase* dlg, - QString& debugString, const QString& endCommand, bool skipColonsAndStripWhiteSpace) + TQString& debugString, const TQString& endCommand, bool skipColonsAndStripWhiteSpace) { Q_UNUSED(dlg); - QTextStream resultStream(&debugString, IO_ReadOnly); + TQTextStream resultStream(&debugString, IO_ReadOnly); // Load expected result, compare - QString expectedLine, resultLine; + TQString expectedLine, resultLine; while (true) { const bool testFileStreamAtEnd = testFileStream.atEnd(); if (!testFileStreamAtEnd) { @@ -317,7 +317,7 @@ bool AlterTableTester::checkInternal(KexiDialogBase* dlg, expectedLine = testFileStream.readLine(); if (skipColonsAndStripWhiteSpace) { expectedLine = expectedLine.stripWhiteSpace(); - expectedLine.remove(QRegExp(",$")); //no need to have "," at the end of lines + expectedLine.remove(TQRegExp(",$")); //no need to have "," at the end of lines } } if (testFileStreamAtEnd || endCommand==expectedLine.stripWhiteSpace()) { @@ -329,18 +329,18 @@ bool AlterTableTester::checkInternal(KexiDialogBase* dlg, } //test line loaded, load result if (resultStream.atEnd()) { - showError( QString("Result ends unexpectedly. There is at least one additinal test line: '") + showError( TQString("Result ends unexpectedly. There is at least one additinal test line: '") + expectedLine +"'" ); return false; } resultLine = resultStream.readLine(); if (skipColonsAndStripWhiteSpace) { resultLine = resultLine.stripWhiteSpace(); - resultLine.remove(QRegExp(",$")); //no need to have "," at the end of lines + resultLine.remove(TQRegExp(",$")); //no need to have "," at the end of lines } if (resultLine!=expectedLine) { showError( - QString("Result differs from the expected:\nExpected: ") + TQString("Result differs from the expected:\nExpected: ") +expectedLine+"\n????????: "+resultLine+"\n"); return false; } @@ -350,16 +350,16 @@ bool AlterTableTester::checkInternal(KexiDialogBase* dlg, bool AlterTableTester::checkSchema(KexiDialogBase* dlg) { - QString schemaDebugString; + TQString schemaDebugString; if (!getSchemaDump(dlg, schemaDebugString)) return false; bool result = checkInternal(dlg, schemaDebugString, "endSchema", true /*skipColonsAndStripWhiteSpace*/); - kdDebug() << QString("Schema check for table '%1': %2").arg(dlg->partItem()->name()) - .arg(result ? "OK" : "Failed") << endl; + kdDebug() << TQString("Schema check for table '%1': %2").tqarg(dlg->partItem()->name()) + .tqarg(result ? "OK" : "Failed") << endl; return result; } -bool AlterTableTester::getActionsDump(KexiDialogBase* dlg, QString& actionsDebugString) +bool AlterTableTester::getActionsDump(KexiDialogBase* dlg, TQString& actionsDebugString) { KexiTableDesignerInterface* designerIface = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() ); @@ -367,7 +367,7 @@ bool AlterTableTester::getActionsDump(KexiDialogBase* dlg, QString& actionsDebug return false; tristate result = designerIface->simulateAlterTableExecution(&actionsDebugString); if (true!=result) { - showError( QString("Computing simplified actions for table '%1' failed.").arg(dlg->partItem()->name()) ); + showError( TQString("Computing simplified actions for table '%1' failed.").tqarg(dlg->partItem()->name()) ); return false; } return true; @@ -375,25 +375,25 @@ bool AlterTableTester::getActionsDump(KexiDialogBase* dlg, QString& actionsDebug bool AlterTableTester::showActions(KexiDialogBase* dlg, bool copyToClipboard) { - QString actionsDebugString; + TQString actionsDebugString; if (!getActionsDump(dlg, actionsDebugString)) return false; if (copyToClipboard) - QApplication::clipboard()->setText( actionsDebugString ); + TQApplication::tqclipboard()->setText( actionsDebugString ); else - kdDebug() << QString("Simplified actions for altering table '%1':\n").arg(dlg->partItem()->name()) + kdDebug() << TQString("Simplified actions for altering table '%1':\n").tqarg(dlg->partItem()->name()) + actionsDebugString+"\n" << endl; return true; } bool AlterTableTester::checkActions(KexiDialogBase* dlg) { - QString actionsDebugString; + TQString actionsDebugString; if (!getActionsDump(dlg, actionsDebugString)) return false; bool result = checkInternal(dlg, actionsDebugString, "endActions", true /*skipColonsAndStripWhiteSpace*/); - kdDebug() << QString("Actions check for table '%1': %2").arg(dlg->partItem()->name()) - .arg(result ? "OK" : "Failed") << endl; + kdDebug() << TQString("Actions check for table '%1': %2").tqarg(dlg->partItem()->name()) + .tqarg(result ? "OK" : "Failed") << endl; return result; } @@ -405,26 +405,26 @@ bool AlterTableTester::saveTableDesign(KexiDialogBase* dlg) return false; tristate result = designerIface->executeRealAlterTable(); if (true!=result) { - showError( QString("Saving design of table '%1' failed.").arg(dlg->partItem()->name()) ); + showError( TQString("Saving design of table '%1' failed.").tqarg(dlg->partItem()->name()) ); return false; } return true; } -bool AlterTableTester::getTableDataDump(KexiDialogBase* dlg, QString& dataString) +bool AlterTableTester::getTableDataDump(KexiDialogBase* dlg, TQString& dataString) { KexiTableDesignerInterface* designerIface = dynamic_cast<KexiTableDesignerInterface*>( dlg->selectedView() ); if (!designerIface) return false; - QMap<QString,QString> args; - QTextStream ts( &dataString, IO_WriteOnly ); - args["textStream"] = KexiUtils::ptrToString<QTextStream>( &ts ); + TQMap<TQString,TQString> args; + TQTextStream ts( &dataString, IO_WriteOnly ); + args["textStream"] = KexiUtils::ptrToString<TQTextStream>( &ts ); args["destinationType"]="file"; args["delimiter"]="\t"; args["textQuote"]="\""; - args["itemId"] = QString::number( + args["itemId"] = TQString::number( prj->dbConnection()->tableSchema( dlg->partItem()->name() )->id() ); if (!KexiInternalPart::executeCommand("csv_importexport", win, "KexiCSVExport", &args)) { showError( "Error exporting table contents." ); @@ -435,24 +435,24 @@ bool AlterTableTester::getTableDataDump(KexiDialogBase* dlg, QString& dataString bool AlterTableTester::showTableData(KexiDialogBase* dlg, bool copyToClipboard) { - QString dataString; + TQString dataString; if (!getTableDataDump(dlg, dataString)) return false; if (copyToClipboard) - QApplication::clipboard()->setText( dataString ); + TQApplication::tqclipboard()->setText( dataString ); else - kdDebug() << QString("Contents of table '%1':\n").arg(dlg->partItem()->name())+dataString+"\n" << endl; + kdDebug() << TQString("Contents of table '%1':\n").tqarg(dlg->partItem()->name())+dataString+"\n" << endl; return true; } bool AlterTableTester::checkTableData(KexiDialogBase* dlg) { - QString dataString; + TQString dataString; if (!getTableDataDump(dlg, dataString)) return false; bool result = checkInternal(dlg, dataString, "endTableData", false /*!skipColonsAndStripWhiteSpace*/); - kdDebug() << QString("Table '%1' contents: %2").arg(dlg->partItem()->name()) - .arg(result ? "OK" : "Failed") << endl; + kdDebug() << TQString("Table '%1' contents: %2").tqarg(dlg->partItem()->name()) + .tqarg(result ? "OK" : "Failed") << endl; return result; } @@ -460,10 +460,10 @@ bool AlterTableTester::closeWindow(KexiDialogBase* dlg) { if (!dlg) return true; - QString name = dlg->partItem()->name(); - tristate result = true == win->closeDialog(dlg, true/*layoutTaskBar*/, true/*doNotSaveChanges*/); - kdDebug() << QString("Closing window for table '%1': %2").arg(name) - .arg(result==true ? "OK" : (result==false ? "Failed" : "Cancelled")) << endl; + TQString name = dlg->partItem()->name(); + tristate result = true == win->closeDialog(dlg, true/*tqlayoutTaskBar*/, true/*doNotSaveChanges*/); + kdDebug() << TQString("Closing window for table '%1': %2").tqarg(name) + .tqarg(result==true ? "OK" : (result==false ? "Failed" : "Cancelled")) << endl; return result == true; } @@ -472,7 +472,7 @@ tristate AlterTableTester::run(bool &closeAppRequested) { closeAppRequested = false; while (!m_finishedCopying) - qApp->processEvents(300); + tqApp->processEvents(300); kdDebug() << "Database copied to temporary: " << dbFilename << endl; @@ -489,16 +489,16 @@ tristate AlterTableTester::run(bool &closeAppRequested) if (true != res) return ~res; - QString tableName(testFileLine[1]); + TQString tableName(testFileLine[1]); KexiPart::Item *item = prj->itemForMimeType("kexi/table", tableName); if (!item) { - showError(QString("No such table '%1'").arg(tableName)); + showError(TQString("No such table '%1'").tqarg(tableName)); return false; } bool openingCancelled; KexiDialogBase* dlg = win->openObject(item, Kexi::DesignViewMode, openingCancelled); if (!dlg) { - showError(QString("Could not open table '%1'").arg(item->name())); + showError(TQString("Could not open table '%1'").tqarg(item->name())); return false; } KexiTableDesignerInterface* designerIface @@ -507,8 +507,8 @@ tristate AlterTableTester::run(bool &closeAppRequested) return false; //dramatic speedup: temporary hide the window and propeditor - QWidget * propeditor - = KexiUtils::findFirstChild<QWidget>(qApp->mainWidget(), "KexiPropertyEditorView"); + TQWidget * propeditor + = KexiUtils::findFirstChild<TQWidget>(tqApp->mainWidget(), "KexiPropertyEditorView"); if (propeditor) propeditor->hide(); dlg->hide(); @@ -518,7 +518,7 @@ tristate AlterTableTester::run(bool &closeAppRequested) res = readLineFromTestFile(); if (true != res) return ~res; - QString command( testFileLine[0] ); + TQString command( testFileLine[0] ); if (designTable) { //subcommands available within "designTable" commands if (command=="endDesign") { @@ -570,7 +570,7 @@ tristate AlterTableTester::run(bool &closeAppRequested) bool ok; variableI = command.mid(2).toInt(&ok); if (!ok) { - showError(QString("Invalid variable initialization '%1'").arg(command)); + showError(TQString("Invalid variable initialization '%1'").tqarg(command)); return false; } continue; @@ -622,7 +622,7 @@ tristate AlterTableTester::run(bool &closeAppRequested) if (command=="stop") { if (!checkItemsNumber(1)) return false; - kdDebug() << QString("Test STOPPED at line %1.").arg(testLineNumber) << endl; + kdDebug() << TQString("Test STOPPED at line %1.").tqarg(testLineNumber) << endl; break; } else if (command=="closeWindow") { @@ -636,11 +636,11 @@ tristate AlterTableTester::run(bool &closeAppRequested) if (!checkItemsNumber(1) || !closeWindow(dlg)) return false; closeAppRequested = true; - kdDebug() << QString("Quitting the application...") << endl; + kdDebug() << TQString("Quitting the application...") << endl; break; } else { - showError( QString("No such command '%1'").arg(command) ); + showError( TQString("No such command '%1'").tqarg(command) ); return false; } } @@ -652,7 +652,7 @@ tristate AlterTableTester::run(bool &closeAppRequested) int quit(int result) { testFile.close(); - delete qApp; + delete tqApp; if (newArgv) delete [] newArgv; return result; @@ -674,7 +674,7 @@ int main(int argc, char *argv[]) testFilename = argv[argc-1]; testFile.setName(testFilename); if (!testFile.open(IO_ReadOnly)) { - kdWarning() << QString("Opening test file %1 failed.").arg(testFilename) << endl; + kdWarning() << TQString("Opening test file %1 failed.").tqarg(testFilename) << endl; return quit(1); } //load db name @@ -693,22 +693,22 @@ int main(int argc, char *argv[]) KAboutData* aboutdata = Kexi::createAboutData(); aboutdata->setProgramName( "Kexi Alter Table Test" ); int result = KexiMainWindowImpl::create(newArgc, newArgv, aboutdata); - if (!qApp) + if (!tqApp) return quit(result); win = KexiMainWindowImpl::self(); AlterTableTester tester; - //QObject::connect(win, SIGNAL(projectOpened()), &tester, SLOT(run())); + //TQObject::connect(win, TQT_SIGNAL(projectOpened()), &tester, TQT_SLOT(run())); bool closeAppRequested; res = tester.run(closeAppRequested); if (true != res) { if (false == res) - kdWarning() << QString("Running test for file '%1' failed.").arg(testFilename) << endl; + kdWarning() << TQString("Running test for file '%1' failed.").tqarg(testFilename) << endl; return quit(res==false ? 1 : 0); } - kdDebug() << QString("Tests from file '%1': OK").arg(testFilename) << endl; - result = (closeOnFinish || closeAppRequested) ? 0 : qApp->exec(); + kdDebug() << TQString("Tests from file '%1': OK").tqarg(testFilename) << endl; + result = (closeOnFinish || closeAppRequested) ? 0 : tqApp->exec(); quit(result); return result; } |