[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdeedu/kiten
From: Jason Katz-Brown <jason () katzbrown ! com>
Date: 2004-11-21 2:40:46
Message-ID: 20041121024046.8A16E16F3E () office ! kde ! org
[Download RAW message or body]
CVS commit by katz:
fix 93414, get rid of crash of double-clicking delete button in learn
M +23 -14 learn.cpp 1.21
M +10 -1 learn.h 1.8
M +3 -1 widgets.cpp 1.71
--- kdeedu/kiten/learn.cpp #1.20:1.21
@@ -44,4 +44,16 @@
#include "learn.h"
+LearnItem::LearnItem(QListView *parent, QString label1, QString label2, QString \
label3, QString label4, QString label5, QString label6, QString label7, QString \
label8) + : QListViewItem(parent, label1, label2, label3, label4, label5, \
label6, label7, label8) +{
+}
+
+int LearnItem::compare(QListViewItem *item, int col, bool ascending) const
+{
+ // "Returns < 0 if this item is less than i [item] , 0 if they
+ // are equal and > 0 if this item is greater than i [item]."
+ return key(col, ascending).toInt() - item->key(col, ascending).toInt();
+}
+
const int Learn::numberOfAnswers = 5;
@@ -496,5 +508,5 @@ void Learn::add(Dict::Entry toAdd, bool
unsigned int grade = toAdd.grade();
- addItem(new QListViewItem(List, kanji, meanings, readings, \
QString::number(grade), QString::number(score)), noEmit); + addItem(new \
LearnItem(List, kanji, meanings, readings, QString::number(grade), \
QString::number(score)), noEmit);
numChanged();
@@ -584,22 +596,17 @@ void Learn::del()
}
- if (List->childCount() < 1)
- {
- // this isn't a good state, quizzing is unstable
- }
- else
- {
- if (makenewq)
- {
curItem = List->firstChild();
- backAct->setEnabled(false);
prevItem = curItem;
+ backAct->setEnabled(false);
+
+ if (makenewq)
+ {
qnew();
}
- }
setDirty();
}
+ itemSelectionChanged();
numChanged();
}
@@ -667,7 +674,9 @@ void Learn::answerClicked(int i)
//config.writeEntry(curItem->text(0) + "_4", newscore);
- QListViewItem *newItem = new QListViewItem(List, curItem->text(0), \
curItem->text(1), curItem->text(2), curItem->text(3), QString::number(newscore)); + \
QListViewItem *newItem = new LearnItem(List, curItem->text(0), curItem->text(1), \
curItem->text(2), curItem->text(3), QString::number(newscore));
// readd, so it sorts
+ // 20 November 2004: why?? why not List->sort() ??
+ // haha I used to be naive
delete curItem;
curItem = newItem;
--- kdeedu/kiten/learn.h #1.7:1.8
@@ -22,4 +22,6 @@
#define LEARN_H
+#include <qlistview.h>
+
#include <kurl.h>
@@ -28,5 +30,4 @@
class KAction;
class KConfig;
-class KListView;
class KPushButton;
class QButtonGroup;
@@ -35,4 +36,12 @@ class QSplitter;
class QTabWidget;
+// Item that sorts all columns numerically
+class LearnItem : public QListViewItem
+{
+public:
+ LearnItem(QListView *parent, QString label1, QString label2 = QString::null, \
QString label3 = QString::null, QString label4 = QString::null, QString label5 = \
QString::null, QString label6 = QString::null, QString label7 = QString::null, \
QString label8 = QString::null); + int compare(QListViewItem *item, int col, \
bool ascending) const; +};
+
class Learn : public KMainWindow
{
--- kdeedu/kiten/widgets.cpp #1.70:1.71
@@ -118,5 +118,7 @@ void ResultView::addKanjiResult(Dict::En
html = html.arg(i18n("Rare"));
else
- html = html.arg(i18n("Once", "%1 Times", freq));
+ // this isn't a number of times, it's simply an index of
+ // probability
+ html = html.arg(i18n("Probability rank #%1").arg(freq));
html += "<br />";
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic