kexthighscore_gui.h

00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001-02 Nicolas Hadacek (hadacek@kde.org)
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License version 2 as published by the Free Software Foundation.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KEXTHIGHSCORE_GUI_H
00021 #define KEXTHIGHSCORE_GUI_H
00022 
00023 #include <qcheckbox.h>
00024 #include <qlabel.h>
00025 #include <qvbox.h>
00026 #include <qtabwidget.h>
00027 
00028 #include <klistview.h>
00029 #include <klineedit.h>
00030 #include <kpushbutton.h>
00031 #include <kdialogbase.h>
00032 
00033 #include "kexthighscore.h"
00034 
00035 
00036 namespace KExtHighscore
00037 {
00038 
00039 class ItemContainer;
00040 class ItemArray;
00041 class Score;
00042 class AdditionalTab;
00043 
00044 //-----------------------------------------------------------------------------
00045 class ShowItem : public KListViewItem
00046 {
00047  public:
00048     ShowItem(QListView *, bool highlight);
00049 
00050  protected:
00051     virtual void paintCell(QPainter *, const QColorGroup &, int column,
00052                            int width, int align);
00053 
00054  private:
00055     bool _highlight;
00056 };
00057 
00058 class ScoresList : public KListView
00059 {
00060  Q_OBJECT
00061  public:
00062     ScoresList(QWidget *parent);
00063 
00064     void addHeader(const ItemArray &);
00065 
00066  protected:
00067     QListViewItem *addLine(const ItemArray &, uint index, bool highlight);
00068     virtual QString itemText(const ItemContainer &, uint row) const = 0;
00069 
00070  private:
00071     virtual void addLineItem(const ItemArray &, uint index,
00072                              QListViewItem *item);
00073 };
00074 
00075 //-----------------------------------------------------------------------------
00076 class HighscoresList : public ScoresList
00077 {
00078  Q_OBJECT
00079  public:
00080     HighscoresList(QWidget *parent);
00081 
00082     void load(const ItemArray &, int highlight);
00083 
00084  protected:
00085     QString itemText(const ItemContainer &, uint row) const;
00086 };
00087 
00088 class HighscoresWidget : public QWidget
00089 {
00090  Q_OBJECT
00091  public:
00092     HighscoresWidget(QWidget *parent);
00093 
00094     void load(int rank);
00095 
00096  signals:
00097     void tabChanged(int i);
00098 
00099  public slots:
00100     void changeTab(int i);
00101 
00102  private slots:
00103     void showURL(const QString &) const;
00104     void tabChanged() { emit tabChanged(_tw->currentPageIndex()); }
00105 
00106  private:
00107     QTabWidget     *_tw;
00108     HighscoresList *_scoresList, *_playersList;
00109     KURLLabel      *_scoresUrl, *_playersUrl;
00110     AdditionalTab  *_statsTab, *_histoTab;
00111 };
00112 
00113 class HighscoresDialog : public KDialogBase
00114 {
00115  Q_OBJECT
00116  public:
00117     HighscoresDialog(int rank, QWidget *parent);
00118 
00119  private slots:
00120     void slotUser1();
00121     void slotUser2();
00122     void tabChanged(int i) { _tab = i; }
00123     void createPage(QWidget *);
00124 
00125  private:
00126     int _rank, _tab;
00127     QWidget *_current;
00128     QValueVector<HighscoresWidget *> _widgets;
00129 };
00130 
00131 //-----------------------------------------------------------------------------
00132 class LastMultipleScoresList : public ScoresList
00133 {
00134     Q_OBJECT
00135 public:
00136     LastMultipleScoresList(const QValueVector<Score> &, QWidget *parent);
00137 
00138 private:
00139     void addLineItem(const ItemArray &, uint index, QListViewItem *line);
00140     QString itemText(const ItemContainer &, uint row) const;
00141 
00142 private:
00143     const QValueVector<Score> &_scores;
00144 };
00145 
00146 class TotalMultipleScoresList : public ScoresList
00147 {
00148     Q_OBJECT
00149 public:
00150     TotalMultipleScoresList(const QValueVector<Score> &, QWidget *parent);
00151 
00152 private:
00153     void addLineItem(const ItemArray &, uint index, QListViewItem *line);
00154     QString itemText(const ItemContainer &, uint row) const;
00155 
00156 private:
00157     const QValueVector<Score> &_scores;
00158 };
00159 
00160 //-----------------------------------------------------------------------------
00161 class ConfigDialog : public KDialogBase
00162 {
00163  Q_OBJECT
00164  public:
00165     ConfigDialog(QWidget *parent);
00166 
00167     bool hasBeenSaved() const { return _saved; }
00168 
00169  private slots:
00170     void modifiedSlot();
00171     void removeSlot();
00172     void accept();
00173     void slotApply() { save(); }
00174     void nickNameChanged(const QString &);
00175 
00176  private:
00177     bool         _saved;
00178     QCheckBox   *_WWHEnabled;
00179     QLineEdit   *_nickname, *_comment;
00180     KLineEdit   *_key, *_registeredName;
00181     KPushButton *_removeButton;
00182 
00183     void load();
00184     bool save();
00185 };
00186 
00187 //-----------------------------------------------------------------------------
00188 class AskNameDialog : public KDialogBase
00189 {
00190  Q_OBJECT
00191  public:
00192     AskNameDialog(QWidget *parent);
00193 
00194     QString name() const { return _edit->text(); }
00195     bool dontAskAgain() const { return _checkbox->isChecked(); }
00196 
00197  private slots:
00198     void nameChanged();
00199 
00200  private:
00201     QLineEdit *_edit;
00202     QCheckBox *_checkbox;
00203 };
00204 
00205 } // namespace
00206 
00207 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys