From: Frederik Gladhorn Date: Fri, 4 Jan 2008 23:11:36 +0000 (+0000) Subject: Enable word type finding code again (only within word type container class). Make... X-Git-Tag: v4.0.71~93^2~3 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=92fc3cb44e6b90f98950d716ed801cfa33086ecd;p=libqmvoc.git Enable word type finding code again (only within word type container class). Make use of it for comparison forms. svn path=/branches/work/kdeedu_parley/libkdeedu/; revision=757439 --- diff --git a/keduvocdocument/keduvocwordtype.cpp b/keduvocdocument/keduvocwordtype.cpp index 74c50f6..be4b32b 100644 --- a/keduvocdocument/keduvocwordtype.cpp +++ b/keduvocdocument/keduvocwordtype.cpp @@ -101,17 +101,16 @@ KEduVocWordType::EnumWordType KEduVocWordType::wordType() const return d->m_wordType; } -///@todo provide a function to find a certain word type container... used for "make this a noun" buttons -// KEduVocContainer * KEduVocContainer::childOfType(KEduVocContainer::EnumContainerType type) -// { -// if(containerType()==type) { -// return this; -// } -// foreach(KEduVocContainer* child, childContainers()) { -// KEduVocContainer* result = child->childOfType(type); -// if(result) { -// return result; -// } -// } -// return 0; -// } +KEduVocWordType* KEduVocWordType::childOfType(KEduVocWordType::EnumWordType type) +{ + if(wordType()==type) { + return this; + } + foreach(KEduVocContainer* child, childContainers()) { + KEduVocWordType* result = static_cast(child)->childOfType(type); + if(result) { + return result; + } + } + return 0; +} diff --git a/keduvocdocument/keduvocwordtype.h b/keduvocdocument/keduvocwordtype.h index a8c9b6b..0a82a8c 100644 --- a/keduvocdocument/keduvocwordtype.h +++ b/keduvocdocument/keduvocwordtype.h @@ -60,7 +60,7 @@ public: KEduVocWordType::EnumWordType wordType() const; -// KEduVocContainer* childOfType(KEduVocContainer::EnumContainerType type); + KEduVocWordType* childOfType(KEduVocWordType::EnumWordType type); KEduVocTranslation * translation(int row); @@ -72,8 +72,6 @@ public: /** get the number of entries in the lesson */ int entryCount(); -// KEduVocWordType *parent(); - private: class Private; Private * const d;