1 /***************************************************************************
2 * ktouchcharstats.cpp *
3 * ------------------- *
4 * Copyright (C) 2003 by Andreas Nicolai *
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 #include "ktouchcharstats.h"
13 #include <qtextstream.h>
15 int KTouchCharStats::hitMissRatio() const {
16 if (m_correctCount
+m_wrongCount
==0) return 0;
17 return static_cast<int>(100.0*m_wrongCount
/(m_correctCount
+m_wrongCount
));
20 QTextStream
& operator<<(QTextStream
&out
, const KTouchCharStats
&ch
) {
21 return (out
<< ch
.m_char
.unicode() << " " << ch
.m_correctCount
<< " " << ch
.m_wrongCount
);
24 bool greaterHitMissRatio(const KTouchCharStats
&lhs
, const KTouchCharStats
&rhs
) {
25 return (lhs
.hitMissRatio() > rhs
.hitMissRatio());