summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmprototypemanager.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmprototypemanager.h
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpovmodeler/pmprototypemanager.h')
-rw-r--r--kpovmodeler/pmprototypemanager.h149
1 files changed, 149 insertions, 0 deletions
diff --git a/kpovmodeler/pmprototypemanager.h b/kpovmodeler/pmprototypemanager.h
new file mode 100644
index 00000000..025b8213
--- /dev/null
+++ b/kpovmodeler/pmprototypemanager.h
@@ -0,0 +1,149 @@
+//-*-C++-*-
+/*
+**************************************************************************
+ description
+ --------------------
+ copyright : (C) 2000-2002 by Andreas Zehender
+ email : zehender@kde.org
+**************************************************************************
+
+**************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+**************************************************************************/
+
+
+#ifndef PMPTMANAGER_H
+#define PMPTMANAGER_H
+
+#include "pmobject.h"
+#include <qdict.h>
+#include <qmap.h>
+#include <qvaluelist.h>
+
+class PMPart;
+
+/**
+ * Description class for declarations types, used by @ref PMPrototypeManager
+ * and @ref PMDeclare
+ */
+class PMDeclareDescription
+{
+public:
+ PMDeclareDescription( ) { }
+ PMDeclareDescription( const PMDeclareDescription& d )
+ {
+ type = d.type;
+ description = d.description;
+ pixmap = d.pixmap;
+ }
+ PMDeclareDescription( PMMetaObject* t, const QString& d, const QString& p )
+ {
+ type = t;
+ description = d;
+ pixmap = p;
+ }
+ PMDeclareDescription& operator=( const PMDeclareDescription& d )
+ {
+ type = d.type;
+ description = d.description;
+ pixmap = d.pixmap;
+ return *this;
+ }
+ PMMetaObject* type;
+ QString description;
+ QString pixmap;
+};
+
+/**
+ * Prototype manager for @ref PMObject.
+ *
+ * This class stores class and inheritance information for each
+ * available object type.
+ *
+ * Each @ref PMPart class holds one instance of this class. The
+ * available objects depend on the loaded plugins.
+ *
+ * Patterns: Prototype
+ */
+class PMPrototypeManager
+{
+public:
+ /**
+ * Creates a prototype manager for the part.
+ */
+ PMPrototypeManager( PMPart* part );
+ /**
+ * Deletes the prototype manager
+ */
+ ~PMPrototypeManager( );
+ /**
+ * Adds the object to the list of prototypes. The prototype becomes
+ * the owner of the object and will be delete immediately by the
+ * prototype manager.
+ */
+ void addPrototype( PMObject* obj );
+ /**
+ * Adds a declaration type. Needed information is the class type,
+ * the @ref description( ) and the @ref pixmap( )
+ */
+ void addDeclarationType( const QString& className,
+ const QString& description,
+ const QString& pixmap );
+ /**
+ * Returns an iterator to the list of available objects
+ */
+ QPtrListIterator<PMMetaObject> prototypeIterator( ) const;
+ /**
+ * Returns an iterator to the list of available declaration types
+ */
+ const QValueList<PMDeclareDescription>& declarationTypes( ) const;
+ /**
+ * Returns a new PMObject by class name
+ */
+ PMObject* newObject( const QString& name ) const;
+ /**
+ * Returns the meta object by class name or 0 if this class does
+ * not exist.
+ * @see PMMetaObject
+ */
+ PMMetaObject* metaObject( const QString& name ) const;
+ /**
+ * Returns true if the class exists
+ */
+ bool existsClass( const QString& name ) const
+ {
+ return metaObject( name );
+ }
+ /**
+ * Returns true if the second class is a base class for
+ * the first class
+ */
+ bool isA( const QString& className, const QString& baseClassName ) const;
+ /**
+ * Returns true if the second class is a base class for
+ * the first class
+ */
+ bool isA( PMMetaObject* c, const QString& baseClassName ) const;
+ /**
+ * Returns the real class if only the lower case version is know.
+ * Used by the xml parser
+ */
+ QString className( const QString& lowercase ) const;
+ /**
+ * Returns a pointer to the part
+ */
+ PMPart* part( ) const { return m_pPart; }
+
+private:
+ QPtrList<PMMetaObject> m_prototypes;
+ QDict<PMMetaObject> m_metaDict;
+ QMap<QString, QString> m_lowerCaseDict;
+ QValueList<PMDeclareDescription> m_declareDescriptions;
+ PMPart* m_pPart;
+};
+#endif