summaryrefslogtreecommitdiffstats
path: root/kvoctrain/kvoctrain/query-dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'kvoctrain/kvoctrain/query-dialogs')
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.cpp303
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.h87
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/AdjQueryDlgForm.ui344
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.cpp346
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.h87
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/ArtQueryDlgForm.ui347
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.cpp448
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.h90
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/MCQueryDlgForm.ui444
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/Makefile.am13
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.cpp334
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.h111
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.cpp690
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.h106
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/RandomQueryDlgForm.ui418
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.cpp336
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.h83
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlgForm.ui348
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.cpp516
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.h100
-rw-r--r--kvoctrain/kvoctrain/query-dialogs/VerbQueryDlgForm.ui549
21 files changed, 6100 insertions, 0 deletions
diff --git a/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.cpp b/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.cpp
new file mode 100644
index 00000000..c643ba01
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.cpp
@@ -0,0 +1,303 @@
+/***************************************************************************
+
+ query dialog for adjectives
+
+ -----------------------------------------------------------------------
+
+ begin : Sat Dec 4 15:09:18 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2004-2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#include "AdjQueryDlg.h"
+
+#include <kv_resource.h>
+#include <langset.h>
+
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kprogress.h>
+
+#include <qtimer.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+
+AdjQueryDlg::AdjQueryDlg
+(
+ QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Comparison &_comp)
+ : QueryDlgBase(i18n("Comparison Training"))
+{
+ mw = new AdjQueryDlgForm(this);
+ setMainWidget(mw);
+
+ connect(mw->dont_know, SIGNAL(clicked()), SLOT(dontKnowClicked()) );
+ connect(mw->know_it, SIGNAL(clicked()), SLOT(knowItClicked()) );
+ connect(mw->verify, SIGNAL(clicked()), SLOT(verifyClicked()) );
+ connect(mw->show_all, SIGNAL(clicked()), SLOT(showAllClicked()) );
+
+ connect(mw->lev1Field, SIGNAL(returnPressed()), SLOT(returnPressed()) );
+ connect(mw->lev2Field, SIGNAL(returnPressed()), SLOT(returnPressed()) );
+ connect(mw->lev3Field, SIGNAL(returnPressed()), SLOT(returnPressed()) );
+
+ connect(mw->lev1Field, SIGNAL(textChanged(const QString&)), SLOT(lev1Changed(const QString&)) );
+ connect(mw->lev2Field, SIGNAL(textChanged(const QString&)), SLOT(lev2Changed(const QString&)) );
+ connect(mw->lev3Field, SIGNAL(textChanged(const QString&)), SLOT(lev3Changed(const QString&)) );
+
+ qtimer = 0;
+
+ mw->lev1Label->setBuddy(mw->lev1Field);
+ mw->lev2Label->setBuddy(mw->lev2Field);
+ mw->lev3Label->setBuddy(mw->lev3Field);
+
+ setQuery (type, entry, col, query_cycle, query_num, query_startnum, exp, doc, _comp);
+ mw->countbar->setFormat("%v/%m");
+ mw->timebar->setFormat("%v");
+ resize(configDialogSize("AdjQueryDialog"));
+}
+
+
+AdjQueryDlg::~AdjQueryDlg()
+{
+ saveDialogSize("AdjQueryDialog");
+}
+
+
+void AdjQueryDlg::setQuery(QString,
+ int entry,
+ int col,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Comparison &_comp)
+{
+ //type_timeout = type_to;
+ kv_doc = doc;
+ kv_exp = exp;
+ q_row = entry;
+ q_ocol = col;
+ mw->timebar->setEnabled(Prefs::showCounter());
+ mw->timelabel->setEnabled(Prefs::showCounter());
+ comp = _comp;
+ mw->show_all->setDefault(true);
+ QString s;
+ s.setNum (q_cycle);
+ mw->progCount->setText (s);
+
+ mw->lev1Field->setText ("");
+ mw->lev2Field->setText ("");
+ mw->lev3Field->setText ("");
+
+ int sel = getRandom(3);
+ switch (sel) {
+ case 0: mw->lev1Field->setText (comp.l1() );
+ break;
+
+ case 1: mw->lev2Field->setText (comp.l2() );
+ break;
+
+ case 2: mw->lev3Field->setText (comp.l3() );
+ break;
+ }
+
+ mw->lev1Field->setEnabled(!comp.l1().isEmpty() );
+ mw->lev2Field->setEnabled(!comp.l2().isEmpty() );
+ mw->lev3Field->setEnabled(!comp.l3().isEmpty() );
+
+ mw->countbar->setTotalSteps(q_start);
+ mw->countbar->setProgress(q_start - q_num + 1);
+
+ int mqtime = Prefs::maxTimePer();
+ if (mqtime > 0) {
+ if (qtimer == 0) {
+ qtimer = new QTimer( this );
+ connect( qtimer, SIGNAL(timeout()), this, SLOT(timeoutReached()) );
+ }
+
+ if (Prefs::queryTimeout() != Prefs::EnumQueryTimeout::NoTimeout) {
+ timercount = mqtime;
+ mw->timebar->setTotalSteps(timercount);
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ resetAllFields();
+}
+
+
+void AdjQueryDlg::initFocus() const
+{
+ mw->lev1Field->setFocus();
+}
+
+
+void AdjQueryDlg::showAllClicked()
+{
+ resetAllFields();
+ mw->lev1Field->setText (comp.l1() );
+ mw->lev2Field->setText (comp.l2() );
+ mw->lev3Field->setText (comp.l3() );
+
+ verifyField (mw->lev1Field, comp.l1());
+ verifyField (mw->lev2Field, comp.l2());
+ verifyField (mw->lev3Field, comp.l3());
+
+ mw->dont_know->setDefault(true);
+}
+
+
+void AdjQueryDlg::verifyClicked()
+{
+ bool all_known = true;
+
+ if (!verifyField (mw->lev1Field, comp.l1()) )
+ all_known = false;
+
+ if (!verifyField (mw->lev2Field, comp.l2()) )
+ all_known = false;
+
+ if (!verifyField (mw->lev3Field, comp.l3()) )
+ all_known = false;
+
+ if (all_known)
+// know_it->setDefault(true);
+ knowItClicked();
+ else
+ mw->dont_know->setDefault(true);
+}
+
+
+void AdjQueryDlg::resetAllFields()
+{
+ resetField(mw->lev1Field);
+ resetField(mw->lev2Field);
+ resetField(mw->lev3Field);
+}
+
+
+void AdjQueryDlg::knowItClicked()
+{
+ emit sigQueryChoice(Known);
+}
+
+
+void AdjQueryDlg::timeoutReached()
+{
+ if (timercount > 0) {
+ timercount--;
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+
+ if (timercount <= 0) {
+ mw->timebar->setProgress(0);
+ if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Show) {
+ showAllClicked();
+ mw->dont_know->setDefault(true);
+ }
+ else if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Continue)
+ emit sigQueryChoice(Timeout);
+ }
+}
+
+
+void AdjQueryDlg::dontKnowClicked()
+{
+ emit sigQueryChoice(Unknown);
+}
+
+
+void AdjQueryDlg::slotUser2()
+{
+
+ if (qtimer != 0)
+ qtimer->stop();
+
+ emit sigEditEntry (q_row, KV_COL_ORG+q_ocol);
+}
+
+
+void AdjQueryDlg::keyPressEvent( QKeyEvent *e )
+{
+ switch( e->key() )
+ {
+ case Key_Escape:
+ dontKnowClicked();
+ break;
+
+ case Key_Return:
+ case Key_Enter:
+ if (mw->dont_know->isDefault() )
+ dontKnowClicked();
+ else if (mw->know_it->isDefault() )
+ knowItClicked();
+ else if (mw->show_all->isDefault() )
+ showAllClicked();
+ else if (mw->verify->isDefault() )
+ verifyClicked();
+ break;
+
+ default:
+ e->ignore();
+ break;
+ }
+}
+
+
+void AdjQueryDlg::returnPressed()
+{
+}
+
+
+void AdjQueryDlg::lev1Changed(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField (mw->lev1Field);
+}
+
+
+void AdjQueryDlg::lev2Changed(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField (mw->lev2Field);
+}
+
+
+void AdjQueryDlg::lev3Changed(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField (mw->lev3Field);
+}
+
+
+#include "AdjQueryDlg.moc"
diff --git a/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.h b/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.h
new file mode 100644
index 00000000..29561404
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlg.h
@@ -0,0 +1,87 @@
+/***************************************************************************
+
+ query dialog for adjectives
+
+ -----------------------------------------------------------------------
+
+ begin : Sat Dec 4 15:09:18 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef AdjQueryDlg_included
+#define AdjQueryDlg_included
+
+#include "AdjQueryDlgForm.h"
+#include "QueryDlgBase.h"
+
+class AdjQueryDlg : public QueryDlgBase
+{
+ Q_OBJECT
+
+public:
+ AdjQueryDlg
+ (
+ QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Comparison &comp);
+
+ ~AdjQueryDlg();
+
+ void setQuery(QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Comparison &comp);
+
+public slots:
+ virtual void initFocus() const;
+
+protected:
+ void keyPressEvent(QKeyEvent *e);
+ void resetAllFields();
+
+protected slots:
+ void lev1Changed(const QString&);
+ void lev2Changed(const QString&);
+ void lev3Changed(const QString&);
+ void showAllClicked();
+ void slotUser2();
+ void knowItClicked();
+ void returnPressed();
+ void dontKnowClicked();
+ void verifyClicked();
+ void timeoutReached();
+
+protected:
+ Comparison comp;
+
+private:
+ AdjQueryDlgForm * mw;
+};
+#endif // AdjQueryDlg_included
diff --git a/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlgForm.ui b/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlgForm.ui
new file mode 100644
index 00000000..b8218978
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/AdjQueryDlgForm.ui
@@ -0,0 +1,344 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>AdjQueryDlgForm</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>AdjQueryDlgForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>396</width>
+ <height>226</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Fill in the missing comparison expressions:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>lev1Label</cstring>
+ </property>
+ <property name="text">
+ <string>Level &amp;1:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>lev1Field</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>lev3Label</cstring>
+ </property>
+ <property name="text">
+ <string>Level &amp;3:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>lev3Field</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>lev2Label</cstring>
+ </property>
+ <property name="text">
+ <string>Level &amp;2:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>lev2Field</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>lev1Field</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>lev2Field</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="3" column="1">
+ <property name="name">
+ <cstring>lev3Field</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <spacer row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>390</width>
+ <height>60</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="5" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>verify</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Verify</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>know_it</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>I &amp;Know It</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>show_all</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>dont_know</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Do Not Know</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>progressgroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Progress</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KProgress" row="0" column="1">
+ <property name="name">
+ <cstring>countbar</cstring>
+ </property>
+ </widget>
+ <widget class="KProgress" row="1" column="1">
+ <property name="name">
+ <cstring>timebar</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>countlabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Count:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>timelabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>Cyclelabel</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="text">
+ <string>Cycle:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>progCount</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>lev1Field</tabstop>
+ <tabstop>lev2Field</tabstop>
+ <tabstop>lev3Field</tabstop>
+ <tabstop>show_all</tabstop>
+ <tabstop>verify</tabstop>
+ <tabstop>know_it</tabstop>
+ <tabstop>dont_know</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kprogress.h</includehint>
+ <includehint>kprogress.h</includehint>
+</includehints>
+</UI>
diff --git a/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.cpp b/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.cpp
new file mode 100644
index 00000000..a35ffa83
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.cpp
@@ -0,0 +1,346 @@
+/***************************************************************************
+
+ query dialog for articles
+
+ -----------------------------------------------------------------------
+
+ begin : Fri Dec 3 18:28:18 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2004-2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#include "ArtQueryDlg.h"
+
+#include <kv_resource.h>
+
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kapplication.h>
+#include <kprogress.h>
+
+#include <qtimer.h>
+#include <qradiobutton.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qbuttongroup.h>
+
+ArtQueryDlg::ArtQueryDlg
+(
+ QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Article &articles)
+ : QueryDlgBase(i18n("Article Training"))
+{
+ mw = new ArtQueryDlgForm(this);
+ setMainWidget(mw);
+
+ qtimer = 0;
+
+ mw->artGroup->insert (mw->natural);
+ mw->artGroup->insert (mw->male);
+ mw->artGroup->insert (mw->rb_fem);
+
+ connect(mw->dont_know, SIGNAL(clicked()), SLOT(dontKnowClicked()) );
+ connect(mw->know_it, SIGNAL(clicked()), SLOT(knowItClicked()) );
+ connect(mw->verify, SIGNAL(clicked()), SLOT(verifyClicked()) );
+ connect(mw->show_all, SIGNAL(clicked()), SLOT(showAllClicked()) );
+
+ connect(mw->natural, SIGNAL(clicked()), SLOT(slotNaturalClicked()) );
+ connect(mw->male, SIGNAL(clicked()), SLOT(slotMaleClicked()) );
+ connect(mw->rb_fem, SIGNAL(clicked()), SLOT(slotFemClicked()) );
+
+ setQuery (type, entry, col, query_cycle, query_num, query_startnum, exp, doc, articles);
+ mw->countbar->setFormat("%v/%m");
+ mw->timebar->setFormat("%v");
+ resize(configDialogSize("ArtQueryDialog"));
+}
+
+
+ArtQueryDlg::~ArtQueryDlg()
+{
+ saveDialogSize("ArtQueryDialog");
+}
+
+
+void ArtQueryDlg::setQuery(QString,
+ int entry,
+ int col,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Article &art)
+{
+ //type_timeout = type_to;
+ kv_exp = exp;
+ kv_doc = doc;
+ q_row = entry;
+ q_ocol = col;
+ mw->timebar->setEnabled(Prefs::showCounter());
+ mw->timelabel->setEnabled(Prefs::showCounter());
+ mw->show_all->setDefault(true);
+ articles = art;
+
+ QString s;
+ if (col == 0)
+ s = exp->getOriginal().stripWhiteSpace();
+ else
+ s = exp->getTranslation(q_ocol).stripWhiteSpace();
+
+ QString def, indef;
+ bool removed = false;
+
+ articles.female(def, indef);
+ mw->rb_fem->setText (i18n("&female:\t")+def+" / "+indef);
+ mw->rb_fem->setEnabled (!QString(def+indef).isEmpty() );
+ if (!removed && s.find(def+" ") == 0) {
+ s.remove (0, def.length()+1);
+ removed = true;
+ }
+ if (!removed && s.find(indef+" ") == 0) {
+ s.remove (0, indef.length()+1);
+ removed = true;
+ }
+
+ articles.male(def, indef);
+ mw->male->setText (i18n("&male:\t")+def+" / "+indef);
+ mw->male->setEnabled (!QString(def+indef).isEmpty() );
+ if (!removed && s.find(def+" ") == 0) {
+ s.remove (0, def.length()+1);
+ removed = true;
+ }
+ if (!removed && s.find(indef+" ") == 0) {
+ s.remove (0, indef.length()+1);
+ removed = true;
+ }
+
+ articles.natural(def, indef);
+ mw->natural->setText (i18n("&natural:\t")+def+" / "+indef);
+ mw->natural->setEnabled (!QString(def+indef).isEmpty() );
+ if (!removed && s.find(def+" ") == 0) {
+ s.remove (0, def.length()+1);
+ removed = true;
+ }
+ if (!removed && s.find(indef+" ") == 0) {
+ s.remove (0, indef.length()+1);
+ removed = true;
+ }
+
+ mw->orgField->setText(s);
+ s.setNum (q_cycle);
+ mw->progCount->setText (s);
+
+ mw->countbar->setTotalSteps(q_start);
+ mw->countbar->setProgress(q_start - q_num + 1);
+ int mqtime = Prefs::maxTimePer();
+ if (mqtime > 0) {
+ if (qtimer == 0) {
+ qtimer = new QTimer( this );
+ connect( qtimer, SIGNAL(timeout()), this, SLOT(timeoutReached()) );
+ }
+
+ if (Prefs::queryTimeout() != Prefs::EnumQueryTimeout::NoTimeout) {
+ timercount = mqtime;
+ mw->timebar->setTotalSteps(timercount);
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ }
+ else
+ mw->timebar->setEnabled(false);
+}
+
+
+void ArtQueryDlg::initFocus() const
+{
+ mw->rb_fem->setFocus();
+}
+
+
+void ArtQueryDlg::showAllClicked()
+{
+ resetButton(mw->rb_fem);
+ resetButton(mw->male);
+ resetButton(mw->natural);
+
+ if (kv_exp->getType (q_ocol) == QM_NOUN QM_TYPE_DIV QM_NOUN_F) {
+ mw->rb_fem->setChecked (true);
+ verifyButton(mw->rb_fem, true);
+ }
+ else if (kv_exp->getType (q_ocol) == QM_NOUN QM_TYPE_DIV QM_NOUN_M) {
+ mw->male->setChecked (true);
+ verifyButton(mw->male, true);
+ }
+ else if (kv_exp->getType (q_ocol) == QM_NOUN QM_TYPE_DIV QM_NOUN_S) {
+ mw->natural->setChecked (true);
+ verifyButton(mw->natural, true);
+ }
+ mw->dont_know->setDefault(true);
+}
+
+
+void ArtQueryDlg::showMoreClicked()
+{
+}
+
+
+void ArtQueryDlg::verifyClicked()
+{
+ bool known = false;
+ if (kv_exp->getType (q_ocol) == QM_NOUN QM_TYPE_DIV QM_NOUN_F)
+ known = mw->rb_fem->isChecked ();
+ else if (kv_exp->getType (q_ocol) == QM_NOUN QM_TYPE_DIV QM_NOUN_M)
+ known = mw->male->isChecked ();
+ else if (kv_exp->getType (q_ocol) == QM_NOUN QM_TYPE_DIV QM_NOUN_S)
+ known = mw->natural->isChecked ();
+
+ if (mw->rb_fem->isChecked() ) {
+ verifyButton(mw->rb_fem, known);
+ resetButton(mw->male);
+ resetButton(mw->natural);
+ }
+ else if (mw->male->isChecked() ) {
+ verifyButton(mw->male, known);
+ resetButton(mw->rb_fem);
+ resetButton(mw->natural);
+ }
+ else if (mw->natural->isChecked() ) {
+ verifyButton(mw->natural, known);
+ resetButton(mw->male);
+ resetButton(mw->rb_fem);
+ }
+
+ if (known)
+// know_it->setDefault(true);
+ knowItClicked();
+ else
+ mw->dont_know->setDefault(true);
+}
+
+
+void ArtQueryDlg::knowItClicked()
+{
+ emit sigQueryChoice(Known);
+}
+
+
+void ArtQueryDlg::timeoutReached()
+{
+ if (timercount > 0) {
+ timercount--;
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+
+ if (timercount <= 0) {
+ mw->timebar->setProgress(0);
+ if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Show) {
+ showAllClicked();
+ mw->dont_know->setDefault(true);
+ }
+ else if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Continue)
+ emit sigQueryChoice(Timeout);
+ }
+}
+
+
+void ArtQueryDlg::dontKnowClicked()
+{
+ emit sigQueryChoice (Unknown);
+}
+
+
+void ArtQueryDlg::slotUser2()
+{
+
+ if (qtimer != 0)
+ qtimer->stop();
+
+ emit sigEditEntry (q_row, KV_COL_ORG+q_ocol);
+}
+
+
+void ArtQueryDlg::keyPressEvent( QKeyEvent *e )
+{
+ switch( e->key() )
+ {
+ case Key_Escape:
+ dontKnowClicked();
+ break;
+
+ case Key_Return:
+ case Key_Enter:
+ if (mw->dont_know->isDefault() )
+ dontKnowClicked();
+ else if (mw->know_it->isDefault() )
+ knowItClicked();
+ else if (mw->show_all->isDefault() )
+ showAllClicked();
+ else if (mw->verify->isDefault() )
+ verifyClicked();
+ break;
+
+ default:
+ e->ignore();
+ break;
+ }
+}
+
+
+void ArtQueryDlg::returnPressed()
+{
+}
+
+
+void ArtQueryDlg::slotFemClicked()
+{
+ resetButton(mw->rb_fem);
+ resetButton(mw->male);
+ resetButton(mw->natural);
+ verifyClicked();
+}
+
+
+void ArtQueryDlg::slotMaleClicked()
+{
+ resetButton(mw->male);
+ resetButton(mw->natural);
+ resetButton(mw->rb_fem);
+ verifyClicked();
+}
+
+
+void ArtQueryDlg::slotNaturalClicked()
+{
+ resetButton(mw->natural);
+ resetButton(mw->male);
+ resetButton(mw->rb_fem);
+ verifyClicked();
+}
+
+
+#include "ArtQueryDlg.moc"
diff --git a/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.h b/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.h
new file mode 100644
index 00000000..61d84103
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlg.h
@@ -0,0 +1,87 @@
+/***************************************************************************
+
+ query dialog for articles
+
+ -----------------------------------------------------------------------
+
+ begin : Fri Dec 3 18:28:18 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef ArtQueryDlg_included
+#define ArtQueryDlg_included
+
+#include "ArtQueryDlgForm.h"
+#include "QueryDlgBase.h"
+
+class ArtQueryDlg : public QueryDlgBase
+{
+
+ Q_OBJECT
+
+public:
+ ArtQueryDlg(
+ QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Article &articles);
+
+ ~ArtQueryDlg();
+
+ void setQuery (QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Article &articles);
+
+public slots:
+ virtual void initFocus() const;
+
+protected:
+ void keyPressEvent( QKeyEvent *e );
+
+protected slots:
+ void showMoreClicked();
+ void showAllClicked();
+ void slotFemClicked();
+ void slotUser2();
+ void knowItClicked();
+ void slotNaturalClicked();
+ void slotMaleClicked();
+ void dontKnowClicked();
+ void verifyClicked();
+ void returnPressed();
+ void timeoutReached();
+
+protected:
+ Article articles;
+
+private:
+ ArtQueryDlgForm * mw;
+};
+
+#endif // ArtQueryDlg_included
diff --git a/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlgForm.ui b/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlgForm.ui
new file mode 100644
index 00000000..7792ca92
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/ArtQueryDlgForm.ui
@@ -0,0 +1,347 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ArtQueryDlgForm</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ArtQueryDlgForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>369</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Select the correct article for this noun:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>orgField</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QButtonGroup" row="2" column="0">
+ <property name="name">
+ <cstring>artGroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <property name="layoutSpacing" stdset="0">
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>rb_fem</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;female</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>male</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;male</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>natural</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;neutral</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>progressgroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Progress</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KProgress" row="0" column="1">
+ <property name="name">
+ <cstring>countbar</cstring>
+ </property>
+ </widget>
+ <widget class="KProgress" row="1" column="1">
+ <property name="name">
+ <cstring>timebar</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>countlabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Count:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>timelabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>Cyclelabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="text">
+ <string>Cycle:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>progCount</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>verify</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Verify</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>know_it</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>I &amp;Know It</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>show_all</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>dont_know</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Do Not Know</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>rb_fem</tabstop>
+ <tabstop>male</tabstop>
+ <tabstop>natural</tabstop>
+ <tabstop>show_all</tabstop>
+ <tabstop>verify</tabstop>
+ <tabstop>know_it</tabstop>
+ <tabstop>dont_know</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kprogress.h</includehint>
+ <includehint>kprogress.h</includehint>
+</includehints>
+</UI>
diff --git a/kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.cpp b/kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.cpp
new file mode 100644
index 00000000..596492ad
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.cpp
@@ -0,0 +1,448 @@
+/***************************************************************************
+
+ multiple choice query dialog
+
+ -----------------------------------------------------------------------
+
+ begin : Thu Nov 25 11:45:53 MET 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2004-2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "MCQueryDlg.h"
+
+#include <kv_resource.h>
+
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kprogress.h>
+
+#include <qtimer.h>
+#include <qlabel.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qpushbutton.h>
+
+#include <algorithm>
+using namespace std;
+
+MCQueryDlg::MCQueryDlg(
+ QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc)
+ : QueryDlgBase(i18n("Multiple Choice"))
+{
+ mw = new MCQueryDlgForm(this);
+ setMainWidget(mw);
+
+ mw->transgroup->insert(mw->rb_trans1);
+ mw->transgroup->insert(mw->rb_trans2);
+ mw->transgroup->insert(mw->rb_trans3);
+ mw->transgroup->insert(mw->rb_trans4);
+ mw->transgroup->insert(mw->rb_trans5);
+
+ connect( mw->dont_know, SIGNAL(clicked()), SLOT(dontKnowClicked()) );
+ connect( mw->know_it, SIGNAL(clicked()), SLOT(knowItClicked()) );
+// connect( verify, SIGNAL(clicked()), SLOT(verifyClicked()) );
+ connect( mw->show_all, SIGNAL(clicked()), SLOT(showItClicked()) );
+ connect( mw->rb_trans5, SIGNAL(clicked()), SLOT(trans5clicked()) );
+ connect( mw->rb_trans4, SIGNAL(clicked()), SLOT(trans4clicked()) );
+ connect( mw->rb_trans3, SIGNAL(clicked()), SLOT(trans3clicked()) );
+ connect( mw->rb_trans2, SIGNAL(clicked()), SLOT(trans2clicked()) );
+ connect( mw->rb_trans1, SIGNAL(clicked()), SLOT(trans1clicked()) );
+
+ qtimer = 0;
+
+ setQuery (org, trans, entry, orgcol, transcol, q_cycle, q_num, q_start, exp, doc);
+ mw->countbar->setFormat("%v/%m");
+ mw->timebar->setFormat("%v");
+ resize(configDialogSize("MCQueryDialog"));
+}
+
+
+MCQueryDlg::~MCQueryDlg()
+{
+ saveDialogSize("MCQueryDialog");
+}
+
+
+void MCQueryDlg::setQuery(QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc)
+{
+ //type_timeout = type_to;
+ kv_doc = doc;
+ q_row = entry;
+ q_ocol = orgcol;
+ q_tcol = transcol;
+ translation = trans;
+ mw->timebar->setEnabled(Prefs::showCounter());
+ mw->timelabel->setEnabled(Prefs::showCounter());
+ mw->orgField->setFont(Prefs::tableFont());
+ mw->orgField->setText (org);
+ mw->show_all->setDefault(true);
+ QString s;
+ s.setNum (q_cycle);
+ mw->progCount->setText (s);
+
+ mw->countbar->setTotalSteps(q_start);
+ mw->countbar->setProgress(q_start - q_num + 1);
+ int mqtime = Prefs::maxTimePer();
+ if (mqtime > 0) {
+ if (qtimer == 0) {
+ qtimer = new QTimer( this );
+ connect( qtimer, SIGNAL(timeout()), this, SLOT(timeoutReached()) );
+ }
+
+ if (Prefs::queryTimeout() != Prefs::EnumQueryTimeout::NoTimeout) {
+ timercount = mqtime;
+ mw->timebar->setTotalSteps(timercount);
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ }
+ else
+ mw->timebar->setEnabled(false);
+
+ vector<QString> strings;
+ button_ref.clear();
+ button_ref.push_back(RB_Label(mw->rb_trans1, mw->trans1));
+ button_ref.push_back(RB_Label(mw->rb_trans2, mw->trans2));
+ button_ref.push_back(RB_Label(mw->rb_trans3, mw->trans3));
+ button_ref.push_back(RB_Label(mw->rb_trans4, mw->trans4));
+ button_ref.push_back(RB_Label(mw->rb_trans5, mw->trans5));
+ random_shuffle(button_ref.begin(), button_ref.end() );
+ resetButton(button_ref[0].rb, button_ref[0].label);
+ resetButton(button_ref[1].rb, button_ref[1].label);
+ resetButton(button_ref[2].rb, button_ref[2].label);
+ resetButton(button_ref[3].rb, button_ref[3].label);
+ resetButton(button_ref[4].rb, button_ref[4].label);
+
+ solution = 0;
+
+ MultipleChoice mc = exp->getMultipleChoice(q_tcol);
+ for (unsigned i = 0; i < QMIN(MAX_MULTIPLE_CHOICE, mc.size()); ++i)
+ strings.push_back(mc.mc(i));
+ std::random_shuffle(strings.begin(), strings.end());
+
+ // always include false friend
+ QString ff;
+ if (q_tcol != 0)
+ ff = exp->getFauxAmi (q_tcol, false).stripWhiteSpace();
+ else
+ ff = exp->getFauxAmi (q_ocol, true).stripWhiteSpace();
+
+ if (ff.length())
+ strings.insert(strings.begin(), ff);
+
+ if (doc->numEntries() <= MAX_MULTIPLE_CHOICE) {
+ for (int i = strings.size(); i < doc->numEntries(); ++i ) {
+ kvoctrainExpr *act = doc->getEntry(i);
+
+ if (act != exp) {
+ if (q_tcol == 0)
+ strings.push_back(act->getOriginal());
+ else
+ strings.push_back(act->getTranslation(q_tcol));
+ }
+ }
+ }
+ else {
+ vector<kvoctrainExpr*> exprlist;
+ solution = 0;
+
+ srand((unsigned int)time((time_t *)NULL));
+ int count = MAX_MULTIPLE_CHOICE;
+ // gather random expressions for the choice
+ while (count > 0) {
+ int nr = (int) (doc->numEntries() * ((1.0*rand())/RAND_MAX));
+ // append if new expr found
+ bool newex = true;
+ for (int i = 0; newex && i < (int) exprlist.size(); i++) {
+ if (exprlist[i] == doc->getEntry(nr))
+ newex = false;
+ }
+ if (newex && exp != doc->getEntry(nr)) {
+ count--;
+ exprlist.push_back(doc->getEntry(nr));
+ }
+ }
+
+ for (int i = 0; i < (int) exprlist.size(); i++) {
+ if (q_tcol == 0)
+ strings.push_back(exprlist[i]->getOriginal());
+ else
+ strings.push_back(exprlist[i]->getTranslation(q_tcol));
+ }
+
+ }
+
+ // solution is always the first
+ if (q_tcol == 0)
+ strings.insert(strings.begin(), exp->getOriginal());
+ else
+ strings.insert(strings.begin(), exp->getTranslation(q_tcol));
+
+ for (int i = strings.size(); i < MAX_MULTIPLE_CHOICE; i++ )
+ strings.push_back("");
+
+ if (strings.size() > MAX_MULTIPLE_CHOICE)
+ strings.erase(strings.begin()+MAX_MULTIPLE_CHOICE, strings.end());
+
+ button_ref[0].rb->setEnabled(!strings[0].isEmpty() );
+ button_ref[1].rb->setEnabled(!strings[1].isEmpty() );
+ button_ref[2].rb->setEnabled(!strings[2].isEmpty() );
+ button_ref[3].rb->setEnabled(!strings[3].isEmpty() );
+ button_ref[4].rb->setEnabled(!strings[4].isEmpty() );
+
+ button_ref[0].label->setEnabled(!strings[0].isEmpty() );
+ button_ref[1].label->setEnabled(!strings[1].isEmpty() );
+ button_ref[2].label->setEnabled(!strings[2].isEmpty() );
+ button_ref[3].label->setEnabled(!strings[3].isEmpty() );
+ button_ref[4].label->setEnabled(!strings[4].isEmpty() );
+
+ button_ref[0].label->setText(strings[0]);
+ button_ref[0].label->setFont(Prefs::tableFont());
+ button_ref[1].label->setText(strings[1]);
+ button_ref[1].label->setFont(Prefs::tableFont());
+ button_ref[2].label->setText(strings[2]);
+ button_ref[2].label->setFont(Prefs::tableFont());
+ button_ref[3].label->setText(strings[3]);
+ button_ref[3].label->setFont(Prefs::tableFont());
+ button_ref[4].label->setText(strings[4]);
+ button_ref[4].label->setFont(Prefs::tableFont());
+
+ mw->rb_trans1->setChecked (false);
+ mw->rb_trans2->setChecked (false);
+ mw->rb_trans3->setChecked (false);
+ mw->rb_trans4->setChecked (false);
+ mw->rb_trans5->setChecked (false);
+
+ mw->show_all->setFocus();
+}
+
+
+void MCQueryDlg::initFocus() const
+{
+ mw->rb_trans1->setFocus();
+}
+
+
+void MCQueryDlg::showItClicked()
+{
+ resetButton(button_ref[0].rb, button_ref[0].label);
+ resetButton(button_ref[1].rb, button_ref[1].label);
+ resetButton(button_ref[2].rb, button_ref[2].label);
+ resetButton(button_ref[3].rb, button_ref[3].label);
+ resetButton(button_ref[4].rb, button_ref[4].label);
+
+ button_ref[solution].rb->setFocus();
+ button_ref[solution].rb->setChecked(true);
+ verifyButton(button_ref[solution].rb, true, button_ref[solution].label);
+ mw->dont_know->setDefault(true);
+}
+
+
+void MCQueryDlg::verifyClicked()
+{
+
+ bool known = false;
+ if (solution == 0)
+ known = button_ref[0].rb->isChecked ();
+ if (solution == 1)
+ known = button_ref[1].rb->isChecked ();
+ if (solution == 2)
+ known = button_ref[2].rb->isChecked ();
+ if (solution == 3)
+ known = button_ref[3].rb->isChecked ();
+ if (solution == 4)
+ known = button_ref[4].rb->isChecked ();
+
+ if (button_ref[0].rb->isChecked() ) {
+ verifyButton(button_ref[0].rb, known, button_ref[0].label);
+ resetButton(button_ref[1].rb, button_ref[1].label);
+ resetButton(button_ref[2].rb, button_ref[2].label);
+ resetButton(button_ref[3].rb, button_ref[3].label);
+ resetButton(button_ref[4].rb, button_ref[4].label);
+ }
+ else if (button_ref[1].rb->isChecked() ) {
+ resetButton(button_ref[0].rb, button_ref[0].label);
+ verifyButton(button_ref[1].rb, known, button_ref[1].label);
+ resetButton(button_ref[2].rb, button_ref[2].label);
+ resetButton(button_ref[3].rb, button_ref[3].label);
+ resetButton(button_ref[4].rb, button_ref[4].label);
+ }
+ else if (button_ref[2].rb->isChecked() ) {
+ resetButton(button_ref[0].rb, button_ref[0].label);
+ resetButton(button_ref[1].rb, button_ref[1].label);
+ verifyButton(button_ref[2].rb, known, button_ref[2].label);
+ resetButton(button_ref[3].rb, button_ref[3].label);
+ resetButton(button_ref[4].rb, button_ref[4].label);
+ }
+ else if (button_ref[3].rb->isChecked() ) {
+ resetButton(button_ref[0].rb, button_ref[0].label);
+ resetButton(button_ref[1].rb, button_ref[1].label);
+ resetButton(button_ref[2].rb, button_ref[2].label);
+ verifyButton(button_ref[3].rb, known, button_ref[3].label);
+ resetButton(button_ref[4].rb, button_ref[4].label);
+ }
+ else if (button_ref[4].rb->isChecked() ) {
+ resetButton(button_ref[0].rb, button_ref[0].label);
+ resetButton(button_ref[1].rb, button_ref[1].label);
+ resetButton(button_ref[2].rb, button_ref[2].label);
+ resetButton(button_ref[3].rb, button_ref[3].label);
+ verifyButton(button_ref[4].rb, known, button_ref[4].label);
+ }
+
+ if (known) {
+ mw->status->setText(getOKComment((mw->countbar->progress()/mw->countbar->totalSteps()) * 100));
+ knowItClicked();
+ }
+ else {
+ mw->status->setText(getNOKComment((mw->countbar->progress()/mw->countbar->totalSteps()) * 100));
+ mw->dont_know->setDefault(true);
+ }
+}
+
+
+void MCQueryDlg::knowItClicked()
+{
+ mw->status->setText("");
+ emit sigQueryChoice (Known);
+}
+
+
+void MCQueryDlg::timeoutReached()
+{
+ if (timercount > 0) {
+ timercount--;
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+
+ if (timercount <= 0) {
+ mw->status->setText(getTimeoutComment((mw->countbar->progress()/mw->countbar->totalSteps()) * 100));
+ mw->timebar->setProgress(0);
+ if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Show)
+ {
+ showItClicked();
+ mw->dont_know->setDefault(true);
+ }
+ else if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Continue)
+ emit sigQueryChoice (Timeout);
+ }
+ else
+ mw->status->setText("");
+}
+
+
+void MCQueryDlg::dontKnowClicked()
+{
+ mw->status->setText("");
+ emit sigQueryChoice (Unknown);
+}
+
+
+void MCQueryDlg::slotUser2()
+{
+
+ if (qtimer != 0)
+ qtimer->stop();
+
+ emit sigEditEntry (q_row, KV_COL_ORG+q_ocol);
+
+ kvoctrainExpr *exp = kv_doc->getEntry(q_row);
+ mw->orgField->setText (q_ocol == 0
+ ? exp->getOriginal()
+ : exp->getTranslation(q_ocol));
+}
+
+
+void MCQueryDlg::keyPressEvent( QKeyEvent *e )
+{
+ switch( e->key() )
+ {
+ case Key_Escape:
+ dontKnowClicked();
+ break;
+
+ case Key_Return:
+ case Key_Enter:
+ if (mw->dont_know->isDefault() )
+ dontKnowClicked();
+ else if (mw->know_it->isDefault() )
+ knowItClicked();
+ else if (mw->show_all->isDefault() )
+ showItClicked();
+ break;
+
+ default:
+ e->ignore();
+ break;
+ }
+}
+
+
+void MCQueryDlg::trans1clicked()
+{
+ verifyClicked();
+}
+
+
+void MCQueryDlg::trans2clicked()
+{
+ verifyClicked();
+}
+
+
+void MCQueryDlg::trans3clicked()
+{
+ verifyClicked();
+}
+
+
+void MCQueryDlg::trans4clicked()
+{
+ verifyClicked();
+}
+
+
+void MCQueryDlg::trans5clicked()
+{
+ verifyClicked();
+}
+
+
+#include "MCQueryDlg.moc"
diff --git a/kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.h b/kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.h
new file mode 100644
index 00000000..4e94f9db
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/MCQueryDlg.h
@@ -0,0 +1,90 @@
+/***************************************************************************
+
+ multiple choice query dialog
+
+ -----------------------------------------------------------------------
+
+ begin : Thu Nov 25 11:45:53 MET 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef MCQuery_Dlg_H
+#define MCQuery_Dlg_H
+
+#include "MCQueryDlgForm.h"
+#include "QueryDlgBase.h"
+
+class MCQueryDlg : public QueryDlgBase
+{
+ Q_OBJECT
+
+public:
+ MCQueryDlg(
+ QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc);
+
+ ~MCQueryDlg();
+
+ void setQuery(QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc);
+
+public slots:
+ virtual void initFocus() const;
+
+protected:
+ void keyPressEvent(QKeyEvent *e);
+
+public slots:
+ void showItClicked();
+ void knowItClicked();
+ void dontKnowClicked();
+ void timeoutReached();
+ void slotUser2();
+ void trans1clicked();
+ void trans2clicked();
+ void trans3clicked();
+ void trans4clicked();
+ void trans5clicked();
+ void verifyClicked();
+
+protected:
+ int solution;
+ vector<RB_Label> button_ref;
+
+private:
+ MCQueryDlgForm * mw;
+};
+
+#endif // MCQuery_Dlg_H
diff --git a/kvoctrain/kvoctrain/query-dialogs/MCQueryDlgForm.ui b/kvoctrain/kvoctrain/query-dialogs/MCQueryDlgForm.ui
new file mode 100644
index 00000000..098bf7fa
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/MCQueryDlgForm.ui
@@ -0,0 +1,444 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>MCQueryDlgForm</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>MCQueryDlgForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>425</width>
+ <height>335</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Select the correct translation:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>orgField</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QButtonGroup" row="2" column="0">
+ <property name="name">
+ <cstring>transgroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>rb_trans2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;2:</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>rb_trans3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;3:</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>rb_trans1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;1:</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="3" column="0">
+ <property name="name">
+ <cstring>rb_trans4</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;4:</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="4" column="0">
+ <property name="name">
+ <cstring>rb_trans5</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;5:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>trans3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>trans2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="1">
+ <property name="name">
+ <cstring>trans1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="1">
+ <property name="name">
+ <cstring>trans4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="1">
+ <property name="name">
+ <cstring>trans5</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>dont_know</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Do Not Know</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>show_all</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>know_it</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>I &amp;Know It</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>verify</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>&amp;Verify</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>progressgroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Progress</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KProgress" row="0" column="1">
+ <property name="name">
+ <cstring>countbar</cstring>
+ </property>
+ </widget>
+ <widget class="KProgress" row="1" column="1">
+ <property name="name">
+ <cstring>timebar</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>countlabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Count:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>timelabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>Cyclelabel</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="text">
+ <string>Cycle:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>progCount</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>rb_trans1</tabstop>
+ <tabstop>rb_trans2</tabstop>
+ <tabstop>rb_trans3</tabstop>
+ <tabstop>rb_trans4</tabstop>
+ <tabstop>rb_trans5</tabstop>
+ <tabstop>show_all</tabstop>
+ <tabstop>know_it</tabstop>
+ <tabstop>dont_know</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kprogress.h</includehint>
+ <includehint>kprogress.h</includehint>
+</includehints>
+</UI>
diff --git a/kvoctrain/kvoctrain/query-dialogs/Makefile.am b/kvoctrain/kvoctrain/query-dialogs/Makefile.am
new file mode 100644
index 00000000..6b7b40b8
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/Makefile.am
@@ -0,0 +1,13 @@
+INCLUDES = -I$(srcdir)/.. -I../common-dialogs -I$(srcdir)/../kvt-core -I$(top_builddir)/kvoctrain/kvoctrain/share $(all_includes)
+
+noinst_LTLIBRARIES = libquerydlg.la
+
+libquerydlg_la_COMPILE_FIRST = ../common-dialogs/prefs.h
+
+libquerydlg_la_SOURCES = QueryDlgBase.cpp MCQueryDlgForm.ui \
+ RandomQueryDlgForm.ui SimpleQueryDlgForm.ui MCQueryDlg.cpp RandomQueryDlg.cpp \
+ SimpleQueryDlg.cpp VerbQueryDlgForm.ui AdjQueryDlgForm.ui ArtQueryDlgForm.ui \
+ VerbQueryDlg.cpp AdjQueryDlg.cpp ArtQueryDlg.cpp
+
+METASOURCES = AUTO
+
diff --git a/kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.cpp b/kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.cpp
new file mode 100644
index 00000000..97b47c57
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.cpp
@@ -0,0 +1,334 @@
+/***************************************************************************
+
+ base class for query dialogs
+
+ -----------------------------------------------------------------------
+
+ begin : Wed Feb 16 20:50:53 MET 2000
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "QueryDlgBase.h"
+
+#include <qlineedit.h>
+#include <qmultilineedit.h>
+#include <qradiobutton.h>
+
+#include <LineList.h>
+
+#include <klocale.h>
+
+QueryDlgBase::QueryDlgBase(const QString & caption, QWidget *parent, const char *name, bool modal)
+ : KDialogBase(Swallow, caption, User1|User2, NoDefault, parent, name, modal, false,
+ KGuiItem(i18n("&Stop Query")), KGuiItem(i18n("&Edit Expression...")))
+{
+ kv_doc = 0;
+ kv_exp = 0;
+ //type_timeout = kvq_notimeout;
+}
+
+
+QueryDlgBase::~QueryDlgBase ()
+{
+}
+
+
+void QueryDlgBase::initFocus() const
+{
+ //
+}
+
+
+bool QueryDlgBase::smartCompare (const QString& s1, const QString &s2,
+ int ) const
+{
+ return s1.stripWhiteSpace() == s2.stripWhiteSpace();
+}
+
+
+bool QueryDlgBase::verifyField(QLineEdit *field, const QString &really)
+{
+ if (!field->isEnabled() )
+ return true;
+
+ QColorGroup u_normal = field->colorGroup();
+ u_normal.setColor(QColorGroup::Text, QColor(0xff, 0x00, 0x00));
+ QColorGroup k_normal = field->colorGroup();
+ k_normal.setColor(QColorGroup::Text, QColor(0x00, 0x80, 0x00));
+
+ QPalette known_pal( field->palette());
+ QPalette unknown_pal( field->palette());
+
+ QFont ft = field->font();
+ if (ft.weight() != QFont::Bold) {
+ ft.setWeight(QFont::Bold);
+ field->setFont(ft);
+ }
+
+ bool ret = false;
+ if (smartCompare(really, field->text(), 0) ) {
+ ret = true;
+ if ( known_pal.inactive() != k_normal
+ || known_pal.active() != k_normal) {
+ // replace text colors
+ known_pal.setActive(k_normal);
+ known_pal.setInactive(k_normal);
+ field->setPalette( known_pal );
+ }
+ }
+ else
+ if ( unknown_pal.inactive() != u_normal
+ || unknown_pal.active() != u_normal) {
+ // replace text colors
+ unknown_pal.setActive(u_normal);
+ unknown_pal.setInactive(u_normal);
+ field->setPalette( unknown_pal );
+ }
+ return ret;
+}
+
+
+void QueryDlgBase::resetField(QLineEdit *field)
+{
+ if (!field->isEnabled() )
+ return;
+ QColorGroup normal = field->colorGroup();
+ normal.setColor(QColorGroup::Text, QColor(0x00, 0x00, 0x00));
+
+ QPalette pal( field->palette());
+ // replace text colors
+
+ if ( pal.inactive() != normal
+ || pal.active() != normal) {
+ pal.setActive(normal);
+ pal.setInactive(normal);
+ field->setPalette( pal );
+ }
+
+ QFont ft = field->font();
+ if (ft.weight() != QFont::Normal) {
+ ft.setWeight(QFont::Normal);
+ field->setFont(ft);
+ }
+}
+
+
+bool QueryDlgBase::verifyField(QMultiLineEdit *field, const QString &really, bool mixed)
+{
+ if (!field->isEnabled())
+ return true;
+ QColorGroup u_normal = field->colorGroup();
+ u_normal.setColor(QColorGroup::Text, QColor(0xff, 0x00, 0x00));
+ QColorGroup k_normal = field->colorGroup();
+ k_normal.setColor(QColorGroup::Text, QColor(0x00, 0x80, 0x00));
+
+ QPalette known_pal( field->palette());
+ QPalette unknown_pal( field->palette());
+
+ QFont ft = field->font();
+ if (ft.weight() != QFont::Bold) {
+ ft.setWeight(QFont::Bold);
+ field->setFont(ft);
+ }
+
+ bool ret = false;
+ bool equal = false;
+ LineList answerlist (really);
+ LineList inputlist (field->text());
+ if (!mixed) // no tolerance
+ equal = smartCompare(answerlist.allLines(), inputlist.allLines(), 0);
+ else {
+ bool all = true;
+ for (int ai = 0; ai < (int) answerlist.count(); ai++) {
+ bool found = false;
+ for (int ii = 0; ii < (int) inputlist.count(); ii++) {
+ if (answerlist.getLine (ai) == inputlist.getLine(ii) ) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ all = false;
+ }
+ if (all)
+ equal = true;
+ }
+
+ if (equal) {
+ ret = true;
+ if (known_pal.inactive() != k_normal
+ || known_pal.active() != k_normal) {
+ // replace text colors
+ known_pal.setActive(k_normal);
+ known_pal.setInactive(k_normal);
+ field->setPalette( known_pal );
+ }
+ }
+ else
+ if ( unknown_pal.inactive() != u_normal
+ || unknown_pal.active() != u_normal) {
+ // replace text colors
+ unknown_pal.setActive(u_normal);
+ unknown_pal.setInactive(u_normal);
+ field->setPalette( unknown_pal );
+ }
+ return ret;
+}
+
+
+void QueryDlgBase::resetField(QMultiLineEdit *field)
+{
+ if (!field->isEnabled() )
+ return;
+ QColorGroup normal = field->colorGroup();
+ normal.setColor(QColorGroup::Text, QColor(0x00, 0x00, 0x00));
+
+ QPalette pal( field->palette());
+ // replace text colors
+
+ if ( pal.inactive() != normal
+ || pal.active() != normal) {
+ pal.setActive(normal);
+ pal.setInactive(normal);
+ field->setPalette( pal );
+ }
+
+ QFont ft = field->font();
+ if (ft.weight() != QFont::Normal) {
+ ft.setWeight(QFont::Normal);
+ field->setFont(ft);
+ }
+}
+
+
+void QueryDlgBase::verifyButton(QRadioButton *radio, bool is_ok, QWidget *widget2)
+{
+ if (!radio->isEnabled() )
+ return;
+
+ QColorGroup u_normal = radio->colorGroup();
+ u_normal.setColor(QColorGroup::Foreground, QColor(0xff, 0x00, 0x00));
+ QColorGroup k_normal = radio->colorGroup();
+ k_normal.setColor(QColorGroup::Foreground, QColor(0x00, 0x80, 0x00));
+
+ QPalette known_pal( radio->palette());
+ QPalette unknown_pal( radio->palette());
+
+ // replace text colors
+
+ QFont ft = radio->font();
+ if (ft.weight() != QFont::Bold) {
+ ft.setWeight(QFont::Bold);
+ radio->setFont(ft);
+ }
+
+ if (widget2 != 0) {
+ ft = widget2->font();
+ if (ft.weight() != QFont::Bold) {
+ ft.setWeight(QFont::Bold);
+ widget2->setFont(ft);
+ }
+ }
+
+ if (is_ok) {
+ if ( known_pal.inactive() != k_normal
+ || known_pal.active() != k_normal) {
+ known_pal.setActive(k_normal);
+ known_pal.setInactive(k_normal);
+ radio->setPalette( known_pal );
+ if (widget2 != 0)
+ widget2->setPalette( known_pal );
+ }
+ }
+ else {
+ if ( unknown_pal.inactive() != u_normal
+ || unknown_pal.active() != u_normal) {
+ unknown_pal.setActive(u_normal);
+ unknown_pal.setInactive(u_normal);
+ radio->setPalette( unknown_pal );
+ if (widget2 != 0)
+ widget2->setPalette( unknown_pal );
+ }
+ }
+}
+
+
+
+void QueryDlgBase::resetButton(QRadioButton *radio, QWidget *widget2)
+{
+ if (!radio->isEnabled() )
+ return;
+ QColorGroup normal = radio->colorGroup();
+ normal.setColor(QColorGroup::Foreground, QColor(0x00, 0x00, 0x00));
+
+ QPalette pal(radio->palette());
+ // replace text colors, avoid flickering
+ if ( pal.inactive() != normal
+ || pal.active() != normal) {
+ pal.setActive(normal);
+ pal.setInactive(normal);
+ radio->setPalette( pal );
+ if (widget2 != 0)
+ widget2->setPalette( pal );
+ }
+
+ QFont ft = radio->font();
+ if (ft.weight() != QFont::Normal) {
+ ft.setWeight(QFont::Normal);
+ radio->setFont(ft);
+ }
+
+ if (widget2 != 0) {
+ ft = widget2->font();
+ if (ft.weight() != QFont::Normal) {
+ ft.setWeight(QFont::Normal);
+ widget2->setFont(ft);
+ }
+ }
+}
+
+
+QString QueryDlgBase::getOKComment(int percent_done)
+{
+ return i18n("Well done, you knew the correct answer. %1% done.").arg(percent_done);
+}
+
+
+QString QueryDlgBase::getTimeoutComment(int percent_done)
+{
+ return i18n("You waited too long to enter the correct answer. %1% done.").arg(percent_done);
+}
+
+
+QString QueryDlgBase::getNOKComment(int percent_done)
+{
+ return i18n("Your answer was wrong. %1% done.").arg(percent_done);
+}
+
+void QueryDlgBase::closeEvent(QCloseEvent * /*e*/)
+{
+ emit sigQueryChoice(StopIt);
+}
+
+void QueryDlgBase::slotUser1()
+{
+ emit sigQueryChoice(StopIt);
+}
+
+
+#include "QueryDlgBase.moc"
diff --git a/kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.h b/kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.h
new file mode 100644
index 00000000..6f62ddf0
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/QueryDlgBase.h
@@ -0,0 +1,111 @@
+/***************************************************************************
+
+ base class for query dialogs
+
+ -----------------------------------------------------------------------
+
+ begin : Thu Nov 25 20:50:53 MET 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef Query_Dlg_Base_H
+#define Query_Dlg_Base_H
+
+#include <time.h>
+#include <stdlib.h>
+
+#include <kdialogbase.h>
+
+#include <QueryManager.h>
+#include <grammarmanager.h>
+
+class kvoctrainExpr;
+class kvoctrainDoc;
+
+class QLineEdit;
+class QMultiLineEdit;
+class QLabel;
+class QRadioButton;
+
+class QueryDlgBase : public KDialogBase
+{
+
+ Q_OBJECT
+
+public:
+ enum Result { Unknown, Known, Timeout, StopIt };
+
+ QueryDlgBase(const QString & caption, QWidget *parent = 0, const char *name = 0, bool modal = false);
+
+ virtual ~QueryDlgBase ();
+
+ bool smartCompare (const QString&, const QString&, int level) const;
+
+ bool verifyField(QLineEdit *field, const QString &really);
+ void resetField (QLineEdit *field);
+
+ bool verifyField(QMultiLineEdit *field, const QString &really,
+ bool mixed);
+ void resetField (QMultiLineEdit *field);
+
+ void verifyButton(QRadioButton *radio, bool is_ok, QWidget *widget2 = 0);
+ void resetButton (QRadioButton *radio, QWidget *widget2 = 0);
+
+ // Show string after selceting known/unknown
+ // depending on progress and randomness
+ QString getOKComment(int percent);
+ QString getNOKComment(int percent);
+ QString getTimeoutComment(int percent);
+
+ int getRandom(int range)
+ {
+// srand((unsigned int)time((time_t *)NULL));
+ return (int) (range * ((1.0*rand())/RAND_MAX));
+ }
+
+ virtual void initFocus() const;
+
+signals:
+ void sigQueryChoice(QueryDlgBase::Result);
+ void sigEditEntry(int row, int col);
+
+protected:
+ virtual void closeEvent(QCloseEvent*e);
+ virtual void slotUser1();
+
+ struct RB_Label {
+ RB_Label (QRadioButton* _rb, QLabel *_label)
+ : rb(_rb), label(_label) {}
+
+ QRadioButton *rb;
+ QLabel *label;
+ };
+
+ int q_row,
+ q_ocol,
+ q_tcol;
+ kvoctrainDoc *kv_doc;
+ kvoctrainExpr *kv_exp;
+ QString translation;
+ QTimer *qtimer;
+ int timercount;
+};
+
+
+#endif // Query_Dlg_Base_H
diff --git a/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.cpp b/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.cpp
new file mode 100644
index 00000000..be309563
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.cpp
@@ -0,0 +1,690 @@
+/***************************************************************************
+
+ dialog when in query mode
+
+ -----------------------------------------------------------------------
+
+ begin : Thu Mar 11 20:50:53 MET 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2004-2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "RandomQueryDlg.h"
+#include "common-dialogs/ProgressDlg.h"
+
+#include <kv_resource.h>
+
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kapplication.h>
+#include <kprogress.h>
+
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qregexp.h>
+#include <qtimer.h>
+
+QStringList RandomQueryDlg::extractTranslations (QString trans)
+{
+ QRegExp full_stop ("^(.*[^\\. ])\\.* *$");
+ //full_stop.setMinimal (true);
+ if ( full_stop.search (trans) >= 0 )
+ trans = full_stop.cap (1);
+ int i;
+ QStringList translations;
+ if ( Prefs::periods() )
+ for ( i = fields - 1; i > 0; i -- )
+ {
+ QString regexp ("^ *");
+ for ( int j = 0; j < i; j ++ )
+ regexp += "([^ ][^.]*)\\.[. ]*";
+ regexp += "([^. ].*)$";
+ QRegExp regex (regexp);
+ if ( regex.search (trans) >= 0 )
+ {
+ translations = regex.capturedTexts();
+ translations.remove (translations.at (0));
+ break;
+ }
+ }
+ if ( Prefs::colons() && translations.count() <= 1 )
+ {
+ translations.clear();
+ for ( i = fields - 1; i > 0; i -- )
+ {
+ QString regexp ("^ *");
+ for ( int j = 0; j < i; j ++ )
+ regexp += "([^ ][^:]*):[: ]*";
+ regexp += "([^: ].*)$";
+ QRegExp regex (regexp);
+ if ( regex.search (trans) >= 0 )
+ {
+ translations = regex.capturedTexts();
+ translations.remove (translations.at (0));
+ break;
+ }
+ }
+ }
+ if ( Prefs::semicolons() && translations.count() <= 1 )
+ {
+ translations.clear();
+ for ( i = fields - 1; i > 0; i -- )
+ {
+ QString regexp ("^ *");
+ for ( int j = 0; j < i; j ++ )
+ regexp += "([^ ][^;]*);[; ]*";
+ regexp += "([^; ].*)$";
+ QRegExp regex (regexp);
+ if ( regex.search (trans) >= 0 )
+ {
+ translations = regex.capturedTexts();
+ translations.remove (translations.at (0));
+ break;
+ }
+ }
+ }
+ if ( Prefs::commas() && translations.count() <= 1 )
+ {
+ translations.clear();
+ for ( i = fields - 1; i > 0; i -- )
+ {
+ QString regexp ("^ *");
+ for ( int j = 0; j < i; j ++ )
+ regexp += "([^ ][^,]*),[, ]*";
+ regexp += "([^, ].*)$";
+ QRegExp regex (regexp);
+ if ( regex.search (trans) >= 0 )
+ {
+ translations = regex.capturedTexts();
+ translations.remove (translations.at (0));
+ break;
+ }
+ }
+ }
+ if ( translations.count() <= 1 )
+ translations = QStringList (trans);
+ return translations;
+}
+
+RandomQueryDlg::RandomQueryDlg(
+ QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc)
+ : QueryDlgBase(i18n("Random Query"))
+{
+ mw = new QueryDlgForm(this);
+ setMainWidget(mw);
+
+ connect( mw->c_type, SIGNAL(clicked()), SLOT(slotTypeClicked()) );
+ connect( mw->c_remark, SIGNAL(clicked()), SLOT(slotRemClicked()) );
+ connect( mw->c_falsefriend, SIGNAL(clicked()), SLOT(slotFFClicked()) );
+ connect( mw->dont_know, SIGNAL(clicked()), SLOT(dontKnowClicked()) );
+ connect( mw->know_it, SIGNAL(clicked()), SLOT(knowItClicked()) );
+ connect( mw->verify, SIGNAL(clicked()), SLOT(verifyClicked()) );
+ connect( mw->show_all, SIGNAL(clicked()), SLOT(showAllClicked()) );
+ connect( mw->show_more, SIGNAL(clicked()), SLOT(showMoreClicked()) );
+
+ mw->show_more -> setEnabled (Prefs::showMore());
+ mw->know_it -> setEnabled (Prefs::iKnow());
+
+ bool split = Prefs::split();
+ fields = Prefs::fields();
+ if ( ! split || fields < 1 )
+ fields = 1;
+ else if ( fields > 10 )
+ fields = 10;
+
+ QVBoxLayout * vb = new QVBoxLayout(mw->TranslationFrame, 0, KDialog::spacingHint());
+
+ bool suggestions = Prefs::suggestions();
+ int i;
+ if ( suggestions )
+ {
+ for ( i = 0; i < fields; i ++ )
+ {
+ transCombos.append (new QComboBox (false, mw->TranslationFrame, QCString ("transCombo") + QCString().setNum (i)));
+ transCombos.at(i) -> setSizePolicy (QSizePolicy ((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, 0, 0, transCombos.at(i) -> sizePolicy().hasHeightForWidth()));
+ transCombos.at(i) -> setEditable (true);
+ transCombos.at(i) -> setInsertionPolicy (QComboBox::NoInsertion);
+ transCombos.at(i) -> setDuplicatesEnabled (false);
+ vb->addWidget(transCombos.at(i));
+ connect (transCombos.at(i), SIGNAL (textChanged (const QString&)), SLOT (slotTransChanged (const QString&)));
+ connect (transCombos.at(i) -> lineEdit(), SIGNAL (lostFocus()), SLOT (slotTransLostFocus()));
+ }
+ }
+ else
+ {
+ for ( i = 0; i < fields; i ++ )
+ {
+ transFields.append (new QLineEdit (mw->TranslationFrame, QCString ("transField") + QCString().setNum (i)));
+ transFields.at(i) -> setSizePolicy (QSizePolicy ((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, 0, 0, transFields.at(i) -> sizePolicy().hasHeightForWidth()));
+ vb->addWidget(transFields.at(i));
+ connect (transFields.at(i), SIGNAL (textChanged (const QString&)), SLOT (slotTransChanged (const QString&)));
+ connect (transFields.at(i), SIGNAL (lostFocus()), SLOT (slotTransLostFocus()));
+ }
+ }
+
+ kv_doc = 0;
+ qtimer = 0;
+ //setCaption (kapp->makeStdCaption(i18n("Random Query")));
+ setQuery (org, trans, entry, orgcol, transcol, q_cycle, q_num, q_start, exp, doc);
+ mw->countbar->setFormat("%v/%m");
+ mw->timebar->setFormat("%v");
+
+ if ( suggestions )
+ {
+ ProgressDlg* pdlg = 0;
+ if ( split && kv_doc -> numEntries() >= 500 )
+ {
+ pdlg = new ProgressDlg (QString(), QString(), kapp -> makeStdCaption (i18n("Loading Random Query")));
+ pdlg -> resize (pdlg -> width(), pdlg -> minimumSize().height());
+ pdlg -> show();
+ kapp -> processEvents();
+ }
+ for ( i = 0; i < kv_doc -> numEntries(); i ++ )
+ {
+ kvoctrainExpr* expr = kv_doc -> getEntry (i);
+ if ( split )
+ vocabulary += extractTranslations (q_tcol ? expr -> getTranslation (q_tcol) : expr -> getOriginal());
+ else
+ vocabulary += q_tcol ? expr -> getTranslation (q_tcol) : expr -> getOriginal();
+ if ( Prefs::swapDirection() )
+ {
+ if ( split )
+ vocabulary += extractTranslations (q_ocol ? expr -> getTranslation (q_ocol) : expr -> getOriginal());
+ else
+ vocabulary += q_ocol ? expr -> getTranslation (q_ocol) : expr -> getOriginal();
+ }
+ if ( pdlg )
+ {
+ pdlg -> setValue (doc, i * 100 / kv_doc -> numEntries());
+ kapp -> processEvents();
+ }
+ }
+ vocabulary.sort();
+ for ( uint k = 1; k < vocabulary.count(); k ++ )
+ if ( vocabulary [k - 1] == vocabulary [k] )
+ vocabulary.remove (vocabulary.at (k --));
+ if ( pdlg )
+ delete pdlg;
+ }
+ resize(configDialogSize("RandomQueryDialog"));
+}
+
+
+RandomQueryDlg::~RandomQueryDlg()
+{
+ saveDialogSize("RandomQueryDialog");
+}
+
+
+void RandomQueryDlg::setQuery(QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *,
+ kvoctrainDoc *doc)
+{
+ //type_timeout = type_to;
+ kv_doc = doc;
+ q_row = entry;
+ q_ocol = orgcol;
+ q_tcol = transcol;
+ translation = trans;
+ if ( Prefs::split() )
+ translations = extractTranslations (trans);
+ else
+ translations = trans;
+ mw->timebar->setEnabled(Prefs::showCounter());
+ mw->timelabel->setEnabled(Prefs::showCounter());
+ int i;
+ uint k;
+ if ( Prefs::suggestions() )
+ {
+ for ( i = 0; i < fields; i ++ )
+ {
+ transCombos.at(i) -> clearEdit();
+ resetField (transCombos.at(i) -> lineEdit());
+ }
+ for ( k = 0; k < translations.count(); k ++ )
+ transCombos.at(k) -> show();
+ for ( i = k; i < fields; i ++ )
+ transCombos.at(i) -> hide();
+ }
+ else
+ {
+ for ( i = 0; i < fields; i ++ )
+ {
+ transFields.at(i) -> clear();
+ transFields.at(i) -> setFont (Prefs::tableFont());
+ resetField (transFields.at(i));
+ }
+ for ( k = 0; k < translations.count(); k ++ )
+ transFields.at(k) -> show();
+ for ( i = k; i < fields; i ++ )
+ transFields.at(i) -> hide();
+ }
+ mw->verify -> setEnabled (true);
+ mw->orgField->setFont(Prefs::tableFont());
+ mw->orgField->setText (org);
+ mw->show_all->setDefault(true);
+ QString s;
+ s.setNum (q_cycle);
+ mw->progCount->setText (s);
+
+ mw->remark->hide();
+ mw->falseFriend->hide();
+ mw->type->hide();
+
+ mw->c_remark->setChecked(false);
+ mw->c_falsefriend->setChecked(false);
+ mw->c_type->setChecked(false);
+ setHintFields();
+
+ mw->countbar->setTotalSteps(q_start);
+ mw->countbar->setProgress(q_start - q_num + 1);
+ int mqtime = Prefs::maxTimePer();
+ if (mqtime > 0) {
+ if (qtimer == 0) {
+ qtimer = new QTimer( this );
+ connect( qtimer, SIGNAL(timeout()), this, SLOT(timeoutReached()) );
+ }
+
+ if (Prefs::queryTimeout() != Prefs::EnumQueryTimeout::NoTimeout) {
+ timercount = mqtime;
+ mw->timebar->setTotalSteps(timercount);
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ }
+ else
+ mw->timebar->setEnabled(false);
+
+ mw->status -> clear();
+ suggestion_hint = false;
+}
+
+
+void RandomQueryDlg::initFocus() const
+{
+ RandomQueryDlg* that = (RandomQueryDlg*) this;
+ if ( Prefs::suggestions() )
+ that -> transCombos.at(0) -> setFocus();
+ else
+ that -> transFields.at(0) -> setFocus();
+}
+
+
+void RandomQueryDlg::verifyClicked()
+{
+ QStringList trans (translations);
+ uint i, j;
+ if ( Prefs::suggestions() )
+ {
+ QPtrList<QComboBox> combos (transCombos);
+ for ( i = combos.count() - 1; i >= translations.count(); i -- )
+ combos.remove (i);
+ for ( i = 0; i < combos.count(); i ++ )
+ for ( j = 0; j < trans.count(); j ++ )
+ if ( smartCompare (trans[j], combos.at(i) -> currentText(), 0) )
+ {
+ verifyField (combos.at(i) -> lineEdit(), trans[j]);
+ trans.remove (trans.at(j));
+ combos.remove (i --);
+ break;
+ }
+ if ( trans.count() == 0 )
+ {
+ int percent = (mw->countbar->progress()/mw->countbar->totalSteps()) * 100;
+ //status->setText(getOKComment(countbar->getPercentage()));
+ mw->status->setText(getOKComment(percent));
+ knowItClicked();
+ }
+ else
+ {
+ for ( i = 0; i < combos.count(); i ++ )
+ verifyField (combos.at(i) -> lineEdit(), "a\na"); // always fail
+ mw->status->setText(getNOKComment((mw->countbar->progress()/mw->countbar->totalSteps()) * 100));
+ mw->dont_know->setDefault(true);
+ }
+ }
+ else
+ {
+ QPtrList<QLineEdit> fields (transFields);
+ for ( i = fields.count() - 1; i >= translations.count(); i -- )
+ fields.remove (i);
+ for ( i = 0; i < fields.count(); i ++ )
+ for ( j = 0; j < trans.count(); j ++ )
+ if ( smartCompare (trans[j], fields.at(i) -> text(), 0) )
+ {
+ verifyField (fields.at(i), "a\na"); // always fail
+ trans.remove (trans.at(j));
+ fields.remove (i --);
+ break;
+ }
+ if ( trans.count() == 0 )
+ {
+ mw->status->setText(getOKComment((mw->countbar->progress()/mw->countbar->totalSteps()) * 100));
+ knowItClicked();
+ }
+ else
+ {
+ for ( i = 0; i < fields.count(); i ++ )
+ verifyField (fields.at(i), trans[i]);
+ mw->status->setText(getNOKComment((mw->countbar->progress()/mw->countbar->totalSteps()) * 100));
+ mw->dont_know->setDefault(true);
+ }
+ }
+ suggestion_hint = false;
+}
+
+
+void RandomQueryDlg::showMoreClicked()
+{
+ if ( Prefs::suggestions() )
+ for ( uint i = 0; i < translations.count(); i ++ )
+ {
+ QComboBox* combo = transCombos.at(i);
+ if ( ! smartCompare (combo -> currentText(), translations[i], 0) )
+ {
+ uint length = combo -> currentText().length() + 1;
+ if ( length >= translations[i].length() )
+ {
+ combo -> setEditText (translations[i]);
+ verifyField (combo -> lineEdit(), translations[i]);
+ mw->verify -> setEnabled (false);
+ }
+ else
+ {
+ combo -> setEditText (translations[i].left (length));
+ resetField (combo -> lineEdit());
+ }
+ mw->dont_know -> setDefault (true);
+ break;
+ }
+ }
+ else
+ for ( uint i = 0; i < translations.count(); i ++ )
+ {
+ QLineEdit* field = transFields.at(i);
+ if ( ! smartCompare (field -> text(), translations[i], 0) )
+ {
+ uint length = field -> text().length() + 1;
+ if ( length >= translations[i].length() )
+ {
+ field -> setText (translations[i]);
+ verifyField (field, translations[i]);
+ mw->verify -> setEnabled (false);
+ }
+ else
+ {
+ field -> setText (translations[i].left (length));
+ resetField (field);
+ }
+ mw->dont_know -> setDefault (true);
+ break;
+ }
+ }
+ mw->status -> clear();
+ suggestion_hint = false;
+}
+
+
+void RandomQueryDlg::showAllClicked()
+{
+ if ( Prefs::suggestions() )
+ for ( uint i = 0; i < translations.count(); i ++ )
+ {
+ transCombos.at(i) -> setEditText (translations[i]);
+ verifyField (transCombos.at(i) -> lineEdit(), translations[i]);
+ }
+ else
+ for ( uint i = 0; i < translations.count(); i ++ )
+ {
+ transFields.at(i) -> setText (translations[i]);
+ verifyField (transFields.at(i), translations[i]);
+ }
+ mw->verify -> setEnabled (false);
+ mw->dont_know->setDefault(true);
+ mw->status -> clear();
+ suggestion_hint = false;
+}
+
+
+void RandomQueryDlg::slotTransChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ bool suggestions = Prefs::suggestions();
+ if ( suggestions && sender() && sender() -> isA ("QComboBox") )
+ {
+ QLineEdit* edit = ((QComboBox*) sender()) -> lineEdit();
+ resetField (edit);
+ suggestion_hint = ! edit -> text().isEmpty() && edit -> text().length() <= 10;
+ if ( suggestion_hint )
+ mw->status -> setText (QString (i18n("Press F5 for a list of translations starting with '%1'\n"
+ "Press F6 for a list of translations containing '%2'")).arg (edit -> text()).arg (edit -> text()));
+ else
+ mw->status -> clear();
+ }
+ else if ( ! suggestions && sender() && sender() -> isA ("QLineEdit") )
+ resetField ((QLineEdit*) sender());
+}
+
+void RandomQueryDlg::slotTransLostFocus()
+{
+ if ( suggestion_hint )
+ mw->status -> clear();
+ suggestion_hint = false;
+}
+
+
+void RandomQueryDlg::knowItClicked()
+{
+ mw->status -> clear();
+ suggestion_hint = false;
+ emit sigQueryChoice (Known);
+}
+
+
+void RandomQueryDlg::timeoutReached()
+{
+ if (timercount > 0) {
+ timercount--;
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+
+ if (timercount <= 0) {
+ mw->timebar->setProgress(0);
+ if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Show) {
+ showAllClicked();
+ mw->dont_know->setDefault(true);
+ }
+ else if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Continue) {
+ emit sigQueryChoice (Timeout);
+ }
+ mw->status->setText(getTimeoutComment((mw->countbar->progress()/mw->countbar->totalSteps()) * 100));
+ }
+
+ suggestion_hint = false;
+}
+
+
+void RandomQueryDlg::dontKnowClicked()
+{
+ mw->status -> clear();
+ suggestion_hint = false;
+ emit sigQueryChoice (Unknown);
+}
+
+
+void RandomQueryDlg::setHintFields()
+{
+ QString s;
+ kvoctrainExpr *exp = kv_doc->getEntry(q_row);
+
+ s = exp->getRemark(q_ocol);
+ mw->remark->setText (s);
+ mw->c_remark->setEnabled(!s.isEmpty() );
+
+ s = exp->getFauxAmi(q_ocol, q_ocol != 0);
+ mw->falseFriend->setText (s);
+ mw->c_falsefriend->setEnabled(!s.isEmpty() );
+
+ s = "";
+ vector<TypeRelation> all_types = QueryManager::getRelation(false);
+ for (int i = 0; i < (int) all_types.size(); i++) {
+ if ( exp->getType(q_ocol) == all_types[i].shortStr()) {
+ s = all_types[i].longStr();
+ break;
+ }
+ }
+ mw->type->setText (s);
+ mw->c_type->setEnabled(!s.isEmpty() );
+}
+
+
+void RandomQueryDlg::slotUser2()
+{
+ if (qtimer != 0)
+ qtimer->stop();
+
+ emit sigEditEntry (q_row, KV_COL_ORG+q_ocol);
+
+ kvoctrainExpr *exp = kv_doc->getEntry(q_row);
+ mw->orgField->setText (q_ocol == 0
+ ? exp->getOriginal()
+ : exp->getTranslation(q_ocol));
+
+ if ( Prefs::suggestions() )
+ for ( int i = 0; i < fields; i ++ )
+ transCombos.at(i) -> clearEdit();
+ else
+ for ( int i = 0; i < fields; i ++ )
+ transFields.at(i) -> clear();
+ mw->status -> clear();
+ suggestion_hint = false;
+
+ setHintFields();
+}
+
+
+void RandomQueryDlg::slotFFClicked()
+{
+ if (mw->c_falsefriend->isChecked() )
+ mw->falseFriend->show();
+ else
+ mw->falseFriend->hide();
+}
+
+
+void RandomQueryDlg::slotRemClicked()
+{
+ if (mw->c_remark->isChecked())
+ mw->remark->show();
+ else
+ mw->remark->hide();
+}
+
+
+void RandomQueryDlg::slotTypeClicked()
+{
+ if (mw->c_type->isChecked() )
+ mw->type->show();
+ else
+ mw->type->hide();
+}
+
+
+void RandomQueryDlg::keyPressEvent( QKeyEvent *e )
+{
+ if ( Prefs::suggestions() )
+ {
+ QComboBox* combo = 0;
+ if ( e -> key() == Key_F4 || e -> key() == Key_F5 || e -> key() == Key_F6 )
+ for ( uint i = 0; i < translations.count(); i ++ )
+ if ( transCombos.at(i) -> hasFocus() )
+ {
+ combo = transCombos.at(i);
+ break;
+ }
+ switch( e->key() )
+ {
+ case Key_F5:
+ case Key_F6:
+ if ( combo && ! combo -> currentText().isEmpty() )
+ {
+ QString curText (combo -> currentText());
+ combo -> clear();
+ for ( uint i = 0; i < vocabulary.count(); i ++ )
+ {
+ QString trans (vocabulary[i]);
+ if ( (e -> key() == Key_F5 && trans.startsWith (curText, false)
+ || e -> key() == Key_F6 && trans.contains (curText, false)) )
+ combo -> insertItem (trans);
+ }
+ combo -> setEditText (curText);
+ }
+ case Key_F4:
+ if ( combo )
+ combo -> popup();
+ break;
+ }
+ }
+
+ switch( e->key() )
+ {
+ case Key_Escape:
+ dontKnowClicked();
+ break;
+
+ case Key_Return:
+ case Key_Enter:
+ if (mw->dont_know->isDefault() )
+ dontKnowClicked();
+ else if (mw->know_it->isDefault() )
+ knowItClicked();
+ else if (mw->show_all->isDefault() )
+ showAllClicked();
+ else if (mw->verify->isDefault() )
+ verifyClicked();
+ break;
+
+ default:
+ e->ignore();
+ break;
+ }
+}
+
+#include "RandomQueryDlg.moc"
diff --git a/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.h b/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.h
new file mode 100644
index 00000000..92ab7fd7
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlg.h
@@ -0,0 +1,106 @@
+/***************************************************************************
+
+ dialog when in random query mode
+
+ -----------------------------------------------------------------------
+
+ begin : Thu Mar 11 20:50:53 MET 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef Query_Dlg_H
+#define Query_Dlg_H
+
+#include "RandomQueryDlgForm.h"
+#include "QueryDlgBase.h"
+
+#include <qcombobox.h>
+#include <qlineedit.h>
+
+class kvoctrainDoc;
+
+class RandomQueryDlg : public QueryDlgBase
+{
+ Q_OBJECT
+
+public:
+ RandomQueryDlg(
+ QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *);
+
+ ~RandomQueryDlg();
+
+ void setQuery(QString org,
+ QString trans,
+ int entry,
+ int orgcol,
+ int transcol,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *);
+
+public slots:
+ virtual void initFocus() const;
+
+public slots:
+ void verifyClicked();
+ void showMoreClicked();
+ void showAllClicked();
+ void knowItClicked();
+ void dontKnowClicked();
+ void timeoutReached();
+ void slotUser2();
+ void slotTransChanged(const QString&);
+ void slotTransLostFocus();
+ void slotFFClicked();
+ void slotTypeClicked();
+ void slotRemClicked();
+
+protected:
+ virtual void keyPressEvent(QKeyEvent *e);
+
+ void setHintFields();
+ QStringList extractTranslations (QString trans);
+
+ kvoctrainDoc * kv_doc;
+
+ QPtrList<QComboBox> transCombos;
+ QPtrList<QLineEdit> transFields;
+
+ QStringList translations;
+ QStringList vocabulary;
+
+ bool suggestion_hint;
+ int fields;
+
+private:
+ QueryDlgForm * mw;
+};
+
+#endif
diff --git a/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlgForm.ui b/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlgForm.ui
new file mode 100644
index 00000000..fc573bf6
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/RandomQueryDlgForm.ui
@@ -0,0 +1,418 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>QueryDlgForm</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>QueryDlgForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>453</width>
+ <height>279</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Enter the correct translation:</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>GroupBox12</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Original Expression</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>falseFriend</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>remark</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="1">
+ <property name="name">
+ <cstring>type</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>c_remark</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Remark:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>c_type</cstring>
+ </property>
+ <property name="text">
+ <string>T&amp;ype:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>c_falsefriend</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;False friend:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>orgField</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QFrame" row="2" column="0">
+ <property name="name">
+ <cstring>TranslationFrame</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>450</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="4" column="0">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>verify</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Verify</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>show_more</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;More</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>show_all</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="2">
+ <property name="name">
+ <cstring>dont_know</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Do Not Know</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>know_it</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>I &amp;Know It</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>progressgroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Progress</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>timelabel</cstring>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>countlabel</cstring>
+ </property>
+ <property name="text">
+ <string>Count:</string>
+ </property>
+ </widget>
+ <widget class="KProgress" row="1" column="1">
+ <property name="name">
+ <cstring>timebar</cstring>
+ </property>
+ </widget>
+ <widget class="KProgress" row="0" column="1">
+ <property name="name">
+ <cstring>countbar</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>progCount</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>Cyclelabel</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="text">
+ <string>Cycle:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<tabstops>
+ <tabstop>c_falsefriend</tabstop>
+ <tabstop>c_remark</tabstop>
+ <tabstop>c_type</tabstop>
+ <tabstop>show_all</tabstop>
+ <tabstop>show_more</tabstop>
+ <tabstop>verify</tabstop>
+ <tabstop>know_it</tabstop>
+ <tabstop>dont_know</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kprogress.h</includehint>
+ <includehint>kprogress.h</includehint>
+</includehints>
+</UI>
diff --git a/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.cpp b/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.cpp
new file mode 100644
index 00000000..47421e7a
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.cpp
@@ -0,0 +1,336 @@
+/***************************************************************************
+
+ query dialog for properties
+
+ -----------------------------------------------------------------------
+
+ begin : Sun Apr 9 18:55:34 2000
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2004-2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "SimpleQueryDlg.h"
+
+#include <kv_resource.h>
+
+#include <qtimer.h>
+#include <qmultilineedit.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kprogress.h>
+
+SimpleQueryDlg::SimpleQueryDlg(
+ QueryType querytype,
+ int entry,
+ int column,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc)
+ : QueryDlgBase("")
+{
+ mw = new SimpleQueryDlgForm(this);
+ setMainWidget(mw);
+
+ connect(mw->dont_know, SIGNAL(clicked()), SLOT(dontKnowClicked()) );
+ connect(mw->know_it, SIGNAL(clicked()), SLOT(knowItClicked()) );
+ connect(mw->verify, SIGNAL(clicked()), SLOT(verifyClicked()) );
+ connect(mw->show_all, SIGNAL(clicked()), SLOT(showAllClicked()) );
+ connect(mw->show_more, SIGNAL(clicked()), SLOT(showMoreClicked()) );
+ connect(mw->answerField, SIGNAL(textChanged()), SLOT(slotAnswerChanged()) );
+
+ kv_doc = 0;
+ qtimer = 0;
+ resize(configDialogSize("SimpleQueryDialog"));
+ setQuery (querytype, entry, column, q_cycle, q_num, q_start, exp, doc);
+ mw->countbar->setFormat("%v/%m");
+ mw->timebar->setFormat("%v");
+
+}
+
+
+SimpleQueryDlg::~ SimpleQueryDlg()
+{
+ saveDialogSize("SimpleQueryDialog");
+}
+
+
+void SimpleQueryDlg::initFocus() const
+{
+ mw->answerField->setFocus();
+}
+
+
+void SimpleQueryDlg::setQuery(QueryType _querytype,
+ int entry,
+ int column,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc)
+{
+ //type_timeout = type_to;
+ querytype = _querytype;
+ kv_doc = doc;
+ q_row = entry;
+ q_ocol = column;
+ mw->timebar->setEnabled(Prefs::showCounter());
+ mw->timelabel->setEnabled(Prefs::showCounter());
+ mw->queryField->setFont(Prefs::tableFont());
+ mw->answerField->setFont(Prefs::tableFont());
+ mw->answerField->setText("");
+
+ QString s;
+ switch (querytype)
+ {
+ case QT_Synonym:
+ {
+ mw->queryLabel->setText(i18n("Expression"));
+ mw->instructionLabel->setText(i18n("Enter the synonym:"));
+ setCaption (i18n("Synonym Training"));
+ answerstring = exp->getSynonym(column);
+ mw->queryField->setAlignment(Qt::AlignVCenter);
+ mw->queryField->setText(column == 0 ? exp->getOriginal() : exp->getTranslation(column));
+ setQueryFieldWordwrap();
+ }
+ break;
+
+ case QT_Antonym:
+ {
+ mw->queryLabel->setText(i18n("Expression"));
+ mw->instructionLabel->setText(i18n("Enter the antonym:"));
+ setCaption (i18n("Antonym Training"));
+ answerstring = exp->getAntonym(column);
+ mw->queryField->setText(column == 0 ? exp->getOriginal() : exp->getTranslation(column));
+ setQueryFieldWordwrap();
+ }
+ break;
+
+ case QT_Paraphrase:
+ {
+ mw->queryLabel->setText(i18n("Paraphrase"));
+ mw->instructionLabel->setText(i18n("Enter the word:"));
+ setCaption (i18n("Paraphrase Training"));
+ mw->queryField->setText(exp->getParaphrase(column));
+ answerstring = column == 0 ? exp->getOriginal() : exp->getTranslation(column);
+ setQueryFieldWordwrap();
+ }
+ break;
+
+ case QT_Example:
+ {
+ mw->queryLabel->setText(i18n("Example sentence"));
+ mw->instructionLabel->setText(i18n("Fill in the missing word:"));
+ setCaption(i18n("Example Training"));
+ s = exp->getExample(column);
+ answerstring = column == 0 ? exp->getOriginal().stripWhiteSpace() : exp->getTranslation(column).stripWhiteSpace();
+ int pos = -1;
+ while ((pos = s.find(answerstring)) > 0)
+ {
+ s.remove(pos, answerstring.length());
+ s.insert (pos, "..");
+ }
+ mw->queryField->setText(s);
+ setQueryFieldWordwrap();
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ mw->show_all->setDefault(true);
+ s.setNum (q_cycle);
+ mw->progCount->setText (s);
+
+ mw->countbar->setTotalSteps(q_start);
+ mw->countbar->setProgress(q_start - q_num + 1);
+ int mqtime = Prefs::maxTimePer();
+
+ if (mqtime > 0) {
+ if (qtimer == 0) {
+ qtimer = new QTimer( this );
+ connect( qtimer, SIGNAL(timeout()), this, SLOT(timeoutReached()) );
+ }
+
+ if (Prefs::queryTimeout() != Prefs::EnumQueryTimeout::NoTimeout) {
+ timercount = mqtime;
+ mw->timebar->setTotalSteps(timercount);
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ resetField (mw->answerField);
+}
+
+
+void SimpleQueryDlg::slotAnswerChanged()
+{
+ mw->verify->setDefault(true);
+ resetField (mw->answerField);
+}
+
+
+void SimpleQueryDlg::timeoutReached()
+{
+ if (timercount > 0) {
+ timercount--;
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+
+ if (timercount <= 0) {
+ mw->timebar->setProgress(0);
+ if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Show) {
+ showAllClicked();
+ mw->dont_know->setDefault(true);
+ }
+ else if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Continue)
+ emit sigQueryChoice (Timeout);
+ }
+}
+
+
+void SimpleQueryDlg::showMoreClicked()
+{
+ if (mw->answerField->text().length() < answerstring.length()) {
+ mw->answerField->setText (answerstring.left(mw->answerField->text().length()+1));
+ mw->dont_know->setDefault(true);
+ }
+ resetField (mw->answerField);
+}
+
+
+void SimpleQueryDlg::showAllClicked()
+{
+ mw->answerField->setText (answerstring);
+ verifyField (mw->answerField, answerstring, querytype == QT_Synonym || querytype == QT_Antonym);
+ mw->dont_know->setDefault(true);
+}
+
+
+void SimpleQueryDlg::verifyClicked()
+{
+ if (verifyField (mw->answerField, answerstring, querytype == QT_Synonym || querytype == QT_Antonym))
+ knowItClicked();
+ else
+ mw->dont_know->setDefault(true);
+}
+
+
+void SimpleQueryDlg::knowItClicked()
+{
+ emit sigQueryChoice(Known);
+}
+
+
+void SimpleQueryDlg::dontKnowClicked()
+{
+ emit sigQueryChoice(Unknown);
+}
+
+
+void SimpleQueryDlg::slotUser2()
+{
+ if (qtimer != 0)
+ qtimer->stop();
+
+ emit sigEditEntry(q_row, KV_COL_ORG+q_ocol);
+
+ kvoctrainExpr *exp = kv_doc->getEntry(q_row);
+// queryField->setText (exp->getTranslation(q_ocol));
+
+ switch (querytype) {
+ case QT_Synonym: {
+ answerstring = exp->getSynonym(q_ocol);
+ mw->queryField->setText(q_ocol == 0 ? exp->getOriginal() : exp->getTranslation(q_ocol));
+ }
+ break;
+
+ case QT_Antonym: {
+ answerstring = exp->getAntonym(q_ocol);
+ mw->queryField->setText(q_ocol == 0 ? exp->getOriginal() : exp->getTranslation(q_ocol));
+ }
+ break;
+
+ case QT_Paraphrase: {
+ mw->queryField->setText(exp->getParaphrase(q_ocol));
+ answerstring = q_ocol == 0 ? exp->getOriginal() : exp->getTranslation(q_ocol);
+ }
+ break;
+
+ case QT_Example: {
+ mw->queryField->setText(exp->getExample(q_ocol));
+ answerstring = q_ocol == 0 ? exp->getOriginal() : exp->getTranslation(q_ocol);
+ }
+ break;
+
+ default:
+ ;
+ }
+}
+
+
+void SimpleQueryDlg::keyPressEvent(QKeyEvent *e)
+{
+ switch( e->key() )
+ {
+ case Key_Escape:
+ dontKnowClicked();
+ break;
+
+ case Key_Return:
+ case Key_Enter:
+ if (mw->dont_know->isDefault() )
+ dontKnowClicked();
+ else if (mw->know_it->isDefault() )
+ knowItClicked();
+ else if (mw->show_all->isDefault() )
+ showAllClicked();
+ else if (mw->verify->isDefault() )
+ verifyClicked();
+ break;
+
+ default:
+ e->ignore();
+ break;
+ }
+}
+
+void SimpleQueryDlg::setQueryFieldWordwrap()
+{
+ QFontMetrics fm(Prefs::tableFont());
+ int w = fm.width(mw->queryField->text());
+ int w2 = mw->width();
+ if (w > w2)
+ mw->queryField->setAlignment(Qt::AlignVCenter | Qt::WordBreak);
+ else
+ mw->queryField->setAlignment(Qt::AlignVCenter);
+}
+
+
+#include "SimpleQueryDlg.moc"
diff --git a/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.h b/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.h
new file mode 100644
index 00000000..adf9827b
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlg.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+
+ query dialog for properties
+
+ -----------------------------------------------------------------------
+
+ begin : Sun Apr 9 18:55:34 2000
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef SimpleQueryDlg_included
+#define SimpleQueryDlg_included
+
+#include "SimpleQueryDlgForm.h"
+#include "QueryDlgBase.h"
+
+class SimpleQueryDlg : public QueryDlgBase
+{
+ Q_OBJECT
+
+public:
+ SimpleQueryDlg (QueryType querytpe,
+ int entry,
+ int column,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc);
+
+ ~SimpleQueryDlg();
+
+ void setQuery(QueryType querytpe,
+ int entry,
+ int column,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc);
+
+public slots:
+ virtual void initFocus() const;
+
+protected:
+ void keyPressEvent( QKeyEvent *e );
+
+public slots:
+ void showMoreClicked();
+ void showAllClicked();
+ void knowItClicked();
+ void dontKnowClicked();
+ void slotAnswerChanged();
+ void slotUser2();
+ void verifyClicked();
+ void timeoutReached();
+
+protected:
+ QString answerstring;
+ QueryType querytype;
+
+private:
+ SimpleQueryDlgForm * mw;
+ void setQueryFieldWordwrap();
+};
+
+#endif // SimpleQueryDlg_included
diff --git a/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlgForm.ui b/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlgForm.ui
new file mode 100644
index 00000000..3ff31b5f
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/SimpleQueryDlgForm.ui
@@ -0,0 +1,348 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SimpleQueryDlgForm</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SimpleQueryDlgForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>471</width>
+ <height>324</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>queryLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>queryField</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>instructionLabel</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QMultiLineEdit">
+ <property name="name">
+ <cstring>answerField</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>300</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout17</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="0" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>progressgroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Progress</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KProgress" row="0" column="1">
+ <property name="name">
+ <cstring>countbar</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="KProgress" row="1" column="1">
+ <property name="name">
+ <cstring>timebar</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>countlabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Count:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>timelabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>Cyclelabel</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="text">
+ <string>Cycle:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>progCount</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout16</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>know_it</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>I &amp;Know It</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="2">
+ <property name="name">
+ <cstring>dont_know</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Do &amp;Not Know</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>show_all</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>show_more</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;More</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>verify</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Verify</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<tabstops>
+ <tabstop>answerField</tabstop>
+ <tabstop>show_all</tabstop>
+ <tabstop>show_more</tabstop>
+ <tabstop>verify</tabstop>
+ <tabstop>know_it</tabstop>
+ <tabstop>dont_know</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kprogress.h</includehint>
+ <includehint>kprogress.h</includehint>
+</includehints>
+</UI>
diff --git a/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.cpp b/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.cpp
new file mode 100644
index 00000000..8a33d2c3
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.cpp
@@ -0,0 +1,516 @@
+/***************************************************************************
+
+ query dialog for verbs
+
+ -----------------------------------------------------------------------
+
+ begin : Fri Dec 3 18:28:18 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2004-2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "VerbQueryDlg.h"
+
+#include <kv_resource.h>
+
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kprogress.h>
+
+#include <qtimer.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+
+VerbQueryDlg::VerbQueryDlg
+(
+ QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Conjugation &prefix,
+ const Conjugation &conjug)
+ : QueryDlgBase(i18n("Verb Training"))
+{
+ mw = new VerbQueryDlgForm(this);
+ setMainWidget(mw);
+
+ connect(mw->dont_know, SIGNAL(clicked()), SLOT(dontKnowClicked()) );
+ connect(mw->know_it, SIGNAL(clicked()), SLOT(knowItClicked()) );
+ connect(mw->verify, SIGNAL(clicked()), SLOT(verifyClicked()) );
+ connect(mw->show_all, SIGNAL(clicked()), SLOT(showAllClicked()) );
+
+ connect(mw->p3pmField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p3pnField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p3snField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p3smField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p3pfField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p3sfField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p2pField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p2sField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p1pField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+ connect(mw->p1sField, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
+
+ connect(mw->p3pmField, SIGNAL(textChanged(const QString&)), SLOT(slotP3pmChanged(const QString&)) );
+ connect(mw->p3snField, SIGNAL(textChanged(const QString&)), SLOT(slotP3snChanged(const QString&)) );
+ connect(mw->p3pnField, SIGNAL(textChanged(const QString&)), SLOT(slotP3pnChanged(const QString&)) );
+ connect(mw->p3smField, SIGNAL(textChanged(const QString&)), SLOT(slotP3smChanged(const QString&)) );
+ connect(mw->p3pfField, SIGNAL(textChanged(const QString&)), SLOT(slotP3pfChanged(const QString&)) );
+ connect(mw->p3sfField, SIGNAL(textChanged(const QString&)), SLOT(slotP3sfChanged(const QString&)) );
+ connect(mw->p2pField, SIGNAL(textChanged(const QString&)), SLOT(slotP2pChanged(const QString&)) );
+ connect(mw->p2sField, SIGNAL(textChanged(const QString&)), SLOT(slotP2sChanged(const QString&)) );
+ connect(mw->p1pField, SIGNAL(textChanged(const QString&)), SLOT(slotP1pChanged(const QString&)) );
+ connect(mw->p1sField, SIGNAL(textChanged(const QString&)), SLOT(slotP1sChanged(const QString&)) );
+
+ qtimer = 0;
+
+ setQuery (type, entry, col, query_cycle, query_num, query_startnum, exp, doc, prefix, conjug);
+ mw->countbar->setFormat("%v/%m");
+ mw->timebar->setFormat("%v");
+ resize(configDialogSize("VerbQueryDialog"));
+}
+
+
+VerbQueryDlg::~ VerbQueryDlg( )
+{
+ saveDialogSize("VerbQueryDialog");
+}
+
+
+void VerbQueryDlg::initFocus() const
+{
+ mw->p1sField->setFocus();
+}
+
+
+void VerbQueryDlg::setQuery(QString,
+ int entry,
+ int col,
+ int q_cycle,
+ int q_num,
+ int q_start,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Conjugation &prefix,
+ const Conjugation &conjug)
+{
+ //type_timeout = type_to;
+ kv_doc = doc;
+ kv_exp = exp;
+ q_row = entry;
+ q_ocol = col;
+ int mqtime = Prefs::maxTimePer();
+ mw->timebar->setEnabled(Prefs::showCounter());
+ mw->timelabel->setEnabled(Prefs::showCounter());
+ mw->show_all->setDefault(true);
+ QString s;
+ s.setNum (q_cycle);
+ mw->progCount->setText (s);
+
+ conjugations = conjug;
+
+ mw->p1sLabel->setText (prefix.pers1Singular(CONJ_PREFIX));
+ mw->p2sLabel->setText (prefix.pers2Singular(CONJ_PREFIX));
+ mw->p3sfLabel->setText (prefix.pers3FemaleSingular(CONJ_PREFIX));
+ mw->p3smLabel->setText (prefix.pers3MaleSingular(CONJ_PREFIX));
+ mw->p3snLabel->setText (prefix.pers3NaturalSingular(CONJ_PREFIX));
+
+ mw->p1pLabel->setText (prefix.pers1Plural(CONJ_PREFIX));
+ mw->p2pLabel->setText (prefix.pers2Plural(CONJ_PREFIX));
+ mw->p3pfLabel->setText (prefix.pers3FemalePlural(CONJ_PREFIX));
+ mw->p3pmLabel->setText (prefix.pers3MalePlural(CONJ_PREFIX));
+ mw->p3pnLabel->setText (prefix.pers3NaturalPlural(CONJ_PREFIX));
+
+ mw->countbar->setTotalSteps(q_start);
+ mw->countbar->setProgress(q_start - q_num + 1);
+
+ if (mqtime > 0) { // more than 1000 milli-seconds
+ if (qtimer == 0) {
+ qtimer = new QTimer( this );
+ connect( qtimer, SIGNAL(timeout()), this, SLOT(timeoutReached()) );
+ }
+
+ if (Prefs::queryTimeout() != Prefs::EnumQueryTimeout::NoTimeout) {
+ timercount = mqtime;
+ mw->timebar->setTotalSteps(timercount);
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ }
+ else
+ mw->timebar->setEnabled(false);
+ all_known = true;
+ current = -1;
+ next();
+}
+
+
+bool VerbQueryDlg::next()
+{
+ resetAllFields();
+ QString s, type;
+ if (q_ocol == 0)
+ s = kv_exp->getOriginal();
+ else
+ s = kv_exp->getTranslation(q_ocol);
+
+ if (current < (int) conjugations.numEntries()-1 )
+ current++;
+
+ type = conjugations.getType(current);
+ QString format = i18n("Current tense is: %1.");
+ QString msg = format.arg(conjugations.getName(type));
+
+ mw->instructionLabel->setText (msg);
+ mw->baseLabel->setText (s);
+
+ mw->p1sField->setText("");
+ mw->p1sField->setEnabled (!conjugations.pers1Singular(type).isEmpty());
+
+ mw->p2sField->setText("");
+ mw->p2sField->setEnabled (!conjugations.pers2Singular(type).isEmpty());
+
+ mw->p3sfField->setText("");
+ mw->p3sfField->setEnabled (!conjugations.pers3FemaleSingular(type).isEmpty());
+
+ mw->p3smField->setText("");
+ mw->p3smField->setEnabled (!conjugations.pers3MaleSingular(type).isEmpty());
+
+ mw->p3snField->setText("");
+ mw->p3snField->setEnabled (!conjugations.pers3NaturalSingular(type).isEmpty());
+
+ mw->p1pField->setText("");
+ mw->p1pField->setEnabled (!conjugations.pers1Plural(type).isEmpty());
+
+ mw->p2pField->setText("");
+ mw->p2pField->setEnabled (!conjugations.pers2Plural(type).isEmpty());
+
+ mw->p3pfField->setText("");
+ mw->p3pfField->setEnabled (!conjugations.pers3FemalePlural(type).isEmpty());
+
+ mw->p3pmField->setText("");
+ mw->p3pmField->setEnabled (!conjugations.pers3MalePlural(type).isEmpty());
+
+ mw->p3pnField->setText("");
+ mw->p3pnField->setEnabled (!conjugations.pers3NaturalPlural(type).isEmpty());
+
+ bool common = conjugations.pers3SingularCommon(type);
+ if (common) {
+ mw->p3smField->setEnabled(false);
+ mw->p3snField->setEnabled(false);
+ }
+
+ common = conjugations.pers3PluralCommon(type);
+ if (common) {
+ mw->p3pmField->setEnabled(false);
+ mw->p3pnField->setEnabled(false);
+ }
+
+ return false;
+}
+
+
+void VerbQueryDlg::showAllClicked()
+{
+ resetAllFields();
+ mw->dont_know->setDefault(true);
+
+ QString type = conjugations.getType (current);
+
+ mw->p1sField->setText (conjugations.pers1Singular(type));
+ mw->p2sField->setText (conjugations.pers2Singular(type));
+ mw->p3sfField->setText (conjugations.pers3FemaleSingular(type));
+ mw->p3smField->setText (conjugations.pers3MaleSingular(type));
+ mw->p3snField->setText (conjugations.pers3NaturalSingular(type));
+
+ mw->p1pField->setText (conjugations.pers1Plural(type));
+ mw->p2pField->setText (conjugations.pers2Plural(type));
+ mw->p3pfField->setText (conjugations.pers3FemalePlural(type));
+ mw->p3pmField->setText (conjugations.pers3MalePlural(type));
+ mw->p3pnField->setText (conjugations.pers3NaturalPlural(type));
+
+ verifyField (mw->p1sField, conjugations.pers1Singular(type));
+ verifyField (mw->p2sField, conjugations.pers2Singular(type));
+ verifyField (mw->p3sfField, conjugations.pers3FemaleSingular(type));
+
+ bool common = conjugations.pers3SingularCommon(type);
+ if (!common) {
+ verifyField (mw->p3smField, conjugations.pers3MaleSingular(type));
+ verifyField (mw->p3snField, conjugations.pers3NaturalSingular(type));
+ }
+
+ verifyField (mw->p1pField, conjugations.pers1Plural(type));
+ verifyField (mw->p2pField, conjugations.pers2Plural(type));
+ verifyField (mw->p3pfField, conjugations.pers3FemalePlural(type));
+
+ common = conjugations.pers3PluralCommon(type);
+ if (!common) {
+ verifyField (mw->p3pmField, conjugations.pers3MalePlural(type));
+ verifyField (mw->p3pnField, conjugations.pers3NaturalPlural(type));
+ }
+
+}
+
+
+void VerbQueryDlg::verifyClicked()
+{
+ QString type = conjugations.getType(current);
+
+ bool known = true;
+
+ if (!verifyField (mw->p1sField, conjugations.pers1Singular(type)))
+ known = false;
+
+ if (!verifyField (mw->p2sField, conjugations.pers2Singular(type)))
+ known = false;
+
+ if (!verifyField (mw->p3sfField, conjugations.pers3FemaleSingular(type)))
+ known = false;
+
+ bool common = conjugations.pers3SingularCommon(type);
+ if (!common) {
+ if (!verifyField (mw->p3smField, conjugations.pers3MaleSingular(type)))
+ known = false;
+
+ if (!verifyField (mw->p3snField, conjugations.pers3NaturalSingular(type)))
+ known = false;
+ }
+
+ if (!verifyField (mw->p1pField, conjugations.pers1Plural(type)))
+ known = false;
+
+ if (!verifyField (mw->p2pField, conjugations.pers2Plural(type)))
+ known = false;
+
+ if (!verifyField (mw->p3pfField, conjugations.pers3FemalePlural(type)))
+ known = false;
+
+ common = conjugations.pers3PluralCommon(type);
+ if (!common) {
+ if (!verifyField (mw->p3pmField, conjugations.pers3MalePlural(type)))
+ known = false;
+
+ if (!verifyField (mw->p3pnField, conjugations.pers3NaturalPlural(type)))
+ known = false;
+ }
+
+ if (known)
+ knowItClicked();
+ else {
+ all_known = false;
+ mw->dont_know->setDefault(true);
+ }
+}
+
+
+void VerbQueryDlg::resetAllFields()
+{
+ resetField(mw->p1sField);
+ resetField(mw->p2sField);
+ resetField(mw->p3sfField);
+ resetField(mw->p3smField);
+ resetField(mw->p3snField);
+
+ resetField(mw->p1pField);
+ resetField(mw->p2pField);
+ resetField(mw->p3pfField);
+ resetField(mw->p3pmField);
+ resetField(mw->p3pnField);
+}
+
+
+void VerbQueryDlg::timeoutReached()
+{
+ if (timercount > 0) {
+ timercount--;
+ mw->timebar->setProgress(timercount);
+ qtimer->start(1000, TRUE);
+ }
+
+ if (timercount <= 0) {
+ mw->timebar->setProgress(0);
+ if (current >= (int) conjugations.numEntries()-1 ) {
+ qtimer->stop();
+ if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Show) {
+ showAllClicked();
+ mw->dont_know->setDefault(true);
+ }
+ else if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Continue)
+ emit sigQueryChoice (Timeout);
+ }
+ else {
+ if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Show) {
+ qtimer->stop();
+ showAllClicked();
+ mw->dont_know->setDefault(true);
+ }
+ else if (Prefs::queryTimeout() == Prefs::EnumQueryTimeout::Continue) {
+ next();
+ qtimer->start(1000, TRUE);
+ timercount = Prefs::maxTimePer();
+ }
+ }
+ }
+}
+
+
+void VerbQueryDlg::knowItClicked()
+{
+ resetAllFields();
+ if (current >= (int) conjugations.numEntries()-1 ) {
+ if (all_known)
+ emit sigQueryChoice (Known);
+ else
+ emit sigQueryChoice (Unknown);
+ }
+ else
+ next();
+}
+
+
+void VerbQueryDlg::dontKnowClicked()
+{
+ all_known = false;
+ if (current >= (int) conjugations.numEntries()-1 )
+ emit sigQueryChoice (Unknown);
+ else {
+ qtimer->start(1000, TRUE);
+ timercount = Prefs::maxTimePer();
+ next();
+ }
+}
+
+
+void VerbQueryDlg::slotUser2()
+{
+
+ if (qtimer != 0)
+ qtimer->stop();
+
+ emit sigEditEntry (q_row, KV_COL_ORG+q_ocol);
+}
+
+
+void VerbQueryDlg::keyPressEvent( QKeyEvent *e )
+{
+ switch( e->key() )
+ {
+ case Key_Escape:
+ dontKnowClicked();
+ break;
+
+ case Key_Return:
+ case Key_Enter:
+ if (mw->dont_know->isDefault() )
+ dontKnowClicked();
+ else if (mw->know_it->isDefault() )
+ knowItClicked();
+ else if (mw->show_all->isDefault() )
+ showAllClicked();
+ else if (mw->verify->isDefault() )
+ verifyClicked();
+ break;
+
+ default:
+ e->ignore();
+ break;
+ }
+}
+
+
+void VerbQueryDlg::slotP3pfChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p3pfField);
+}
+
+
+void VerbQueryDlg::slotP3snChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p3snField);
+}
+
+
+void VerbQueryDlg::slotReturnPressed()
+{
+}
+
+
+void VerbQueryDlg::slotP3smChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p3smField);
+}
+
+
+void VerbQueryDlg::slotP3pnChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p3pnField);
+}
+
+
+void VerbQueryDlg::slotP3sfChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p3sfField);
+}
+
+
+void VerbQueryDlg::slotP1sChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p1sField);
+}
+
+
+void VerbQueryDlg::slotP2sChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p2sField);
+}
+
+
+void VerbQueryDlg::slotP3pmChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p3pmField);
+}
+
+
+void VerbQueryDlg::slotP1pChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p1pField);
+}
+
+
+void VerbQueryDlg::slotP2pChanged(const QString&)
+{
+ mw->verify->setDefault(true);
+ resetField(mw->p2pField);
+}
+
+#include "VerbQueryDlg.moc"
diff --git a/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.h b/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.h
new file mode 100644
index 00000000..e972eb2a
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlg.h
@@ -0,0 +1,100 @@
+/***************************************************************************
+
+ query dialog for verbs
+
+ -----------------------------------------------------------------------
+
+ begin : Fri Dec 3 18:28:18 1999
+
+ copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
+ (C) 2001 The KDE-EDU team
+ (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
+
+ -----------------------------------------------------------------------
+
+ ***************************************************************************
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef VerbQueryDlg_included
+#define VerbQueryDlg_included
+
+#include "VerbQueryDlgForm.h"
+#include "QueryDlgBase.h"
+
+class VerbQueryDlg : public QueryDlgBase
+{
+ Q_OBJECT
+
+public:
+
+ VerbQueryDlg(
+ QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Conjugation &prefix,
+ const Conjugation &conjug);
+
+ ~VerbQueryDlg();
+
+ void setQuery(QString type,
+ int entry,
+ int col,
+ int query_cycle,
+ int query_num,
+ int query_startnum,
+ kvoctrainExpr *exp,
+ kvoctrainDoc *doc,
+ const Conjugation &prefix,
+ const Conjugation &conjug);
+
+public slots:
+ virtual void initFocus() const;
+
+protected:
+ bool next();
+ void keyPressEvent( QKeyEvent *e );
+ void resetAllFields();
+
+protected slots:
+ void slotUser2();
+ void slotP3pfChanged(const QString&);
+ void slotP3snChanged(const QString&);
+ void showAllClicked();
+ void slotReturnPressed();
+ void slotP3smChanged(const QString&);
+ void knowItClicked();
+ void dontKnowClicked();
+ void slotP3pnChanged(const QString&);
+ void slotP3sfChanged(const QString&);
+ void slotP1sChanged(const QString&);
+ void slotP2sChanged(const QString&);
+ void slotP3pmChanged(const QString&);
+ void slotP1pChanged(const QString&);
+ void slotP2pChanged(const QString&);
+ void verifyClicked();
+ void timeoutReached();
+
+protected:
+ int current;
+ Conjugation conjugations;
+ bool all_known;
+
+private:
+ VerbQueryDlgForm * mw;
+};
+
+#endif // VerbQueryDlg_included
diff --git a/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlgForm.ui b/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlgForm.ui
new file mode 100644
index 00000000..0c7a5cb7
--- /dev/null
+++ b/kvoctrain/kvoctrain/query-dialogs/VerbQueryDlgForm.ui
@@ -0,0 +1,549 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>VerbQueryDlgForm</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>VerbQueryDlgForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>473</width>
+ <height>326</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout20</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>lab1</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Enter the correct conjugation forms.</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>instructionLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Current tense is %1.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout30</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout29</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>p3smLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p3smField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>p2sField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="3" column="1">
+ <property name="name">
+ <cstring>p3smField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>p3snLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p3snField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>p1sLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p1sField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>p3sfLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p3sfField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="4" column="1">
+ <property name="name">
+ <cstring>p3snField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>p3sfField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>p2sLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p2sField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>p1sField</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout27</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>p2pField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="4" column="1">
+ <property name="name">
+ <cstring>p3pnField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>p1pLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p1pField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>p2pLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>MShape</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>MShadow</enum>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p2pField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="3" column="1">
+ <property name="name">
+ <cstring>p3pmField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>p3pmLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p3pmField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>p3pfField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>p3pfLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p3pfField</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>p1pField</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>p3pnLabel</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>p3pnField</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout19</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Base form:</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>baseLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="4" column="0">
+ <property name="name">
+ <cstring>layout32</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout31</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>know_it</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>I &amp;Know It</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>verify</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Verify</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>show_all</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show &amp;All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>dont_know</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Do Not Know</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>status</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="0" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>progressgroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Progress</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KProgress" row="0" column="1">
+ <property name="name">
+ <cstring>countbar</cstring>
+ </property>
+ </widget>
+ <widget class="KProgress" row="1" column="1">
+ <property name="name">
+ <cstring>timebar</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>countlabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Count:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>timelabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>Cyclelabel</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="text">
+ <string>Cycle:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>progCount</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>390</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<tabstops>
+ <tabstop>p1sField</tabstop>
+ <tabstop>p2sField</tabstop>
+ <tabstop>p3sfField</tabstop>
+ <tabstop>p3smField</tabstop>
+ <tabstop>p3snField</tabstop>
+ <tabstop>p1pField</tabstop>
+ <tabstop>p2pField</tabstop>
+ <tabstop>p3pfField</tabstop>
+ <tabstop>p3pmField</tabstop>
+ <tabstop>p3pnField</tabstop>
+ <tabstop>show_all</tabstop>
+ <tabstop>verify</tabstop>
+ <tabstop>know_it</tabstop>
+ <tabstop>dont_know</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kprogress.h</includehint>
+ <includehint>kprogress.h</includehint>
+</includehints>
+</UI>