[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu
From:       Frederik Gladhorn <frederik.gladhorn () gmx ! de>
Date:       2008-08-15 12:35:13
Message-ID: 1218803713.479157.22907.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 847466 by gladhorn:

Make language selection work somewhat.
config does not yet save it correctly though.

 M  +2 -0      libkdeedu/CMakeLists.txt  
 M  +0 -13     libkdeedu/keduvocdocument/keduvocdocument.cpp  
 M  +0 -16     libkdeedu/keduvocdocument/keduvocdocument.h  
 M  +3 -1      libkdeedu/keduvocdocument/keduvocidentifier.cpp  
 M  +3 -2      libkdeedu/keduvocdocument/keduvockvtml2reader.cpp  
 M  +1 -1      libkdeedu/keduvocdocument/keduvockvtml2reader.h  
 M  +1 -1      libkdeedu/keduvocdocument/keduvockvtml2writer.cpp  
 M  +43 -33    parley/src/configure-practice/configurepracticewidget.cpp  
 M  +3 -1      parley/src/configure-practice/configurepracticewidget.h  
 M  +58 -13    parley/src/configure-practice/conjugationoptionswidget.ui  
 M  +1 -1      parley/src/entry-dialogs/conjugationwidget.cpp  
 M  +2 -1      parley/src/scripts/scripting/document.h  


--- trunk/KDE/kdeedu/libkdeedu/CMakeLists.txt #847465:847466
@@ -1,5 +1,7 @@
 project(libkdeedu)
 
+#add_definitions( -Wall -fprofile-arcs -ftest-coverage )
+
 add_subdirectory(keduvocdocument)
 add_subdirectory(kdeeduui)
 add_subdirectory(libscience)
--- trunk/KDE/kdeedu/libkdeedu/keduvocdocument/keduvocdocument.cpp #847465:847466
@@ -666,19 +666,6 @@
     setModified(true);
 }
 
-QString KEduVocDocument::tenseName( int index ) const
-{
-    if ( index >= d->m_tenseDescriptions.size() )
-        return "";
-    else
-        return d->m_tenseDescriptions[index];
-}
-
-QStringList KEduVocDocument::tenseDescriptions() const
-{
-    return d->m_tenseDescriptions;
-}
-
 // works if const is removed
 int KEduVocDocument::indexOfIdentifier( const QString &name ) const
 {
--- trunk/KDE/kdeedu/libkdeedu/keduvocdocument/keduvocdocument.h #847465:847466
@@ -256,22 +256,6 @@
      */
     int indexOfIdentifier( const QString &name ) const;
 
-    // *** tense methods ***
-
-    /**
-     * Returns the tense string
-     *
-     * @param index            number of tense
-     * @returns                string
-     */
-    QString tenseName( int index ) const;
-
-    /**
-     * Gets the descriptions of the tenses
-     */
-    QStringList tenseDescriptions() const;
-
-
     // *** grade methods ***
 
     /**
--- trunk/KDE/kdeedu/libkdeedu/keduvocdocument/keduvocidentifier.cpp #847465:847466
@@ -55,8 +55,9 @@
 }
 
 KEduVocIdentifier::KEduVocIdentifier( const KEduVocIdentifier &other )
-: d( new Private )
+: d( new Private( *other.d ) )
 {
+#if 0
     d->m_locale = other.d->m_locale;
     d->m_name = other.d->m_name;
     d->m_articles = other.d->m_articles;
@@ -64,6 +65,7 @@
     d->m_comment = other.d->m_comment;
     d->m_tenses = other.d->m_tenses;
     d->m_type = other.d->m_type;
+#endif
 }
 
 KEduVocIdentifier& KEduVocIdentifier::operator= ( const KEduVocIdentifier &other )
--- trunk/KDE/kdeedu/libkdeedu/keduvocdocument/keduvockvtml2reader.cpp #847465:847466
@@ -270,8 +270,9 @@
         m_doc->identifier(id).setPersonalPronouns( personalPronoun );
     }
 
+    QStringList tenses = readTenses(identifierElement);
+kDebug() << tenses;
 
-    QStringList tenses = readTenses(identifierElement);
     m_doc->identifier(id).setTenseList(tenses);
 
     return result;
@@ -609,7 +610,7 @@
     return true;
 }
 
-const QStringList& KEduVocKvtml2Reader::readTenses( QDomElement &tensesElement )
+QStringList KEduVocKvtml2Reader::readTenses( QDomElement &tensesElement )
 {
     QStringList tenses;
 
--- trunk/KDE/kdeedu/libkdeedu/keduvocdocument/keduvockvtml2reader.h #847465:847466
@@ -106,7 +106,7 @@
     /** read the tenses
      * @param tensesElement QDomElement for the tenses group
      */
-    const QStringList& readTenses( QDomElement &tensesElement );
+    QStringList readTenses( QDomElement &tensesElement );
 
     /** read the usages
      * @param usagesElement QDomElement for the usages group
--- trunk/KDE/kdeedu/libkdeedu/keduvocdocument/keduvockvtml2writer.cpp #847465:847466
@@ -181,7 +181,7 @@
         }
 
         // tenses
-        foreach(const QString &tense, m_doc->tenseDescriptions() ) {
+        foreach(const QString &tense, m_doc->identifier(i).tenseList() ) {
             if ( !( tense.isNull() ) ) {
                 identifier.appendChild( newTextElement( KVTML_TENSE, tense ) );
             }
--- trunk/KDE/kdeedu/parley/src/configure-practice/configurepracticewidget.cpp \
#847465:847466 @@ -59,9 +59,6 @@
         LanguageFromList->addItem( new QListWidgetItem( KIcon(icon), \
m_doc->identifier(i).name() ) );  }
 
-    connect(LanguageFromList, SIGNAL(currentRowChanged(int)), \
                SLOT(fromLanguageSelected(int)));
-    LanguageFromList->setCurrentRow(Prefs::questionLanguage());
-
     OptionsGroupBox->setEnabled( false );
     m_optionsStackedLayout = new QStackedLayout(OptionsGroupBox);
     OptionsGroupBox->setLayout(m_optionsStackedLayout);
@@ -75,23 +72,17 @@
     writtenPracticeUi.setupUi(writtenContainer);
     m_optionsStackedLayout->insertWidget(WrittenPractice, writtenContainer);
 
+    // add the muliple choice practice ui to the stacked widget
+    QWidget* multipleChoiceContainer = new QWidget(OptionsGroupBox);
+    Ui::MultipleChoiceOptionsWidget multipleChoiceUi;
+    multipleChoiceUi.setupUi(multipleChoiceContainer);
+    m_optionsStackedLayout->insertWidget(MultipleChoice, multipleChoiceContainer);
 
     // add the conjugation ui to the stacked widget
-    if ( !m_doc->tenseDescriptions().isEmpty() ) {
-        QWidget* conjugationContainer = new QWidget(OptionsGroupBox);
-        Ui::ConjugationOptionsWidget conjugationUi;
-        conjugationUi.setupUi(conjugationContainer);
-        m_optionsStackedLayout->insertWidget(Conjugation, conjugationContainer);
-        m_tenseListWidget = conjugationUi.tenseSelectionTreeWidget;
-        setupTenses();
-    } else {
-        m_tenseListWidget = 0;
-        QLabel* tenseHint = new QLabel(OptionsGroupBox);
-        tenseHint->setText(i18n("To practice conjugations set up tenses in the \
                \"Edit\" -> \"Grammar\" options and add the conjugation forms to your \
                vocabulary."));
-        tenseHint->setWordWrap(true);
-        m_optionsStackedLayout->insertWidget(Conjugation, tenseHint);
-    }
+    QWidget* conjugationContainer = new QWidget(OptionsGroupBox);
 
+    m_conjugationUi.setupUi(conjugationContainer);
+    m_optionsStackedLayout->insertWidget(Conjugation, conjugationContainer);
 
     // add the comparison ui to the stacked widget
     QWidget* comparisonContainer = new QWidget(OptionsGroupBox);
@@ -117,6 +108,11 @@
         writtenRadioToggled(true);
     }
 
+    connect(LanguageFromList, SIGNAL(currentRowChanged(int)), \
SLOT(fromLanguageSelected(int))); +    \
LanguageFromList->setCurrentRow(Prefs::questionLanguage()); +
+    setupTenses();
+
     connect(AntonymRadio, SIGNAL(toggled(bool)), SLOT(otherRadioToggled(bool)));
     connect(ArticleRadio, SIGNAL(toggled(bool)), SLOT(otherRadioToggled(bool)));
     connect(ExampleRadio, SIGNAL(toggled(bool)), SLOT(otherRadioToggled(bool)));
@@ -158,20 +154,18 @@
         Prefs::setSolutionLanguage(LanguageFromList->currentRow());
     }
 
-    if ( m_tenseListWidget ) {
-        QTreeWidgetItem* parentItem = m_tenseListWidget->invisibleRootItem();
-        QStringList activeTenses;
-        for ( int i = 0; i < parentItem->childCount(); i++ ) {
-            QTreeWidgetItem* tenseItem = parentItem->child(i);
-            if ( tenseItem->checkState(0) == Qt::Checked ) {
-                activeTenses.append(tenseItem->text(0));
-            }
+    QTreeWidgetItem* parentItem = \
m_conjugationUi.tenseSelectionTreeWidget->invisibleRootItem(); +    QStringList \
activeTenses; +    for ( int i = 0; i < parentItem->childCount(); i++ ) {
+        QTreeWidgetItem* tenseItem = parentItem->child(i);
+        if ( tenseItem->checkState(0) == Qt::Checked ) {
+            activeTenses.append(tenseItem->text(0));
         }
+    }
 
-        DocumentSettings documentSettings(m_doc->url().url());
-        documentSettings.setConjugationTenses(activeTenses);
-        documentSettings.writeConfig();
-    }
+    DocumentSettings documentSettings(m_doc->url().url());
+    documentSettings.setConjugationTenses(activeTenses);
+    documentSettings.writeConfig();
 }
 
 void ConfigurePracticeWidget::fromLanguageSelected(int identifierFromIndex)
@@ -197,6 +191,7 @@
     if ( LanguageToList->currentRow() < 0 ) {
         LanguageToList->setCurrentRow(0);
     }
+    setupTenses();
 }
 
 void ConfigurePracticeWidget::updateWidgets()
@@ -281,13 +276,28 @@
 
 void ConfigurePracticeWidget::setupTenses()
 {
-    DocumentSettings currentSettings(m_doc->url().url());
+    int index = LanguageFromList->currentRow();
+kDebug() << "tense: " << index;
+    QTreeWidget *tenseListWidget = m_conjugationUi.tenseSelectionTreeWidget;
+    tenseListWidget->clear();
+
+    // stack widget - select the right index
+    if ( m_doc->identifier(index).tenseList().isEmpty() ) {
+        // help message
+        m_conjugationUi.conjugationStack->setCurrentIndex(1);
+        return;
+    }
+
+    // the tense list
+    m_conjugationUi.conjugationStack->setCurrentIndex(0);
+
+    DocumentSettings currentSettings(m_doc->url().url() + QString::number(index));
     currentSettings.readConfig();
     QStringList activeTenses = currentSettings.conjugationTenses();
     QTreeWidgetItem* tenseItem;
 
-    foreach ( const QString &tenseName, m_doc->tenseDescriptions() ) {
-        tenseItem = new QTreeWidgetItem(m_tenseListWidget);
+    foreach ( const QString &tenseName, m_doc->identifier(index).tenseList() ) {
+        tenseItem = new QTreeWidgetItem(tenseListWidget);
         tenseItem->setText(0, tenseName);
         if ( activeTenses.contains( tenseName ) ) {
             tenseItem->setCheckState(0, Qt::Checked);
@@ -295,7 +305,7 @@
             tenseItem->setCheckState(0, Qt::Unchecked);
         }
         tenseItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | \
                Qt::ItemIsUserCheckable);
-        m_tenseListWidget->addTopLevelItem( tenseItem );
+        tenseListWidget->addTopLevelItem( tenseItem );
     }
     ///@todo emit changed when checkstate changed
 }
--- trunk/KDE/kdeedu/parley/src/configure-practice/configurepracticewidget.h \
#847465:847466 @@ -21,6 +21,7 @@
 #define CONFIGUREPRACTICEWIDGET_H
 
 #include "ui_configurepracticewidget.h"
+#include "ui_conjugationoptionswidget.h"
 
 class KEduVocDocument;
 class QStackedLayout;
@@ -74,7 +75,8 @@
         FlashCards
     };
     QStackedLayout* m_optionsStackedLayout;
-    QTreeWidget* m_tenseListWidget;
+    Ui::ConjugationOptionsWidget m_conjugationUi;
+//     QTreeWidget* m_tenseListWidget;
     KEduVocDocument* m_doc;
     bool m_bilingual;
 };
--- trunk/KDE/kdeedu/parley/src/configure-practice/conjugationoptionswidget.ui \
#847465:847466 @@ -5,24 +5,69 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>278</width>
-    <height>206</height>
+    <width>273</width>
+    <height>188</height>
    </rect>
   </property>
-  <layout class="QHBoxLayout" >
+  <layout class="QHBoxLayout" name="horizontalLayout" >
    <item>
-    <widget class="QTreeWidget" name="tenseSelectionTreeWidget" >
-     <property name="rootIsDecorated" >
-      <bool>false</bool>
+    <widget class="QStackedWidget" name="conjugationStack" >
+     <property name="currentIndex" >
+      <number>0</number>
      </property>
-     <property name="itemsExpandable" >
-      <bool>false</bool>
-     </property>
-     <column>
-      <property name="text" >
-       <string>Tenses</string>
+     <widget class="QWidget" name="page" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>265</width>
+        <height>180</height>
+       </rect>
       </property>
-     </column>
+      <layout class="QHBoxLayout" name="horizontalLayout_2" >
+       <item>
+        <widget class="QTreeWidget" name="tenseSelectionTreeWidget" >
+         <property name="rootIsDecorated" >
+          <bool>false</bool>
+         </property>
+         <property name="itemsExpandable" >
+          <bool>false</bool>
+         </property>
+         <column>
+          <property name="text" >
+           <string>Tenses</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="page_2" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>225</width>
+        <height>144</height>
+       </rect>
+      </property>
+      <layout class="QHBoxLayout" name="horizontalLayout_3" >
+       <item>
+        <widget class="QLabel" name="label" >
+         <property name="text" >
+          <string>You have not defined any tenses.
+Use Edit->Languages to configure the tenses in the document and add conjugation \
forms to the verbs you want to practice.</string> +         </property>
+         <property name="alignment" >
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="wordWrap" >
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
     </widget>
    </item>
   </layout>
--- trunk/KDE/kdeedu/parley/src/entry-dialogs/conjugationwidget.cpp #847465:847466
@@ -257,7 +257,7 @@
 
 void ConjugationWidget::tenseEditingFinished()
 {
-    const QStringList& oldTenses = m_doc->tenseDescriptions();
+    const QStringList& oldTenses = m_doc->identifier(m_identifier).tenseList();
     if (!oldTenses.contains(tenseComboBox->currentText())) {
         // add a new tense
         m_doc->identifier(m_identifier).setTense(oldTenses.count(), \
                tenseComboBox->currentText());
--- trunk/KDE/kdeedu/parley/src/scripts/scripting/document.h #847465:847466
@@ -457,8 +457,9 @@
             /**
              * Gets the document tenses
              * @return A string list of all the document tenses
+* @todo port this
              */
-            QStringList tenses() const { return m_doc->tenseDescriptions(); }
+//             QStringList tenses() const { return m_doc->tenseDescriptions(); }
 
             // *** grade methods ***
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic