kitchensync

filter.h

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2002 Holger Freyther <freyther@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 #ifndef KSYNC_FILTER_H
00022 #define KSYNC_FILTER_H
00023 
00024 #include <qobject.h>
00025 #include <qstringlist.h>
00026 #include <qptrlist.h>
00027 
00028 #include <klibloader.h>
00029 #include <kgenericfactory.h>
00030 
00031 #include <syncer.h>
00032 
00033 class KConfig;
00034 class QWidget;
00035 
00036 #define K_EXPORT_KS_FILTER_CATALOG( libname, FilterClass, catalog ) \
00037  class KDE_NO_EXPORT localFilterFactory : public FilterFactory \
00038  { \
00039    Filter *createFilter( QObject *parent ) \
00040    { \
00041      const char *cat = catalog; \
00042      if ( cat ) \
00043        KGlobal::locale()->insertCatalogue( cat ); \
00044      return new FilterClass( parent ); \
00045    } \
00046  }; \
00047  K_EXPORT_COMPONENT_FACTORY( libname, localFilterFactory )
00048 
00049 
00050 #define K_EXPORT_KS_FILTER( libname, FilterClass ) \
00051     K_EXPORT_KS_FILTER_CATALOG( libname, FilterClass, NULL )
00052 
00053 
00054 namespace KSync {
00055 
00077 class KDE_EXPORT Filter : public QObject
00078 {
00079   public:
00080     typedef QValueList<Filter*> List;
00081   
00082     Filter( QObject *parent, const char *name );
00083     virtual ~Filter();
00084   
00092     void load( KConfig *config );
00093 
00094     void save( KConfig* );
00095 
00102     QString name() const;
00103     virtual QString type() const = 0;
00104   
00115     virtual bool supports( Syncee *syncee ) = 0;
00116 
00124     virtual QWidget *configWidget( QWidget *parent ) = 0;
00125 
00131     virtual void configWidgetClosed( QWidget *widget ) = 0;
00132 
00133     virtual void convert( Syncee* ) = 0;
00134     virtual void reconvert( Syncee* ) = 0;
00135   
00136   protected:
00145     KConfig *config();
00146 
00155     void setName( const QString& name );
00156   
00157   private:
00164     virtual void doLoad() = 0;
00165 
00172     virtual void doSave() = 0;
00173 
00174     KConfig *mConfig;
00175     QString mName;
00176 };
00177 
00178 class FilterFactory : public KLibFactory
00179 {
00180   public:
00181     virtual Filter *createFilter( QObject *parent ) = 0;
00182 
00183   protected:
00184     virtual QObject* createObject( QObject*, const char*, const char*,
00185                                    const QStringList & )
00186     {
00187       return 0;
00188     }
00189 };
00190 
00191 }
00192 
00193 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys