diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kpat/gamestatsimpl.cpp | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpat/gamestatsimpl.cpp')
-rw-r--r-- | kpat/gamestatsimpl.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/kpat/gamestatsimpl.cpp b/kpat/gamestatsimpl.cpp new file mode 100644 index 00000000..a3a67a43 --- /dev/null +++ b/kpat/gamestatsimpl.cpp @@ -0,0 +1,57 @@ +#include "gamestatsimpl.h" +#include "dealer.h" +#include "version.h" + +#include <qcombobox.h> +#include <qlabel.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <klocale.h> + +GameStatsImpl::GameStatsImpl(QWidget* aParent, const char* aname) + : GameStats(aParent, aname) +{ + QStringList list; + QValueList<DealerInfo*>::ConstIterator it; + for (it = DealerInfoList::self()->games().begin(); + it != DealerInfoList::self()->games().end(); ++it) + { + // while we develop, it may happen that some lower + // indices do not exist + uint index = (*it)->gameindex; + for (uint i = 0; i <= index; i++) + if (list.count() <= i) + list.append("unknown"); + list[index] = i18n((*it)->name); + list[index].replace('&',""); + } + GameType->insertStringList(list); + showGameType(0); +} + +void GameStatsImpl::showGameType(int id) +{ + GameType->setCurrentItem(id); + setGameType(id); +} + +void GameStatsImpl::setGameType(int id) +{ + // Trick to reset string to original value + languageChange(); + KConfig *config = kapp->config(); + KConfigGroupSaver kcs(config, scores_group); + unsigned int t = config->readUnsignedNumEntry(QString("total%1").arg(id),0); + Played->setText(Played->text().arg(t)); + unsigned int w = config->readUnsignedNumEntry(QString("won%1").arg(id),0); + Won->setText(Won->text().arg(w)); + if (t) + WonPerc->setText(WonPerc->text().arg(w*100/t)); + else + WonPerc->setText(WonPerc->text().arg(0)); + WinStreak->setText( + WinStreak->text().arg(config->readUnsignedNumEntry(QString("maxwinstreak%1").arg(id),0))); + LooseStreak->setText( + LooseStreak->text().arg(config->readUnsignedNumEntry(QString("maxloosestreak%1").arg(id),0))); +} |