kfeedback.h

00001 /*
00002  *   File name:      kfeedback.h
00003  *   Summary: User feedback form and mailing utilities
00004  *   License: LGPL - See file COPYING.LIB for details.
00005  *   Author:  Stefan Hundhammer <sh@suse.de>
00006  *
00007  *   Updated: 2002-02-24
00008  *
00009  *   $Id: kfeedback_8h-source.html,v 1.10 2007/07/05 17:37:51 kuddel-fl Exp $
00010  *
00011  */
00012 
00013 
00014 #ifndef KFeedback_h
00015 #define KFeedback_h
00016 
00017 #ifdef HAVE_CONFIG_H
00018 #include <config.h>
00019 #endif
00020 
00021 #include <qlistview.h>
00022 #include <qvbox.h>
00023 #include <kdialogbase.h>
00024 
00025 
00026 #ifndef NOT_USED
00027 #    define NOT_USED(PARAM) ( (void) (PARAM) )
00028 #endif
00029 
00030 
00031 class KFeedbackForm;
00032 class KFeedbackQuestionList;
00033 class KFeedbackQuestion;
00034 class KFeedbackAnswer;
00035 class QMultiLineEdit;
00036 
00037 
00042 class KFeedbackDialog: public KDialogBase
00043 {
00044     Q_OBJECT
00045 
00046 public:
00047 
00051     KFeedbackDialog( const QString & feedbackMailAddress,
00052                    const QString & helpTopic = QString::null );
00053 
00054 
00058     virtual ~KFeedbackDialog();
00059 
00060 
00064     KFeedbackForm *form() { return _form; }
00065 
00066 
00067 public slots:
00068 
00073     void checkSendButton();
00074 
00075 
00076 signals:
00083     void mailSent();
00084 
00085 
00086 protected:
00087 
00088     KFeedbackForm *  _form;
00089 };
00090 
00091 
00098 class KFeedbackForm: public QVBox
00099 {
00100     Q_OBJECT
00101 
00102 public:
00106     KFeedbackForm( const QString & feedbackMailAddress,
00107                  QWidget *         parent );
00108 
00112     virtual ~KFeedbackForm();
00113 
00114 
00115 public slots:
00116 
00128      virtual void sendMail();
00129 
00130 
00131 public:
00132 
00137     virtual bool readyToSend();
00138 
00142     KFeedbackQuestionList * questionList() { return _questionList; }
00143 
00144 
00145 signals:
00152     void mailSent();
00153 
00159     void checkComplete();
00160 
00161 
00162 protected slots:
00166     void slotCheckComplete();
00167 
00168 
00169 protected:
00170 
00174     QString formatComment();
00175 
00176 
00177     QString                 _feedbackMailAddress;
00178     KFeedbackQuestionList * _questionList;
00179     QMultiLineEdit *        _comment;
00180 };
00181 
00182 
00183 
00187 class KFeedbackQuestionList: public QListView
00188 {
00189     Q_OBJECT
00190 
00191 public:
00192 
00196     KFeedbackQuestionList( QWidget *parent );
00197 
00201     virtual ~KFeedbackQuestionList();
00202 
00207     virtual bool isComplete();
00208 
00212     QString result();
00213 
00231     KFeedbackQuestion * addQuestion( const QString &    text,
00232                                  const QString & id,
00233                                  bool            exclusiveAnswer      = true,
00234                                  bool            required      = false );
00235 
00239     void addYesNoQuestion( const QString &       text,
00240                         const QString &   id,
00241                         bool              required = false );
00242 
00247     KFeedbackQuestion * firstQuestion() const
00248        { return (KFeedbackQuestion *) QListView::firstChild(); }
00249 
00255     void questionAnswered();
00256 
00262     void questionAdded( KFeedbackQuestion * question );
00263 
00264 signals:
00268     void checkComplete();
00269 };
00270 
00271 
00275 class KFeedbackQuestion: public QCheckListItem
00276 {
00277 public:
00278 
00300     KFeedbackQuestion( KFeedbackQuestionList *   parent,
00301                      const QString &             text,
00302                      const QString &             id,
00303                      bool                 exclusiveAnswer      = true,
00304                      bool                 required      = false,
00305                      bool                 open          = true );
00306 
00313     void addAnswer( const QString & text,
00314                   const QString & id   );
00315 
00319     bool isRequired() { return _required; }
00320 
00324     bool isAnswered();
00325 
00334     QString result();
00335 
00339     QString id() { return _id; }
00340 
00344     QString text();
00345 
00349     bool exclusiveAnswer() { return _exclusiveAnswer; }
00350 
00351 
00357     virtual QString key( int column, bool ascending ) const;
00358 
00362     KFeedbackQuestion * nextQuestion() const
00363        { return (KFeedbackQuestion *) QListViewItem::nextSibling(); }
00364 
00369     KFeedbackAnswer * firstAnswer() const
00370        { return (KFeedbackAnswer *) QListViewItem::firstChild(); }
00371 
00376     KFeedbackQuestionList * questionList() const;
00377 
00378 
00379 protected:
00380 
00381     QString   _id;
00382     bool      _exclusiveAnswer;
00383     bool      _required;
00384     int              _no;
00385 };
00386 
00387 
00388 class KFeedbackAnswer: public QCheckListItem
00389 {
00390 public:
00397     KFeedbackAnswer( KFeedbackQuestion *  parent,
00398                    const QString &        text,
00399                    const QString &        id,
00400                    bool                   exclusive = true );
00401 
00405     QString id() { return _id; }
00406 
00410     QString text();
00411 
00415     bool isExclusive() { return _exclusive; }
00416 
00420     bool isChecked() { return QCheckListItem::isOn(); }
00421 
00425     KFeedbackAnswer * nextAnswer() const
00426        { return (KFeedbackAnswer *) QListViewItem::nextSibling(); }
00427 
00431     KFeedbackQuestion * question() const
00432        { return (KFeedbackQuestion *) QListViewItem::parent(); }
00433 
00439     virtual QString key( int column, bool ascending ) const;
00440 
00441 
00449     virtual void stateChange( bool newState );
00450 
00451 protected:
00452 
00453     QString   _id;
00454     bool      _exclusive;
00455     int              _no;
00456 };
00457 
00458 
00459 
00460 #endif // KFeedback_h
00461 
00462 
00463 // EOF

Generated on Thu Jul 5 19:36:06 2007 for kshowmail by  doxygen 1.5.0