• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

parley

container.h

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 #ifndef SCRIPTINGCONTAINER_H
00016 #define SCRIPTINGCONTAINER_H
00017 
00018 #include <QObject>
00019 #include <KDebug>
00020 
00021 #include <keduvoccontainer.h>
00022 
00023 namespace Scripting
00024 {
00025 
00034     class Container : public QObject
00035     {
00036             Q_OBJECT
00038             Q_PROPERTY ( QString name READ name WRITE setName )
00040             Q_PROPERTY ( bool inPractice READ inPractice WRITE setInPractice )
00042             Q_PROPERTY ( QString imageUrl READ imageUrl WRITE setImageUrl )
00043 //             Q_PROPERTY ( QVariantList childContainers READ childContainers )
00044         public:
00045 
00046             Container ( KEduVocContainer * container = 0 );
00047 
00048             /* copy constructor for d-pointer safe copying */
00049 //             Container ( const Container &other );
00050 
00051 //             Container ( const QString& name, KEduVocContainer::EnumContainerType type, KEduVocContainer *parent = 0 );
00052 
00053             ~Container();
00054 
00055             /* destructor */
00056 //             virtual ~KEduVocContainer();
00057 
00058             /* assignment operator */
00059 //             KEduVocContainer& operator= ( const KEduVocContainer& );
00060 
00061             /* equality operator */
00062 //             bool operator== ( const KEduVocContainer &other );
00063 
00064 
00065             template <class T, class S>
00066             QVariantList toVariantList ( QList<T*> objList ) const;
00067 
00068             static QList<KEduVocContainer*>  flattenContainer ( KEduVocContainer * root );
00069 
00070             KEduVocContainer * kEduVocContainer() { return m_container; }
00071 
00072             static bool enumToBool ( KEduVocContainer::EnumEntriesRecursive recursive );
00073             static KEduVocContainer::EnumEntriesRecursive boolToEnum ( bool recursive );
00074 
00075             /* set the container name
00076              * @param name text to set for the name
00077              */
00078             void setName ( const QString &name ) { m_container->setName ( name ); }
00079 
00080             /* get the container name */
00081             QString name() { return m_container->name(); }
00082 
00083             void appendChildContainer ( Container *child ) { m_container->appendChildContainer ( child->kEduVocContainer() ); }
00084             void insertChildContainer ( int row, Container *child ) { m_container->insertChildContainer ( row,child->kEduVocContainer() ); }
00085 //             void deleteChildContainer ( int row ) { m_container->deleteChildContainer ( row ); }
00086             void removeChildContainer ( int row ) { m_container->removeChildContainer ( row ); }
00087             Container *childContainer ( int row ) { return new Container ( m_container->childContainer ( row ) ); }
00088 
00089             /*
00090              * Retrieve a child container by its name
00091              * Returns 0 if no container is found
00092              * @param name container name
00093              * @return the child container
00094              */
00095             Container *childContainer ( const QString& name ) { return new Container ( m_container->childContainer ( name ) ); }
00096 
00097             int childContainerCount() const { return m_container->childContainerCount(); }
00098 
00099             bool inPractice() { return m_container->inPractice(); }
00100             void setInPractice ( bool inPractice ) { m_container->setInPractice ( inPractice ); }
00101 
00102             /* get the image url for this container if it exists */
00103             QString imageUrl() { return m_container->imageUrl().path(); }
00104 
00105             /* set the image url for this container
00106              * @param url               url of the image
00107              */
00108             void setImageUrl ( const QString & url ) { m_container->setImageUrl ( url ); }
00109 
00110             /* finds the container with the given name */
00111             KEduVocContainer * findContainer(const QString& name);
00112 
00113             /*
00114              * Removes a translation. This has to be called when a language is removed from a document.
00115              * @param translation
00116              */
00117             void removeTranslation ( int translation ) { return m_container->removeTranslation ( translation ); }
00118 
00119             /*
00120              * Returns a list with all the child containers (lessons)
00121              * @return A list of Container objects
00122              */
00123             QVariantList childContainers();
00124 
00125 
00126         public slots:
00127 
00129             int row() const { return m_container->row(); }
00130 
00131 //             virtual Container *parent() { return new Container ( m_container->parent() ); }
00132 
00133             /*
00134              * The type of this container. @see EnumContainerType
00135              * @return
00136              */
00137 //             KEduVocContainer::EnumContainerType containerType();
00138 
00139             /*
00140              * Set the type of container.
00141              * For convenience by default this is taken over from the parent, so no need to set.
00142              * @param type the new type
00143              */
00144 //             void setContainerType ( KEduVocContainer::EnumContainerType type );
00145 
00152             int expressionsOfGrade ( int translation, unsigned int grade, bool recursive ) { return m_container->expressionsOfGrade ( translation,grade, boolToEnum ( recursive ) ); }
00153 
00159             void resetGrades ( int translation, bool recursive ) { return m_container->resetGrades ( translation, boolToEnum ( recursive ) ); }
00160 
00166             double averageGrade ( int translation, bool recursive ) { return m_container->averageGrade ( translation, boolToEnum ( recursive ) ); }
00167 
00168         protected:
00169             KEduVocContainer * m_container;
00170     };
00171 
00172     //Template functions should not be separated from their definition (must be in the header file)
00173     template <class T, class S>
00174     QVariantList Container::toVariantList ( QList<T*> objList ) const
00175     {
00176         QVariantList list;
00177         foreach ( T * t, objList )
00178         {
00179             QObject * obj = new S ( t );
00180             list.push_back ( qVariantFromValue ( obj ) );
00181         }
00182         return list;
00183     }
00184 
00185 }
00186 
00187 
00188 #endif

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  •     lib
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal