diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 47d455dd55be855e4cc691c32f687f723d9247ee (patch) | |
tree | 52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmiomanager.h | |
download | tdegraphics-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/pmiomanager.h')
-rw-r--r-- | kpovmodeler/pmiomanager.h | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/kpovmodeler/pmiomanager.h b/kpovmodeler/pmiomanager.h new file mode 100644 index 00000000..ac3b78eb --- /dev/null +++ b/kpovmodeler/pmiomanager.h @@ -0,0 +1,184 @@ +/* +************************************************************************** + 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 PMIOMANAGER +#define PMIOMANAGER + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qstring.h> +#include <qstringlist.h> +#include <qptrlist.h> +#include <qdict.h> + +class PMParser; +class PMSerializer; +class PMRenderer; +class PMPart; + +class QIODevice; + +/** + * Description class for input and output formats. + * + * A format may provide the following services: + * + * Import: The class can provide a parser to load and import data + * + * Export: The class can provide a output device to export and save data + * + * Renderer: A renderer exists to render the exported data + * + * The class @ref PMIOManager stores a list of instances + * of this class + */ +class PMIOFormat +{ +public: + /** + * Format type enum + */ + enum Services { Import = 1, Export = 2, Renderer = 4, + AllServices = Import | Export | Renderer }; + /** + * Default constructor + */ + PMIOFormat( ); + /** + * Destructor + */ + virtual ~PMIOFormat( ); + + /** + * Returns an unique name of this format. + */ + virtual QString name( ) const = 0; + /** + * Returns a translated description of this format + */ + virtual QString description( ) const = 0; + /** + * Returns the supported services + * (a bitwise combination of the Services enum values) + */ + virtual int services( ) const = 0; + /** + * Returns a parser to parse the io device. + * + * The caller is responsible to delete the returned parser. + */ + virtual PMParser* newParser( PMPart*, QIODevice* ) const + { + return 0; + }; + /** + * Returns a parser to parse the byte array. + * + * The caller is responsible to delete the returned parser. + */ + virtual PMParser* newParser( PMPart*, const QByteArray& ) const + { + return 0; + }; + /** + * Returns an output device to export objects or the complete + * scene to the given io device. + * + * The caller is responsible to delete the returned device + */ + virtual PMSerializer* newSerializer( QIODevice* ) + { + return 0; + } + /** + * Returns a new renderer + */ + virtual PMRenderer* newRenderer( PMPart* ) const + { + return 0; + } + /** + * Returns the mime type for this format + */ + virtual QString mimeType( ) const + { + return QString::null; + } + /** + * Returns a list of patterns for the import file dialog + */ + virtual QStringList importPatterns( ) const + { + return QStringList( ); + } + /** + * Returns a list of patterns for the export file dialog + */ + virtual QStringList exportPatterns( ) const + { + return QStringList( ); + } +}; + +/** + * Manager class that handles all available input and output formats + * as well as renderers for one part + */ +class PMIOManager +{ +public: + /** + * Creates an io manager for the part + */ + PMIOManager( PMPart* part ); + /** + * Deletes the io manager + */ + ~PMIOManager( ); + + /** + * Adds a new format + */ + void addFormat( PMIOFormat* format ); + /** + * Removes a format by name + */ + void removeFormat( const QString& name ); + + /** + * Returns the list of registered io formats + */ + const QPtrList<PMIOFormat>& formats( ) const { return m_formats; } + /** + * Returns a view type by name + */ + PMIOFormat* format( const QString& name ) const; + /** + * Returns the first io format that can handle the mime type + * or 0 if there is none + */ + PMIOFormat* formatForMimeType( const QString& mime ) const; + +private: + QPtrList<PMIOFormat> m_formats; + QDict<PMIOFormat> m_dict; + PMPart* m_pPart; +}; + +#endif |