summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmviewfactory.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/pmviewfactory.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/pmviewfactory.h')
-rw-r--r--kpovmodeler/pmviewfactory.h145
1 files changed, 145 insertions, 0 deletions
diff --git a/kpovmodeler/pmviewfactory.h b/kpovmodeler/pmviewfactory.h
new file mode 100644
index 00000000..b24814cf
--- /dev/null
+++ b/kpovmodeler/pmviewfactory.h
@@ -0,0 +1,145 @@
+/*
+**************************************************************************
+ description
+ --------------------
+ copyright : (C) 2003 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 PMVIEWFACTORY_H
+#define PMVIEWFACTORY_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qstring.h>
+#include <qptrlist.h>
+#include <qdict.h>
+#include <kstaticdeleter.h>
+
+class PMViewBase;
+class QWidget;
+class PMPart;
+class QDomElement;
+class PMViewOptions;
+class PMViewOptionsWidget;
+
+/**
+ * Factory and description class for one view type
+ * @see PMViewFactory
+ */
+class PMViewTypeFactory
+{
+public:
+ /**
+ * Default constructor
+ */
+ PMViewTypeFactory( ) { }
+ /**
+ * Destructor
+ */
+ virtual ~PMViewTypeFactory( ) { }
+ /**
+ * Returns the id for the view type. Choose an unique name.
+ */
+ virtual QString viewType( ) const = 0;
+ /**
+ * Returns a i18n'ed description for the view type
+ */
+ virtual QString description( ) const = 0;
+ /**
+ * Returns a i18n'ed description for the view type, dependent
+ * on the options. Calls the method above by default.
+ */
+ virtual QString description( PMViewOptions* ) const
+ {
+ return description( );
+ }
+ /**
+ * Returns the icon name for the view
+ */
+ virtual QString iconName( ) const = 0;
+ /**
+ * Returns a new view instance
+ */
+ virtual PMViewBase* newInstance( QWidget* parent, PMPart* part ) const = 0;
+ /**
+ * Creates a config object for the view type.
+ * If the view doesn't have special attributes, the function returns 0;
+ */
+ virtual PMViewOptions* newOptionsInstance( ) const { return 0; }
+ /**
+ * Creates a widget to configure the custom options
+ */
+ virtual PMViewOptionsWidget* newOptionsWidget( QWidget*, PMViewOptions* )
+ {
+ return 0;
+ }
+};
+
+
+/**
+ * Factory class for KPovModeler views.
+ *
+ * Plugins can add new view types by adding new
+ * @ref PMViewTypeFactory objects.
+ */
+class PMViewFactory
+{
+public:
+ /**
+ * Destructor
+ */
+ ~PMViewFactory( );
+ /**
+ * Returns the factory instance
+ */
+ static PMViewFactory* theFactory( );
+
+ /**
+ * Adds a new view type
+ *
+ * The factory becomes the owner of the object
+ */
+ void addViewType( PMViewTypeFactory* vt );
+ /**
+ * Returns a new view of type viewType if available
+ */
+ PMViewBase* newViewInstance( const QString& viewType,
+ QWidget* parent, PMPart* part ) const;
+ /**
+ * Returns a new view option instance for the given view type
+ */
+ PMViewOptions* newOptionsInstance( const QString& viewType ) const;
+ /**
+ * Returns the factory for the given view type
+ */
+ PMViewTypeFactory* viewFactory( const QString& viewType ) const;
+ /**
+ * Returns the list of available view types
+ */
+ const QPtrList<PMViewTypeFactory>& viewTypes( ) const;
+private:
+ /**
+ * Constructor
+ */
+ PMViewFactory( );
+
+ QPtrList<PMViewTypeFactory> m_viewTypes;
+ QDict<PMViewTypeFactory> m_dict;
+
+ static PMViewFactory* s_pInstance;
+ static KStaticDeleter<PMViewFactory> s_staticDeleter;
+};
+
+#endif