diff options
Diffstat (limited to 'src/tellico_utils.cpp')
-rw-r--r-- | src/tellico_utils.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/tellico_utils.cpp b/src/tellico_utils.cpp index 6af6706..d660839 100644 --- a/src/tellico_utils.cpp +++ b/src/tellico_utils.cpp @@ -23,41 +23,41 @@ #include <kstandarddirs.h> #include <kcharsets.h> -#include <qregexp.h> -#include <qdir.h> -#include <qcursor.h> -#include <qscrollview.h> +#include <tqregexp.h> +#include <tqdir.h> +#include <tqcursor.h> +#include <tqscrollview.h> namespace { static const int STRING_STORE_SIZE = 997; // too big, too small? } -QColor Tellico::contrastColor; +TQColor Tellico::contrastColor; -QString Tellico::decodeHTML(QString text) { - QRegExp rx(QString::fromLatin1("&(.+);")); +TQString Tellico::decodeHTML(TQString text) { + TQRegExp rx(TQString::tqfromLatin1("&(.+);")); rx.setMinimal(true); int pos = rx.search(text); while(pos > -1) { - QChar c = KCharsets::fromEntity(rx.cap(1)); + TQChar c = KCharsets::fromEntity(rx.cap(1)); if(!c.isNull()) { - text.replace(pos, rx.matchedLength(), c); + text.tqreplace(pos, rx.matchedLength(), c); } pos = rx.search(text, pos+1); } return text; } -QString Tellico::uid(int l, bool prefix) { - QString uid; +TQString Tellico::uid(int l, bool prefix) { + TQString uid; if(prefix) { - uid = QString::fromLatin1("Tellico"); + uid = TQString::tqfromLatin1("Tellico"); } - uid.append(kapp->randomString(QMAX(l - uid.length(), 0))); + uid.append(kapp->randomString(TQMAX(l - uid.length(), 0))); return uid; } -uint Tellico::toUInt(const QString& s, bool* ok) { +uint Tellico::toUInt(const TQString& s, bool* ok) { if(s.isEmpty()) { if(ok) { *ok = false; @@ -78,47 +78,47 @@ uint Tellico::toUInt(const QString& s, bool* ok) { return s.left(idx).toUInt(ok); } -QString Tellico::i18nReplace(QString text) { - // Because QDomDocument sticks in random newlines, go ahead and grab them too - static QRegExp rx(QString::fromLatin1("(?:\\n+ *)*<i18n>([^<]*)</i18n>(?: *\\n+)*")); +TQString Tellico::i18nReplace(TQString text) { + // Because TQDomDocument sticks in random newlines, go ahead and grab them too + static TQRegExp rx(TQString::tqfromLatin1("(?:\\n+ *)*<i18n>([^<]*)</i18n>(?: *\\n+)*")); int pos = rx.search(text); while(pos > -1) { - text.replace(pos, rx.matchedLength(), i18n(rx.cap(1).utf8())); + text.tqreplace(pos, rx.matchedLength(), i18n(rx.cap(1).utf8())); pos = rx.search(text, pos+rx.matchedLength()); } return text; } -QStringList Tellico::findAllSubDirs(const QString& dir_) { +TQStringList Tellico::findAllSubDirs(const TQString& dir_) { if(dir_.isEmpty()) { - return QStringList(); + return TQStringList(); } // TODO: build in symlink checking, for now, prohibit - QDir dir(dir_, QString::null, QDir::Name | QDir::IgnoreCase, QDir::Dirs | QDir::Readable | QDir::NoSymLinks); + TQDir dir(dir_, TQString(), TQDir::Name | TQDir::IgnoreCase, TQDir::Dirs | TQDir::Readable | TQDir::NoSymLinks); - QStringList allSubdirs; // the whole list + TQStringList allSubdirs; // the whole list // find immediate sub directories - const QStringList subdirs = dir.entryList(); - for(QStringList::ConstIterator subdir = subdirs.begin(); subdir != subdirs.end(); ++subdir) { + const TQStringList subdirs = dir.entryList(); + for(TQStringList::ConstIterator subdir = subdirs.begin(); subdir != subdirs.end(); ++subdir) { if((*subdir).isEmpty() || *subdir == Latin1Literal(".") || *subdir == Latin1Literal("..")) { continue; } - QString absSubdir = dir.absFilePath(*subdir); + TQString absSubdir = dir.absFilePath(*subdir); allSubdirs += findAllSubDirs(absSubdir); allSubdirs += absSubdir; } return allSubdirs; } -// Based on QGDict's hash functions, Copyright (C) 1992-2000 Trolltech AS +// Based on TQGDict's hash functions, Copyright (C) 1992-2000 Trolltech AS // and used from Juk, Copyright (C) 2003 - 2004 by Scott Wheeler -int Tellico::stringHash(const QString& str) { +int Tellico::stringHash(const TQString& str) { uint h = 0; uint g = 0; for(uint i = 0; i < str.length(); ++i) { - h = (h << 4) + str.unicode()[i].cell(); + h = (h << 4) + str.tqunicode()[i].cell(); if((g = h & 0xf0000000)) { h ^= g >> 24; } @@ -129,8 +129,8 @@ int Tellico::stringHash(const QString& str) { return index < 0 ? -index : index; } -QString Tellico::shareString(const QString& str) { - static QString stringStore[STRING_STORE_SIZE]; +TQString Tellico::shareString(const TQString& str) { + static TQString stringStore[STRING_STORE_SIZE]; const int hash = stringHash(str) % STRING_STORE_SIZE; if(stringStore[hash] != str) { @@ -139,13 +139,13 @@ QString Tellico::shareString(const QString& str) { return stringStore[hash]; } -void Tellico::updateContrastColor(const QColorGroup& cg_) { +void Tellico::updateContrastColor(const TQColorGroup& cg_) { // if the value difference between background and highlight is more than ??? // use highlight, else go lighter or darker int h1, s1, v1, h2, s2, v2; cg_.background().getHsv(&h1, &s1, &v1); - QColor hl = cg_.highlight(); + TQColor hl = cg_.highlight(); hl.getHsv(&h2, &s2, &v2); h2 += 120; s2 = 255; @@ -162,15 +162,15 @@ void Tellico::updateContrastColor(const QColorGroup& cg_) { } } -KLibrary* Tellico::openLibrary(const QString& libName_) { - QString path = KLibLoader::findLibrary(QFile::encodeName(libName_)); +KLibrary* Tellico::openLibrary(const TQString& libName_) { + TQString path = KLibLoader::findLibrary(TQFile::encodeName(libName_)); if(path.isEmpty()) { kdWarning() << "Tellico::openLibrary() - Could not find library '" << libName_ << "'" << endl; kdWarning() << "ERROR: " << KLibLoader::self()->lastErrorMessage() << endl; return 0; } - KLibrary* library = KLibLoader::self()->library(QFile::encodeName(path)); + KLibrary* library = KLibLoader::self()->library(TQFile::encodeName(path)); if(!library) { kdWarning() << "Tellico::openLibrary() - Could not load library '" << libName_ << "'" << endl; kdWarning() << " PATH: " << path << endl; @@ -181,7 +181,7 @@ KLibrary* Tellico::openLibrary(const QString& libName_) { return library; } -QColor Tellico::blendColors(const QColor& color1, const QColor& color2, int percent) { +TQColor Tellico::blendColors(const TQColor& color1, const TQColor& color2, int percent) { const double factor2 = percent/100.0; const double factor1 = 1.0 - factor2; @@ -189,20 +189,20 @@ QColor Tellico::blendColors(const QColor& color1, const QColor& color2, int perc const int g = static_cast<int>(color1.green() * factor1 + color2.green() * factor2); const int b = static_cast<int>(color1.blue() * factor1 + color2.blue() * factor2); - return QColor(r, g, b); + return TQColor(r, g, b); } -QString Tellico::minutes(int seconds) { +TQString Tellico::minutes(int seconds) { int min = seconds / 60; seconds = seconds % 60; - return QString::number(min) + ':' + QString::number(seconds).rightJustify(2, '0'); + return TQString::number(min) + ':' + TQString::number(seconds).rightJustify(2, '0'); } -QString Tellico::saveLocation(const QString& dir_) { +TQString Tellico::saveLocation(const TQString& dir_) { return KGlobal::dirs()->saveLocation("appdata", dir_, true); } -Tellico::GUI::CursorSaver::CursorSaver(const QCursor& cursor_) : m_restored(false) { +Tellico::GUI::CursorSaver::CursorSaver(const TQCursor& cursor_) : m_restored(false) { kapp->setOverrideCursor(cursor_); } |