]> Git trees. - libqmvoc.git/commitdiff
Start a drag and drop implemntation for the lesson model/view.
authorFrederik Gladhorn <gladhorn@kde.org>
Sat, 15 Dec 2007 14:19:40 +0000 (14:19 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Sat, 15 Dec 2007 14:19:40 +0000 (14:19 +0000)
Moving lessons around works, adding them as child has a tendency to add
the first instead of the selected lesson. Probably trivial.
Lots of cleanup.
WordType class has now always WordType as type, the special types are
handled in the class by a function.

svn path=/branches/work/kdeedu_parley/libkdeedu/; revision=748787

keduvocdocument/keduvoccontainer.cpp
keduvocdocument/keduvoccontainer.h
keduvocdocument/keduvocdocument.cpp
keduvocdocument/keduvockvtml2reader.cpp
keduvocdocument/keduvockvtml2writer.cpp
keduvocdocument/keduvoclesson.cpp
keduvocdocument/keduvocwordtype.cpp
keduvocdocument/keduvocwordtype.h

index 75ee76eaccb5e33cb93a6a3944ee24e43d948e7d..ba877f4fb5e05c49d9cbb4bf77c37db237622b91 100644 (file)
@@ -70,6 +70,7 @@ KEduVocContainer::~KEduVocContainer()
 void KEduVocContainer::appendChildContainer(KEduVocContainer * child)
 {
     d->m_childContainers.append(child);
+    child->d->m_parentContainer = this;
 }
 
 KEduVocContainer * KEduVocContainer::childContainer(int row)
@@ -78,12 +79,17 @@ KEduVocContainer * KEduVocContainer::childContainer(int row)
 }
 
 
-void KEduVocContainer::removeChildContainer(int row)
+void KEduVocContainer::deleteChildContainer(int row)
 {
     kDebug() << "Delete of container - check entry deletion!";
     delete d->m_childContainers.takeAt(row);
 }
 
+void KEduVocContainer::removeChildContainer(int row)
+{
+    d->m_childContainers.removeAt(row);
+}
+
 
 int KEduVocContainer::childContainerCount() const
 {
@@ -211,4 +217,10 @@ KEduVocContainer * KEduVocContainer::childOfType(KEduVocContainer::EnumContainer
     return 0;
 }
 
+void KEduVocContainer::insertChildContainer(int row, KEduVocContainer * child)
+{
+    d->m_childContainers.insert(row, child);
+}
+
+
 
index 885928d20a591206f80ab46fbde6f56f34d8a754..0de1ec0616a09059a6f6ed227d2038cd341a735c 100644 (file)
@@ -33,22 +33,17 @@ public:
     /// @todo let wordtype have only one type and the actual types in a different function
     enum EnumContainerType{
         Container,
-        LessonContainer,
-        LeitnerContainer,
-        WordTypeContainer,
-        WordTypeNounContainer,
-        WordTypeNounMaleContainer,
-        WordTypeNounFemaleContainer,
-        WordTypeNounNeutralContainer,
-        WordTypeVerbContainer,
-        WordTypeAdjectiveContainer,
-        WordTypeAdverbContainer
+        Lesson,
+        WordType,
+        Leitner
     };
 
     /** default constructor */
-    explicit KEduVocContainer(const QString& name, EnumContainerType type = LessonContainer, KEduVocContainer *parent = 0);
+    explicit KEduVocContainer(const QString& name, EnumContainerType type, KEduVocContainer *parent = 0);
 
     void appendChildContainer(KEduVocContainer *child);
+    void insertChildContainer(int row, KEduVocContainer *child);
+    void deleteChildContainer(int row);
     void removeChildContainer(int row);
     KEduVocContainer *childContainer(int row);
 
index 2b66dd71799715513b4d96317d784be925a9c85a..05b45b8cb546a33e46981ee97a571e3964167711 100644 (file)
@@ -83,8 +83,8 @@ public:
 
     QStringList               m_tenseDescriptions;
     QSet<QString>             m_usages;
-// use the name of the root lesson as title
-//     QString                   m_title;
+
+    QString                   m_title;
     QString                   m_author;
     QString                   m_license;
     QString                   m_comment;
@@ -112,7 +112,7 @@ void KEduVocDocument::KEduVocDocumentPrivate::init()
         delete m_lessonContainer;
     }
     m_lessonContainer = new KEduVocLesson("root");
-    m_lessonContainer->setContainerType(KEduVocLesson::LessonContainer);
+    m_lessonContainer->setContainerType(KEduVocLesson::Lesson);
     if ( m_wordTypeContainer ) {
         delete m_wordTypeContainer;
     }
@@ -128,6 +128,7 @@ void KEduVocDocument::KEduVocDocumentPrivate::init()
     m_querytrans = "";
     m_url.setFileName( i18n( "Untitled" ) );
     m_author = "";
+    m_title = "";
     m_comment = "";
     m_version = "";
     m_generator = "";
@@ -748,13 +749,13 @@ QString KEduVocDocument::title() const
     if ( d->m_lessonContainer->name().isEmpty() )
         return d->m_url.fileName();
     else
-        return d->m_lessonContainer->name();
+        return d->m_title;
 }
 
 
 void KEduVocDocument::setTitle( const QString & title )
 {
-    d->m_lessonContainer->setName(title.simplified());
+    d->m_title = title;
 }
 
 
index fb6a8ef1f6bf461110121b141bf69d7ce3cb813d..d0a34ae4546e7ade24a776a326d709d1cc7f3b10 100644 (file)
@@ -532,25 +532,25 @@ bool KEduVocKvtml2Reader::readWordType( KEduVocWordType* parentContainer, QDomEl
     if ( !specialType.isEmpty() ) {
         // get the localized version
         if ( specialType == KVTML_SPECIALWORDTYPE_NOUN ) {
-            wordTypeContainer->setContainerType(KEduVocLesson::WordTypeNounContainer);
+            wordTypeContainer->setWordType(KEduVocWordType::Noun);
         }
         if ( specialType == KVTML_SPECIALWORDTYPE_VERB ) {
-            wordTypeContainer->setContainerType(KEduVocLesson::WordTypeVerbContainer);
+            wordTypeContainer->setWordType(KEduVocWordType::Verb);
         }
         if ( specialType == KVTML_SPECIALWORDTYPE_ADVERB ) {
-            wordTypeContainer->setContainerType(KEduVocLesson::WordTypeAdverbContainer);
+            wordTypeContainer->setWordType(KEduVocWordType::Adverb);
         }
         if ( specialType == KVTML_SPECIALWORDTYPE_ADJECTIVE ) {
-            wordTypeContainer->setContainerType(KEduVocLesson::WordTypeAdjectiveContainer);
+            wordTypeContainer->setWordType(KEduVocWordType::Adjective);
         }
         if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_MALE ) {
-            wordTypeContainer->setContainerType(KEduVocLesson::WordTypeNounMaleContainer);
+            wordTypeContainer->setWordType(KEduVocWordType::NounMale);
         }
         if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_FEMALE ) {
-            wordTypeContainer->setContainerType(KEduVocLesson::WordTypeNounFemaleContainer);
+            wordTypeContainer->setWordType(KEduVocWordType::NounFemale);
         }
         if ( specialType == KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL ) {
-            wordTypeContainer->setContainerType(KEduVocLesson::WordTypeNounNeutralContainer);
+            wordTypeContainer->setWordType(KEduVocWordType::NounNeutral);
         }
     } // special type
 
index ee8daf5c62a288fb7c43a09ec19bb16b6881649a..dcefe478f6f809e0ca834ca40a0a87df0d051f21 100644 (file)
@@ -275,26 +275,26 @@ bool KEduVocKvtml2Writer::writeWordTypes( QDomElement &typesElement, KEduVocWord
         QDomElement typeDefinitionElement = m_domDoc.createElement( KVTML_CONTAINER );
         typeDefinitionElement.appendChild( newTextElement( KVTML_NAME, wordType->name() ) );
 
-        switch (wordType->containerType()) {
-        case KEduVocLesson::WordTypeNounContainer:
+        switch (wordType->wordType()) {
+        case KEduVocWordType::Noun:
             typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN ) );
             break;
-        case KEduVocLesson::WordTypeNounMaleContainer:
+        case KEduVocWordType::NounMale:
             typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN_MALE ) );
             break;
-        case KEduVocLesson::WordTypeNounFemaleContainer:
+        case KEduVocWordType::NounFemale:
             typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN_FEMALE ) );
             break;
-        case KEduVocLesson::WordTypeNounNeutralContainer:
+        case KEduVocWordType::NounNeutral:
             typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_NOUN_NEUTRAL ) );
             break;
-        case KEduVocLesson::WordTypeVerbContainer:
+        case KEduVocWordType::Verb:
             typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_VERB ) );
             break;
-        case KEduVocLesson::WordTypeAdjectiveContainer:
+        case KEduVocWordType::Adjective:
             typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_ADJECTIVE ) );
             break;
-        case KEduVocLesson::WordTypeAdverbContainer:
+        case KEduVocWordType::Adverb:
             typeDefinitionElement.appendChild( newTextElement( KVTML_SPECIALWORDTYPE, KVTML_SPECIALWORDTYPE_ADVERB ) );
             break;
         default:
index 1cd04cb98154335da0f0b932549313f04a3d7721..472242a9d2202a83ffbc01c0402f8679a73f6ea0 100644 (file)
@@ -37,7 +37,7 @@ KEduVocLesson::Private::~ Private()
 }
 
 KEduVocLesson::KEduVocLesson(const QString& name, KEduVocContainer *parent)
-        : d( new Private ), KEduVocContainer(name, LessonContainer, parent)
+        : d( new Private ), KEduVocContainer(name, Lesson, parent)
 {
 }
 
index 7cc324b121d906a881d956dbe88208002c600484..1c48278cb8b1f22bd359f9fc2906896bdfd067a1 100644 (file)
 class KEduVocWordType::Private
 {
 public:
+    EnumWordType m_wordType;
     // entries
     QList<KEduVocTranslation*> m_translations;
 };
 
 
 KEduVocWordType::KEduVocWordType(const QString& name, KEduVocWordType *parent)
-        : d( new Private ), KEduVocContainer(name, WordTypeContainer, parent)
+        : d( new Private ), KEduVocContainer(name, WordType, parent)
 {
+    d->m_wordType = General;
 }
 
 KEduVocWordType::KEduVocWordType( const KEduVocWordType &other )
@@ -89,4 +91,14 @@ KEduVocExpression * KEduVocWordType::entry(int row)
     return entries().value(row);
 }
 
+void KEduVocWordType::setWordType(EnumWordType type)
+{
+    d->m_wordType = type;
+}
+
+KEduVocWordType::EnumWordType KEduVocWordType::wordType() const
+{
+    return d->m_wordType;
+}
+
 
index 4c8d511d555c34d4fe26e15d8a57fe623506e0e0..7c9d4e3ab739ddb8cd2e204c90d6c9b0671401ae 100644 (file)
@@ -31,6 +31,19 @@ class KEduVocTranslation;
 class KEDUVOCDOCUMENT_EXPORT KEduVocWordType :public KEduVocContainer
 {
 public:
+
+    enum EnumWordType {
+        General,
+        Noun,
+        NounMale,
+        NounFemale,
+        NounNeutral,
+        Verb,
+        Adjective,
+        Adverb
+    };
+
+
     /** default constructor */
     explicit KEduVocWordType(const QString& name, KEduVocWordType *parent = 0);
 
@@ -43,6 +56,10 @@ public:
     /** assignment operator */
     KEduVocWordType& operator= ( const KEduVocWordType& );
 
+    void setWordType(EnumWordType type);
+    KEduVocWordType::EnumWordType wordType() const;
+
+
     KEduVocTranslation * translation(int row);
 
     /** get a list of all entries in the lesson */