diff options
Diffstat (limited to 'kexi/kexidb/field.cpp')
-rw-r--r-- | kexi/kexidb/field.cpp | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/kexi/kexidb/field.cpp b/kexi/kexidb/field.cpp index 88233272..97c4ae58 100644 --- a/kexi/kexidb/field.cpp +++ b/kexi/kexidb/field.cpp @@ -29,7 +29,7 @@ #include <kdebug.h> #include <klocale.h> -#include <qdatetime.h> +#include <tqdatetime.h> #include <assert.h> @@ -63,9 +63,9 @@ Field::Field(QuerySchema *querySchema, BaseExpr* expr) setExpression(expr); } -Field::Field(const QString& name, Type ctype, +Field::Field(const TQString& name, Type ctype, uint cconst, uint options, uint length, uint precision, - QVariant defaultValue, const QString& caption, const QString& description, + TQVariant defaultValue, const TQString& caption, const TQString& description, uint width) : m_parent(0) ,m_name(name.lower()) @@ -124,7 +124,7 @@ void Field::init() m_precision = 0; m_visibleDecimalPlaces = -1; m_options = NoOptions; - m_defaultValue = QVariant(QString::null); + m_defaultValue = TQVariant(TQString()); m_order = -1; m_width = 0; m_expr = 0; @@ -138,7 +138,7 @@ Field::Type Field::type() const return m_type; } -QVariant::Type Field::variantType(uint type) +TQVariant::Type Field::variantType(uint type) { switch(type) { @@ -146,67 +146,67 @@ QVariant::Type Field::variantType(uint type) case ShortInteger: case Integer: case BigInteger: - return QVariant::Int; + return TQVariant::Int; case Boolean: - return QVariant::Bool; + return TQVariant::Bool; case Date: - return QVariant::Date; + return TQVariant::Date; case DateTime: - return QVariant::DateTime; + return TQVariant::DateTime; case Time: - return QVariant::Time; + return TQVariant::Time; case Float: case Double: - return QVariant::Double; + return TQVariant::Double; case Text: case LongText: - return QVariant::String; + return TQVariant::String; case BLOB: - return QVariant::ByteArray; + return TQVariant::ByteArray; default: - return QVariant::Invalid; + return TQVariant::Invalid; } - return QVariant::Invalid; + return TQVariant::Invalid; } -QString Field::typeName(uint type) +TQString Field::typeName(uint type) { m_typeNames.init(); - return (type <= LastType) ? m_typeNames.at(type) : QString::number(type); + return (type <= LastType) ? m_typeNames.at(type) : TQString::number(type); } -QString Field::typeString(uint type) +TQString Field::typeString(uint type) { m_typeNames.init(); - return (type <= LastType) ? m_typeNames.at((int)LastType+1 + type) : QString("Type%1").arg(type); + return (type <= LastType) ? m_typeNames.at((int)LastType+1 + type) : TQString("Type%1").tqarg(type); } -QString Field::typeGroupName(uint typeGroup) +TQString Field::typeGroupName(uint typeGroup) { m_typeGroupNames.init(); return (typeGroup <= LastTypeGroup) ? m_typeGroupNames.at(typeGroup) : typeGroupString(typeGroup); } -QString Field::typeGroupString(uint typeGroup) +TQString Field::typeGroupString(uint typeGroup) { m_typeGroupNames.init(); - return (typeGroup <= LastTypeGroup) ? m_typeGroupNames.at((int)LastTypeGroup+1 + typeGroup) : QString("TypeGroup%1").arg(typeGroup); + return (typeGroup <= LastTypeGroup) ? m_typeGroupNames.at((int)LastTypeGroup+1 + typeGroup) : TQString("TypeGroup%1").tqarg(typeGroup); } -Field::Type Field::typeForString(const QString& typeString) +Field::Type Field::typeForString(const TQString& typeString) { m_typeNames.init(); - QMap<QString,Type>::ConstIterator it = m_typeNames.str2num.find(typeString.lower()); + TQMap<TQString,Type>::ConstIterator it = m_typeNames.str2num.tqfind(typeString.lower()); if (it==m_typeNames.str2num.end()) return InvalidType; return it.data(); } -Field::TypeGroup Field::typeGroupForString(const QString& typeGroupString) +Field::TypeGroup Field::typeGroupForString(const TQString& typeGroupString) { m_typeGroupNames.init(); - QMap<QString,TypeGroup>::ConstIterator it = m_typeGroupNames.str2num.find(typeGroupString.lower()); + TQMap<TQString,TypeGroup>::ConstIterator it = m_typeGroupNames.str2num.tqfind(typeGroupString.lower()); if (it==m_typeGroupNames.str2num.end()) return InvalidGroup; return it.data(); @@ -321,7 +321,7 @@ Field::setQuery(QuerySchema *querySchema) } void -Field::setName(const QString& n) +Field::setName(const TQString& n) { m_name = n.lower(); } @@ -330,7 +330,7 @@ void Field::setType(Type t) { if (m_expr) { - KexiDBWarn << QString("Field::setType(%1)").arg(t) + KexiDBWarn << TQString("Field::setType(%1)").tqarg(t) << " could not set type because the field has expression assigned!" << endl; return; } @@ -393,16 +393,16 @@ Field::setUnsigned(bool u) } void -Field::setDefaultValue(const QVariant& def) +Field::setDefaultValue(const TQVariant& def) { m_defaultValue = def; } bool -Field::setDefaultValue(const QCString& def) +Field::setDefaultValue(const TQCString& def) { if (def.isNull()) { - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); return true; } @@ -412,101 +412,101 @@ Field::setDefaultValue(const QCString& def) case Byte: { unsigned int v = def.toUInt(&ok); if (!ok || v > 255) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(v); + m_defaultValue = TQVariant(v); break; }case ShortInteger: { int v = def.toInt(&ok); if (!ok || (!(m_options & Unsigned) && (v < -32768 || v > 32767)) || ((m_options & Unsigned) && (v < 0 || v > 65535))) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(v); + m_defaultValue = TQVariant(v); break; }case Integer: {//4 bytes long v = def.toLong(&ok); //js: FIXME if (!ok || (!(m_options & Unsigned) && (-v > 0x080000000 || v > (0x080000000-1))) || ((m_options & Unsigned) && (v < 0 || v > 0x100000000))) if (!ok || (!(m_options & Unsigned) && (-v > (int)0x07FFFFFFF || v > (int)(0x080000000-1)))) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant((Q_LLONG)v); + m_defaultValue = TQVariant((TQ_LLONG)v); break; }case BigInteger: {//8 bytes //! @todo BigInteger support /* - Q_LLONG long v = def.toLongLong(&ok); + TQ_LLONG long v = def.toLongLong(&ok); //TODO: 2-part decoding if (!ok || (!(m_options & Unsigned) && (-v > 0x080000000 || v > (0x080000000-1)))) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else if (m_options & Unsigned) - m_defaultValue=QVariant((Q_ULLONG) v); + m_defaultValue=TQVariant((TQ_ULLONG) v); else - m_defaultValue = QVariant((Q_LLONG)v);*/ + m_defaultValue = TQVariant((TQ_LLONG)v);*/ break; }case Boolean: { unsigned short v = def.toUShort(&ok); if (!ok || v > 1) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant((bool)v); + m_defaultValue = TQVariant((bool)v); break; }case Date: {//YYYY-MM-DD - QDate date = QDate::fromString( def, Qt::ISODate ); + TQDate date = TQDate::fromString( def, Qt::ISODate ); if (!date.isValid()) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(date); + m_defaultValue = TQVariant(date); break; }case DateTime: {//YYYY-MM-DDTHH:MM:SS - QDateTime dt = QDateTime::fromString( def, Qt::ISODate ); + TQDateTime dt = TQDateTime::fromString( def, Qt::ISODate ); if (!dt.isValid()) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(dt); + m_defaultValue = TQVariant(dt); break; }case Time: {//HH:MM:SS - QTime time = QTime::fromString( def, Qt::ISODate ); + TQTime time = TQTime::fromString( def, Qt::ISODate ); if (!time.isValid()) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(time); + m_defaultValue = TQVariant(time); break; }case Float: { float v = def.toFloat(&ok); if (!ok || ((m_options & Unsigned) && (v < 0.0))) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(v); + m_defaultValue = TQVariant(v); break; }case Double: { double v = def.toDouble(&ok); if (!ok || ((m_options & Unsigned) && (v < 0.0))) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(v); + m_defaultValue = TQVariant(v); break; }case Text: { if (def.isNull() || (def.length() > 255)) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant((QString)def); + m_defaultValue = TQVariant((TQString)def); break; }case LongText: { if (def.isNull()) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant((QString)def); + m_defaultValue = TQVariant((TQString)def); break; }case BLOB: { //TODO if (def.isNull()) - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); else - m_defaultValue = QVariant(def); + m_defaultValue = TQVariant(def); break; }default: - m_defaultValue = QVariant(); + m_defaultValue = TQVariant(); } return m_defaultValue.isNull(); } @@ -580,25 +580,25 @@ void Field::setIndexed(bool s) } -QString Field::debugString() const +TQString Field::debugString() const { KexiDB::Connection *conn = table() ? table()->connection() : 0; - QString dbg = (m_name.isEmpty() ? "<NONAME> " : m_name + " "); + TQString dbg = (m_name.isEmpty() ? "<NONAME> " : m_name + " "); if (m_options & Field::Unsigned) dbg += " UNSIGNED "; dbg += (conn && conn->driver()) ? conn->driver()->sqlTypeName(type()) : Driver::defaultSQLTypeName(type()); if (isFPNumericType() && m_precision>0) { if (scale()>0) - dbg += QString::fromLatin1("(%1,%2)").arg(m_precision).arg(scale()); + dbg += TQString::tqfromLatin1("(%1,%2)").tqarg(m_precision).tqarg(scale()); else - dbg += QString::fromLatin1("(%1)").arg(m_precision); + dbg += TQString::tqfromLatin1("(%1)").tqarg(m_precision); } else if (m_type==Field::Text && m_length>0) - dbg += QString::fromLatin1("(%1)").arg(m_length); + dbg += TQString::tqfromLatin1("(%1)").tqarg(m_length); if (m_constraints & Field::AutoInc) dbg += " AUTOINC"; if (m_constraints & Field::Unique) - dbg += " UNIQUE"; + dbg += " UNITQUE"; if (m_constraints & Field::PrimaryKey) dbg += " PKEY"; if (m_constraints & Field::ForeignKey) @@ -608,18 +608,18 @@ QString Field::debugString() const if (m_constraints & Field::NotEmpty) dbg += " NOTEMPTY"; if (!m_defaultValue.isNull()) - dbg += QString(" DEFAULT=[%1]").arg(m_defaultValue.typeName()) + KexiDB::variantToString(m_defaultValue); + dbg += TQString(" DEFAULT=[%1]").tqarg(m_defaultValue.typeName()) + KexiDB::variantToString(m_defaultValue); if (m_expr) dbg += " EXPRESSION=" + m_expr->debugString(); if (m_customProperties && !m_customProperties->isEmpty()) { - dbg += QString(" CUSTOM PROPERTIES (%1): ").arg(m_customProperties->count()); + dbg += TQString(" CUSTOM PROPERTIES (%1): ").tqarg(m_customProperties->count()); bool first = true; foreach (CustomPropertiesMap::ConstIterator, it, *m_customProperties) { if (first) first = false; else dbg += ", "; - dbg += QString("%1 = %2 (%3)").arg(it.key()).arg(it.data().toString()).arg(it.data().typeName()); + dbg += TQString("%1 = %2 (%3)").tqarg(TQString(it.key())).tqarg(TQString(it.data().toString())).tqarg(TQString(it.data().typeName())); } } return dbg; @@ -641,18 +641,18 @@ void Field::setExpression(KexiDB::BaseExpr *expr) m_expr = expr; } -QVariant Field::customProperty(const QCString& propertyName, - const QVariant& defaultValue) const +TQVariant Field::customProperty(const TQCString& propertyName, + const TQVariant& defaultValue) const { if (!m_customProperties) return defaultValue; - CustomPropertiesMap::ConstIterator it(m_customProperties->find(propertyName)); + CustomPropertiesMap::ConstIterator it(m_customProperties->tqfind(propertyName)); if (it==m_customProperties->constEnd()) return defaultValue; return it.data(); } -void Field::setCustomProperty(const QCString& propertyName, const QVariant& value) +void Field::setCustomProperty(const TQCString& propertyName, const TQVariant& value) { if (propertyName.isEmpty()) return; @@ -664,13 +664,13 @@ void Field::setCustomProperty(const QCString& propertyName, const QVariant& valu //------------------------------------------------------- #define ADDTYPE(type, i18, str) this->at(Field::type) = i18; \ this->at(Field::type+Field::LastType+1) = str; \ - str2num.insert(QString::fromLatin1(str).lower(), type) + str2num.insert(TQString::tqfromLatin1(str).lower(), type) #define ADDGROUP(type, i18, str) this->at(Field::type) = i18; \ this->at(Field::type+Field::LastTypeGroup+1) = str; \ - str2num.insert(QString::fromLatin1(str).lower(), type) + str2num.insert(TQString::tqfromLatin1(str).lower(), type) Field::FieldTypeNames::FieldTypeNames() - : QValueVector<QString>() + : TQValueVector<TQString>() , m_initialized(false) { } @@ -701,7 +701,7 @@ void Field::FieldTypeNames::init() //------------------------------------------------------- Field::FieldTypeGroupNames::FieldTypeGroupNames() - : QValueVector<QString>() + : TQValueVector<TQString>() , m_initialized(false) { } |