kalarm

specialactions.h

00001 /*
00002  *  specialactions.h  -  widget to specify special alarm actions
00003  *  Program:  kalarm
00004  *  Copyright © 2004,2005 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program 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
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef SPECIALACTIONS_H
00022 #define SPECIALACTIONS_H
00023 
00024 #include <kdialogbase.h>
00025 #include <qwidget.h>
00026 #include <qpushbutton.h>
00027 
00028 class KLineEdit;
00029 
00030 
00031 class SpecialActionsButton : public QPushButton
00032 {
00033         Q_OBJECT
00034     public:
00035         SpecialActionsButton(const QString& caption, QWidget* parent = 0, const char* name = 0);
00036         void           setActions(const QString& pre, const QString& post);
00037         const QString& preAction() const      { return mPreAction; }
00038         const QString& postAction() const     { return mPostAction; }
00039         virtual void   setReadOnly(bool ro)   { mReadOnly = ro; }
00040         virtual bool   isReadOnly() const     { return mReadOnly; }
00041 
00042     signals:
00043         void           selected();
00044 
00045     protected slots:
00046         void           slotButtonPressed();
00047 
00048     private:
00049         QString  mPreAction;
00050         QString  mPostAction;
00051         bool     mReadOnly;
00052 };
00053 
00054 
00055 // Pre- and post-alarm actions widget
00056 class SpecialActions : public QWidget
00057 {
00058         Q_OBJECT
00059     public:
00060         SpecialActions(QWidget* parent = 0, const char* name = 0);
00061         void         setActions(const QString& pre, const QString& post);
00062         QString      preAction() const;
00063         QString      postAction() const;
00064         void         setReadOnly(bool);
00065         bool         isReadOnly() const    { return mReadOnly; }
00066 
00067     private:
00068         KLineEdit*   mPreAction;
00069         KLineEdit*   mPostAction;
00070         bool         mReadOnly;
00071 };
00072 
00073 
00074 // Pre- and post-alarm actions dialogue displayed by the push button
00075 class SpecialActionsDlg : public KDialogBase
00076 {
00077         Q_OBJECT
00078     public:
00079         SpecialActionsDlg(const QString& preAction, const QString& postAction,
00080                           const QString& caption, QWidget* parent = 0, const char* name = 0);
00081         QString      preAction() const     { return mActions->preAction(); }
00082         QString      postAction() const    { return mActions->postAction(); }
00083         void         setReadOnly(bool ro)  { mActions->setReadOnly(ro); }
00084         bool         isReadOnly() const    { return mActions->isReadOnly(); }
00085 
00086     protected:
00087         virtual void resizeEvent(QResizeEvent*);
00088 
00089     protected slots:
00090         virtual void slotOk();
00091 
00092     private:
00093         SpecialActions* mActions;
00094 };
00095 
00096 #endif // SPECIALACTIONS_H