kexthighscore_tab.h

00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2002 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_TAB_H
00021 #define KEXTHIGHSCORE_TAB_H
00022 
00023 #include <qcombobox.h>
00024 #include <qmemarray.h>
00025 
00026 class QLabel;
00027 class KListView;
00028 
00029 
00030 namespace KExtHighscore
00031 {
00032 
00033 //-----------------------------------------------------------------------------
00034 class PlayersCombo : public QComboBox
00035 {
00036  Q_OBJECT
00037  public:
00038     PlayersCombo(QWidget *parent = 0, const char *name = 0);
00039 
00040     void load();
00041 
00042  signals:
00043     void playerSelected(uint i);
00044     void allSelected();
00045     void noneSelected();
00046 
00047  private slots:
00048     void activatedSlot(int i);
00049 };
00050 
00051 //-----------------------------------------------------------------------------
00052 class AdditionalTab : public QWidget
00053 {
00054  Q_OBJECT
00055  public:
00056     AdditionalTab(QWidget *parent, const char *name);
00057 
00058     virtual void load();
00059 
00060  private slots:
00061     void playerSelected(uint i) { display(i) ; }
00062     void allSelected();
00063 
00064  protected:
00065     void init();
00066     static QString percent(uint n, uint total, bool withBraces = false);
00067     virtual void display(uint i) = 0;
00068 
00069  private:
00070     PlayersCombo *_combo;
00071 };
00072 
00073 //-----------------------------------------------------------------------------
00074 class StatisticsTab : public AdditionalTab
00075 {
00076  Q_OBJECT
00077  public:
00078     StatisticsTab(QWidget *parent);
00079 
00080     void load();
00081 
00082  private:
00083     enum Count { Total = 0, Won, Lost, Draw, Nb_Counts };
00084     static const char *COUNT_LABELS[Nb_Counts];
00085     enum Trend { CurrentTrend = 0, WonTrend, LostTrend, Nb_Trends };
00086     static const char *TREND_LABELS[Nb_Trends];
00087     struct Data {
00088         uint count[Nb_Counts];
00089         double trend[Nb_Trends];
00090     };
00091     QMemArray<Data> _data;
00092     QLabel *_nbs[Nb_Counts], *_percents[Nb_Counts], *_trends[Nb_Trends];
00093 
00094     QString percent(const Data &, Count) const;
00095     void display(uint i);
00096 };
00097 
00098 //-----------------------------------------------------------------------------
00099 class HistogramTab : public AdditionalTab
00100 {
00101  Q_OBJECT
00102  public:
00103     HistogramTab(QWidget *parent);
00104 
00105     void load();
00106 
00107  private:
00108     QMemArray<uint> _counts;
00109     QMemArray<uint> _data;
00110     KListView       *_list;
00111 
00112     void display(uint i);
00113 };
00114 
00115 } // namespace
00116 
00117 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys