synchelper.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <qapplication.h>
00023 #include <qthread.h>
00024
00025 #include "synchelper.h"
00026
00027 using namespace KSync;
00028
00029 namespace {
00030 struct DoneEvent : public QCustomEvent {
00031 DoneEvent() : QCustomEvent( 6666 ) {
00032 }
00033 ~DoneEvent() {
00034 }
00035 };
00036 class SyncThread : public QThread {
00037 public:
00038 SyncThread(Syncer*, QObject* obj );
00039 ~SyncThread();
00040 void run();
00041 private:
00042 Syncer* m_sync;
00043 QObject* m_obj;
00044 };
00045 SyncThread::SyncThread( Syncer* syn, QObject* obj) {
00046 m_sync = syn;
00047 m_obj = obj;
00048 }
00049 SyncThread::~SyncThread() {
00050 }
00051 void SyncThread::run() {
00052 m_sync->sync();
00053
00054 QApplication::postEvent( m_obj, new DoneEvent );
00055 }
00056
00057 }
00058 struct SyncHelper::Data {
00059 Syncer *syncer;
00060 };
00061
00062 SyncHelper::SyncHelper( SyncUi* ui, SyncAlgorithm* al) {
00063 data = new Data;
00064 data->syncer = new Syncer( ui, al );
00065 }
00066 SyncHelper::~SyncHelper() {
00067 delete data->syncer;
00068 delete data;
00069 }
00070 void SyncHelper::sync() {
00071 SyncThread thread(data->syncer, this );
00072 thread.start();
00073 }
00074 void SyncHelper::addSyncee( Syncee* syn ) {
00075 data->syncer->addSyncee( syn);
00076 }
00077 void SyncHelper::customEvent( QCustomEvent* ) {
00078 emit done();
00079 }
00080
00081 #include "synchelper.moc"
This file is part of the documentation for kitchensync Library Version 3.3.2.