KDEGames

khighscore.h
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Andreas Beckermann ([email protected])
4  Copyright (C) 2003 Nicolas Hadacek <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KHIGHSCORE_H
22 #define KHIGHSCORE_H
23 
24 #include <libkdegames_export.h>
25 
26 #include <QObject>
27 #include <QLoggingCategory>
28 
29 class KConfig;
30 
83 class KDEGAMES_EXPORT KHighscore : public QObject
84 {
85  Q_OBJECT
86  public:
95  explicit KHighscore(bool forceLocal=true, QObject *parent=nullptr);
96 
102  void readCurrentConfig();
103 
114  static void init(const char *appname);
115 
131  bool lockForWriting(QWidget *widget = nullptr);
132 
138  void writeAndUnlock();
139 
144  bool isLocked() const;
145 
150  ~KHighscore();
151 
159  void writeEntry(int entry, const QString& key, const QString& value);
160 
165  void writeEntry(int entry, const QString& key, int value);
166 
172  void writeEntry(int entry, const QString& key, const QVariant &value);
173 
185  QString readEntry(int entry, const QString& key, const QString& pDefault = QLatin1String("")) const;
186 
198  int readNumEntry(int entry, const QString& key, int pDefault = -1) const;
199 
207  QVariant readPropertyEntry(int entry, const QString &key, const QVariant &pDefault) const;
208 
213  bool hasEntry(int entry, const QString& key) const;
214 
232  QStringList readList(const QString& key, int lastEntry = 20) const;
233 
245  void writeList(const QString& key, const QStringList& list);
246 
255  bool hasTable() const;
256 
264  void setHighscoreGroup(const QString& groupname = QLatin1String(""));
265 
273  QStringList groupList() const;
274 
280  QString highscoreGroup() const;
281 
282  protected:
287  QString group() const;
288 
294  KConfig* config() const;
295 
296  void init(bool forceLocal);
297 
298  private:
299  class KHighscorePrivate;
300  KHighscorePrivate* const d;
301 };
302 
303 Q_DECLARE_LOGGING_CATEGORY(GAMES_HIGHSCORE)
304 #endif
Class for managing highscore tables.
Definition: khighscore.h:83
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:37:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.