diff options
Diffstat (limited to 'libkdegames/highscore/kexthighscore_internal.cpp')
-rw-r--r-- | libkdegames/highscore/kexthighscore_internal.cpp | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/libkdegames/highscore/kexthighscore_internal.cpp b/libkdegames/highscore/kexthighscore_internal.cpp index a8395753..3c73c3aa 100644 --- a/libkdegames/highscore/kexthighscore_internal.cpp +++ b/libkdegames/highscore/kexthighscore_internal.cpp @@ -23,9 +23,9 @@ #include <sys/types.h> #include <unistd.h> -#include <qfile.h> -#include <qlayout.h> -#include <qdom.h> +#include <tqfile.h> +#include <tqlayout.h> +#include <tqdom.h> #include <kglobal.h> #include <kio/netaccess.h> @@ -62,17 +62,17 @@ void ItemContainer::setItem(Item *item) _item = item; } -QString ItemContainer::entryName() const +TQString ItemContainer::entryName() const { if ( _subGroup.isEmpty() ) return _name; return _name + "_" + _subGroup; } -QVariant ItemContainer::read(uint i) const +TQVariant ItemContainer::read(uint i) const { Q_ASSERT(_item); - QVariant v = _item->defaultValue(); + TQVariant v = _item->defaultValue(); if ( isStored() ) { internal->hsConfig().setHighscoreGroup(_group); v = internal->hsConfig().readPropertyEntry(i+1, entryName(), v); @@ -80,13 +80,13 @@ QVariant ItemContainer::read(uint i) const return _item->read(i, v); } -QString ItemContainer::pretty(uint i) const +TQString ItemContainer::pretty(uint i) const { Q_ASSERT(_item); return _item->pretty(i, read(i)); } -void ItemContainer::write(uint i, const QVariant &value) const +void ItemContainer::write(uint i, const TQVariant &value) const { Q_ASSERT( isStored() ); Q_ASSERT( internal->hsConfig().isLocked() ); @@ -111,14 +111,14 @@ ItemArray::~ItemArray() for (uint i=0; i<size(); i++) delete at(i); } -int ItemArray::findIndex(const QString &name) const +int ItemArray::findIndex(const TQString &name) const { for (uint i=0; i<size(); i++) if ( at(i)->name()==name ) return i; return -1; } -const ItemContainer *ItemArray::item(const QString &name) const +const ItemContainer *ItemArray::item(const TQString &name) const { int i = findIndex(name); if ( i==-1 ) kdError(11002) << k_funcinfo << "no item named \"" << name @@ -126,7 +126,7 @@ const ItemContainer *ItemArray::item(const QString &name) const return at(i); } -ItemContainer *ItemArray::item(const QString &name) +ItemContainer *ItemArray::item(const TQString &name) { int i = findIndex(name); if ( i==-1 ) kdError(11002) << k_funcinfo << "no item named \"" << name @@ -134,7 +134,7 @@ ItemContainer *ItemArray::item(const QString &name) return at(i); } -void ItemArray::setItem(const QString &name, Item *item) +void ItemArray::setItem(const TQString &name, Item *item) { int i = findIndex(name); if ( i==-1 ) kdError(11002) << k_funcinfo << "no item named \"" << name @@ -144,7 +144,7 @@ void ItemArray::setItem(const QString &name, Item *item) _setItem(i, name, item, stored, canHaveSubGroup); } -void ItemArray::addItem(const QString &name, Item *item, +void ItemArray::addItem(const TQString &name, Item *item, bool stored, bool canHaveSubGroup) { if ( findIndex(name)!=-1 ) @@ -155,16 +155,16 @@ void ItemArray::addItem(const QString &name, Item *item, _setItem(i, name, item, stored, canHaveSubGroup); } -void ItemArray::_setItem(uint i, const QString &name, Item *item, +void ItemArray::_setItem(uint i, const TQString &name, Item *item, bool stored, bool canHaveSubGroup) { at(i)->setItem(item); at(i)->setName(name); - at(i)->setGroup(stored ? _group : QString::null); - at(i)->setSubGroup(canHaveSubGroup ? _subGroup : QString::null); + at(i)->setGroup(stored ? _group : TQString::null); + at(i)->setSubGroup(canHaveSubGroup ? _subGroup : TQString::null); } -void ItemArray::setGroup(const QString &group) +void ItemArray::setGroup(const TQString &group) { Q_ASSERT( !group.isNull() ); _group = group; @@ -172,7 +172,7 @@ void ItemArray::setGroup(const QString &group) if ( at(i)->isStored() ) at(i)->setGroup(group); } -void ItemArray::setSubGroup(const QString &subGroup) +void ItemArray::setSubGroup(const TQString &subGroup) { Q_ASSERT( !subGroup.isNull() ); _subGroup = subGroup; @@ -197,7 +197,7 @@ void ItemArray::write(uint k, const Score &data, uint nb) const } } -void ItemArray::exportToText(QTextStream &s) const +void ItemArray::exportToText(TQTextStream &s) const { for (uint k=0; k<nbEntries()+1; k++) { for (uint i=0; i<size(); i++) { @@ -219,7 +219,7 @@ class ScoreNameItem : public NameItem ScoreNameItem(const ScoreInfos &score, const PlayerInfos &infos) : _score(score), _infos(infos) {} - QString pretty(uint i, const QVariant &v) const { + TQString pretty(uint i, const TQVariant &v) const { uint id = _score.item("id")->read(i).toUInt(); if ( id==0 ) return NameItem::pretty(i, v); return _infos.prettyName(id-1); @@ -269,7 +269,7 @@ PlayerInfos::PlayerInfos() it = Manager::createItem(Manager::BestScoreDefault); addItem("best score", it, true, true); addItem("date", new DateItem, true, true); - it = new Item(QString::null, i18n("Comment"), Qt::AlignLeft); + it = new Item(TQString::null, i18n("Comment"), Qt::AlignLeft); addItem("comment", it); // statistics items @@ -281,7 +281,7 @@ PlayerInfos::PlayerInfos() addItem("max won trend", new Item((uint)0), true, true); struct passwd *pwd = getpwuid(getuid()); - QString username = pwd->pw_name; + TQString username = pwd->pw_name; #ifdef HIGHSCORE_DIRECTORY internal->hsConfig().setHighscoreGroup("players"); for (uint i=0; ;i++) { @@ -300,9 +300,9 @@ PlayerInfos::PlayerInfos() internal->hsConfig().lockForWriting(); KEMailSettings emailConfig; emailConfig.setProfile(emailConfig.defaultProfileName()); - QString name = emailConfig.getSetting(KEMailSettings::RealName); + TQString name = emailConfig.getSetting(KEMailSettings::RealName); if ( name.isEmpty() || isNameUsed(name) ) name = username; - if ( isNameUsed(name) ) name= QString(ItemContainer::ANONYMOUS); + if ( isNameUsed(name) ) name= TQString(ItemContainer::ANONYMOUS); #ifdef HIGHSCORE_DIRECTORY internal->hsConfig().writeEntry(_id+1, "username", username); item("name")->write(_id, name); @@ -314,14 +314,14 @@ PlayerInfos::PlayerInfos() #ifdef HIGHSCORE_DIRECTORY if (_oldLocalPlayer) { // player already exists in local config file // copy player data - QString prefix = QString("%1_").arg(_oldLocalId+1); - QMap<QString, QString> entries = + TQString prefix = TQString("%1_").arg(_oldLocalId+1); + TQMap<TQString, TQString> entries = cg.config()->entryMap("KHighscore_players"); - QMap<QString, QString>::const_iterator it; + TQMap<TQString, TQString>::const_iterator it; for (it=entries.begin(); it!=entries.end(); ++it) { - QString key = it.key(); + TQString key = it.key(); if ( key.find(prefix)==0 ) { - QString name = key.right(key.length()-prefix.length()); + TQString name = key.right(key.length()-prefix.length()); if ( name!="name" || !isNameUsed(it.data()) ) internal->hsConfig().writeEntry(_id+1, name, it.data()); } @@ -340,7 +340,7 @@ PlayerInfos::PlayerInfos() internal->hsConfig().writeAndUnlock(); } -void PlayerInfos::createHistoItems(const QMemArray<uint> &scores, bool bound) +void PlayerInfos::createHistoItems(const TQMemArray<uint> &scores, bool bound) { Q_ASSERT( _histogram.size()==0 ); _bound = bound; @@ -357,14 +357,14 @@ bool PlayerInfos::isAnonymous() const uint PlayerInfos::nbEntries() const { internal->hsConfig().setHighscoreGroup("players"); - QStringList list = internal->hsConfig().readList("name", -1); + TQStringList list = internal->hsConfig().readList("name", -1); return list.count(); } -QString PlayerInfos::key() const +TQString PlayerInfos::key() const { ConfigGroup cg; - return cg.config()->readEntry(HS_KEY, QString::null); + return cg.config()->readEntry(HS_KEY, TQString::null); } bool PlayerInfos::isWWEnabled() const @@ -373,13 +373,13 @@ bool PlayerInfos::isWWEnabled() const return cg.config()->readBoolEntry(HS_WW_ENABLED, false); } -QString PlayerInfos::histoName(uint i) const +TQString PlayerInfos::histoName(uint i) const { - const QMemArray<uint> &sh = _histogram; + const TQMemArray<uint> &sh = _histogram; Q_ASSERT( i<sh.size() || (_bound || i==sh.size()) ); if ( i==sh.size() ) - return QString("nb scores greater than %1").arg(sh[sh.size()-1]); - return QString("nb scores less than %1").arg(sh[i]); + return TQString("nb scores greater than %1").arg(sh[sh.size()-1]); + return TQString("nb scores less than %1").arg(sh[i]); } uint PlayerInfos::histoSize() const @@ -446,7 +446,7 @@ void PlayerInfos::submitScore(const Score &score) const // update histogram if ( score.type()==Won ) { - const QMemArray<uint> &sh = _histogram; + const TQMemArray<uint> &sh = _histogram; for (uint i=1; i<histoSize(); i++) if ( i==sh.size() || score.score()<sh[i] ) { item(histoName(i))->increment(_id); @@ -455,7 +455,7 @@ void PlayerInfos::submitScore(const Score &score) const } } -bool PlayerInfos::isNameUsed(const QString &newName) const +bool PlayerInfos::isNameUsed(const TQString &newName) const { if ( newName==name() ) return false; // own name... for (uint i=0; i<nbEntries(); i++) @@ -464,14 +464,14 @@ bool PlayerInfos::isNameUsed(const QString &newName) const return false; } -void PlayerInfos::modifyName(const QString &newName) const +void PlayerInfos::modifyName(const TQString &newName) const { item("name")->write(_id, newName); } -void PlayerInfos::modifySettings(const QString &newName, - const QString &comment, bool WWEnabled, - const QString &newKey) const +void PlayerInfos::modifySettings(const TQString &newName, + const TQString &comment, bool WWEnabled, + const TQString &newKey) const { modifyName(newName); item("comment")->write(_id, comment); @@ -481,10 +481,10 @@ void PlayerInfos::modifySettings(const QString &newName, if (WWEnabled) cg.config()->writeEntry(HS_REGISTERED_NAME, newName); } -QString PlayerInfos::registeredName() const +TQString PlayerInfos::registeredName() const { ConfigGroup cg; - return cg.config()->readEntry(HS_REGISTERED_NAME, QString::null); + return cg.config()->readEntry(HS_REGISTERED_NAME, TQString::null); } void PlayerInfos::removeKey() @@ -493,12 +493,12 @@ void PlayerInfos::removeKey() // save old key/nickname uint i = 0; - QString str = "%1 old #%2"; - QString sk; + TQString str = "%1 old #%2"; + TQString sk; do { i++; sk = str.arg(HS_KEY).arg(i); - } while ( !cg.config()->readEntry(sk, QString::null).isEmpty() ); + } while ( !cg.config()->readEntry(sk, TQString::null).isEmpty() ); cg.config()->writeEntry(sk, key()); cg.config()->writeEntry(str.arg(HS_REGISTERED_NAME).arg(i), registeredName()); @@ -531,11 +531,11 @@ ManagerPrivate::~ManagerPrivate() delete _hsConfig; } -KURL ManagerPrivate::queryURL(QueryType type, const QString &newName) const +KURL ManagerPrivate::queryURL(QueryType type, const TQString &newName) const { KURL url = serverURL; - QString nameItem = "nickname"; - QString name = _playerInfos->registeredName(); + TQString nameItem = "nickname"; + TQString name = _playerInfos->registeredName(); bool withVersion = true; bool key = false; bool level = false; @@ -572,7 +572,7 @@ KURL ManagerPrivate::queryURL(QueryType type, const QString &newName) const if ( !name.isEmpty() ) Manager::addToQueryURL(url, nameItem, name); if (key) Manager::addToQueryURL(url, "key", _playerInfos->key()); if (level) { - QString label = manager.gameTypeLabel(_gameType, Manager::WW); + TQString label = manager.gameTypeLabel(_gameType, Manager::WW); if ( !label.isEmpty() ) Manager::addToQueryURL(url, "level", label); } @@ -602,61 +602,61 @@ const char *DUMMY_STRINGS[] = { const char *UNABLE_TO_CONTACT = I18N_NOOP("Unable to contact world-wide highscore server"); -bool ManagerPrivate::doQuery(const KURL &url, QWidget *parent, - QDomNamedNodeMap *map) +bool ManagerPrivate::doQuery(const KURL &url, TQWidget *parent, + TQDomNamedNodeMap *map) { KIO::http_update_cache(url, true, 0); // remove cache ! - QString tmpFile; + TQString tmpFile; if ( !KIO::NetAccess::download(url, tmpFile, parent) ) { - QString details = i18n("Server URL: %1").arg(url.host()); + TQString details = i18n("Server URL: %1").arg(url.host()); KMessageBox::detailedSorry(parent, i18n(UNABLE_TO_CONTACT), details); return false; } - QFile file(tmpFile); + TQFile file(tmpFile); if ( !file.open(IO_ReadOnly) ) { KIO::NetAccess::removeTempFile(tmpFile); - QString details = i18n("Unable to open temporary file."); + TQString details = i18n("Unable to open temporary file."); KMessageBox::detailedSorry(parent, i18n(UNABLE_TO_CONTACT), details); return false; } - QTextStream t(&file); - QString content = t.read().stripWhiteSpace(); + TQTextStream t(&file); + TQString content = t.read().stripWhiteSpace(); file.close(); KIO::NetAccess::removeTempFile(tmpFile); - QDomDocument doc; + TQDomDocument doc; if ( doc.setContent(content) ) { - QDomElement root = doc.documentElement(); - QDomElement element = root.firstChild().toElement(); + TQDomElement root = doc.documentElement(); + TQDomElement element = root.firstChild().toElement(); if ( element.tagName()=="success" ) { if (map) *map = element.attributes(); return true; } if ( element.tagName()=="error" ) { - QDomAttr attr = element.attributes().namedItem("label").toAttr(); + TQDomAttr attr = element.attributes().namedItem("label").toAttr(); if ( !attr.isNull() ) { - QString msg = i18n(attr.value().latin1()); - QString caption = i18n("Message from world-wide highscores " + TQString msg = i18n(attr.value().latin1()); + TQString caption = i18n("Message from world-wide highscores " "server"); KMessageBox::sorry(parent, msg, caption); return false; } } } - QString msg = i18n("Invalid answer from world-wide highscores server."); - QString details = i18n("Raw message: %1").arg(content); + TQString msg = i18n("Invalid answer from world-wide highscores server."); + TQString details = i18n("Raw message: %1").arg(content); KMessageBox::detailedSorry(parent, msg, details); return false; } -bool ManagerPrivate::getFromQuery(const QDomNamedNodeMap &map, - const QString &name, QString &value, - QWidget *parent) +bool ManagerPrivate::getFromQuery(const TQDomNamedNodeMap &map, + const TQString &name, TQString &value, + TQWidget *parent) { - QDomAttr attr = map.namedItem(name).toAttr(); + TQDomAttr attr = map.namedItem(name).toAttr(); if ( attr.isNull() ) { KMessageBox::sorry(parent, i18n("Invalid answer from world-wide " @@ -683,11 +683,11 @@ int ManagerPrivate::rank(const Score &score) const return (i<_scoreInfos->maxNbEntries() ? (int)i : -1); } -bool ManagerPrivate::modifySettings(const QString &newName, - const QString &comment, bool WWEnabled, - QWidget *widget) +bool ManagerPrivate::modifySettings(const TQString &newName, + const TQString &comment, bool WWEnabled, + TQWidget *widget) { - QString newKey; + TQString newKey; bool newPlayer = false; if (WWEnabled) { @@ -696,7 +696,7 @@ bool ManagerPrivate::modifySettings(const QString &newName, KURL url = queryURL((newPlayer ? Register : Change), newName); Manager::addToQueryURL(url, "comment", comment); - QDomNamedNodeMap map; + TQDomNamedNodeMap map; bool ok = doQuery(url, widget, &map); if ( !ok || (newPlayer && !getFromQuery(map, "key", newKey, widget)) ) return false; @@ -720,7 +720,7 @@ void ManagerPrivate::convertToGlobal() // read old highscores KHighscore *tmp = _hsConfig; _hsConfig = new KHighscore(true, 0); - QValueVector<Score> scores(_scoreInfos->nbEntries()); + TQValueVector<Score> scores(_scoreInfos->nbEntries()); for (uint i=0; i<scores.count(); i++) scores[i] = readScore(i); @@ -759,8 +759,8 @@ void ManagerPrivate::setGameType(uint type) Q_ASSERT( type<_nbGameTypes ); _gameType = kMin(type, _nbGameTypes-1); - QString str = "scores"; - QString lab = manager.gameTypeLabel(_gameType, Manager::Standard); + TQString str = "scores"; + TQString lab = manager.gameTypeLabel(_gameType, Manager::Standard); if ( !lab.isEmpty() ) { _playerInfos->setSubGroup(lab); str += "_" + lab; @@ -774,22 +774,22 @@ void ManagerPrivate::checkFirst() } int ManagerPrivate::submitScore(const Score &ascore, - QWidget *widget, bool askIfAnonymous) + TQWidget *widget, bool askIfAnonymous) { checkFirst(); Score score = ascore; score.setData("id", _playerInfos->id() + 1); - score.setData("date", QDateTime::currentDateTime()); + score.setData("date", TQDateTime::currentDateTime()); // ask new name if anonymous and winner const char *dontAskAgainName = "highscore_ask_name_dialog"; - QString newName; + TQString newName; KMessageBox::ButtonCode dummy; if ( score.type()==Won && askIfAnonymous && _playerInfos->isAnonymous() && KMessageBox::shouldBeShownYesNo(dontAskAgainName, dummy) ) { AskNameDialog d(widget); - if ( d.exec()==QDialog::Accepted ) newName = d.name(); + if ( d.exec()==TQDialog::Accepted ) newName = d.name(); if ( d.dontAskAgain() ) KMessageBox::saveDontShowAgainYesNo(dontAskAgainName, KMessageBox::No); @@ -825,7 +825,7 @@ int ManagerPrivate::submitLocal(const Score &score) } bool ManagerPrivate::submitWorldWide(const Score &score, - QWidget *widget) const + TQWidget *widget) const { if ( score.type()==Lost && !trackLostGames ) return true; if ( score.type()==Draw && !trackDrawGames ) return true; @@ -833,15 +833,15 @@ bool ManagerPrivate::submitWorldWide(const Score &score, KURL url = queryURL(Submit); manager.additionalQueryItems(url, score); int s = (score.type()==Won ? score.score() : (int)score.type()); - QString str = QString::number(s); + TQString str = TQString::number(s); Manager::addToQueryURL(url, "score", str); - KMD5 context(QString(_playerInfos->registeredName() + str).latin1()); + KMD5 context(TQString(_playerInfos->registeredName() + str).latin1()); Manager::addToQueryURL(url, "check", context.hexDigest()); return doQuery(url, widget); } -void ManagerPrivate::exportHighscores(QTextStream &s) +void ManagerPrivate::exportHighscores(TQTextStream &s) { uint tmp = _gameType; |