diff options
Diffstat (limited to 'kexi/kexidb/utils.cpp')
-rw-r--r-- | kexi/kexidb/utils.cpp | 350 |
1 files changed, 175 insertions, 175 deletions
diff --git a/kexi/kexidb/utils.cpp b/kexi/kexidb/utils.cpp index 78b7e416..a44f9c36 100644 --- a/kexi/kexidb/utils.cpp +++ b/kexi/kexidb/utils.cpp @@ -22,11 +22,11 @@ #include "drivermanager.h" #include "lookupfieldschema.h" -#include <qmap.h> -#include <qthread.h> -#include <qdom.h> -#include <qintdict.h> -#include <qbuffer.h> +#include <tqmap.h> +#include <tqthread.h> +#include <tqdom.h> +#include <tqintdict.h> +#include <tqbuffer.h> #include <kdebug.h> #include <klocale.h> @@ -42,10 +42,10 @@ using namespace KexiDB; //! Cache struct TypeCache { - QMap< uint, TypeGroupList > tlist; - QMap< uint, QStringList > nlist; - QMap< uint, QStringList > slist; - QMap< uint, Field::Type > def_tlist; + TQMap< uint, TypeGroupList > tlist; + TQMap< uint, TQStringList > nlist; + TQMap< uint, TQStringList > slist; + TQMap< uint, Field::Type > def_tlist; }; static KStaticDeleter<TypeCache> KexiDB_typeCacheDeleter; @@ -58,8 +58,8 @@ static void initList() for (uint t=0; t<=KexiDB::Field::LastType; t++) { const uint tg = KexiDB::Field::typeGroup( t ); TypeGroupList list; - QStringList name_list, str_list; - if (KexiDB_typeCache->tlist.find( tg )!=KexiDB_typeCache->tlist.end()) { + TQStringList name_list, str_list; + if (KexiDB_typeCache->tlist.tqfind( tg )!=KexiDB_typeCache->tlist.end()) { list = KexiDB_typeCache->tlist[ tg ]; name_list = KexiDB_typeCache->nlist[ tg ]; str_list = KexiDB_typeCache->slist[ tg ]; @@ -88,14 +88,14 @@ const TypeGroupList KexiDB::typesForGroup(KexiDB::Field::TypeGroup typeGroup) return KexiDB_typeCache->tlist[ typeGroup ]; } -QStringList KexiDB::typeNamesForGroup(KexiDB::Field::TypeGroup typeGroup) +TQStringList KexiDB::typeNamesForGroup(KexiDB::Field::TypeGroup typeGroup) { if (!KexiDB_typeCache) initList(); return KexiDB_typeCache->nlist[ typeGroup ]; } -QStringList KexiDB::typeStringsForGroup(KexiDB::Field::TypeGroup typeGroup) +TQStringList KexiDB::typeStringsForGroup(KexiDB::Field::TypeGroup typeGroup) { if (!KexiDB_typeCache) initList(); @@ -109,7 +109,7 @@ KexiDB::Field::Type KexiDB::defaultTypeForGroup(KexiDB::Field::TypeGroup typeGro return (typeGroup <= Field::LastTypeGroup) ? KexiDB_typeCache->def_tlist[ typeGroup ] : Field::InvalidType; } -void KexiDB::getHTMLErrorMesage(Object* obj, QString& msg, QString &details) +void KexiDB::getHTMLErrorMesage(Object* obj, TQString& msg, TQString &details) { Connection *conn = 0; if (!obj || !obj->error()) { @@ -138,9 +138,9 @@ void KexiDB::getHTMLErrorMesage(Object* obj, QString& msg, QString &details) if (!obj->serverErrorMsg().isEmpty()) details += "<p><b><nobr>" +i18n("Message from server:") + "</nobr></b><br>" + obj->serverErrorMsg(); if (!obj->recentSQLString().isEmpty()) - details += "<p><b><nobr>" +i18n("SQL statement:") + QString("</nobr></b><br><tt>%1</tt>").arg(obj->recentSQLString()); + details += "<p><b><nobr>" +i18n("SQL statement:") + TQString("</nobr></b><br><tt>%1</tt>").tqarg(obj->recentSQLString()); int serverResult; - QString serverResultName; + TQString serverResultName; if (obj->serverResult()!=0) { serverResult = obj->serverResult(); serverResultName = obj->serverResultName(); @@ -150,22 +150,22 @@ void KexiDB::getHTMLErrorMesage(Object* obj, QString& msg, QString &details) serverResultName = obj->previousServerResultName(); } if (!serverResultName.isEmpty()) - details += (QString("<p><b><nobr>")+i18n("Server result name:")+"</nobr></b><br>"+serverResultName); + details += (TQString("<p><b><nobr>")+i18n("Server result name:")+"</nobr></b><br>"+serverResultName); if (!details.isEmpty() && (!obj->serverErrorMsg().isEmpty() || !obj->recentSQLString().isEmpty() || !serverResultName.isEmpty() || serverResult!=0) ) { - details += (QString("<p><b><nobr>")+i18n("Server result number:")+"</nobr></b><br>"+QString::number(serverResult)); + details += (TQString("<p><b><nobr>")+i18n("Server result number:")+"</nobr></b><br>"+TQString::number(serverResult)); } if (!details.isEmpty() && !details.startsWith("<qt>")) { if (details.startsWith("<p>")) - details = QString::fromLatin1("<qt>")+details; + details = TQString::tqfromLatin1("<qt>")+details; else - details = QString::fromLatin1("<qt><p>")+details; + details = TQString::tqfromLatin1("<qt><p>")+details; } } -void KexiDB::getHTMLErrorMesage(Object* obj, QString& msg) +void KexiDB::getHTMLErrorMesage(Object* obj, TQString& msg) { getHTMLErrorMesage(obj, msg, msg); } @@ -175,11 +175,11 @@ void KexiDB::getHTMLErrorMesage(Object* obj, ResultInfo *result) getHTMLErrorMesage(obj, result->msg, result->desc); } -int KexiDB::idForObjectName( Connection &conn, const QString& objName, int objType ) +int KexiDB::idForObjectName( Connection &conn, const TQString& objName, int objType ) { RowData data; - if (true!=conn.querySingleRecord(QString("select o_id from kexi__objects where lower(o_name)='%1' and o_type=%2") - .arg(objName.lower()).arg(objType), data)) + if (true!=conn.querySingleRecord(TQString("select o_id from kexi__objects where lower(o_name)='%1' and o_type=%2") + .tqarg(objName.lower()).tqarg(objType), data)) return 0; bool ok; int id = data[0].toInt(&ok); @@ -188,26 +188,26 @@ int KexiDB::idForObjectName( Connection &conn, const QString& objName, int objTy //----------------------------------------- -TableOrQuerySchema::TableOrQuerySchema(Connection *conn, const QCString& name) +TableOrQuerySchema::TableOrQuerySchema(Connection *conn, const TQCString& name) : m_name(name) { - m_table = conn->tableSchema(QString(name)); - m_query = m_table ? 0 : conn->querySchema(QString(name)); + m_table = conn->tableSchema(TQString(name)); + m_query = m_table ? 0 : conn->querySchema(TQString(name)); if (!m_table && !m_query) KexiDBWarn << "TableOrQuery(FieldList &tableOrQuery) : " " tableOrQuery is neither table nor query!" << endl; } -TableOrQuerySchema::TableOrQuerySchema(Connection *conn, const QCString& name, bool table) +TableOrQuerySchema::TableOrQuerySchema(Connection *conn, const TQCString& name, bool table) : m_name(name) - , m_table(table ? conn->tableSchema(QString(name)) : 0) - , m_query(table ? 0 : conn->querySchema(QString(name))) + , m_table(table ? conn->tableSchema(TQString(name)) : 0) + , m_query(table ? 0 : conn->querySchema(TQString(name))) { if (table && !m_table) - KexiDBWarn << "TableOrQuery(Connection *conn, const QCString& name, bool table) : " + KexiDBWarn << "TableOrQuery(Connection *conn, const TQCString& name, bool table) : " "no table specified!" << endl; if (!table && !m_query) - KexiDBWarn << "TableOrQuery(Connection *conn, const QCString& name, bool table) : " + KexiDBWarn << "TableOrQuery(Connection *conn, const TQCString& name, bool table) : " "no query specified!" << endl; } @@ -266,7 +266,7 @@ const QueryColumnInfo::Vector TableOrQuerySchema::columns(bool unique) return QueryColumnInfo::Vector(); } -QCString TableOrQuerySchema::name() const +TQCString TableOrQuerySchema::name() const { if (m_table) return m_table->name().latin1(); @@ -275,7 +275,7 @@ QCString TableOrQuerySchema::name() const return m_name; } -QString TableOrQuerySchema::captionOrName() const +TQString TableOrQuerySchema::captionOrName() const { SchemaData *sdata = m_table ? static_cast<SchemaData *>(m_table) : static_cast<SchemaData *>(m_query); if (!sdata) @@ -283,7 +283,7 @@ QString TableOrQuerySchema::captionOrName() const return sdata->caption().isEmpty() ? sdata->name() : sdata->caption(); } -Field* TableOrQuerySchema::field(const QString& name) +Field* TableOrQuerySchema::field(const TQString& name) { if (m_table) return m_table->field(name); @@ -293,7 +293,7 @@ Field* TableOrQuerySchema::field(const QString& name) return 0; } -QueryColumnInfo* TableOrQuerySchema::columnInfo(const QString& name) +QueryColumnInfo* TableOrQuerySchema::columnInfo(const TQString& name) { if (m_table) return m_table->query()->columnInfo(name); @@ -304,13 +304,13 @@ QueryColumnInfo* TableOrQuerySchema::columnInfo(const QString& name) return 0; } -QString TableOrQuerySchema::debugString() +TQString TableOrQuerySchema::debugString() { if (m_table) return m_table->debugString(); else if (m_query) return m_query->debugString(); - return QString::null; + return TQString(); } void TableOrQuerySchema::debug() @@ -333,7 +333,7 @@ Connection* TableOrQuerySchema::connection() const //------------------------------------------ -class ConnectionTestThread : public QThread { +class ConnectionTestThread : public TQThread { public: ConnectionTestThread(ConnectionTestDialog *dlg, const KexiDB::ConnectionData& connData); virtual void run(); @@ -372,7 +372,7 @@ void ConnectionTestThread::run() } // SQL database backends like PostgreSQL require executing "USE database" // if we really want to know connection to the server succeeded. - QString tmpDbName; + TQString tmpDbName; if (!conn->useTemporaryDatabaseIfNeeded( tmpDbName )) { m_dlg->error(conn); delete conn; @@ -382,12 +382,12 @@ void ConnectionTestThread::run() m_dlg->error(0); } -ConnectionTestDialog::ConnectionTestDialog(QWidget* parent, +ConnectionTestDialog::ConnectionTestDialog(TQWidget* tqparent, const KexiDB::ConnectionData& data, KexiDB::MessageHandler& msgHandler) - : KProgressDialog(parent, "testconn_dlg", + : KProgressDialog(tqparent, "testconn_dlg", i18n("Test Connection"), i18n("<qt>Testing connection to <b>%1</b> database server...</qt>") - .arg(data.serverInfoString(true)), true /*modal*/) + .tqarg(data.serverInfoString(true)), true /*modal*/) , m_thread(new ConnectionTestThread(this, data)) , m_connData(data) , m_msgHandler(&msgHandler) @@ -398,7 +398,7 @@ ConnectionTestDialog::ConnectionTestDialog(QWidget* parent, showCancelButton(true); progressBar()->setPercentageVisible(false); progressBar()->setTotalSteps(0); - connect(&m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout())); + connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout())); adjustSize(); resize(250, height()); } @@ -441,13 +441,13 @@ void ConnectionTestDialog::slotTimeout() else if (notResponding) { KMessageBox::sorry(0, i18n("<qt>Test connection to <b>%1</b> database server failed. The server is not responding.</qt>") - .arg(m_connData.serverInfoString(true)), + .tqarg(m_connData.serverInfoString(true)), i18n("Test Connection")); } else { KMessageBox::information(0, i18n("<qt>Test connection to <b>%1</b> database server established successfully.</qt>") - .arg(m_connData.serverInfoString(true)), + .tqarg(m_connData.serverInfoString(true)), i18n("Test Connection")); } // slotCancel(); @@ -483,17 +483,17 @@ void ConnectionTestDialog::slotCancel() KProgressDialog::slotCancel(); } -void KexiDB::connectionTestDialog(QWidget* parent, const KexiDB::ConnectionData& data, +void KexiDB::connectionTestDialog(TQWidget* tqparent, const KexiDB::ConnectionData& data, KexiDB::MessageHandler& msgHandler) { - ConnectionTestDialog dlg(parent, data, msgHandler); + ConnectionTestDialog dlg(tqparent, data, msgHandler); dlg.exec(); } -int KexiDB::rowCount(Connection &conn, const QString& sql) +int KexiDB::rowCount(Connection &conn, const TQString& sql) { int count = -1; //will be changed only on success of querySingleNumber() - QString selectSql( QString::fromLatin1("SELECT COUNT() FROM (") + sql + ")" ); + TQString selectSql( TQString::tqfromLatin1("SELECT COUNT() FROM (") + sql + ")" ); conn.querySingleNumber(selectSql, count); return count; } @@ -507,7 +507,7 @@ int KexiDB::rowCount(const KexiDB::TableSchema& tableSchema) } int count = -1; //will be changed only on success of querySingleNumber() tableSchema.connection()->querySingleNumber( - QString::fromLatin1("SELECT COUNT(*) FROM ") + TQString::tqfromLatin1("SELECT COUNT(*) FROM ") + tableSchema.connection()->driver()->escapeIdentifier(tableSchema.name()), count ); @@ -523,7 +523,7 @@ int KexiDB::rowCount(KexiDB::QuerySchema& querySchema) } int count = -1; //will be changed only on success of querySingleNumber() querySchema.connection()->querySingleNumber( - QString::fromLatin1("SELECT COUNT(*) FROM (") + TQString::tqfromLatin1("SELECT COUNT(*) FROM (") + querySchema.connection()->selectStatement(querySchema) + ")", count ); @@ -548,24 +548,24 @@ int KexiDB::fieldCount(KexiDB::TableOrQuerySchema& tableOrQuery) return -1; } -QMap<QString,QString> KexiDB::toMap( const ConnectionData& data ) +TQMap<TQString,TQString> KexiDB::toMap( const ConnectionData& data ) { - QMap<QString,QString> m; + TQMap<TQString,TQString> m; m["caption"] = data.caption; m["description"] = data.description; m["driverName"] = data.driverName; m["hostName"] = data.hostName; - m["port"] = QString::number(data.port); - m["useLocalSocketFile"] = QString::number((int)data.useLocalSocketFile); + m["port"] = TQString::number(data.port); + m["useLocalSocketFile"] = TQString::number((int)data.useLocalSocketFile); m["localSocketFileName"] = data.localSocketFileName; m["password"] = data.password; - m["savePassword"] = QString::number((int)data.savePassword); + m["savePassword"] = TQString::number((int)data.savePassword); m["userName"] = data.userName; m["fileName"] = data.fileName(); return m; } -void KexiDB::fromMap( const QMap<QString,QString>& map, ConnectionData& data ) +void KexiDB::fromMap( const TQMap<TQString,TQString>& map, ConnectionData& data ) { data.caption = map["caption"]; data.description = map["description"]; @@ -580,13 +580,13 @@ void KexiDB::fromMap( const QMap<QString,QString>& map, ConnectionData& data ) data.setFileName(map["fileName"]); } -bool KexiDB::splitToTableAndFieldParts(const QString& string, - QString& tableName, QString& fieldName, +bool KexiDB::splitToTableAndFieldParts(const TQString& string, + TQString& tableName, TQString& fieldName, SplitToTableAndFieldPartsOptions option) { - const int id = string.find('.'); + const int id = string.tqfind('.'); if (option & SetFieldNameIfNoTableName && id==-1) { - tableName = QString::null; + tableName = TQString(); fieldName = string; return !fieldName.isEmpty(); } @@ -603,21 +603,21 @@ bool KexiDB::supportsVisibleDecimalPlacesProperty(Field::Type type) return Field::isFPNumericType(type); } -QString KexiDB::formatNumberForVisibleDecimalPlaces(double value, int decimalPlaces) +TQString KexiDB::formatNumberForVisibleDecimalPlaces(double value, int decimalPlaces) { //! @todo round? if (decimalPlaces < 0) { - QString s( QString::number(value, 'f', 10 /*reasonable precision*/)); + TQString s( TQString::number(value, 'f', 10 /*reasonable precision*/)); uint i = s.length()-1; while (i>0 && s[i]=='0') i--; if (s[i]=='.') //remove '.' i--; - s = s.left(i+1).replace('.', KGlobal::locale()->decimalSymbol()); + s = s.left(i+1).tqreplace('.', KGlobal::locale()->decimalSymbol()); return s; } if (decimalPlaces == 0) - return QString::number((int)value); + return TQString::number((int)value); return KGlobal::locale()->formatNumber(value, decimalPlaces); } @@ -630,7 +630,7 @@ KexiDB::Field::Type KexiDB::intToFieldType( int type ) return (KexiDB::Field::Type)type; } -static bool setIntToFieldType( Field& field, const QVariant& value ) +static bool setIntToFieldType( Field& field, const TQVariant& value ) { bool ok; const int intType = value.toInt(&ok); @@ -643,14 +643,14 @@ static bool setIntToFieldType( Field& field, const QVariant& value ) } //! for KexiDB::isBuiltinTableFieldProperty() -static KStaticDeleter< QAsciiDict<char> > KexiDB_builtinFieldPropertiesDeleter; +static KStaticDeleter< TQAsciiDict<char> > KexiDB_builtinFieldPropertiesDeleter; //! for KexiDB::isBuiltinTableFieldProperty() -QAsciiDict<char>* KexiDB_builtinFieldProperties = 0; +TQAsciiDict<char>* KexiDB_builtinFieldProperties = 0; -bool KexiDB::isBuiltinTableFieldProperty( const QCString& propertyName ) +bool KexiDB::isBuiltinTableFieldProperty( const TQCString& propertyName ) { if (!KexiDB_builtinFieldProperties) { - KexiDB_builtinFieldPropertiesDeleter.setObject( KexiDB_builtinFieldProperties, new QAsciiDict<char>(499) ); + KexiDB_builtinFieldPropertiesDeleter.setObject( KexiDB_builtinFieldProperties, new TQAsciiDict<char>(499) ); #define ADD(name) KexiDB_builtinFieldProperties->insert(name, (char*)1) ADD("type"); ADD("primaryKey"); @@ -671,13 +671,13 @@ bool KexiDB::isBuiltinTableFieldProperty( const QCString& propertyName ) //! @todo always update this when new builtins appear! #undef ADD } - return KexiDB_builtinFieldProperties->find( propertyName ); + return KexiDB_builtinFieldProperties->tqfind( propertyName ); } -bool KexiDB::setFieldProperties( Field& field, const QMap<QCString, QVariant>& values ) +bool KexiDB::setFieldProperties( Field& field, const TQMap<TQCString, TQVariant>& values ) { - QMapConstIterator<QCString, QVariant> it; - if ( (it = values.find("type")) != values.constEnd() ) { + TQMapConstIterator<TQCString, TQVariant> it; + if ( (it = values.tqfind("type")) != values.constEnd() ) { if (!setIntToFieldType(field, *it)) return false; } @@ -690,57 +690,57 @@ bool KexiDB::setFieldProperties( Field& field, const QMap<QCString, QVariant>& v uint constraints = field.constraints(); bool ok = true; - if ( (it = values.find("primaryKey")) != values.constEnd() ) + if ( (it = values.tqfind("primaryKey")) != values.constEnd() ) SET_BOOLEAN_FLAG(PrimaryKey, (*it).toBool()); - if ( (it = values.find("indexed")) != values.constEnd() ) + if ( (it = values.tqfind("indexed")) != values.constEnd() ) SET_BOOLEAN_FLAG(Indexed, (*it).toBool()); - if ( (it = values.find("autoIncrement")) != values.constEnd() + if ( (it = values.tqfind("autoIncrement")) != values.constEnd() && KexiDB::Field::isAutoIncrementAllowed(field.type()) ) SET_BOOLEAN_FLAG(AutoInc, (*it).toBool()); - if ( (it = values.find("unique")) != values.constEnd() ) + if ( (it = values.tqfind("unique")) != values.constEnd() ) SET_BOOLEAN_FLAG(Unique, (*it).toBool()); - if ( (it = values.find("notNull")) != values.constEnd() ) + if ( (it = values.tqfind("notNull")) != values.constEnd() ) SET_BOOLEAN_FLAG(NotNull, (*it).toBool()); - if ( (it = values.find("allowEmpty")) != values.constEnd() ) + if ( (it = values.tqfind("allowEmpty")) != values.constEnd() ) SET_BOOLEAN_FLAG(NotEmpty, !(*it).toBool()); field.setConstraints( constraints ); uint options = 0; - if ( (it = values.find("unsigned")) != values.constEnd()) { + if ( (it = values.tqfind("unsigned")) != values.constEnd()) { options |= KexiDB::Field::Unsigned; if (!(*it).toBool()) options ^= KexiDB::Field::Unsigned; } field.setOptions( options ); - if ( (it = values.find("name")) != values.constEnd()) + if ( (it = values.tqfind("name")) != values.constEnd()) field.setName( (*it).toString() ); - if ( (it = values.find("caption")) != values.constEnd()) + if ( (it = values.tqfind("caption")) != values.constEnd()) field.setCaption( (*it).toString() ); - if ( (it = values.find("description")) != values.constEnd()) + if ( (it = values.tqfind("description")) != values.constEnd()) field.setDescription( (*it).toString() ); - if ( (it = values.find("length")) != values.constEnd()) + if ( (it = values.tqfind("length")) != values.constEnd()) field.setLength( (*it).isNull() ? 0/*default*/ : (*it).toUInt(&ok) ); if (!ok) return false; - if ( (it = values.find("precision")) != values.constEnd()) + if ( (it = values.tqfind("precision")) != values.constEnd()) field.setPrecision( (*it).isNull() ? 0/*default*/ : (*it).toUInt(&ok) ); if (!ok) return false; - if ( (it = values.find("defaultValue")) != values.constEnd()) + if ( (it = values.tqfind("defaultValue")) != values.constEnd()) field.setDefaultValue( *it ); - if ( (it = values.find("width")) != values.constEnd()) + if ( (it = values.tqfind("width")) != values.constEnd()) field.setWidth( (*it).isNull() ? 0/*default*/ : (*it).toUInt(&ok) ); if (!ok) return false; - if ( (it = values.find("visibleDecimalPlaces")) != values.constEnd() + if ( (it = values.tqfind("visibleDecimalPlaces")) != values.constEnd() && KexiDB::supportsVisibleDecimalPlacesProperty(field.type()) ) field.setVisibleDecimalPlaces( (*it).isNull() ? -1/*default*/ : (*it).toInt(&ok) ); if (!ok) return false; // set custom properties - typedef QMap<QCString, QVariant> PropertiesMap; + typedef TQMap<TQCString, TQVariant> PropertiesMap; foreach( PropertiesMap::ConstIterator, it, values ) { if (!isBuiltinTableFieldProperty( it.key() ) && !isExtendedTableFieldProperty( it.key() )) { field.setCustomProperty( it.key(), it.data() ); @@ -751,14 +751,14 @@ bool KexiDB::setFieldProperties( Field& field, const QMap<QCString, QVariant>& v } //! for KexiDB::isExtendedTableFieldProperty() -static KStaticDeleter< QAsciiDict<char> > KexiDB_extendedPropertiesDeleter; +static KStaticDeleter< TQAsciiDict<char> > KexiDB_extendedPropertiesDeleter; //! for KexiDB::isExtendedTableFieldProperty() -QAsciiDict<char>* KexiDB_extendedProperties = 0; +TQAsciiDict<char>* KexiDB_extendedProperties = 0; -bool KexiDB::isExtendedTableFieldProperty( const QCString& propertyName ) +bool KexiDB::isExtendedTableFieldProperty( const TQCString& propertyName ) { if (!KexiDB_extendedProperties) { - KexiDB_extendedPropertiesDeleter.setObject( KexiDB_extendedProperties, new QAsciiDict<char>(499, false) ); + KexiDB_extendedPropertiesDeleter.setObject( KexiDB_extendedProperties, new TQAsciiDict<char>(499, false) ); #define ADD(name) KexiDB_extendedProperties->insert(name, (char*)1) ADD("visibleDecimalPlaces"); ADD("rowSource"); @@ -773,10 +773,10 @@ bool KexiDB::isExtendedTableFieldProperty( const QCString& propertyName ) ADD("displayWidget"); #undef ADD } - return KexiDB_extendedProperties->find( propertyName ); + return KexiDB_extendedProperties->tqfind( propertyName ); } -bool KexiDB::setFieldProperty( Field& field, const QCString& propertyName, const QVariant& value ) +bool KexiDB::setFieldProperty( Field& field, const TQCString& propertyName, const TQVariant& value ) { #define SET_BOOLEAN_FLAG(flag, value) { \ constraints |= KexiDB::Field::flag; \ @@ -806,8 +806,8 @@ bool KexiDB::setFieldProperty( Field& field, const QCString& propertyName, const } else { if (!field.table()) { - KexiDBWarn << QString("KexiDB::setFieldProperty() Cannot set \"%1\" property - no table assinged for field!") - .arg(propertyName) << endl; + KexiDBWarn << TQString("KexiDB::setFieldProperty() Cannot set \"%1\" property - no table assinged for field!") + .tqarg(propertyName.data()) << endl; } else { LookupFieldSchema *lookup = field.table()->lookupFieldSchema(field); @@ -886,45 +886,45 @@ bool KexiDB::setFieldProperty( Field& field, const QCString& propertyName, const #undef GET_INT } -int KexiDB::loadIntPropertyValueFromDom( const QDomNode& node, bool* ok ) +int KexiDB::loadIntPropertyValueFromDom( const TQDomNode& node, bool* ok ) { - QCString valueType = node.nodeName().latin1(); + TQCString valueType = node.nodeName().latin1(); if (valueType.isEmpty() || valueType!="number") { if (ok) *ok = false; return 0; } - const QString text( QDomNode(node).toElement().text() ); + const TQString text( TQDomNode(node).toElement().text() ); int val = text.toInt(ok); return val; } -QString KexiDB::loadStringPropertyValueFromDom( const QDomNode& node, bool* ok ) +TQString KexiDB::loadStringPropertyValueFromDom( const TQDomNode& node, bool* ok ) { - QCString valueType = node.nodeName().latin1(); + TQCString valueType = node.nodeName().latin1(); if (valueType!="string") { if (ok) *ok = false; return 0; } - return QDomNode(node).toElement().text(); + return TQDomNode(node).toElement().text(); } -QVariant KexiDB::loadPropertyValueFromDom( const QDomNode& node ) +TQVariant KexiDB::loadPropertyValueFromDom( const TQDomNode& node ) { - QCString valueType = node.nodeName().latin1(); + TQCString valueType = node.nodeName().latin1(); if (valueType.isEmpty()) - return QVariant(); - const QString text( QDomNode(node).toElement().text() ); + return TQVariant(); + const TQString text( TQDomNode(node).toElement().text() ); bool ok; if (valueType == "string") { return text; } else if (valueType == "cstring") { - return QCString(text.latin1()); + return TQCString(text.latin1()); } else if (valueType == "number") { // integer or double - if (text.find('.')!=-1) { + if (text.tqfind('.')!=-1) { double val = text.toDouble(&ok); if (ok) return val; @@ -933,106 +933,106 @@ QVariant KexiDB::loadPropertyValueFromDom( const QDomNode& node ) const int val = text.toInt(&ok); if (ok) return val; - const Q_LLONG valLong = text.toLongLong(&ok); + const TQ_LLONG valLong = text.toLongLong(&ok); if (ok) return valLong; } } else if (valueType == "bool") { - return QVariant(text.lower()=="true" || text=="1", 1); + return TQVariant(text.lower()=="true" || text=="1", 1); } -//! @todo add more QVariant types +//! @todo add more TQVariant types KexiDBWarn << "loadPropertyValueFromDom(): unknown type '" << valueType << "'" << endl; - return QVariant(); + return TQVariant(); } -QDomElement KexiDB::saveNumberElementToDom(QDomDocument& doc, QDomElement& parentEl, - const QString& elementName, int value) +TQDomElement KexiDB::saveNumberElementToDom(TQDomDocument& doc, TQDomElement& tqparentEl, + const TQString& elementName, int value) { - QDomElement el( doc.createElement(elementName) ); - parentEl.appendChild( el ); - QDomElement numberEl( doc.createElement("number") ); + TQDomElement el( doc.createElement(elementName) ); + tqparentEl.appendChild( el ); + TQDomElement numberEl( doc.createElement("number") ); el.appendChild( numberEl ); - numberEl.appendChild( doc.createTextNode( QString::number(value) ) ); + numberEl.appendChild( doc.createTextNode( TQString::number(value) ) ); return el; } -QDomElement KexiDB::saveBooleanElementToDom(QDomDocument& doc, QDomElement& parentEl, - const QString& elementName, bool value) +TQDomElement KexiDB::saveBooleanElementToDom(TQDomDocument& doc, TQDomElement& tqparentEl, + const TQString& elementName, bool value) { - QDomElement el( doc.createElement(elementName) ); - parentEl.appendChild( el ); - QDomElement numberEl( doc.createElement("bool") ); + TQDomElement el( doc.createElement(elementName) ); + tqparentEl.appendChild( el ); + TQDomElement numberEl( doc.createElement("bool") ); el.appendChild( numberEl ); numberEl.appendChild( doc.createTextNode( - value ? QString::fromLatin1("true") : QString::fromLatin1("false") ) ); + value ? TQString::tqfromLatin1("true") : TQString::tqfromLatin1("false") ) ); return el; } //! Used in KexiDB::emptyValueForType() -static KStaticDeleter< QValueVector<QVariant> > KexiDB_emptyValueForTypeCacheDeleter; -QValueVector<QVariant> *KexiDB_emptyValueForTypeCache = 0; +static KStaticDeleter< TQValueVector<TQVariant> > KexiDB_emptyValueForTypeCacheDeleter; +TQValueVector<TQVariant> *KexiDB_emptyValueForTypeCache = 0; -QVariant KexiDB::emptyValueForType( KexiDB::Field::Type type ) +TQVariant KexiDB::emptyValueForType( KexiDB::Field::Type type ) { if (!KexiDB_emptyValueForTypeCache) { KexiDB_emptyValueForTypeCacheDeleter.setObject( KexiDB_emptyValueForTypeCache, - new QValueVector<QVariant>(int(Field::LastType)+1) ); + new TQValueVector<TQVariant>(int(Field::LastType)+1) ); #define ADD(t, value) (*KexiDB_emptyValueForTypeCache)[t]=value; ADD(Field::Byte, 0); ADD(Field::ShortInteger, 0); ADD(Field::Integer, 0); ADD(Field::BigInteger, 0); - ADD(Field::Boolean, QVariant(false, 0)); + ADD(Field::Boolean, TQVariant(false, 0)); ADD(Field::Float, 0.0); ADD(Field::Double, 0.0); //! @todo ok? we have no better defaults - ADD(Field::Text, QString(" ")); - ADD(Field::LongText, QString(" ")); - ADD(Field::BLOB, QByteArray()); + ADD(Field::Text, TQString(" ")); + ADD(Field::LongText, TQString(" ")); + ADD(Field::BLOB, TQByteArray()); #undef ADD } - const QVariant val( KexiDB_emptyValueForTypeCache->at( + const TQVariant val( KexiDB_emptyValueForTypeCache->at( (type<=Field::LastType) ? type : Field::InvalidType) ); if (!val.isNull()) return val; else { //special cases if (type==Field::Date) - return QDate::currentDate(); + return TQDate::tqcurrentDate(); if (type==Field::DateTime) - return QDateTime::currentDateTime(); + return TQDateTime::tqcurrentDateTime(); if (type==Field::Time) - return QTime::currentTime(); + return TQTime::currentTime(); } KexiDBWarn << "KexiDB::emptyValueForType() no value for type " << Field::typeName(type) << endl; - return QVariant(); + return TQVariant(); } //! Used in KexiDB::notEmptyValueForType() -static KStaticDeleter< QValueVector<QVariant> > KexiDB_notEmptyValueForTypeCacheDeleter; -QValueVector<QVariant> *KexiDB_notEmptyValueForTypeCache = 0; +static KStaticDeleter< TQValueVector<TQVariant> > KexiDB_notEmptyValueForTypeCacheDeleter; +TQValueVector<TQVariant> *KexiDB_notEmptyValueForTypeCache = 0; -QVariant KexiDB::notEmptyValueForType( KexiDB::Field::Type type ) +TQVariant KexiDB::notEmptyValueForType( KexiDB::Field::Type type ) { if (!KexiDB_notEmptyValueForTypeCache) { KexiDB_notEmptyValueForTypeCacheDeleter.setObject( KexiDB_notEmptyValueForTypeCache, - new QValueVector<QVariant>(int(Field::LastType)+1) ); + new TQValueVector<TQVariant>(int(Field::LastType)+1) ); #define ADD(t, value) (*KexiDB_notEmptyValueForTypeCache)[t]=value; // copy most of the values for (int i = int(Field::InvalidType) + 1; i<=Field::LastType; i++) { if (i==Field::Date || i==Field::DateTime || i==Field::Time) continue; //'current' value will be returned if (i==Field::Text || i==Field::LongText) { - ADD(i, QVariant(QString(""))); + ADD(i, TQVariant(TQString(""))); continue; } if (i==Field::BLOB) { //! @todo blobs will contain other mime types too - QByteArray ba; - QBuffer buffer( ba ); + TQByteArray ba; + TQBuffer buffer( ba ); buffer.open( IO_WriteOnly ); - QPixmap pm(SmallIcon("filenew")); + TQPixmap pm(SmallIcon("filenew")); pm.save( &buffer, "PNG"/*! @todo default? */ ); ADD(i, ba); continue; @@ -1041,46 +1041,46 @@ QVariant KexiDB::notEmptyValueForType( KexiDB::Field::Type type ) } #undef ADD } - const QVariant val( KexiDB_notEmptyValueForTypeCache->at( + const TQVariant val( KexiDB_notEmptyValueForTypeCache->at( (type<=Field::LastType) ? type : Field::InvalidType) ); if (!val.isNull()) return val; else { //special cases if (type==Field::Date) - return QDate::currentDate(); + return TQDate::tqcurrentDate(); if (type==Field::DateTime) - return QDateTime::currentDateTime(); + return TQDateTime::tqcurrentDateTime(); if (type==Field::Time) - return QTime::currentTime(); + return TQTime::currentTime(); } KexiDBWarn << "KexiDB::notEmptyValueForType() no value for type " << Field::typeName(type) << endl; - return QVariant(); + return TQVariant(); } -QString KexiDB::escapeBLOB(const QByteArray& array, BLOBEscapingType type) +TQString KexiDB::escapeBLOB(const TQByteArray& array, BLOBEscapingType type) { const int size = array.size(); if (size==0) - return QString::null; + return TQString(); int escaped_length = size*2; if (type == BLOBEscape0xHex || type == BLOBEscapeOctal) escaped_length += 2/*0x or X'*/; else if (type == BLOBEscapeXHex) escaped_length += 3; //X' + ' - QString str; + TQString str; str.reserve(escaped_length); if (str.capacity() < (uint)escaped_length) { KexiDBWarn << "KexiDB::Driver::escapeBLOB(): no enough memory (cannot allocate "<< escaped_length<<" chars)" << endl; - return QString::null; + return TQString(); } if (type == BLOBEscapeXHex) - str = QString::fromLatin1("X'"); + str = TQString::tqfromLatin1("X'"); else if (type == BLOBEscape0xHex) - str = QString::fromLatin1("0x"); + str = TQString::tqfromLatin1("0x"); else if (type == BLOBEscapeOctal) - str = QString::fromLatin1("'"); + str = TQString::tqfromLatin1("'"); int new_length = str.length(); //after X' or 0x, etc. if (type == BLOBEscapeOctal) { @@ -1113,9 +1113,9 @@ QString KexiDB::escapeBLOB(const QByteArray& array, BLOBEscapingType type) return str; } -QByteArray KexiDB::pgsqlByteaToByteArray(const char* data, int length) +TQByteArray KexiDB::pgsqlByteaToByteArray(const char* data, int length) { - QByteArray array; + TQByteArray array; int output=0; for (int pass=0; pass<2; pass++) {//2 passes to avoid allocating buffer twice: // 0: count #of chars; 1: copy data @@ -1161,41 +1161,41 @@ QByteArray KexiDB::pgsqlByteaToByteArray(const char* data, int length) return array; } -QString KexiDB::variantToString( const QVariant& v ) +TQString KexiDB::variantToString( const TQVariant& v ) { - if (v.type()==QVariant::ByteArray) + if (v.type()==TQVariant::ByteArray) return KexiDB::escapeBLOB(v.toByteArray(), KexiDB::BLOBEscapeHex); return v.toString(); } -QVariant KexiDB::stringToVariant( const QString& s, QVariant::Type type, bool &ok ) +TQVariant KexiDB::stringToVariant( const TQString& s, TQVariant::Type type, bool &ok ) { if (s.isNull()) { ok = true; - return QVariant(); + return TQVariant(); } - if (QVariant::Invalid==type) { + if (TQVariant::Invalid==type) { ok = false; - return QVariant(); + return TQVariant(); } - if (type==QVariant::ByteArray) {//special case: hex string + if (type==TQVariant::ByteArray) {//special case: hex string const uint len = s.length(); - QByteArray ba(len/2 + len%2); + TQByteArray ba(len/2 + len%2); for (uint i=0; i<(len-1); i+=2) { int c = s.mid(i,2).toInt(&ok, 16); if (!ok) { KexiDBWarn << "KexiDB::stringToVariant(): Error in digit " << i << endl; - return QVariant(); + return TQVariant(); } ba[i/2] = (char)c; } ok = true; return ba; } - QVariant result(s); + TQVariant result(s); if (!result.cast( type )) { ok = false; - return QVariant(); + return TQVariant(); } ok = true; return result; @@ -1228,7 +1228,7 @@ void KexiDB::getLimitsForType(Field::Type type, int &minValue, int &maxValue) void KexiDB::debugRowData(const RowData& rowData) { - KexiDBDbg << QString("ROW DATA (%1 columns):").arg(rowData.count()) << endl; + KexiDBDbg << TQString("ROW DATA (%1 columns):").tqarg(rowData.count()) << endl; foreach(RowData::ConstIterator, it, rowData) KexiDBDbg << "- " << (*it) << endl; } @@ -1248,7 +1248,7 @@ Field::Type KexiDB::maximumForIntegerTypes(Field::Type t1, Field::Type t2) return KexiDB::maximumForIntegerTypes(t2, t1); //swap } -QString KexiDB::simplifiedTypeName(const Field& field) +TQString KexiDB::simplifiedTypeName(const Field& field) { if (field.isNumericType()) return i18n("Number"); //simplify |