00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "changerecorder.h"
00021 #include "changerecorder_p.h"
00022
00023 #include <kdebug.h>
00024 #include <QtCore/QSettings>
00025
00026 using namespace Akonadi;
00027
00028 ChangeRecorder::ChangeRecorder( QObject * parent ) :
00029 Monitor( new ChangeRecorderPrivate( this ), parent )
00030 {
00031 }
00032
00033 ChangeRecorder::ChangeRecorder( ChangeRecorderPrivate *privateclass, QObject * parent ) :
00034 Monitor( privateclass, parent )
00035 {
00036 }
00037
00038 ChangeRecorder::~ ChangeRecorder()
00039 {
00040 Q_D( ChangeRecorder );
00041 d->saveNotifications();
00042 }
00043
00044 void ChangeRecorder::setConfig(QSettings * settings)
00045 {
00046 Q_D( ChangeRecorder );
00047 if ( settings ) {
00048 d->settings = settings;
00049 Q_ASSERT( d->pendingNotifications.isEmpty() );
00050 d->loadNotifications();
00051 } else if ( d->settings ) {
00052 d->saveNotifications();
00053 d->settings = settings;
00054 }
00055 }
00056
00057 void ChangeRecorder::replayNext()
00058 {
00059 Q_D( ChangeRecorder );
00060 if ( !d->pendingNotifications.isEmpty() ) {
00061 const NotificationMessage msg = d->pendingNotifications.first();
00062 if ( d->ensureDataAvailable( msg ) )
00063 d->emitNotification( msg );
00064 else
00065 d->pipeline.enqueue( msg );
00066 } else {
00067
00068
00069
00070 emit nothingToReplay();
00071 }
00072 d->saveNotifications();
00073 }
00074
00075 bool ChangeRecorder::isEmpty() const
00076 {
00077 Q_D( const ChangeRecorder );
00078 return d->pendingNotifications.isEmpty();
00079 }
00080
00081 void ChangeRecorder::changeProcessed()
00082 {
00083 Q_D( ChangeRecorder );
00084 if ( !d->pendingNotifications.isEmpty() )
00085 d->pendingNotifications.removeFirst();
00086 d->saveNotifications();
00087 }
00088
00089 void ChangeRecorder::setChangeRecordingEnabled( bool enable )
00090 {
00091 Q_D( ChangeRecorder );
00092 if ( d->enableChangeRecording == enable )
00093 return;
00094 d->enableChangeRecording = enable;
00095 if ( !enable )
00096 d->dispatchNotifications();
00097 }
00098
00099 #include "changerecorder.moc"