khighscore.h
00001 /* 00002 This file is part of the TDE games library 00003 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de) 00004 Copyright (C) 2003 Nicolas Hadacek <hadacek@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 /* 00021 $Id$ 00022 */ 00023 #ifndef __KHIGHSCORE_H__ 00024 #define __KHIGHSCORE_H__ 00025 00026 #include <tqstring.h> 00027 #include <tqobject.h> 00028 #include <kdemacros.h> 00029 class TDEConfig; 00030 class KFileLock; 00031 class KRawConfig; 00032 class KHighscorePrivate; 00033 00084 class KDE_EXPORT KHighscore : public TQObject 00085 { 00086 Q_OBJECT 00087 00088 public: 00093 KHighscore(TQObject* parent = 0); 00094 00104 KHighscore(bool forceLocal, TQObject *parent); 00105 00112 void readCurrentConfig(); 00113 00124 static void init(const char *appname); 00125 00141 bool lockForWriting(TQWidget *widget = 0); 00142 00149 void writeAndUnlock(); 00150 00156 bool isLocked() const; 00157 00162 ~KHighscore(); 00163 00171 void writeEntry(int entry, const TQString& key, const TQString& value); 00172 00177 void writeEntry(int entry, const TQString& key, int value); 00178 00184 void writeEntry(int entry, const TQString& key, const TQVariant &value); 00185 00197 TQString readEntry(int entry, const TQString& key, const TQString& pDefault = TQString()) const; 00198 00210 int readNumEntry(int entry, const TQString& key, int pDefault = -1) const; 00211 00219 TQVariant readPropertyEntry(int entry, const TQString &key, const TQVariant &pDefault) const; 00220 00225 bool hasEntry(int entry, const TQString& key) const; 00226 00244 TQStringList readList(const TQString& key, int lastEntry = 20) const; 00245 00257 void writeList(const TQString& key, const TQStringList& list); 00258 00266 bool hasTable() const; 00267 00271 void sync(); 00272 00280 void setHighscoreGroup(const TQString& groupname = TQString()); 00281 00287 const TQString& highscoreGroup() const; 00288 00289 protected: 00294 TQString group() const; 00295 00301 TDEConfig* config() const; 00302 00303 void init(bool forceLocal); 00304 00305 private: 00306 KHighscorePrivate* d; 00307 00308 static KFileLock *_lock; // lock on system-wide highscore file 00309 static KRawConfig *_config; // config for system-wide highscore file 00310 }; 00311 00312 #endif