moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / ktouch / src / ktouchcharstats.h
blob3d8338d50c96a7d2cfa47c98dbf175cdf2dbd3ed
1 /***************************************************************************
2 * ktouchcharstats.h *
3 * ----------------- *
4 * Copyright (C) 2003 by Andreas Nicolai *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
12 #ifndef KTOUCHCHARSTATS_H
13 #define KTOUCHCHARSTATS_H
15 #include <qstring.h> // for QChar
17 class QTextStream;
19 /** Contains the stats for a character.
20 * Basically in this class the number of times the character has been pressed is counted. Both
21 * the number of times it was correctly pressed and the number of times it was missed are stored
22 * which allows to calculate a relative "hit-miss-ratio".
24 class KTouchCharStats {
25 public:
26 /// Default constructor.
27 KTouchCharStats() {};
28 /// Constructor with parameters.
29 KTouchCharStats(QChar ch, unsigned int correct, unsigned int wrong)
30 : m_char(ch), m_correctCount(correct), m_wrongCount(wrong) {};
31 /// Returns the hit-miss ratio (a value between 0-all correct and 100-all wrong).
32 int hitMissRatio() const;
34 QChar m_char; ///< The character that has been missed.
35 unsigned int m_correctCount; ///< How often the character has been typed correctly.
36 unsigned int m_wrongCount; ///< How often the character has been missed (not typed when it ought to be typed).
39 /// Comparison operator < : returns 'true' when the char-code of 'lhs' is less then the one of 'rhs'
40 inline bool operator<(const KTouchCharStats &lhs, const KTouchCharStats &rhs) { return lhs.m_char<rhs.m_char; }
41 /// Comparison operator > : returns 'true' when the char-code of 'lhs' is greater then the one of 'rhs'
42 inline bool operator>(const KTouchCharStats &lhs, const KTouchCharStats &rhs) { return lhs.m_char>rhs.m_char; }
43 /// Comparison operator == : returns 'true' when the char-code of 'lhs' is equal to then the one of 'rhs'
44 inline bool operator==(const KTouchCharStats &lhs, const KTouchCharStats &rhs) { return lhs.m_char==rhs.m_char; }
46 /// Writes the content of a KTouchCharStats object into the text stream.
47 QTextStream& operator<<(QTextStream &out, const KTouchCharStats &ch);
49 /// Sort criterion: Returns 'true' when the hit-miss ratio of 'lhs' is worse then the one of 'rhs'.
50 bool greaterHitMissRatio(const KTouchCharStats &lhs, const KTouchCharStats &rhs);
52 #endif // KTOUCHCHARSTATS_H