kmail
recipientseditor.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef RECIPIENTSEDITOR_H
00025 #define RECIPIENTSEDITOR_H
00026
00027 #include <qwidget.h>
00028 #include <qscrollview.h>
00029 #include <qguardedptr.h>
00030 #include <qlineedit.h>
00031 #include <qtooltip.h>
00032
00033 #include "kmlineeditspell.h"
00034 #include <qcombobox.h>
00035
00036 class RecipientsPicker;
00037
00038 class KWindowPositioner;
00039
00040 class QLabel;
00041 class QPushButton;
00042 class SideWidget;
00043
00044 class Recipient
00045 {
00046 public:
00047 typedef QValueList<Recipient> List;
00048
00049 enum Type { To, Cc, Bcc, Undefined };
00050
00051 Recipient( const QString &email = QString::null, Type type = To );
00052
00053 void setType( Type );
00054 Type type() const;
00055
00056 void setEmail( const QString & );
00057 QString email() const;
00058
00059 bool isEmpty() const;
00060
00061 static int typeToId( Type );
00062 static Type idToType( int );
00063
00064 QString typeLabel() const; static QString typeLabel( Type );
00065 static QStringList allTypeLabels();
00066
00067 private:
00068 QString mEmail;
00069 Type mType;
00070 };
00071
00072 class RecipientComboBox : public QComboBox
00073 {
00074 Q_OBJECT
00075 public:
00076 RecipientComboBox( QWidget *parent );
00077
00078 signals:
00079 void rightPressed();
00080
00081 protected:
00082 void keyPressEvent( QKeyEvent *ev );
00083 };
00084
00085 class RecipientLineEdit : public KMLineEdit
00086 {
00087 Q_OBJECT
00088 public:
00089 RecipientLineEdit( QWidget * parent ) :
00090 KMLineEdit( true, parent ) {}
00091
00092 signals:
00093 void deleteMe();
00094 void leftPressed();
00095 void rightPressed();
00096
00097 protected:
00098 void keyPressEvent( QKeyEvent *ev );
00099 };
00100
00101 class RecipientLine : public QWidget
00102 {
00103 Q_OBJECT
00104 public:
00105 RecipientLine( QWidget *parent );
00106
00107 void setRecipient( const Recipient & );
00108 Recipient recipient() const;
00109
00110 void setRecipientType( Recipient::Type );
00111 Recipient::Type recipientType() const;
00112
00113 void setRecipient( const QString & );
00114
00115 void activate();
00116 bool isActive();
00117
00118 bool isEmpty();
00119
00123 bool isModified();
00124
00127 void clearModified();
00128
00129 int setComboWidth( int w );
00130
00131 void fixTabOrder( QWidget *previous );
00132 QWidget *tabOut() const;
00133
00134 void clear();
00135
00136 int recipientsCount();
00137
00138 void setRemoveLineButtonEnabled( bool b );
00139
00140 signals:
00141 void returnPressed( RecipientLine * );
00142 void downPressed( RecipientLine * );
00143 void upPressed( RecipientLine * );
00144 void rightPressed();
00145 void deleteLine( RecipientLine * );
00146 void countChanged();
00147 void typeModified( RecipientLine * );
00148
00149 protected:
00150 void keyPressEvent( QKeyEvent * );
00151 RecipientLineEdit* lineEdit() const { return mEdit; }
00152
00153 protected slots:
00154 void slotReturnPressed();
00155 void analyzeLine( const QString & );
00156 void slotFocusUp();
00157 void slotFocusDown();
00158 void slotPropagateDeletion();
00159 void slotTypeModified();
00160
00161 private:
00162 friend class RecipientsView;
00163 QComboBox *mCombo;
00164 RecipientLineEdit *mEdit;
00165 QPushButton *mRemoveButton;
00166 int mRecipientsCount;
00167 bool mModified;
00168 };
00169
00170 class RecipientsView : public QScrollView
00171 {
00172 Q_OBJECT
00173 public:
00174 RecipientsView( QWidget *parent );
00175
00176 QSize minimumSizeHint() const;
00177 QSize sizeHint() const;
00178
00179 RecipientLine *activeLine();
00180
00181 RecipientLine *emptyLine();
00182
00183 Recipient::List recipients() const;
00184
00189 void removeRecipient( const QString & recipient, Recipient::Type type );
00190
00194 bool isModified();
00195
00198 void clearModified();
00199
00200 void activateLine( RecipientLine * );
00201
00208 int setFirstColumnWidth( int );
00209
00210 public slots:
00211 void setCompletionMode( KGlobalSettings::Completion );
00212 RecipientLine *addLine();
00213
00214 void setFocus();
00215 void setFocusTop();
00216 void setFocusBottom();
00217
00218 signals:
00219 void totalChanged( int recipients, int lines );
00220 void focusUp();
00221 void focusDown();
00222 void focusRight();
00223 void completionModeChanged( KGlobalSettings::Completion );
00224 void sizeHintChanged();
00225
00226 protected:
00227 void viewportResizeEvent( QResizeEvent * );
00228 void resizeView();
00229
00230 protected slots:
00231 void slotReturnPressed( RecipientLine * );
00232 void slotDownPressed( RecipientLine * );
00233 void slotUpPressed( RecipientLine * );
00234 void slotDecideLineDeletion( RecipientLine * );
00235 void slotDeleteLine();
00236 void calculateTotal();
00237 void slotTypeModified( RecipientLine * );
00238 void moveCompletionPopup();
00239
00240 private:
00241 QPtrList<RecipientLine> mLines;
00242 QGuardedPtr<RecipientLine> mCurDelLine;
00243 int mLineHeight;
00244 int mFirstColumnWidth;
00245 bool mModified;
00246 KGlobalSettings::Completion mCompletionMode;
00247 };
00248
00249 class RecipientsToolTip : public QToolTip
00250 {
00251 public:
00252 RecipientsToolTip( RecipientsView *, QWidget *parent );
00253
00254 protected:
00255 void maybeTip( const QPoint & p );
00256
00257 QString line( const Recipient & );
00258
00259 private:
00260 RecipientsView *mView;
00261 };
00262
00263 class SideWidget : public QWidget
00264 {
00265 Q_OBJECT
00266 public:
00267 SideWidget( RecipientsView *view, QWidget *parent );
00268 ~SideWidget();
00269
00270 RecipientsPicker* picker() const;
00271
00272 public slots:
00273 void setTotal( int recipients, int lines );
00274 void setFocus();
00275
00276 void pickRecipient();
00277
00278 signals:
00279 void pickedRecipient( const Recipient & );
00280 void saveDistributionList();
00281
00282 private:
00283 RecipientsView *mView;
00284 QLabel *mTotalLabel;
00285 QPushButton *mDistributionListButton;
00286 QPushButton *mSelectButton;
00289 mutable RecipientsPicker *mRecipientPicker;
00291 mutable KWindowPositioner *mPickerPositioner;
00292 };
00293
00294 class RecipientsEditor : public QWidget
00295 {
00296 Q_OBJECT
00297 public:
00298 RecipientsEditor( QWidget *parent );
00299 ~RecipientsEditor();
00300
00301 void clear();
00302
00303 Recipient::List recipients() const;
00304 RecipientsPicker* picker() const;
00305
00306 void setRecipientString( const QString &, Recipient::Type );
00307 QString recipientString( Recipient::Type );
00308
00313 void addRecipient( const QString & recipient, Recipient::Type type );
00314
00319 void removeRecipient( const QString & recipient, Recipient::Type type );
00320
00324 bool isModified();
00325
00328 void clearModified();
00329
00336 int setFirstColumnWidth( int );
00337
00341 void setCompletionMode( KGlobalSettings::Completion );
00342
00343 public slots:
00344 void setFocus();
00345 void setFocusTop();
00346 void setFocusBottom();
00347
00348 void selectRecipients();
00349 void saveDistributionList();
00350
00351 signals:
00352 void focusUp();
00353 void focusDown();
00354 void completionModeChanged( KGlobalSettings::Completion );
00355 void sizeHintChanged();
00356
00357 protected slots:
00358 void slotPickedRecipient( const Recipient & );
00359
00360 private:
00361 RecipientsView *mRecipientsView;
00362 SideWidget* mSideWidget;
00363 bool mModified;
00364 };
00365
00366 #endif
|