summaryrefslogtreecommitdiffstats
path: root/kexi/kexidb/alter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kexi/kexidb/alter.cpp')
-rw-r--r--kexi/kexidb/alter.cpp132
1 files changed, 66 insertions, 66 deletions
diff --git a/kexi/kexidb/alter.cpp b/kexi/kexidb/alter.cpp
index f894b299..5a84424e 100644
--- a/kexi/kexidb/alter.cpp
+++ b/kexi/kexidb/alter.cpp
@@ -21,7 +21,7 @@
#include "utils.h"
#include <kexiutils/utils.h>
-#include <qmap.h>
+#include <tqmap.h>
#include <kstaticdeleter.h>
@@ -36,7 +36,7 @@ class AlterTableHandler::Private
~Private()
{}
ActionList actions;
- QGuardedPtr<Connection> conn;
+ TQGuardedPtr<Connection> conn;
};
}
@@ -91,7 +91,7 @@ AlterTableHandler::MoveFieldPositionAction& AlterTableHandler::ActionBase::toMov
//--------------------------------------------------------
-AlterTableHandler::FieldActionBase::FieldActionBase(const QString& fieldName, int uid)
+AlterTableHandler::FieldActionBase::FieldActionBase(const TQString& fieldName, int uid)
: ActionBase()
, m_fieldUID(uid)
, m_fieldName(fieldName)
@@ -110,21 +110,21 @@ AlterTableHandler::FieldActionBase::~FieldActionBase()
//--------------------------------------------------------
-static KStaticDeleter< QMap<QCString,int> > KexiDB_alteringTypeForProperty_deleter;
-QMap<QCString,int> *KexiDB_alteringTypeForProperty = 0;
+static KStaticDeleter< TQMap<TQCString,int> > KexiDB_alteringTypeForProperty_deleter;
+TQMap<TQCString,int> *KexiDB_alteringTypeForProperty = 0;
-int AlterTableHandler::alteringTypeForProperty(const QCString& propertyName)
+int AlterTableHandler::alteringTypeForProperty(const TQCString& propertyName)
{
if (!KexiDB_alteringTypeForProperty) {
KexiDB_alteringTypeForProperty_deleter.setObject( KexiDB_alteringTypeForProperty,
- new QMap<QCString,int>() );
+ new TQMap<TQCString,int>() );
#define I(name, type) \
- KexiDB_alteringTypeForProperty->insert(QCString(name).lower(), (int)AlterTableHandler::type)
+ KexiDB_alteringTypeForProperty->insert(TQCString(name).lower(), (int)AlterTableHandler::type)
#define I2(name, type1, type2) \
flag = (int)AlterTableHandler::type1|(int)AlterTableHandler::type2; \
if (flag & AlterTableHandler::PhysicalAlteringRequired) \
flag |= AlterTableHandler::MainSchemaAlteringRequired; \
- KexiDB_alteringTypeForProperty->insert(QCString(name).lower(), flag)
+ KexiDB_alteringTypeForProperty->insert(TQCString(name).lower(), flag)
/* useful links:
http://dev.mysql.com/doc/refman/5.0/en/create-table.html
@@ -180,8 +180,8 @@ int AlterTableHandler::alteringTypeForProperty(const QCString& propertyName)
if (res == 0) {
if (KexiDB::isExtendedTableFieldProperty(propertyName))
return (int)ExtendedSchemaAlteringRequired;
- KexiDBWarn << QString("AlterTableHandler::alteringTypeForProperty(): property \"%1\" not found!")
- .arg(propertyName) << endl;
+ KexiDBWarn << TQString("AlterTableHandler::alteringTypeForProperty(): property \"%1\" not found!")
+ .tqarg(propertyName.data()) << endl;
}
return res;
}
@@ -189,7 +189,7 @@ int AlterTableHandler::alteringTypeForProperty(const QCString& propertyName)
//---
AlterTableHandler::ChangeFieldPropertyAction::ChangeFieldPropertyAction(
- const QString& fieldName, const QString& propertyName, const QVariant& newValue, int uid)
+ const TQString& fieldName, const TQString& propertyName, const TQVariant& newValue, int uid)
: FieldActionBase(fieldName, uid)
, m_propertyName(propertyName)
, m_newValue(newValue)
@@ -211,12 +211,12 @@ void AlterTableHandler::ChangeFieldPropertyAction::updateAlteringRequirements()
setAlteringRequirements( alteringTypeForProperty( m_propertyName.latin1() ) );
}
-QString AlterTableHandler::ChangeFieldPropertyAction::debugString(const DebugOptions& debugOptions)
+TQString AlterTableHandler::ChangeFieldPropertyAction::debugString(const DebugOptions& debugOptions)
{
- QString s = QString("Set \"%1\" property for table field \"%2\" to \"%3\"")
- .arg(m_propertyName).arg(fieldName()).arg(m_newValue.toString());
+ TQString s = TQString("Set \"%1\" property for table field \"%2\" to \"%3\"")
+ .tqarg(m_propertyName).tqarg(fieldName()).tqarg(m_newValue.toString());
if (debugOptions.showUID)
- s.append(QString(" (UID=%1)").arg(m_fieldUID));
+ s.append(TQString(" (UID=%1)").tqarg(m_fieldUID));
return s;
}
@@ -230,9 +230,9 @@ static AlterTableHandler::ActionDict* createActionDict(
}
static void debugAction(AlterTableHandler::ActionBase *action, int nestingLevel,
- bool simulate, const QString& prependString = QString::null, QString* debugTarget = 0)
+ bool simulate, const TQString& prependString = TQString(), TQString* debugTarget = 0)
{
- QString debugString;
+ TQString debugString;
if (!debugTarget)
debugString = prependString;
if (action) {
@@ -260,14 +260,14 @@ static void debugAction(AlterTableHandler::ActionBase *action, int nestingLevel,
static void debugActionDict(AlterTableHandler::ActionDict *dict, int fieldUID, bool simulate)
{
- QString fieldName;
+ TQString fieldName;
AlterTableHandler::ActionDictIterator it(*dict);
if (dynamic_cast<AlterTableHandler::FieldActionBase*>(it.current())) //retrieve field name from the 1st related action
fieldName = dynamic_cast<AlterTableHandler::FieldActionBase*>(it.current())->fieldName();
else
fieldName = "??";
- QString dbg = QString("Action dict for field \"%1\" (%2, UID=%3):")
- .arg(fieldName).arg(dict->count()).arg(fieldUID);
+ TQString dbg = TQString("Action dict for field \"%1\" (%2, UID=%3):")
+ .tqarg(fieldName).tqarg(dict->count()).tqarg(fieldUID);
KexiDBDbg << dbg << endl;
#ifdef KEXI_DEBUG_GUI
if (simulate)
@@ -314,9 +314,9 @@ void AlterTableHandler::ChangeFieldPropertyAction::simplifyActions(ActionDictDic
ActionDict *actionsLikeThis = fieldActions[ uid() ];
if (m_propertyName=="name") {
// Case 1. special: name1 -> name2, i.e. rename action
- QString newName( newValue().toString() );
+ TQString newName( newValue().toString() );
// try to find rename(newName, otherName) action
- ActionBase *renameActionLikeThis = actionsLikeThis ? actionsLikeThis->find( "name" ) : 0;
+ ActionBase *renameActionLikeThis = actionsLikeThis ? actionsLikeThis->tqfind( "name" ) : 0;
if (dynamic_cast<ChangeFieldPropertyAction*>(renameActionLikeThis)) {
// 1. instead of having rename(fieldName(), newValue()) action,
// let's have rename(fieldName(), otherName) action
@@ -334,7 +334,7 @@ void AlterTableHandler::ChangeFieldPropertyAction::simplifyActions(ActionDictDic
adict->insert(m_propertyName.latin1(), newRenameAction);*/
}
else {
- ActionBase *removeActionForThisField = actionsLikeThis ? actionsLikeThis->find( ":remove:" ) : 0;
+ ActionBase *removeActionForThisField = actionsLikeThis ? actionsLikeThis->tqfind( ":remove:" ) : 0;
if (removeActionForThisField) {
//if this field is going to be removed, jsut change the action's field name
// and do not add a new action
@@ -362,7 +362,7 @@ void AlterTableHandler::ChangeFieldPropertyAction::simplifyActions(ActionDictDic
}
return;
}
- ActionBase *removeActionForThisField = actionsLikeThis ? actionsLikeThis->find( ":remove:" ) : 0;
+ ActionBase *removeActionForThisField = actionsLikeThis ? actionsLikeThis->tqfind( ":remove:" ) : 0;
if (removeActionForThisField) {
//if this field is going to be removed, do not add a new action
return;
@@ -372,7 +372,7 @@ void AlterTableHandler::ChangeFieldPropertyAction::simplifyActions(ActionDictDic
// becomes: [ setCaption(A, "captionB") ]
// because adding this action does nothing
ActionDict *nextActionsLikeThis = fieldActions[ uid() ]; //fieldName().latin1() ];
- if (!nextActionsLikeThis || !nextActionsLikeThis->find( m_propertyName.latin1() )) {
+ if (!nextActionsLikeThis || !nextActionsLikeThis->tqfind( m_propertyName.latin1() )) {
//no such action, add this
AlterTableHandler::ChangeFieldPropertyAction* newAction
= new AlterTableHandler::ChangeFieldPropertyAction( *this );
@@ -389,7 +389,7 @@ bool AlterTableHandler::ChangeFieldPropertyAction::shouldBeRemoved(ActionDictDic
}
tristate AlterTableHandler::ChangeFieldPropertyAction::updateTableSchema(TableSchema &table, Field* field,
- QMap<QString, QString>& fieldMap)
+ TQMap<TQString, TQString>& fieldMap)
{
//1. Simpler cases first: changes that do not affect table schema at all
// "caption", "description", "width", "visibleDecimalPlaces"
@@ -471,7 +471,7 @@ return true;
//--------------------------------------------------------
-AlterTableHandler::RemoveFieldAction::RemoveFieldAction(const QString& fieldName, int uid)
+AlterTableHandler::RemoveFieldAction::RemoveFieldAction(const TQString& fieldName, int uid)
: FieldActionBase(fieldName, uid)
{
}
@@ -493,11 +493,11 @@ void AlterTableHandler::RemoveFieldAction::updateAlteringRequirements()
//! @todo
}
-QString AlterTableHandler::RemoveFieldAction::debugString(const DebugOptions& debugOptions)
+TQString AlterTableHandler::RemoveFieldAction::debugString(const DebugOptions& debugOptions)
{
- QString s = QString("Remove table field \"%1\"").arg(fieldName());
+ TQString s = TQString("Remove table field \"%1\"").tqarg(fieldName());
if (debugOptions.showUID)
- s.append(QString(" (UID=%1)").arg(uid()));
+ s.append(TQString(" (UID=%1)").tqarg(uid()));
return s;
}
@@ -519,7 +519,7 @@ void AlterTableHandler::RemoveFieldAction::simplifyActions(ActionDictDict &field
}
tristate AlterTableHandler::RemoveFieldAction::updateTableSchema(TableSchema &table, Field* field,
- QMap<QString, QString>& fieldMap)
+ TQMap<TQString, TQString>& fieldMap)
{
fieldMap.remove( field->name() );
table.removeField(field);
@@ -569,7 +569,7 @@ void AlterTableHandler::InsertFieldAction::setField(KexiDB::Field* field)
if (m_field)
delete m_field;
m_field = field;
- setFieldName(m_field ? m_field->name() : QString::null);
+ setFieldName(m_field ? m_field->name() : TQString());
}
void AlterTableHandler::InsertFieldAction::updateAlteringRequirements()
@@ -580,14 +580,14 @@ void AlterTableHandler::InsertFieldAction::updateAlteringRequirements()
//! @todo
}
-QString AlterTableHandler::InsertFieldAction::debugString(const DebugOptions& debugOptions)
+TQString AlterTableHandler::InsertFieldAction::debugString(const DebugOptions& debugOptions)
{
- QString s = QString("Insert table field \"%1\" at position %2")
- .arg(m_field->name()).arg(m_index);
+ TQString s = TQString("Insert table field \"%1\" at position %2")
+ .tqarg(m_field->name()).tqarg(m_index);
if (debugOptions.showUID)
- s.append(QString(" (UID=%1)").arg(m_fieldUID));
+ s.append(TQString(" (UID=%1)").tqarg(m_fieldUID));
if (debugOptions.showFieldDebug)
- s.append(QString(" (%1)").arg(m_field->debugString()));
+ s.append(TQString(" (%1)").tqarg(m_field->debugString()));
return s;
}
@@ -608,7 +608,7 @@ void AlterTableHandler::InsertFieldAction::simplifyActions(ActionDictDict &field
// Try to find actions related to this action
ActionDict *actionsForThisField = fieldActions[ uid() ]; //m_field->name().latin1() ];
- ActionBase *removeActionForThisField = actionsForThisField ? actionsForThisField->find( ":remove:" ) : 0;
+ ActionBase *removeActionForThisField = actionsForThisField ? actionsForThisField->tqfind( ":remove:" ) : 0;
if (removeActionForThisField) {
//if this field is going to be removed, do not add a new action
//and remove the "Remove" action
@@ -617,7 +617,7 @@ void AlterTableHandler::InsertFieldAction::simplifyActions(ActionDictDict &field
}
if (actionsForThisField) {
//collect property values that have to be changed in this field
- QMap<QCString, QVariant> values;
+ TQMap<TQCString, TQVariant> values;
for (ActionDictIterator it(*actionsForThisField); it.current();) {
ChangeFieldPropertyAction* changePropertyAction = dynamic_cast<ChangeFieldPropertyAction*>(it.current());
if (changePropertyAction) {
@@ -642,13 +642,13 @@ void AlterTableHandler::InsertFieldAction::simplifyActions(ActionDictDict &field
field().debug();
#ifdef KEXI_DEBUG_GUI
KexiUtils::addAlterTableActionDebug(
- QString("** Property-set actions moved to field definition itself:\n")+field().debugString(), 0);
+ TQString("** Property-set actions moved to field definition itself:\n")+field().debugString(), 0);
#endif
}
else {
#ifdef KEXI_DEBUG_GUI
KexiUtils::addAlterTableActionDebug(
- QString("** Failed to set properties for field ")+field().debugString(), 0);
+ TQString("** Failed to set properties for field ")+field().debugString(), 0);
#endif
KexiDBWarn << "AlterTableHandler::InsertFieldAction::simplifyActions(): KexiDB::setFieldProperties() failed!" << endl;
delete f;
@@ -665,7 +665,7 @@ void AlterTableHandler::InsertFieldAction::simplifyActions(ActionDictDict &field
}
tristate AlterTableHandler::InsertFieldAction::updateTableSchema(TableSchema &table, Field* field,
- QMap<QString, QString>& fieldMap)
+ TQMap<TQString, TQString>& fieldMap)
{
//in most cases we won't add the field to fieldMap
Q_UNUSED(field);
@@ -686,7 +686,7 @@ tristate AlterTableHandler::InsertFieldAction::execute(Connection& conn, TableSc
//--------------------------------------------------------
AlterTableHandler::MoveFieldPositionAction::MoveFieldPositionAction(
- int fieldIndex, const QString& fieldName, int uid)
+ int fieldIndex, const TQString& fieldName, int uid)
: FieldActionBase(fieldName, uid)
, m_index(fieldIndex)
{
@@ -707,12 +707,12 @@ void AlterTableHandler::MoveFieldPositionAction::updateAlteringRequirements()
//! @todo
}
-QString AlterTableHandler::MoveFieldPositionAction::debugString(const DebugOptions& debugOptions)
+TQString AlterTableHandler::MoveFieldPositionAction::debugString(const DebugOptions& debugOptions)
{
- QString s = QString("Move table field \"%1\" to position %2")
- .arg(fieldName()).arg(m_index);
+ TQString s = TQString("Move table field \"%1\" to position %2")
+ .tqarg(fieldName()).tqarg(m_index);
if (debugOptions.showUID)
- s.append(QString(" (UID=%1)").arg(uid()));
+ s.append(TQString(" (UID=%1)").tqarg(uid()));
return s;
}
@@ -782,7 +782,7 @@ void AlterTableHandler::debug()
it.current()->debug();
}
-TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArguments& args)
+TableSchema* AlterTableHandler::execute(const TQString& tableName, ExecutionArguments& args)
{
args.result = false;
if (!d->conn) {
@@ -860,7 +860,7 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
ActionVector actionsVector(allActionsCount);
int currentActionsCount = 0; //some actions may be removed
args.requirements = 0;
- QDict<char> fieldsWithChangedMainSchema(997); // Used to collect fields with changed main schema.
+ TQDict<char> fieldsWithChangedMainSchema(997); // Used to collect fields with changed main schema.
// This will be used when recreateTable is false to update kexi__fields
for (ActionDictDictIterator it(fieldActions); it.current(); ++it) {
for (AlterTableHandler::ActionDictIterator it2(*it.current());it2.current(); ++it2, currentActionsCount++) {
@@ -878,7 +878,7 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
}
}
// - Debug
- QString dbg = QString("** Overall altering requirements: %1").arg(args.requirements);
+ TQString dbg = TQString("** Overall altering requirements: %1").tqarg(args.requirements);
KexiDBDbg << dbg << endl;
if (args.onlyComputeRequirements) {
@@ -892,14 +892,14 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
if (args.simulate)
KexiUtils::addAlterTableActionDebug(dbg, 0);
#endif
- dbg = QString("** Ordered, simplified actions (%1, was %2):").arg(currentActionsCount).arg(allActionsCount);
+ dbg = TQString("** Ordered, simplified actions (%1, was %2):").tqarg(currentActionsCount).tqarg(allActionsCount);
KexiDBDbg << dbg << endl;
#ifdef KEXI_DEBUG_GUI
if (args.simulate)
KexiUtils::addAlterTableActionDebug(dbg, 0);
#endif
for (int i=0; i<allActionsCount; i++) {
- debugAction(actionsVector[i], 1, args.simulate, QString("%1: ").arg(i+1), args.debugString);
+ debugAction(actionsVector[i], 1, args.simulate, TQString("%1: ").tqarg(i+1), args.debugString);
}
if (args.requirements == 0) {//nothing to do
@@ -916,9 +916,9 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
TableSchema *newTable = recreateTable ? new TableSchema(*oldTable, false/*!copy id*/) : oldTable;
// find nonexisting temp name for new table schema
if (recreateTable) {
- QString tempDestTableName;
+ TQString tempDestTableName;
while (true) {
- tempDestTableName = QString("%1_temp%2%3").arg(newTable->name()).arg(QString::number(rand(), 16)).arg(QString::number(rand(), 16));
+ tempDestTableName = TQString("%1_temp%2%3").tqarg(newTable->name()).tqarg(TQString::number(rand(), 16)).tqarg(TQString::number(rand(), 16));
if (!d->conn->tableSchema(tempDestTableName))
break;
}
@@ -931,7 +931,7 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
// Update table schema in memory ----
int lastUID = -1;
Field *currentField = 0;
- QMap<QString, QString> fieldMap; // a map from new value to old value
+ TQMap<TQString, TQString> fieldMap; // a map from new value to old value
foreach_list( Field::ListIterator, it, newTable->fieldsIterator() ) {
fieldMap.insert( it.current()->name(), it.current()->name() );
}
@@ -1007,14 +1007,14 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
// -Some source fields can be skipped in case when there are deleted fields.
// -Some destination fields can be skipped in case when there
// are new empty fields without fixed/default value.
- QString sql = QString("INSERT INTO %1 (").arg(d->conn->escapeIdentifier(newTable->name()));
+ TQString sql = TQString("INSERT INTO %1 (").tqarg(d->conn->escapeIdentifier(newTable->name()));
//insert list of dest. fields
bool first = true;
- QString sourceFields;
+ TQString sourceFields;
foreach_list( Field::ListIterator, it, newTable->fieldsIterator() ) {
Field * const f = it.current();
- QString renamedFieldName( fieldMap[ f->name() ] );
- QString sourceSQLString;
+ TQString renamedFieldName( fieldMap[ f->name() ] );
+ TQString sourceSQLString;
if (!renamedFieldName.isEmpty()) {
//this field should be renamed
sourceSQLString = d->conn->escapeIdentifier(renamedFieldName);
@@ -1051,7 +1051,7 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
sourceFields.append( sourceSQLString );
}
}
- sql.append(QString(") SELECT ") + sourceFields + " FROM " + oldTable->name());
+ sql.append(TQString(") SELECT ") + sourceFields + " FROM " + oldTable->name());
KexiDBDbg << " ** " << sql << endl;
if (!d->conn->executeSQL( sql )) {
setError(d->conn);
@@ -1060,7 +1060,7 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
return 0;
}
- const QString oldTableName = oldTable->name();
+ const TQString oldTableName = oldTable->name();
/* args.result = d->conn->dropTable( oldTable );
if (!args.result || ~args.result) {
setError(d->conn);
@@ -1070,7 +1070,7 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
oldTable = 0;*/
// Replace the old table with the new one (oldTable will be destroyed)
- if (!d->conn->alterTableName(*newTable, oldTableName, true /*replace*/)) {
+ if (!d->conn->alterTableName(*newTable, oldTableName, true /*tqreplace*/)) {
setError(d->conn);
//! @todo delete newTable...
args.result = false;
@@ -1082,7 +1082,7 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
if (!recreateTable) {
if ((MainSchemaAlteringRequired & args.requirements) && !fieldsWithChangedMainSchema.isEmpty()) {
//update main schema (kexi__fields) for changed fields
- foreach_list(QDictIterator<char>, it, fieldsWithChangedMainSchema) {
+ foreach_list(TQDictIterator<char>, it, fieldsWithChangedMainSchema) {
Field *f = newTable->field( it.currentKey() );
if (f) {
if (!d->conn->storeMainFieldSchema(f)) {
@@ -1100,12 +1100,12 @@ TableSchema* AlterTableHandler::execute(const QString& tableName, ExecutionArgum
return newTable;
}
-/*TableSchema* AlterTableHandler::execute(const QString& tableName, tristate &result, bool simulate)
+/*TableSchema* AlterTableHandler::execute(const TQString& tableName, tristate &result, bool simulate)
{
return executeInternal( tableName, result, simulate, 0 );
}
-tristate AlterTableHandler::simulateExecution(const QString& tableName, QString& debugString)
+tristate AlterTableHandler::simulateExecution(const TQString& tableName, TQString& debugString)
{
tristate result;
(void)executeInternal( tableName, result, true//simulate