ktimer
ktimer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KTIMER_H_INCLUDED
00020 #define KTIMER_H_INCLUDED
00021
00022 #include <QDialog>
00023 #include <QWidget>
00024 #include <QProcess>
00025 #include "ui_prefwidget.h"
00026
00027 class QTreeWidgetItem;
00028 class KConfig;
00029
00030 class KTimerJob : public QObject {
00031 Q_OBJECT
00032
00033 public:
00034 KTimerJob( QObject *parent=0);
00035 virtual ~KTimerJob();
00036
00037 enum States { Stopped, Paused, Started };
00038
00039 unsigned delay() const;
00040 QString command() const;
00041 bool loop() const;
00042 bool oneInstance() const;
00043 unsigned value() const;
00044 States state() const;
00045 void *user();
00046 void setUser( void *user );
00047
00048 void load( KConfig *cfg, const QString& grp );
00049 void save( KConfig *cfg, const QString& grp );
00050
00051 public slots:
00052 void setDelay( unsigned int sec );
00053 void setDelay( int sec );
00054 void setCommand( const QString &cmd );
00055 void setLoop( bool loop );
00056 void setOneInstance( bool one );
00057 void setValue( unsigned int value );
00058 void setValue( int value );
00059 void setState( States state );
00060
00061 void pause();
00062 void stop();
00063 void start();
00064
00065 signals:
00066 void stateChanged( KTimerJob *job, States state );
00067 void delayChanged( KTimerJob *job, unsigned int sec );
00068 void commandChanged( KTimerJob *job, const QString &cmd );
00069 void loopChanged( KTimerJob *job, bool loop );
00070 void oneInstanceChanged( KTimerJob *job, bool one );
00071 void valueChanged( KTimerJob *job, unsigned int value );
00072
00073 void changed( KTimerJob *job );
00074 void fired( KTimerJob *job );
00075 void finished( KTimerJob *job, bool error );
00076 void error( KTimerJob *job );
00077
00078 protected slots:
00079 virtual void fire();
00080
00081 private slots:
00082 void timeout();
00083 void processExited(int, QProcess::ExitStatus);
00084
00085 private:
00086 struct KTimerJobPrivate *d;
00087 };
00088
00089
00090 class KTimerPref : public QDialog, public Ui::PrefWidget
00091 {
00092 Q_OBJECT
00093 public:
00094 KTimerPref( QWidget *parent=0);
00095 virtual ~KTimerPref();
00096
00097 protected slots:
00098 void add();
00099 void remove();
00100 void currentChanged( QTreeWidgetItem * , QTreeWidgetItem *);
00101
00102 void saveJobs( KConfig *cfg );
00103 void loadJobs( KConfig *cfg );
00104
00105 private slots:
00106 void jobChanged( KTimerJob *job );
00107 void jobFinished( KTimerJob *job, bool error );
00108
00109 private:
00110 struct KTimerPrefPrivate *d;
00111 };
00112
00113 #endif