[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/parley/src
From: Frederik Gladhorn <frederik.gladhorn () gmx ! de>
Date: 2007-09-30 22:23:07
Message-ID: 1191190987.038963.14111.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 719330 by gladhorn:
Add a Mixed Letters practice which suffles the demanded word.
Image practice is gone now, the other dialogs display the image.
M +2 -2 configure-practice/configurepracticewidget.ui
M +34 -18 practice/imagepracticedlg.cpp
M +1 -0 practice/imagepracticedlg.h
M +4 -4 practice/imagepracticedlg.ui
M +1 -1 practice/practicemanager.cpp
M +1 -1 settings/parley.kcfg
--- trunk/KDE/kdeedu/parley/src/configure-practice/configurepracticewidget.ui \
#719329:719330 @@ -69,9 +69,9 @@
</widget>
</item>
<item row="5" column="0" colspan="2" >
- <widget class="QRadioButton" name="ImagePracticeRadio" >
+ <widget class="QRadioButton" name="MixedLettersPracticeRadio" >
<property name="text" >
- <string>Image Practice</string>
+ <string>Mixed Letters Practice</string>
</property>
</widget>
</item>
--- trunk/KDE/kdeedu/parley/src/practice/imagepracticedlg.cpp #719329:719330
@@ -17,6 +17,7 @@
#include <keduvocdocument.h>
#include <KLocale>
+#include <KRandomSequence>
#include <QGraphicsItem>
#include <QTimer>
#include <QTextEdit>
@@ -36,13 +37,15 @@
connect(verifySolutionButton, SIGNAL(clicked()), SLOT(verifyClicked()));
connect(showSolutionButton, SIGNAL(clicked()), SLOT(showSolution()));
- connect(answerLineEdit, SIGNAL(textChanged()), SLOT(slotAnswerChanged()));
+ connect(answerLineEdit, SIGNAL(textEdited(const QString&)), \
SLOT(slotAnswerChanged()));
countbar->setFormat("%v/%m");
timeProgressBar->setFormat("%v");
verifySolutionButton->setIcon( KIcon("ok") );
+ imageGraphicsView->setScene(new QGraphicsScene());
+
KConfigGroup cg(KGlobal::config(), "ImagePracticeDlg");
restoreDialogSize(cg);
}
@@ -74,25 +77,24 @@
resetQueryWidget(answerLineEdit);
answerLineEdit->setFocus();
- originalLabel->setText( \
m_entry->exp->translation(Prefs::fromIdentifier()).text() );
- QString url;
- url = m_entry->exp->translation(identifier).imageUrl().toLocalFile();
- if ( url.isEmpty() ) {
- url = m_entry->exp->translation(Prefs::fromIdentifier()).imageUrl().toLocalFile();
+ QString original = m_entry->exp->translation(Prefs::fromIdentifier()).text();
+ originalLabel->setText( original );
+
+ QString translation = m_entry->exp->translation(Prefs::toIdentifier()).text();
+
+ // remove old items
+ foreach ( QGraphicsItem* item, imageGraphicsView->scene()->items() ) {
+ imageGraphicsView->scene()->removeItem(item);
+ delete item;
}
- if ( !url.isEmpty() ) {
- imageShowFile(imageGraphicsView, url);
- } else {
- if ( !imageGraphicsView->scene() ) {
- imageGraphicsView->setScene(new QGraphicsScene());
- }
+ m_answerTextItems.clear();
- foreach ( QGraphicsItem* item, imageGraphicsView->scene()->items() ) {
- imageGraphicsView->scene()->removeItem(item);
- delete item;
- }
- QGraphicsTextItem* textItem = new QGraphicsTextItem( \
m_entry->exp->translation(Prefs::fromIdentifier()).text() );
- textItem->translate(-textItem->boundingRect().width()/2.0, \
-textItem->boundingRect().height()/2.0 ); + KRandomSequence random = \
KRandomSequence( QDateTime::currentDateTime().toTime_t() ); +
+ for ( int i = 0; i < translation.length(); i++ ) {
+ QGraphicsTextItem* textItem = new QGraphicsTextItem( QString(translation[i]) \
); + textItem->translate( 10 + random.getLong(imageGraphicsView->width() - 20 \
), 10 + random.getLong(imageGraphicsView->height() -20 ) ); + \
m_answerTextItems.append(textItem); imageGraphicsView->scene()->addItem( textItem );
}
}
@@ -100,6 +102,20 @@
void ImagePracticeDlg::slotAnswerChanged()
{
+ QString solution = m_entry->exp->translation(Prefs::toIdentifier()).text();
+ for ( int i = 0; i < solution.length(); i++ ) {
+ if ( answerLineEdit->text()[i] == solution[i] ) {
+ m_answerTextItems[i]->setHtml("<b><font color=\"#188C18\">" + \
solution[i] + "</font></b>"); + } else {
+// if ( i >= answerLineEdit->text().length() ) {
+ // no input yet
+ m_answerTextItems[i]->setHtml(QString(solution[i]));
+// } else {
+ // wrong
+// m_answerTextItems[i]->setHtml("<b><font color=\"#FF0000\">" + \
solution[i] + "</font></b>"); +// }
+ }
+ }
resetQueryWidget(answerLineEdit);
verifySolutionButton->setDefault(true);
}
--- trunk/KDE/kdeedu/parley/src/practice/imagepracticedlg.h #719329:719330
@@ -40,6 +40,7 @@
QProgressBar* timebar();
bool m_wrongAnswer;
+ QList <QGraphicsTextItem*> m_answerTextItems;
};
#endif
--- trunk/KDE/kdeedu/parley/src/practice/imagepracticedlg.ui #719329:719330
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>511</width>
- <height>577</height>
+ <width>388</width>
+ <height>525</height>
</rect>
</property>
<property name="windowTitle" >
@@ -50,7 +50,7 @@
</sizepolicy>
</property>
<property name="title" >
- <string>What do you see?</string>
+ <string>Can you order the letters?</string>
</property>
<layout class="QVBoxLayout" >
<item>
@@ -90,7 +90,7 @@
<string>Verify</string>
</property>
<property name="icon" >
- <iconset>../../../../../../.designer/backup</iconset>
+ <iconset>../../../../../../../../../../.designer/backup</iconset>
</property>
</widget>
</item>
--- trunk/KDE/kdeedu/parley/src/practice/practicemanager.cpp #719329:719330
@@ -177,7 +177,7 @@
case Prefs::EnumTestType::MultipleChoiceTest:
m_testDialog = new MCQueryDlg(m_doc, m_app);
break;
- case Prefs::EnumTestType::ImageTest:
+ case Prefs::EnumTestType::MixedLettersTest:
m_testDialog = new ImagePracticeDlg(m_doc, m_app);
break;
--- trunk/KDE/kdeedu/parley/src/settings/parley.kcfg #719329:719330
@@ -215,7 +215,7 @@
<choice name="GrammarTest"/>
<choice name="ParaphraseTest"/>
<choice name="ExampleTest"/>
- <choice name="ImageTest"/>
+ <choice name="MixedLettersTest"/>
</choices>
<label>The test type that is currently selected.</label>
</entry>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic