Hello community, here is the log from the commit of package kbruch for openSUSE:Factory checked in at Thu Oct 6 16:05:51 CEST 2011.
-------- --- openSUSE:Factory/kbruch/kbruch.changes 2011-09-23 02:04:37.000000000 +0200 +++ kbruch/kbruch.changes 2011-10-02 16:38:08.000000000 +0200 @@ -1,0 +2,6 @@ +Sun Oct 2 16:38:05 CEST 2011 - dmuel...@suse.de + +- update to 4.7.2 + * see http://kde.org/announcements/changelogs/changelog4_7_1to4_7_2.php for details + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- kbruch-4.7.1.tar.bz2 New: ---- kbruch-4.7.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kbruch.spec ++++++ --- /var/tmp/diff_new_pack.ox913o/_old 2011-10-06 16:05:44.000000000 +0200 +++ /var/tmp/diff_new_pack.ox913o/_new 2011-10-06 16:05:44.000000000 +0200 @@ -47,7 +47,7 @@ BuildRequires: ocaml BuildRequires: ocaml-facile %endif -Version: 4.7.1 +Version: 4.7.2 Release: 1 License: GPLv2+ Summary: Excercise Fractions ++++++ kbruch-4.7.1.tar.bz2 -> kbruch-4.7.2.tar.bz2 ++++++ Files old/kbruch-4.7.1/doc/checked.png and new/kbruch-4.7.2/doc/checked.png differ Files old/kbruch-4.7.1/doc/compare.png and new/kbruch-4.7.2/doc/compare.png differ Files old/kbruch-4.7.1/doc/convert.png and new/kbruch-4.7.2/doc/convert.png differ Files old/kbruch-4.7.1/doc/factorize.png and new/kbruch-4.7.2/doc/factorize.png differ Files old/kbruch-4.7.1/doc/gui_main.png and new/kbruch-4.7.2/doc/gui_main.png differ Files old/kbruch-4.7.1/doc/gui_mode.png and new/kbruch-4.7.2/doc/gui_mode.png differ Files old/kbruch-4.7.1/doc/index.cache.bz2 and new/kbruch-4.7.2/doc/index.cache.bz2 differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kbruch-4.7.1/doc/index.docbook new/kbruch-4.7.2/doc/index.docbook --- old/kbruch-4.7.1/doc/index.docbook 2011-05-20 22:33:55.000000000 +0200 +++ new/kbruch-4.7.2/doc/index.docbook 2011-10-02 15:24:52.000000000 +0200 @@ -35,15 +35,15 @@ </copyright> <legalnotice>&FDLNotice;</legalnotice> -<date>2009-02-03</date> -<releaseinfo>4.2</releaseinfo> +<date>2011-08-03</date> +<releaseinfo>4.2 (&kde; 4.7)</releaseinfo> <abstract> <para>&kbruch; is a small program to practice calculating with fractions and percentages. Different exercises are provided for this purpose and you can use the learning mode to practice with fractions. The program checks the user's input and gives feedback. </para> - + </abstract> <keywordset> @@ -62,7 +62,7 @@ <title>Introduction</title> <para> -&kbruch; is a small program to practice calculating with fractions and percentages. Five different exercises +&kbruch; is a small program to practice calculating with fractions and percentages. Six different exercises are offered as well as a learning mode. </para> @@ -73,7 +73,7 @@ </para></listitem> <listitem><para> Comparison - in this exercise you have to compare the size of 2 given -fractions, using the symbols <guibutton>></guibutton>, <guibutton><</guibutton> +fractions, using the symbols <guibutton>></guibutton>, <guibutton><</guibutton> or <guibutton>=</guibutton>. </para></listitem> <listitem><para> @@ -81,7 +81,11 @@ into a fraction. </para></listitem> <listitem><para> - Factorization - in this exercise you have to factorize a given number + Mixed Numbers - in this exercise you have to convert a mixed number into an improper fraction + (ratio) and vice versa. + </para></listitem> + <listitem><para> + Factorization - in this exercise you have to factorize a given number into its prime factors. </para></listitem> <listitem><para> @@ -96,14 +100,14 @@ <para> &kbruch; counts how many tasks were solved at all and how many tasks were -solved correctly. The statistics are shown to the user. +solved correctly. The statistics are shown to the user. <!-- The user can reset the statistics at any point.--> </para> <para> &kbruch; is very compact and focuses on the core idea of a task generator. An online help system provides context-sensitive help for the different -situations. +situations. </para> </chapter> @@ -115,7 +119,7 @@ <sect1 id="mode"> <title>Choosing the mode: learning or exercises</title> <para>When you start &kbruch;, it offers you two modes: -<guilabel>Freestyle</guilabel> which is the training mode and +<guilabel>Exercise</guilabel> which is the training mode and <guilabel>Learning</guilabel> where you can understand fractions. Clicking one of the pictures will enter the chosen mode. Here is a screenshot of &kbruch;'s mode choices:</para> @@ -135,12 +139,12 @@ </sect1> <sect1 id="overview"> -<title>Main freestyle screen</title> +<title>Main Exercise Screen</title> -<para>Here is a screenshot of &kbruch;'s main freestyle screen:</para> +<para>Here is a screenshot of &kbruch;'s main exercise screen:</para> <screenshot> - <screeninfo>&kbruch; main screen, directly after the freestyle start</screeninfo> + <screeninfo>&kbruch; main screen, directly after the exercise start</screeninfo> <mediaobject> <imageobject> <imagedata fileref="gui_main.png" format="PNG"/> @@ -163,7 +167,7 @@ </para></listitem> <listitem><para> the toolbar, where you can switch between the different -exercises +exercises </para></listitem> <listitem><para> the <guilabel>Options</guilabel> on the left, where you can @@ -184,7 +188,7 @@ </para></note> <para> First you have to choose an exercise in the toolbar. Default is <guilabel>Arithmetic</guilabel>. The -task part will change according to the chosen task. Some settings in the <guilabel>Options</guilabel> section +task part will change according to the chosen task. Some settings in the <guilabel>Options</guilabel> section will be enabled, depending on the task you have chosen. </para> <para> @@ -219,7 +223,7 @@ </screenshot> <para> -In this part of the main screen you can see: +In this part of the main screen you can see: <itemizedlist> <listitem><para> on the left, how many tasks have been solved @@ -239,11 +243,11 @@ You can reset the statistics by clicking on the <guimenu>New</guimenu> button in the toolbar or choosing <menuchoice><guimenu>File</guimenu> <guimenuitem>New</guimenuitem></menuchoice> in the menubar. -</para> +</para> <para> The statistics will be saved when &kbruch; is closed and restored on next startup. -</para> +</para> </sect1> <sect1 id="settings"> @@ -268,7 +272,7 @@ </screenshot> <para> -There are two tabs to adjust the setting: +There are two tabs to adjust the setting: <itemizedlist> <!-- <listitem><para> <guilabel>General</guilabel>: Set whether to show the mixed number notation in the result. @@ -370,7 +374,7 @@ </para></listitem> </varlistentry> - +<!-- Not in v. 4.2 <varlistentry> <term><guilabel>Solution</guilabel></term> <listitem><para> @@ -380,11 +384,11 @@ <term><guilabel>Mixed number</guilabel></term> <listitem><para>Set if the fractions will appear as mixed numbers or not in the solution ( mixed number example: 1 4/5 = 9/5 ).</para></listitem> </varlistentry> - </variablelist> </para></listitem> </varlistentry> +--> <varlistentry> <term><guilabel>Operations</guilabel></term> @@ -397,22 +401,22 @@ </variablelist> <para> -After you have changed the parameters you have to click on the <guimenu>New</guimenu> +After you have changed the parameters you have to click on the <guimenu>New</guimenu> button in the toolbar to generate a task which uses the new parameters. You can also call this action from the menubar with <menuchoice><guimenu>Task</guimenu><guimenuitem>New</guimenuitem></menuchoice>. -This will reset the statistics. To avoid that, click the <guibutton>Next</guibutton> +This will reset the statistics. To avoid that, click the <guibutton>Next</guibutton> button to proceed with the changed parameters. </para> <!--<note> <para> Your selection of the maximum main denominator will be reset to a default -value every time you change the number of terms. So you should change the +value every time you change the number of terms. So you should change the number of terms first and then select the maximum main denominator. </para> </note>--> <!--para> -If you have not solved the current task and call the <guimenu>New</guimenu> +If you have not solved the current task and call the <guimenu>New</guimenu> action, the task will be counted as not solved correctly. To prevent this you have to change the parameters after you solved the task but before generating a new one. @@ -427,10 +431,10 @@ <title>Solving Tasks</title> <para> After you have solved a given task, you need to enter the result into the three -input boxes. In the left box you enter the integer part of the fraction, in the +input boxes. In the left box you enter the integer part of the fraction, in the upper box the numerator and in the lower box the denominator. -If the option <guilabel>Mixed number</guilabel> in the <guilabel>Answer</guilabel> -section is unchecked, the left box for the integer part of the fraction is hidden. Then you use +If the option <guilabel>Mixed number</guilabel> in the <guilabel>Answer</guilabel> +section is unchecked, the left box for the integer part of the fraction is hidden. Then you use only the numerator box and the denominator box for your input. </para> <para> @@ -439,7 +443,7 @@ If the result has a denominator of 1, you can leave the lower box empty. </para> <para> -After you have entered the result you should click the <guibutton>Check</guibutton> +After you have entered the result you should click the <guibutton>Check</guibutton> button below the input boxes. &kbruch; will check your input and present the correct result on the right below the <guilabel>Incorrect!</guilabel> string: </para> @@ -460,7 +464,7 @@ </para> <note> <para> -If you checked the <guibutton>Reduced form</guibutton> in the Options in the <guilabel>Answers</guilabel> section +If you checked the <guibutton>Reduced form</guibutton> in the Options in the <guilabel>Answers</guilabel> section then you always have to enter the result reduced. &kbruch; will show you a short message like the one in the screenshot below, if you enter the correct result unreduced. The answer will then be counted as incorrect. @@ -557,6 +561,49 @@ </sect1> +<sect1 id="exer_mixed"> +<title>Exercise Mixed Numbers</title> + +<para>In this exercise you have to convert a given mixed number into an improper fraction (ratio) and +vice versa. You have to enter numerator and denominator for improper fraction or a whole number, +numerator and denominator for mixed number. +</para> + +<screenshot> +<screeninfo>Exercise Mixed Numbers</screeninfo> +<mediaobject> + <imageobject> + <imagedata fileref="mixed.png" format="PNG"/> + </imageobject> + <textobject> + <phrase>Exercise Mixed Numbers</phrase> + </textobject> +</mediaobject> +</screenshot> + +<para>On the left side of the equal sign in the screenshot above you can see a +mixed number. This means, that the number is made up of a whole number and a +proper fraction. You should enter the equal improper fraction (the numerator +part of such fraction is greater or equal to the denominator part). +</para> + +<para>After you have entered the numerator and denominator click on the +<guibutton>Check</guibutton> button. &kbruch; will check your input and +present the correct result. After this step you will get to the next task by +clicking on the <guibutton>Next</guibutton> button. +</para> + +<note> +<para> +Do not forget to enter the result reduced. Unreduced results will be counted as +solved not correctly. +</para> +</note> + +<para>In this exercise all options are disabled.</para> + +</sect1> + <sect1 id="exer_factorize"> <title>Exercise Factorization</title> @@ -577,7 +624,7 @@ </screenshot> <para>You can enter a factor by clicking on the prime factor -buttons. The <quote>*</quote> sign is automatically inserted, when you click the next +buttons. The <quote>x</quote> sign is automatically inserted, when you click the next prime factor button. You can remove the last entered prime factor by clicking on the <guibutton>Backspace</guibutton> button. </para> @@ -588,7 +635,7 @@ clicking on the <guibutton>Next</guibutton> button. </para> -<para>In the screenshot at the top of this page you can see a <quote>*</quote> +<para>In the screenshot at the top of this page you can see a <quote>x</quote> between the prime factors. This is the multiplication sign. The product of all prime factors must be the number you try to factorize. </para> Files old/kbruch-4.7.1/doc/learning.png and new/kbruch-4.7.2/doc/learning.png differ Files old/kbruch-4.7.1/doc/mixed.png and new/kbruch-4.7.2/doc/mixed.png differ Files old/kbruch-4.7.1/doc/percentage.png and new/kbruch-4.7.2/doc/percentage.png differ Files old/kbruch-4.7.1/doc/reduced.png and new/kbruch-4.7.2/doc/reduced.png differ Files old/kbruch-4.7.1/doc/settings.png and new/kbruch-4.7.2/doc/settings.png differ Files old/kbruch-4.7.1/doc/statistics.png and new/kbruch-4.7.2/doc/statistics.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kbruch-4.7.1/src/PrimeFactorsLineEdit.cpp new/kbruch-4.7.2/src/PrimeFactorsLineEdit.cpp --- old/kbruch-4.7.1/src/PrimeFactorsLineEdit.cpp 2011-05-20 22:33:55.000000000 +0200 +++ new/kbruch-4.7.2/src/PrimeFactorsLineEdit.cpp 2011-10-02 15:24:53.000000000 +0200 @@ -28,7 +28,10 @@ #ifdef DEBUG kDebug() << "constructor PrimeFactorsLineEdit"; #endif - m_allowedChars = "0123456789x"; + m_usedFactors << "2" << "3" << "5" << "7" << "11" << "13" << "17" << "19"; + // I need this so dead keys go trough keyPressEvent + setAttribute(Qt::WA_InputMethodEnabled, false); + connect(this, SIGNAL(textEdited(QString)), this, SLOT(textHasChanged(QString))); } /* destructor */ @@ -39,44 +42,95 @@ #endif } -/** ignore all invalid characters */ -void PrimeFactorsLineEdit::keyPressEvent(QKeyEvent * e) +void PrimeFactorsLineEdit::textHasChanged(QString text) { - // forward special chars to KLineEdit - if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return || e->key() == - Qt::Key_Delete || e->key() == Qt::Key_Backspace || (e->modifiers() - & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | - Qt::GroupSwitchModifier))) - { - KLineEdit::keyPressEvent(e); - return; - } + QPalette palette; - // first ignore all chars, which are not numeric or multiply sign "*" - if (! m_allowedChars.contains(e->text())) { - return; + if(!checkCorrectness(text)) { + palette.setColor(QPalette::Base, Qt::red); + setPalette(palette); + emit contentIsRight(false); + } else { + palette.setColor(QPalette::Base, Qt::white); + setPalette(palette); + emit contentIsRight(true); } +} + +bool PrimeFactorsLineEdit::checkCorrectness(const QString& theText) +{ + QString auxStr = theText; + QString noSpaces = auxStr.remove(' '); + QStringList terms = noSpaces.split('x'); + + return (areFactors(terms) || text().isEmpty()); +} - // don't allow 2 multiply signs next to each other - const QString currentText = text(); - if (e->text() == "x" && currentText.right(1) == "x") { - return; - } - - // valid char, process it as usual - KLineEdit::keyPressEvent(e); -} - -/** react on change input method events */ -void PrimeFactorsLineEdit::inputMethodEvent(QInputMethodEvent * e) -{ - const QString str = e->commitString(); - - Q_FOREACH(QChar ch, str) { - if (! m_allowedChars.contains(ch)) { - return; +bool PrimeFactorsLineEdit::areFactors(const QStringList& factors) +{ + m_theFactors.clear(); + foreach(QString str, factors) { + bool found = false; + foreach(QString aux, m_usedFactors) { + if(str.compare(str, aux) == 0) { + found = true; + m_theFactors.append(str); + break; + } + } + if(!found) { + return false; } } - KLineEdit::inputMethodEvent(e); + return true; +} + +QStringList PrimeFactorsLineEdit::getFactors() const +{ + return m_theFactors; +} + +void PrimeFactorsLineEdit::keyPressEvent(QKeyEvent * event) +{ + QString allowedChars = "123579xX*"; + QString allowedDigits = "123579"; + QString symbols = "xX*"; + bool backspaceKey = (event->key() == Qt::Key_Backspace); + bool returnKey = (event->key() == Qt::Key_Return + || event->key() == Qt::Key_Enter); + + setCursorPosition(text().length()); + + if(allowedChars.contains(event->text()) || backspaceKey || returnKey) { + QString lastFactor; + QChar ch = '#'; + QString factor = ""; + if(!event->text().isEmpty()) { + ch = event->text().at(0); + } + if(!text().isEmpty()) { + lastFactor = text().section('x', -1); + factor = lastFactor + ch; + } else { + factor = ch; + } + + if(allowedChars.contains(ch) || backspaceKey || returnKey) { + // turns '*' and 'X' into 'x' to avoid mixed symbols + // and to make easier to split the text later + if(!event->text().isEmpty() && (symbols.indexOf(ch) != -1) && (factor.compare("x") != 0) && !lastFactor.isEmpty() && lastFactor.compare("1") != 0) { + QKeyEvent myKeyEvent(QKeyEvent::KeyPress, Qt::Key_X, Qt::NoModifier, "x", false, 0); + KLineEdit::keyPressEvent(&myKeyEvent); + } + + if((m_usedFactors.indexOf(factor) == -1) + && (factor.compare("1") != 0) && !backspaceKey && + !returnKey) { + return; + } + + KLineEdit::keyPressEvent(event); + } + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kbruch-4.7.1/src/PrimeFactorsLineEdit.h new/kbruch-4.7.2/src/PrimeFactorsLineEdit.h --- old/kbruch-4.7.1/src/PrimeFactorsLineEdit.h 2011-05-20 22:33:55.000000000 +0200 +++ new/kbruch-4.7.2/src/PrimeFactorsLineEdit.h 2011-10-02 15:24:52.000000000 +0200 @@ -43,20 +43,38 @@ public: /** constructor */ - explicit PrimeFactorsLineEdit (QWidget* parent = 0); + explicit PrimeFactorsLineEdit(QWidget* parent = 0); /** destructor */ ~PrimeFactorsLineEdit(); -protected: - /** override key press event */ - void keyPressEvent (QKeyEvent * e); + /** return the factors entered */ + QStringList getFactors() const; - /** override input method change event */ - void inputMethodEvent (QInputMethodEvent * e); +public slots: + /** called when the text in KLineEdit's content changes */ + void textHasChanged(QString text); + +signals: + /** emitted when KLineEdit's content changes and it's correct + itIs is true if the content is correct otherwise. + */ + void contentIsRight(bool itIs); private: - QString m_allowedChars; + /** will content the factor the application will used: + * 2, 3, 5, 7, 11, 13, 17, 19 */ + QStringList m_usedFactors; + /** the factors entered in the KLineEdit */ + QStringList m_theFactors; + + /** will check if the KLineEdit's content is right */ + bool checkCorrectness(const QString &text); + /** will check if every factors' element is actually a factor */ + bool areFactors(const QStringList &factors); + + /** reimplement keyPressEvent inherited from QWidget */ + void keyPressEvent(QKeyEvent * event); }; #endif // PRIMEFACTORSLINEEDIT_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kbruch-4.7.1/src/exercisefactorize.cpp new/kbruch-4.7.2/src/exercisefactorize.cpp --- old/kbruch-4.7.1/src/exercisefactorize.cpp 2011-05-20 22:33:55.000000000 +0200 +++ new/kbruch-4.7.2/src/exercisefactorize.cpp 2011-10-02 15:24:53.000000000 +0200 @@ -110,6 +110,10 @@ m_factorsEnteredEdit->setFont (defaultFont); m_factorsEnteredEdit->setFixedSize (320, 35); taskLayout->addWidget (m_factorsEnteredEdit, 1, 3, 1, 5); + + connect(m_factorsEnteredEdit, SIGNAL(contentIsRight(bool)), this, SLOT(editContentChanged(bool))); + connect(m_factorsEnteredEdit, SIGNAL(returnPressed (const QString &)), + this, SLOT(slotFactorsEditReturnPressed(const QString &))); defaultFont.setPointSize (10); @@ -287,6 +291,15 @@ } m_currentState = _CHECK_TASK; m_checkButton->setText (i18n ("&Check")); + + // Maybe the skip button was clicked with while + // wrong content was int the KLineEdit so... + // Set the KLineEdit's background to white + QPalette palette; + palette.setColor(QPalette::Base, Qt::white); + m_factorsEnteredEdit->setPalette(palette); + // and enable all buttons that could be disabled. + setButtonsEnabled(true); // generate next task (void) nextTask(); @@ -488,6 +501,13 @@ /* ------ private slots ------ */ +void ExerciseFactorize::slotFactorsEditReturnPressed(const QString &) +{ + if (m_checkButton->isEnabled()) { + slotCheckButtonClicked(); + } +} + void ExerciseFactorize::slotCheckButtonClicked() { if (m_currentState == _CHECK_TASK) { @@ -603,3 +623,33 @@ if (isVisible()) m_factorsEnteredEdit->setFocus(); } + +void ExerciseFactorize::editContentChanged(bool correct) +{ + if (correct) { + QStringList factors = m_factorsEnteredEdit->getFactors(); + + m_factorsEntered.clear(); + foreach (QString auxStr, factors) { + m_factorsEntered.append(auxStr.toUInt()); + } + } + setButtonsEnabled(correct); +} + +void ExerciseFactorize::setButtonsEnabled(bool enabled) +{ + // set the state of the buttons involved in factorization + m_checkButton->setEnabled(enabled); + m_factor2Button->setEnabled(enabled); + m_factor3Button->setEnabled(enabled); + m_factor5Button->setEnabled(enabled); + m_factor7Button->setEnabled(enabled); + m_factor11Button->setEnabled(enabled); + m_factor13Button->setEnabled(enabled); + m_factor17Button->setEnabled(enabled); + m_factor19Button->setEnabled(enabled); + m_removeLastFactorButton->setEnabled(enabled); +} + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kbruch-4.7.1/src/exercisefactorize.h new/kbruch-4.7.2/src/exercisefactorize.h --- old/kbruch-4.7.1/src/exercisefactorize.h 2011-05-20 22:33:55.000000000 +0200 +++ new/kbruch-4.7.2/src/exercisefactorize.h 2011-10-02 15:24:53.000000000 +0200 @@ -144,6 +144,8 @@ private slots: + void slotFactorsEditReturnPressed(const QString &); + void slotCheckButtonClicked(); void slotSkipButtonClicked(); @@ -156,6 +158,9 @@ void slotFactor17ButtonClicked(); void slotFactor19ButtonClicked(); void slotRemoveLastFactorButtonClicked(); + + void editContentChanged(bool correct); + void setButtonsEnabled(bool enabled); }; #endif continue with "q"... Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org