KDEGames

kgamehighscoredialog.cpp
1/*
2 SPDX-FileCopyrightText: 1998 Sandro Sigala <ssigala@globalnet.it>.
3 SPDX-FileCopyrightText: 2001 Waldo Bastian <bastian@kde.org>
4 SPDX-FileCopyrightText: 2007 Matt Williams <matt@milliams.com>
5
6 SPDX-License-Identifier: ICS
7*/
8
9#include "kgamehighscoredialog.h"
10
11// own
12#include "../kgamedifficulty.h"
13#include "kgamehighscore.h"
14#include <kdegames_highscore_logging.h>
15// KF
16#include <KConfig>
17#include <KLineEdit>
18#include <KLocalizedString>
19#include <KSeparator>
20#include <KUser>
21// Qt
22#include <QApplication>
23#include <QByteArray>
24#include <QDialogButtonBox>
25#include <QGridLayout>
26#include <QKeyEvent>
27#include <QLabel>
28#include <QLayout>
29#include <QList>
30#include <QPushButton>
31#include <QStackedWidget>
32#include <QStyle>
33#include <QTabWidget>
34#include <QTimer>
35// Std
36#include <utility>
37
38typedef QList<KGameHighScoreDialog::FieldInfo> GroupScores; ///< The list of scores in a group
39
40class KGameHighScoreDialogPrivate
41{
42public:
43 // QList<FieldInfo*> scores;
44 QMap<QByteArray, GroupScores> scores; ///< Maps config group name to GroupScores
45 QList<QByteArray> hiddenGroups; /// Groups that should not be shown in the dialog
46 QMap<int, QByteArray> configGroupWeights; /// Weights of the groups, defines ordering
47 QTabWidget *tabWidget;
48 // QWidget *page;
49 // QGridLayout *layout;
50 KLineEdit *edit; ///< The line edit for entering player name
52 QMap<QByteArray, QList<QLabel *>> labels; ///< For each group, the labels along each row in turn starting from "#1"
53 QLabel *commentLabel;
54 QString comment;
55 int fields;
56 int hiddenFields;
57 QPair<QByteArray, int> newName; // index of the new name to add (groupKey, position)
58 QPair<QByteArray, int> latest; // index of the latest addition (groupKey, position)
59 int nrCols;
60 bool loaded;
61 QByteArray configGroup;
62 KGameHighscore *highscoreObject;
63 QMap<QByteArray, QString> translatedGroupNames; ///< List of the translated group names.
65
67 QMap<int, QString> header; ///< Header for fields. Maps field index to a string
68 QMap<int, QString> key; ///< Keys for fields. Maps field index to a string
69 QString player;
70 int lastHighPosition; /// remember the position to delete if the user wants to forget
71
72 QDialogButtonBox *buttonBox;
73
74 KGameHighScoreDialog *const q;
75
76public:
77 // Q-Pointer
78 explicit KGameHighScoreDialogPrivate(KGameHighScoreDialog *parent)
79 : q(parent)
80 {
81 }
82
83 // Functions
84 void loadScores();
85 void saveScores();
86
87 void setupDialog();
88 void setupGroup(const QByteArray &groupName);
89 void aboutToShow();
90
91 QString findTranslatedGroupName(const QByteArray &name);
92};
93
95 : QDialog(parent)
96 , d_ptr(new KGameHighScoreDialogPrivate(this))
97{
99
100 setWindowTitle(i18nc("@title:window", "High Scores"));
101 setModal(true);
102 d->highscoreObject = new KGameHighscore();
103 d->edit = nullptr;
104 fields |= Score; // Make 'Score' field automatic (it can be hidden if necessary)
105 d->fields = fields;
106 d->hiddenFields = 0;
107 d->newName = QPair<QByteArray, int>(QByteArray(), -1);
108 d->latest = QPair<QByteArray, int>("Null", -1);
109 d->loaded = false;
110 d->nrCols = 0;
111 d->configGroup = QByteArray();
112
113 // Set up the default table headers
114 d->header[Name] = i18nc("@title:column", "Name");
115 d->key[Name] = QStringLiteral("Name");
116 d->header[Date] = i18nc("@title:column", "Date");
117 d->key[Date] = QStringLiteral("Date");
118 d->header[Level] = i18nc("@title:column", "Level");
119 d->key[Level] = QStringLiteral("Level");
120 d->header[Score] = i18nc("@title:column", "Score");
121 d->key[Score] = QStringLiteral("Score");
122 d->header[Time] = i18nc("@title:column", "Time");
123 d->key[Time] = QStringLiteral("Time");
124
125 // d->page = new QWidget(this);
126
127 d->tabWidget = new QTabWidget(this);
128 d->tabWidget->setTabPosition(QTabWidget::West);
129
130 QVBoxLayout *mainLayout = new QVBoxLayout;
131 setLayout(mainLayout);
132 mainLayout->addWidget(d->tabWidget);
133
134 d->buttonBox = new QDialogButtonBox(this);
135
136 d->buttonBox->setStandardButtons(QDialogButtonBox::Close);
138
139 mainLayout->addWidget(d->buttonBox);
140}
141
142KGameHighScoreDialog::~KGameHighScoreDialog()
143{
145
146 delete d->highscoreObject;
147}
148
149void KGameHighScoreDialog::setConfigGroup(const QPair<QByteArray, QString> &group)
150{
152
153 d->configGroup = group.first; // untranslated string
154 addLocalizedConfigGroupName(group); // add the translation to the list
155 d->loaded = false;
156}
157
158void KGameHighScoreDialog::addLocalizedConfigGroupName(const QPair<QByteArray, QString> &group)
159{
161
162 if (!d->translatedGroupNames.contains(group.first)) {
163 d->translatedGroupNames.insert(group.first, group.second);
164 qCDebug(KDEGAMES_HIGHSCORE_LOG) << "adding" << group.first << "->" << group.second;
165 }
166}
167
169{
171
173 for (; it != groups.end(); ++it) {
174 addLocalizedConfigGroupName(qMakePair(it.key(), it.value()));
175 }
176}
177
178void KGameHighScoreDialog::initFromDifficulty(const KGameDifficulty *diff, bool doSetConfigGroup)
179{
180 QMap<QByteArray, QString> localizedLevelStrings;
181 QMap<int, QByteArray> levelWeights;
182 const auto levels = diff->levels();
183 for (const KGameDifficultyLevel *level : levels) {
184 localizedLevelStrings.insert(level->key(), level->title());
185 levelWeights.insert(level->hardness(), level->key());
186 }
187 addLocalizedConfigGroupNames(localizedLevelStrings);
188 setConfigGroupWeights(levelWeights);
189 if (doSetConfigGroup) {
190 const KGameDifficultyLevel *curLvl = diff->currentLevel();
191 setConfigGroup(qMakePair(curLvl->key(), curLvl->title()));
192 }
193}
194
196{
198
199 d->hiddenGroups = hiddenGroups;
200}
201
203{
205
206 d->configGroupWeights = weights;
207}
208
209QString KGameHighScoreDialogPrivate::findTranslatedGroupName(const QByteArray &name)
210{
211 const QString lookupResult = translatedGroupNames.value(name);
212 // If it wasn't found then just try i18n( to see if it happens to be in the database
213 return lookupResult.isEmpty() ? i18n(name.constData()) : lookupResult; // FIXME?
214}
215
217{
219
220 d->comment = comment;
221}
222
223void KGameHighScoreDialog::addField(int field, const QString &header, const QString &key)
224{
226
227 d->fields |= field;
228 d->header[field] = header;
229 d->key[field] = key;
230}
231
233{
235
236 d->hiddenFields |= field;
237}
238
239/*
240Create the widgets and layouts etc. for the dialog
241*/
242void KGameHighScoreDialogPrivate::setupDialog()
243{
244 nrCols = 1;
245 for (int field = 1; field < fields; field = field * 2) {
246 if ((fields & field) && !(hiddenFields & field))
247 col[field] = nrCols++;
248 }
249
250 tabWidget->clear();
251 QList<QByteArray> keysToConfigure = scores.keys();
252 for (const QByteArray &groupName : std::as_const(configGroupWeights)) {
253 int index = keysToConfigure.indexOf(groupName);
254 if (index != -1) {
255 setupGroup(groupName);
256 keysToConfigure.removeAt(index);
257 }
258 }
259 for (const QByteArray &groupName : std::as_const(keysToConfigure)) {
260 setupGroup(groupName);
261 }
262}
263
264void KGameHighScoreDialogPrivate::setupGroup(const QByteArray &groupKey)
265{
266 if (hiddenGroups.contains(groupKey))
267 return;
268 QWidget *widget = new QWidget(q);
269 tabs[groupKey] = widget;
270
271 QString tabName = groupKey.isEmpty() ? i18nc("@title:tab", "High Scores") : findTranslatedGroupName(groupKey);
272 tabWidget->addTab(widget, tabName);
273
274 QGridLayout *layout = new QGridLayout(widget);
275 // layout->setObjectName( QLatin1String("ScoreTab-" )+groupName);
276 // layout->setMargin(QApplication::style()->pixelMetric(QStyle::PM_DefaultChildMargin)+20);
277 // layout->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
278 layout->addItem(new QSpacerItem(0, 15), 4, 0);
279
280 commentLabel = new QLabel(tabWidget);
282
283 QFont bold = q->font();
284 bold.setBold(true);
285
286 QLabel *label;
287 layout->addItem(new QSpacerItem(50, 0), 0, 0);
288 label = new QLabel(i18nc("@title:group", "Rank"), widget);
289 layout->addWidget(label, 3, 0);
290 label->setFont(bold);
291
292 for (int field = 1; field < fields; field = field * 2) {
293 if ((fields & field) && !(hiddenFields & field)) // If it's used and not hidden
294 {
295 layout->addItem(new QSpacerItem(50, 0), 0, col[field]);
296 label = new QLabel(header[field], widget);
297 layout->addWidget(label, 3, col[field], field <= KGameHighScoreDialog::Name ? Qt::AlignLeft : Qt::AlignRight);
298 label->setFont(bold);
299 }
300 }
301
302 KSeparator *sep = new KSeparator(Qt::Horizontal, tabWidget->widget(tabWidget->currentIndex()));
303 layout->addWidget(sep, 4, 0, 1, nrCols);
304
305 QString num;
306 for (int i = 1; i <= 10; ++i) {
307 QLabel *label;
308 num.setNum(i);
309 label = new QLabel(i18nc("Enumeration (#1, #2 ...) of the highscore entries", "#%1", num), widget);
310 labels[groupKey].insert((i - 1) * nrCols + 0, label); // Fill up column zero
311 layout->addWidget(label, i + 4, 0);
312 if (fields & KGameHighScoreDialog::Name) // If we have a Name field
313 {
314 QStackedWidget *localStack = new QStackedWidget(widget);
315 stack[groupKey].insert(i - 1, localStack);
316 layout->addWidget(localStack, i + 4, col[KGameHighScoreDialog::Name]);
317 label = new QLabel(localStack);
318 labels[groupKey].insert((i - 1) * nrCols + col[KGameHighScoreDialog::Name], label);
319 localStack->addWidget(label);
320 localStack->setCurrentWidget(label);
321 }
322 for (int field = KGameHighScoreDialog::Name * 2; field < fields; field = field * 2) {
323 if ((fields & field) && !(hiddenFields & field)) // Maybe disable for Name?
324 {
325 label = new QLabel(widget);
326 labels[groupKey].insert((i - 1) * nrCols + col[field], label);
327 layout->addWidget(label, i + 4, col[field], Qt::AlignRight);
328 }
329 }
330 }
331}
332
333/*
334Fill the dialog with the correct data
335*/
336void KGameHighScoreDialogPrivate::aboutToShow()
337{
338 if (!loaded)
339 loadScores();
340
341 if (!nrCols)
342 setupDialog();
343
344 int tabIndex = 0; // Index of the current tab
345
346 QMap<QByteArray, GroupScores>::const_iterator it = scores.constBegin();
347 for (; it != scores.constEnd(); ++it) {
348 const QByteArray &groupKey = it.key();
349 if (hiddenGroups.contains(groupKey))
350 continue;
351 qCDebug(KDEGAMES_HIGHSCORE_LOG) << latest.first << tabWidget->tabText(tabIndex);
352
353 // Only display the comment on the page with the new score (or) this one if there's only one tab
354 if (latest.first == groupKey || (latest.first.isEmpty() && groupKey == "High Scores")) {
355 QWidget *widget = tabs.value(groupKey);
356 QGridLayout *layout = qobject_cast<QGridLayout *>(widget->layout());
357
358 commentLabel->setText(comment);
359 if (comment.isEmpty()) {
360 commentLabel->setMinimumSize(QSize(1, 1));
361 commentLabel->hide();
362 layout->addItem(new QSpacerItem(0, -15), 0, 0);
363 layout->addItem(new QSpacerItem(0, -15), 2, 0);
364 } else {
365 layout->addWidget(commentLabel, 1, 0, 1, nrCols);
366 commentLabel->setMinimumSize(commentLabel->sizeHint());
367 commentLabel->show();
368 layout->addItem(new QSpacerItem(0, -10), 0, 0);
369 layout->addItem(new QSpacerItem(0, 10), 2, 0);
370 }
371 comment.clear();
372
373 tabWidget->setCurrentWidget(widget);
374 }
375
376 QFont normal = q->font();
377 QFont bold = normal;
378 bold.setBold(true);
379
380 QString num;
381 for (int i = 1; i <= 10; ++i) {
382 QLabel *label;
383 num.setNum(i);
384
385 // qCDebug(KDEGAMES_HIGHSCORE_LOG) << "groupName:" << groupName << "id:" << i-1;
386
387 KGameHighScoreDialog::FieldInfo score = scores[groupKey].at(i - 1);
388 label = labels[groupKey].at((i - 1) * nrCols + 0); // crash! FIXME
389 if ((i == latest.second) && (groupKey == latest.first))
390 label->setFont(bold);
391 else
392 label->setFont(normal);
393
394 if (fields & KGameHighScoreDialog::Name) {
395 if ((newName.second == i) && (groupKey == newName.first)) {
396 QStackedWidget *localStack = stack[groupKey].at(i - 1);
397 edit = new KLineEdit(player, localStack);
398 edit->setMinimumWidth(40);
399 localStack->addWidget(edit);
400 localStack->setCurrentWidget(edit);
401 edit->setFocus();
402 QObject::connect(edit, &KLineEdit::returnKeyPressed, q, &KGameHighScoreDialog::slotGotReturn);
403 } else {
404 label = labels[groupKey].at((i - 1) * nrCols + col[KGameHighScoreDialog::Name]);
405 if ((i == latest.second) && (groupKey == latest.first))
406 label->setFont(bold);
407 else
408 label->setFont(normal);
409 label->setText(score[KGameHighScoreDialog::Name]);
410 }
411 }
412 for (int field = KGameHighScoreDialog::Name * 2; field < fields; field = field * 2) {
413 if ((fields & field) && !(hiddenFields & field)) {
414 label = labels[groupKey].at((i - 1) * nrCols + col[field]);
415 if ((i == latest.second) && (groupKey == latest.first))
416 label->setFont(bold);
417 else
418 label->setFont(normal);
419 label->setText(score[field]);
420 }
421 }
422 }
423 tabIndex++;
424 }
425 int configGroupIndex = tabWidget->indexOf(tabs.value(configGroup));
426 if (!hiddenGroups.contains(configGroup) && configGroupIndex > -1) {
427 tabWidget->setCurrentIndex(configGroupIndex);
428 }
429 latest = QPair<QByteArray, int>(QByteArray(), -1);
430 q->setFixedSize(q->minimumSizeHint()); // NOTE Remove this line to make dialog resizable
431}
432
433void KGameHighScoreDialogPrivate::loadScores()
434{
435 scores.clear();
436
437 QList<QByteArray> groupKeyList; // This will be a list of all the groups in the config file
438 const auto groupStrings = highscoreObject->groupList();
439 for (const QString &groupString : groupStrings) {
440 groupKeyList << groupString.toUtf8(); // Convert all the QStrings to QByteArrays
441 }
442
443 QByteArray tempCurrentGroup = configGroup; // temp to store the user-set group name
444
445 if (!groupKeyList.contains(configGroup)) // If the current group doesn't have any entries, add it to the list to process
446 {
447 qCDebug(KDEGAMES_HIGHSCORE_LOG) << "The current high score group " << configGroup << " isn't in the list, adding it";
448 groupKeyList << configGroup;
449 setupGroup(configGroup);
450 }
451
452 for (const QByteArray &groupKey : std::as_const(groupKeyList)) {
453 highscoreObject->setHighscoreGroup(QLatin1String(groupKey));
454 player = highscoreObject->readEntry(0, QStringLiteral("LastPlayer")); // FIXME
455
456 for (int i = 1; i <= 10; ++i) {
458 for (int field = 1; field < fields; field = field * 2) {
459 if (fields & field) {
460 score[field] = highscoreObject->readEntry(i, key[field], QStringLiteral("-"));
461 }
462 }
463 scores[groupKey].append(score);
464 }
465 }
466 highscoreObject->setHighscoreGroup(QLatin1String(tempCurrentGroup)); // reset to the user-set group name
467 const auto groupKeys = scores.keys();
468 for (const QByteArray &groupKey : groupKeys) {
469 if ((scores[groupKey][0].value(KGameHighScoreDialog::Score) == QLatin1String("-")) && (scores.size() > 1) && (latest.first != groupKey)) {
470 qCDebug(KDEGAMES_HIGHSCORE_LOG) << "Removing group " << groupKey << " since it's unused.";
471 scores.remove(groupKey);
472 }
473 }
474 loaded = true;
475}
476
477void KGameHighScoreDialogPrivate::saveScores()
478{
479 highscoreObject->setHighscoreGroup(QLatin1String(configGroup));
480
481 highscoreObject->writeEntry(0, QStringLiteral("LastPlayer"), player);
482
483 for (int i = 1; i <= 10; ++i) {
484 KGameHighScoreDialog::FieldInfo score = scores[configGroup].at(i - 1);
485 for (int field = 1; field < fields; field = field * 2) {
486 if (fields & field) {
487 highscoreObject->writeEntry(i, key[field], score[field]);
488 }
489 }
490 }
491 highscoreObject->writeAndUnlock();
492}
493
495{
497
498 qCDebug(KDEGAMES_HIGHSCORE_LOG) << "adding new score";
499
500 bool askName = false, lessIsMore = false;
502 askName = true;
504 lessIsMore = true;
505
506 d->latest.first = d->configGroup; // Temporarily set this so loadScores() knows not to delete this group
507 if (!d->loaded)
508 d->loadScores();
509 d->latest.first = "Null"; // and reset it.
510
511 for (int i = 0; i < d->scores[d->configGroup].size(); i++) {
512 FieldInfo score = d->scores[d->configGroup].at(i); // First look at the score in the config file
513 bool ok; // will be false if there isn't any score yet in position i
514 int num_score = score[Score].toLong(&ok); // test if the stored score is a number
515
516 score = FieldInfo(newInfo); // now look at the submitted score
517 int newScore = score[Score].toInt();
518
519 qCDebug(KDEGAMES_HIGHSCORE_LOG) << "num_score =" << num_score << " - newScore =" << newScore;
520
521 if (((newScore > num_score) && !lessIsMore) || ((newScore < num_score) && lessIsMore) || !ok) {
522 d->latest = QPair<QByteArray, int>(d->configGroup, i + 1);
523 d->scores[d->configGroup].insert(i, score);
524 // Save the position to delete in case of Forget
525 d->lastHighPosition = i;
526
527 if (score[Name].isEmpty()) // If we don't have a name, prompt the player.
528 {
529 if (!d->player.isEmpty()) // d->player should be filled out by d->loadScores()
530 {
531 score[Name] = d->player;
532 } else {
533 KUser user;
534 score[Name] = user.property(KUser::FullName).toString();
535 if (score[Name].isEmpty()) {
536 score[Name] = user.loginName();
537 }
538 }
539 askName = true;
540 }
541
542 if (askName) {
543 d->player = score[Name];
544 d->newName = QPair<QByteArray, int>(d->configGroup, i + 1);
545
546 d->buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
547
548 d->buttonBox->button(QDialogButtonBox::Ok)->setText(i18nc("@action:button", "&Remember"));
549 d->buttonBox->button(QDialogButtonBox::Cancel)->setText(i18nc("@action:button", "&Forget"));
550 d->buttonBox->button(QDialogButtonBox::Ok)->setToolTip(i18nc("@info:tooltip", "Remember this high score"));
551 d->buttonBox->button(QDialogButtonBox::Cancel)->setToolTip(i18nc("@info:tooltip", "Forget this high score"));
552
553 connect(d->buttonBox, &QDialogButtonBox::accepted, this, &KGameHighScoreDialog::slotGotName);
554 connect(d->buttonBox, &QDialogButtonBox::rejected, this, &KGameHighScoreDialog::slotForgetScore);
555 } else
556 d->saveScores();
557
558 if (i == 0)
559 d->comment = i18n("Excellent!\nYou have a new high score!");
560 else
561 d->comment = i18n("Well done!\nYou made it to the high score list!");
562 return i + 1;
563 }
564 }
565 d->latest = qMakePair(d->configGroup, 0);
566 return 0;
567}
568
570{
571 FieldInfo scoreInfo;
572 scoreInfo[Score] = QString::number(newScore);
573 return addScore(scoreInfo, AskName | flags);
574}
575
577{
579
580 d->aboutToShow();
582}
583
585{
587
588 d->aboutToShow();
589 return QDialog::exec();
590}
591
592void KGameHighScoreDialog::slotGotReturn()
593{
594 QTimer::singleShot(0, this, &KGameHighScoreDialog::slotGotName);
595 // TODO: Is it better to hide the window, as if any button where pressed?
596}
597
598void KGameHighScoreDialog::slotGotName()
599{
601
602 if (d->newName.second == -1)
603 return;
604
605 d->player = d->edit->text();
606
607 d->scores[d->newName.first][d->newName.second - 1][Name] = d->player;
608 d->saveScores();
609
610 QFont bold = font();
611 bold.setBold(true);
612
613 QLabel *label = d->labels[d->newName.first].at((d->newName.second - 1) * d->nrCols + d->col[Name]);
614 label->setFont(bold);
615 label->setText(d->player);
616 d->stack[d->newName.first].at((d->newName.second - 1))->setCurrentWidget(label);
617 d->stack[d->newName.first].at((d->newName.second - 1))->removeWidget(d->edit);
618 delete d->edit;
619 d->edit = nullptr;
620 d->newName = QPair<QByteArray, int>(QByteArray(), -1);
621 d->scores[d->configGroup].removeAt(10);
622 d->comment.clear(); // hide the congratulations
623 d->commentLabel->hide();
624
625 d->buttonBox->setStandardButtons(QDialogButtonBox::Close);
627}
628
629void KGameHighScoreDialog::slotForgetScore()
630{
632
633 if (d->newName.second == -1)
634 return;
635 // remove the editor from the stack
636 d->stack[d->newName.first].at((d->newName.second - 1))->removeWidget(d->edit);
637 // delete the editor
638 delete d->edit;
639 d->edit = nullptr;
640 // avoid to recreate the KTextEdit widget
641 d->newName = QPair<QByteArray, int>(QByteArray(), -1);
642 // delete the highscore to forget
643 d->scores[d->configGroup].removeAt(d->lastHighPosition);
644 d->comment.clear();
645 d->commentLabel->hide();
646
647 d->buttonBox->setStandardButtons(QDialogButtonBox::Close);
649}
650
652{
654
655 if (!d->loaded)
656 d->loadScores();
657
658 if (!d->scores[d->configGroup].isEmpty())
659 return d->scores[d->configGroup].first()[Score].toInt();
660 else
661 return 0;
662}
663
664void KGameHighScoreDialog::keyPressEvent(QKeyEvent *ev)
665{
667
668 if ((d->newName.second != -1) && (ev->key() == Qt::Key_Return)) {
669 ev->ignore();
670 return;
671 }
673}
674
675#include "moc_kgamehighscoredialog.cpp"
KGameDifficulty manages difficulty levels of a game in a standard way.
QList< const KGameDifficultyLevel * > levels() const
A simple high score implementation.
void setHiddenConfigGroups(const QList< QByteArray > &hiddenGroups)
Hide some config groups so that they are not shown on the dialog (but are still stored in the configu...
int exec() override
Display the dialog as modal.
virtual void show()
Display the dialog as non-modal.
KGameHighScoreDialog(int fields=Name, QWidget *parent=nullptr)
@ LessIsMore
A lower numerical score means higher placing on the table.
@ AskName
Promt the player for their name.
void initFromDifficulty(const KGameDifficulty *difficulty, bool setConfigGroup=true)
Assume that config groups (incl.
void addLocalizedConfigGroupNames(const QMap< QByteArray, QString > &groups)
You must add the translations of all group names to the dialog.
void addField(int field, const QString &header, const QString &key)
Define an extra FieldInfo entry.
void addLocalizedConfigGroupName(const QPair< QByteArray, QString > &group)
You must add the translations of all group names to the dialog.
void setConfigGroupWeights(const QMap< int, QByteArray > &weights)
It is a good idea giving config group weights, otherwise tabs get ordered by their tab name that is n...
void setConfigGroup(const QPair< QByteArray, QString > &group)
The group name must be passed though i18n() in order for the group name to be translated.
void setComment(const QString &comment)
int addScore(const FieldInfo &newInfo=FieldInfo(), AddScoreFlags flags={})
Adds a new score to the list.
void hideField(int field)
Hide a field so that it is not shown on the table (but is still stored in the configuration file).
Class for managing highscore tables.
QStringList groupList() const
Returns a list of group names without the KHighscore_ prexix.
void writeAndUnlock()
Effectively write and unlock the system-wide highscore file (.
void writeEntry(int entry, const QString &key, const QString &value)
QString readEntry(int entry, const QString &key, const QString &pDefault=QString()) const
Reads an entry from the highscore table.
void setHighscoreGroup(const QString &groupname=QString())
Set the new highscore group.
void returnKeyPressed(const QString &text)
QVariant property(UserProperty which) const
QString loginName() const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
bool isEmpty() const const
virtual int exec()
virtual void keyPressEvent(QKeyEvent *e) override
virtual QSize minimumSizeHint() const const override
void setModal(bool modal)
virtual void reject()
void ignore()
bool testFlag(Enum flag) const const
void setBold(bool enable)
virtual void addItem(QLayoutItem *item) override
void addWidget(QWidget *widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment)
int key() const const
void setAlignment(Qt::Alignment)
virtual QSize sizeHint() const const override
void setText(const QString &)
bool contains(const AT &value) const const
qsizetype indexOf(const AT &value, qsizetype from) const const
void removeAt(qsizetype i)
iterator begin()
iterator end()
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
int addWidget(QWidget *widget)
void setCurrentWidget(QWidget *widget)
const QChar at(qsizetype position) const const
void clear()
const QChar * constData() const const
bool isEmpty() const const
QString number(double n, char format, int precision)
QString & setNum(double n, char format, int precision)
AlignVCenter
Key_Return
Horizontal
int addTab(QWidget *page, const QIcon &icon, const QString &label)
void clear()
int indexOf(const QWidget *w) const const
void setCurrentWidget(QWidget *widget)
QString tabText(int index) const const
QWidget * widget(int index) const const
QString toString() const const
void hide()
QLayout * layout() const const
void setMinimumSize(const QSize &)
void setMinimumWidth(int minw)
void setFixedSize(const QSize &s)
void setFocus()
void setLayout(QLayout *layout)
void show()
void setWindowTitle(const QString &)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.