parley
container.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 00003 Copyright 2008 Avgoustinos Kadis <avgoustinos.kadis@kdemail.net> 00004 00005 ***************************************************************************/ 00006 00007 /*************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 #include "container.h" 00016 00017 namespace Scripting 00018 { 00019 00020 Container::Container ( KEduVocContainer * container ) 00021 : QObject(), m_container ( container ) 00022 { 00023 00024 } 00025 00026 // Container::Container ( const QString& name, EnumContainerType type, KEduVocContainer *parent = 0 ) 00027 // : QObject() 00028 // { 00029 // m_container = new KEduVocContainer ( name,type,parent ); 00030 // } 00031 00032 // Container::Container ( const Container &other ) 00033 // : QObject() 00034 // { 00035 // m_container = new KEduVocLesson ( other.kEduVocLesson() ); 00036 // } 00037 00038 00039 Container::~Container() 00040 { 00041 } 00042 00043 bool Container::enumToBool ( KEduVocContainer::EnumEntriesRecursive recursive ) 00044 { 00045 if ( recursive == KEduVocContainer::Recursive ) 00046 return true; 00047 return false; 00048 } 00049 00050 KEduVocContainer::EnumEntriesRecursive Container::boolToEnum ( bool recursive ) 00051 { 00052 if ( recursive ) 00053 return KEduVocContainer::Recursive; 00054 return KEduVocContainer::NotRecursive; 00055 } 00056 00057 QVariantList Container::childContainers() 00058 { 00059 return toVariantList<KEduVocContainer,Container> ( m_container->childContainers() ); 00060 } 00061 00062 QList<KEduVocContainer*> Container::flattenContainer ( KEduVocContainer * root ) 00063 { 00064 QList<KEduVocContainer*> list; 00065 if ( root ) 00066 { 00067 list << root; 00068 foreach ( KEduVocContainer * child, root->childContainers() ) 00069 list += flattenContainer ( child ); 00070 } 00071 return list; 00072 } 00073 00074 KEduVocContainer * Container::findContainer ( const QString& name ) 00075 { 00076 QList<KEduVocContainer*> list = flattenContainer(m_container); 00077 foreach (KEduVocContainer * container, list) 00078 if (container->name() == name) 00079 return container; 00080 return 0; 00081 } 00082 00083 00084 }
KDE 4.4 API Reference