00001 /* 00002 * GPLv2 00003 */ 00004 00005 #ifndef P_SLAVE_INTER_FACE_H 00006 #define P_SLAVE_INTER_FACE_H 00007 00008 #include <qfileinfo.h> 00009 #include <qstringlist.h> 00010 #include <qmap.h> 00011 00016 class QPixmap; 00017 class SlaveInterface { 00018 public: 00019 SlaveInterface(const QStringList& imageformats); 00020 virtual ~SlaveInterface(); 00021 00022 QStringList imageFormats()const; 00023 bool supports( const QString& )const; 00024 virtual QString iconViewName(const QString&) = 0; 00025 virtual QString fullImageInfo(const QString& )= 0; 00026 virtual QPixmap pixmap( const QString&, int width, int height ) = 0; 00027 private: 00028 QStringList m_list; 00029 }; 00030 00031 inline bool SlaveInterface::supports( const QString& str)const { 00032 return m_list.contains( QFileInfo( str ).extension(false).lower() ); 00033 } 00034 00035 typedef SlaveInterface* (*phunkSlaveCreateFunc )(); 00036 typedef QMap<QString,phunkSlaveCreateFunc> SlaveMap; 00037 00038 typedef QMap<QString, SlaveInterface*> SlaveObjects; 00039 00040 SlaveMap* slaveMap(); 00041 SlaveObjects* slaveObjects(); 00042 00043 00044 00045 #define PHUNK_VIEW_INTERFACE( NAME, IMPL ) \ 00046 static SlaveInterface *create_ ## IMPL() { \ 00047 return new IMPL(); \ 00048 } \ 00049 static SlaveMap::Iterator dummy_ ## IMPL = slaveMap()->insert( NAME, create_ ## IMPL ); 00050 00051 00052 00053 #endif
1.4.2