• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

parley

ArtQueryDlg.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003                      query dialog for articles
00004 
00005     -----------------------------------------------------------------------
00006 
00007     begin         : Fri Dec 3 18:28:18 1999
00008 
00009     copyright     : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
00010                     (C) 2004-2007 Peter Hedlund <peter.hedlund@kdemail.net>
00011 
00012     -----------------------------------------------------------------------
00013 
00014  ***************************************************************************
00015 
00016  ***************************************************************************
00017  *                                                                         *
00018  *   This program is free software; you can redistribute it and/or modify  *
00019  *   it under the terms of the GNU General Public License as published by  *
00020  *   the Free Software Foundation; either version 2 of the License, or     *
00021  *   (at your option) any later version.                                   *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #include "ArtQueryDlg.h"
00026 
00027 #include <keduvocwordtype.h>
00028 #include <keduvocdocument.h>
00029 #include <KLocale>
00030 #include <QTimer>
00031 #include <QRadioButton>
00032 #include <QLabel>
00033 #include <QPushButton>
00034 #include <QButtonGroup>
00035 
00036 ArtQueryDlg::ArtQueryDlg(KEduVocDocument *doc, QWidget *parent) : PracticeDialog(i18nc("@title:window", "Article Training"), doc, parent)
00037 {
00038     mw = new Ui::ArtQueryDlgForm();
00039     mw->setupUi(mainWidget());
00040 
00041     mw->stopPracticeButton->setIcon( KIcon("process-stop") );
00042     mw->know_it->setIcon(KIcon("go-next"));
00043     mw->dont_know->setIcon(KIcon("go-next"));
00044 
00045     connect(mw->stopPracticeButton, SIGNAL(clicked()), SLOT(close()));
00046 
00047     articles = m_doc->identifier(Prefs::solutionLanguage()).article();
00048 
00049     connect(mw->dont_know, SIGNAL(clicked()), SLOT(skipUnknown()()));
00050     connect(mw->know_it, SIGNAL(clicked()), SLOT(skipKnown()));
00051     connect(mw->show_all, SIGNAL(clicked()), SLOT(showSolution()));
00052 
00053     connect(mw->maleRadio, SIGNAL(clicked()), SLOT(verifyClicked()));
00054     connect(mw->femaleRadio, SIGNAL(clicked()), SLOT(verifyClicked()));
00055     connect(mw->neutralRadio, SIGNAL(clicked()), SLOT(verifyClicked()));
00056 
00057     mw->dont_know->setShortcut(QKeySequence(Qt::Key_Escape));
00058 
00059     mw->countbar->setFormat("%v/%m");
00060     mw->timebar->setFormat("%v");
00061 
00062     mw->know_it->setVisible(Prefs::skipKnownEnabled());
00063     mw->imageGraphicsView->setVisible(false);
00064 
00065     KConfigGroup cg(KGlobal::config(), "ArtQueryDlg");
00066     restoreDialogSize(cg);
00067 }
00068 
00069 
00070 ArtQueryDlg::~ArtQueryDlg()
00071 {
00072     KConfigGroup cg(KGlobal::config(), "ArtQueryDlg");
00073     KDialog::saveDialogSize(cg);
00074 }
00075 
00076 
00077 void ArtQueryDlg::setEntry(TestEntry* entry)
00078 {
00079     PracticeDialog::setEntry(entry);
00080 
00081     mw->timebar->setVisible(Prefs::practiceTimeout());
00082     mw->timelabel->setVisible(Prefs::practiceTimeout());
00083     mw->show_all->setDefault(true);
00084 
00085     QString def, indef;
00086 
00087     KEduVocWordFlag::Flags singular = KEduVocWordFlag::Singular;
00088     KEduVocWordFlag::Flags definite = KEduVocWordFlag::Definite;
00089     KEduVocWordFlag::Flags indefinite = KEduVocWordFlag::Indefinite;
00090     KEduVocWordFlag::Flags male = KEduVocWordFlag::Masculine;
00091     KEduVocWordFlag::Flags female = KEduVocWordFlag::Feminine;
00092     KEduVocWordFlag::Flags neutral = KEduVocWordFlag::Neuter;
00093 
00094     // set the word (possibly without the article)
00095     QString noun = m_entry->entry()->translation(Prefs::solutionLanguage())->text();
00096 
00097     // strip the article
00098      QStringList qsl = noun.split(QRegExp("\\s"), QString::SkipEmptyParts);
00099      QMutableStringListIterator qsli(qsl);
00100      while (qsli.hasNext())
00101           if (articles.isArticle(qsli.next()))
00102              qsli.remove();
00103 
00104      noun = qsl.join(" ");
00105 
00106     mw->orgField->setText(noun);
00107     mw->progCount->setText(QString::number(entry->statisticCount()));
00108 
00109 
00110     // set the choices
00111     if(articles.isEmpty()) {
00112         mw->maleRadio->setText(i18nc("@label the gender of the word: masculine", "&masculine"));
00113         mw->femaleRadio->setText(i18nc("@label the gender of the word: feminine", "&feminine"));
00114         mw->neutralRadio->setText(i18nc("@label the gender of the word: neuter", "&neuter"));
00115     } else {
00116         def = articles.article( singular | definite | male );
00117         indef = articles.article( singular | indefinite | male );
00118         bool male = !(def.isEmpty() && indef.isEmpty());
00119         QString article;
00120         if((!def.isEmpty()) && (!indef.isEmpty())) {
00121             article = def + " / " + indef;
00122         } else {
00123             article = def + indef;
00124         }
00125         mw->maleRadio->setText(i18nc("@label the gender of the word: masculine", "&masculine:\t") + article);
00126 
00127         def = articles.article( singular | definite | female );
00128         indef = articles.article( singular | indefinite | female );
00129         bool female = !(def.isEmpty() && indef.isEmpty());
00130         if((!def.isEmpty()) && (!indef.isEmpty())) {
00131             article = def + " / " + indef;
00132         } else {
00133             article = def + indef;
00134         }
00135         mw->femaleRadio->setText(i18nc("@label the gender of the word: feminine", "&feminine:\t") + article);
00136 
00137         def = articles.article( singular | definite | neutral );
00138         indef = articles.article( singular | indefinite | neutral );
00139         bool neutral = !(def.isEmpty() && indef.isEmpty());
00140         if((!def.isEmpty()) && (!indef.isEmpty())) {
00141             article = def + " / " + indef;
00142         } else {
00143             article = def + indef;
00144         }
00145         if (!neutral && male && female) {
00146             mw->neutralRadio->setVisible(false);
00147         } else {
00148             mw->neutralRadio->setText(i18nc("@label the gender of the word: neuter", "&neuter:\t") + article);
00149             mw->neutralRadio->setVisible(true);
00150         }
00151     }
00152 
00153     setWidgetStyle(mw->maleRadio);
00154     setWidgetStyle(mw->femaleRadio);
00155     setWidgetStyle(mw->neutralRadio);
00156 
00157     // As long as the buttons are AutoExclusive we cannot uncheck all.
00158     mw->maleRadio->setChecked(true);
00159     mw->maleRadio->setAutoExclusive ( false );
00160     mw->maleRadio->setChecked(false);
00161     mw->maleRadio->setAutoExclusive ( true );
00162 
00163     mw->dont_know->setFocus();
00164 
00165     imageShowFromEntry( mw->imageGraphicsView );
00166 }
00167 
00168 
00169 void ArtQueryDlg::showSolution()
00170 {
00171     setWidgetStyle(mw->maleRadio);
00172     setWidgetStyle(mw->femaleRadio);
00173     setWidgetStyle(mw->neutralRadio);
00175 //     QString specialSubType = m_doc->wordTypes().specialSubType(m_entry->entry()->translation(Prefs::solutionLanguage())->type(), m_entry->entry()->translation(Prefs::solutionLanguage())->subType());
00176 //
00177 //     if (specialSubType == m_doc->wordTypes().specialTypeNounMale()) {
00178 //         mw->maleRadio->setChecked(true);
00179 //         setWidgetStyle(mw->maleRadio, PositiveResult);
00180 //     } else if (specialSubType == m_doc->wordTypes().specialTypeNounFemale()) {
00181 //         mw->femaleRadio->setChecked(true);
00182 //         setWidgetStyle(mw->femaleRadio, PositiveResult);
00183 //     } else if (specialSubType == m_doc->wordTypes().specialTypeNounNeutral()) {
00184 //         mw->neutralRadio->setChecked(true);
00185 //         setWidgetStyle(mw->neutralRadio, PositiveResult);
00186 //     }
00187 //     mw->dont_know->setDefault(true);
00188 //     setAnswerTainted();
00189 }
00190 
00191 
00192 void ArtQueryDlg::verifyClicked()
00193 {
00195 //     QString specialSubType = m_doc->wordTypes().specialSubType(m_entry->entry()->translation(Prefs::solutionLanguage())->type(), m_entry->entry()->translation(Prefs::solutionLanguage())->subType());
00196 //
00197 //     bool correct = false;
00198 //
00199 //     if (specialSubType ==  m_doc->wordTypes().specialTypeNounMale()) {
00200 //         if ( mw->maleRadio->isChecked() ) {
00201 //             setWidgetStyle(mw->maleRadio, PositiveResult);
00202 //             correct = true;
00203 //         } else {
00204 //             setWidgetStyle(mw->maleRadio, NegativeResult);
00205 //         }
00206 //     }
00207 //     if (specialSubType == m_doc->wordTypes().specialTypeNounFemale()) {
00208 //         if ( mw->femaleRadio->isChecked() ) {
00209 //             setWidgetStyle(mw->femaleRadio, PositiveResult);
00210 //             correct = true;
00211 //         } else {
00212 //             setWidgetStyle(mw->femaleRadio, NegativeResult);
00213 //         }
00214 //     }
00215 //     if (specialSubType == m_doc->wordTypes().specialTypeNounNeutral()) {
00216 //         if ( mw->neutralRadio->isChecked() ) {
00217 //             setWidgetStyle(mw->neutralRadio, PositiveResult);
00218 //             correct = true;
00219 //         } else {
00220 //             setWidgetStyle(mw->neutralRadio, NegativeResult);
00221 //         }
00222 //     }
00223 //
00224 //     if (correct) {
00225 //         resultCorrect();
00226 //         emit showSolutionFinished();
00227 //     } else {
00228 //         mw->dont_know->setDefault(true);
00229 //     }
00230 }
00231 
00232 
00233 void ArtQueryDlg::setProgressCounter(int current, int total)
00234 {
00235     mw->countbar->setMaximum(total);
00236     mw->countbar->setValue(current);
00237 }
00238 
00239 
00240 #include "ArtQueryDlg.moc"
00241 
00242 

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal