KDEGames

kscoredialog.h
1 /****************************************************************
2 Copyright (c) 1998 Sandro Sigala <[email protected]>
3 Copyright (c) 2001 Waldo Bastian <[email protected]>
4 Copyright (c) 2007 Matt Williams <[email protected]>
5 All rights reserved.
6 
7 Permission to use, copy, modify, and distribute this software
8 and its documentation for any purpose and without fee is hereby
9 granted, provided that the above copyright notice appear in all
10 copies and that both that the copyright notice and this
11 permission notice and warranty disclaimer appear in supporting
12 documentation, and that the name of the author not be used in
13 advertising or publicity pertaining to distribution of the
14 software without specific, written prior permission.
15 
16 The author disclaim all warranties with regard to this
17 software, including all implied warranties of merchantability
18 and fitness. In no event shall the author be liable for any
19 special, indirect or consequential damages or any damages
20 whatsoever resulting from loss of use, data or profits, whether
21 in an action of contract, negligence or other tortious action,
22 arising out of or in connection with the use or performance of
23 this software.
24 ****************************************************************/
25 
26 #ifndef KSCOREDIALOG_H
27 #define KSCOREDIALOG_H
28 
29 #include <libkdegames_export.h>
30 
31 #include <QMap>
32 #include <QFlags>
33 #include <QDialogButtonBox>
34 
35 #include <QDialog>
36 
37 class KgDifficulty;
38 
96 class KDEGAMES_EXPORT KScoreDialog : public QDialog
97 {
98  Q_OBJECT
99 
100  public:
102  enum Fields {
103  Name = 1 << 0,
104  Level = 1 << 1,
105  Date = 1 << 2,
106  Time = 1 << 3,
107  Score = 1 << 4,
108 
109  Custom1 = 1 << 10,
110  Custom2 = 1 << 11,
111  Custom3 = 1 << 12,
112  Custom4 = 1 << 13,
113  Custom5 = 1 << 14,
114 
115  Max = 1 << 30
116  };
117 
120  {
121  AskName = 0x1,
122  LessIsMore = 0x2
123  };
124  Q_DECLARE_FLAGS(AddScoreFlags, AddScoreFlag)
125 
126  typedef QMap<int, QString> FieldInfo;
127 
132  explicit KScoreDialog(int fields=Name, QWidget *parent=nullptr);
133 
134  ~KScoreDialog();
135 
146  void KDE_DEPRECATED setConfigGroup(const QString& group = QString());
147  //void setConfigGroup(const QString& group, const QString& i18nName);
148 
158  void setConfigGroup(const QPair<QByteArray, QString>& group);
159 
168  void addLocalizedConfigGroupName(const QPair<QByteArray, QString>& group);
169 
180  void addLocalizedConfigGroupNames(const QMap<QByteArray, QString>& groups);
181 
193  void setHiddenConfigGroups(const QList<QByteArray>& hiddenGroups);
194 
205  void setConfigGroupWeights(const QMap<int, QByteArray>& weights);
206 
211  void setComment(const QString& comment);
212 
219  void addField(int field, const QString& header, const QString& key);
220 
225  void hideField(int field);
226 
236  int addScore(const FieldInfo& newInfo = FieldInfo(), const AddScoreFlags& flags={});
237 
247  int addScore(int newScore, const AddScoreFlags& flags={});
248 
252  int highScore();
253 
264  void initFromDifficulty(const KgDifficulty* difficulty, bool setConfigGroup = true);
265 
267  virtual void show();
269  int exec() override;
270 
271  private Q_SLOTS:
272  void slotGotReturn();
273  void slotGotName();
274  void slotForgetScore();
275 
276  private:
277  void keyPressEvent(QKeyEvent *ev) override;
278 
279  private:
280  class KScoreDialogPrivate;
281  KScoreDialogPrivate* const d;
282 };
283 Q_DECLARE_OPERATORS_FOR_FLAGS(KScoreDialog::AddScoreFlags)
284 
285 #endif //KSCOREDIALOG_H
AddScoreFlag
Flags for setting preferences for adding scores.
Definition: kscoredialog.h:119
A simple high score implementation.
Definition: kscoredialog.h:96
virtual int exec()
virtual void keyPressEvent(QKeyEvent *e) override
Fields
Highscore fields.
Definition: kscoredialog.h:102
void show()
KgDifficulty manages difficulty levels of a game in a standard way.
Definition: kgdifficulty.h:96
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.