ksync

ksyncview.h

00001 /*
00002     This file is part of ksync.
00003 
00004     Copyright (c) 2001 Cornelius Schumacher <schumacher@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 KSYNCVIEW_H
00022 #define KSYNCVIEW_H
00023 
00024 #include <qptrlist.h>
00025 #include <qwidget.h>
00026 
00027 #include <ktempfile.h>
00028 #include <kurl.h>
00029 #include <kio/job.h>
00030 #include <kdebug.h>
00031 
00032 #include <ksyncer.h>
00033 #include <kdepimmacros.h>
00034 
00035 class QListView;
00036 class QCheckBox;
00037 class QComboBox;
00038 class QPushButton;
00039 class KConfig;
00040 class KURLRequester;
00041 
00042 class KSyncer;
00043 
00044 
00053 class KDE_EXPORT KSyncView : public QWidget
00054 {
00055     Q_OBJECT
00056   public:
00058     KSyncView(QWidget *parent = 0, const char *name=0);
00060     ~KSyncView();
00061 
00062     enum { TypeCalendar, TypeBookmarks, TypeAddressBook };
00063 
00065     void print(QPrinter *pPrinter);
00066 
00067     void readConfig(KConfig *);
00068     void readTypeConfig(KConfig *);
00069     void writeConfig(KConfig *);
00070     void writeTypeConfig(KConfig *);
00071 
00072     void synceeLoadError();
00073     void synceeLoaded();
00074 
00075   private slots:
00076     void addSource();
00077     void removeSource();
00078     void showSource();
00079     void doSync();
00080     void checkSyncBack();
00081     void reloadSyncees();
00082     void finishSync();
00083     void jobFinished(KIO::Job *job);
00084     void slotSelectionChanged();  
00085   private:
00086     void checkFinish();
00087     KSyncee *createSyncee(const KURL &);
00088     QString createTempFile();
00089     
00090     QListView *mSourceListView;
00091     QComboBox *mTypeCombo;
00092     KURLRequester *mTargetReq;
00093     QCheckBox *mSyncBackCheck;
00094     
00095     int mCurrentType;
00096     
00097     KSyncer *mSyncer;
00098     KSyncee *mTarget;
00099     QPtrList<KTempFile> mTmpFiles;
00100     int mLoadCount;
00101     bool mLoadError;
00102     QPushButton *showButton,*removeButton;
00103 };
00104 
00105 
00106 class SynceeLoader : public QObject
00107 {
00108     Q_OBJECT
00109   public:
00110     SynceeLoader(KSyncView *parent,KSyncee *syncee,const QString &filename) :
00111       mSyncee(syncee), mParent(parent)
00112     {
00113       mSyncee->setFilename(filename);
00114     }
00115     virtual ~SynceeLoader() {}
00116     
00117   public slots:
00118     void loadSyncee(KIO::Job *job)
00119     {
00120       if (job->error()) {
00121         job->showErrorDialog(mParent);
00122         mParent->synceeLoadError();
00123       } else {
00124         loadSyncee();
00125         mParent->synceeLoaded();
00126       }
00127       delete this;
00128     }
00129     
00130     void loadSyncee()
00131     {
00132       kdDebug() << "SynceeLoader::loadSyncee(): " << mSyncee->filename()
00133                 << endl;
00134       if (!mSyncee->load()) {
00135         mParent->synceeLoadError();
00136       }
00137     }
00138     
00139   private:
00140     KSyncee *mSyncee;
00141     KSyncView *mParent;
00142 };
00143 
00144 #endif // KSYNCVIEW_H
KDE Home | KDE Accessibility Home | Description of Access Keys