00001
00002
00003
00004
00005
#ifndef __KMComposeWin
00006
#define __KMComposeWin
00007
00008
#include "secondarywindow.h"
00009
00010
#include <qlabel.h>
00011
#include <qlistview.h>
00012
00013
#include <qcheckbox.h>
00014
#include <qpushbutton.h>
00015
#include <qclipboard.h>
00016
#include <qpalette.h>
00017
#include <qfont.h>
00018
#include <qptrlist.h>
00019
#include <qvaluevector.h>
00020
00021
#include <kio/job.h>
00022
#include <kglobalsettings.h>
00023
#include <kdeversion.h>
00024
#include <keditcl.h>
00025
00026
#include "kmmsgpart.h"
00027
#include "kmmsgbase.h"
00028
#include "mailcomposerIface.h"
00029
00030
#include <libkdepim/addresseelineedit.h>
00031
#include <mimelib/mediatyp.h>
00032
00033
#include <kleo/enum.h>
00034
00035
class _StringPair {
00036
public:
00037
QString name;
00038
QString value;
00039 };
00040
00041
class QCloseEvent;
00042
class QComboBox;
00043
class QFrame;
00044
class QGridLayout;
00045
class QListView;
00046
class QPopupMenu;
00047
class QPushButton;
00048
class QCString;
00049
class KCompletion;
00050
class KEdit;
00051
class KMComposeWin;
00052
class KMFolderComboBox;
00053
class KMMessage;
00054
class KProcess;
00055
class KDirWatch;
00056
class KSelectAction;
00057
class KFontAction;
00058
class KFontSizeAction;
00059
class KSelectAction;
00060
class KSpell;
00061
class KSpellConfig;
00062
class KDictSpellingHighlighter;
00063
class KStatusBar;
00064
class KAction;
00065
class KToggleAction;
00066
class KTempFile;
00067
class KToolBar;
00068
class KToggleAction;
00069
class KSelectColorAction;
00070
class KURL;
00071
class SpellingFilter;
00072
class MessageComposer;
00073
00074
namespace KPIM {
00075
class IdentityCombo;
00076
class Identity;
00077 }
00078
00079
namespace KMail {
00080
class AttachmentListView;
00081
class DictionaryComboBox;
00082 }
00083
00084
namespace GpgME {
00085
class Error;
00086 }
00087
00088
00089
00090
class KMEdit:
public KEdit
00091 {
00092 Q_OBJECT
00093
public:
00094 KMEdit(
QWidget *parent=0,KMComposeWin* composer=0,
00095 KSpellConfig* spellConfig = 0,
00096
const char *name=0);
00097
virtual ~KMEdit();
00098
00102
void spellcheck();
00103
00107
QString brokenText();
00108
00112
int autoSpellChecking(
bool );
00113
00117
void setUseExternalEditor(
bool use ) { mUseExtEditor = use; }
00118
void setExternalEditorPath(
const QString & path ) { mExtEditor = path; }
00119
00126
bool checkExternalEditorFinished();
00127
00128
void setSpellCheckingActive(
bool spellCheckingActive);
00129
00131
void contentsDragEnterEvent(
QDragEnterEvent *e);
00132
void contentsDragMoveEvent(
QDragMoveEvent *e);
00133
void contentsDropEvent(
QDropEvent *e);
00134
00135
void initializeAutoSpellChecking( KSpellConfig* autoSpellConfig );
00136
void deleteAutoSpellChecking();
00137
00138 signals:
00139
void spellcheck_done(
int result);
00140
public slots:
00141
void slotSpellcheck2(KSpell*);
00142
void slotSpellResult(
const QString&);
00143
void slotSpellDone();
00144
void slotExternalEditorDone(KProcess*);
00145
void slotMisspelling(
const QString &,
const QStringList &,
unsigned int);
00146
void slotCorrected (
const QString &,
const QString &,
unsigned int);
00147
void addSuggestion(
const QString& text,
const QStringList& lst,
unsigned int );
00148
virtual void cut();
00149
virtual void clear();
00150
virtual void del();
00151
protected:
00155
virtual bool eventFilter(
QObject*,
QEvent*);
00156
virtual void keyPressEvent(
QKeyEvent* );
00157
00158 KMComposeWin* mComposer;
00159
00160
private slots:
00161
void slotExternalEditorTempFileChanged(
const QString & fileName );
00162
00163
private:
00164
void killExternalEditor();
00165
00166
private:
00167 KSpell *mKSpell;
00168
QMap<QString,QStringList> mReplacements;
00169 SpellingFilter* mSpellingFilter;
00170 KTempFile *mExtEditorTempFile;
00171 KDirWatch *mExtEditorTempFileWatcher;
00172 KProcess *mExtEditorProcess;
00173
bool mUseExtEditor;
00174
QString mExtEditor;
00175
bool mWasModifiedBeforeSpellCheck;
00176 KDictSpellingHighlighter *mSpellChecker;
00177
bool mSpellLineEdit;
00178 };
00179
00180
00181
00182
class KMLineEdit :
public KPIM::AddresseeLineEdit
00183 {
00184 Q_OBJECT
00185
public:
00186 KMLineEdit(KMComposeWin* composer,
bool useCompletion,
QWidget *parent = 0,
00187
const char *name = 0);
00188
protected:
00189
00190
virtual void loadContacts();
00191
00192
virtual void keyPressEvent(
QKeyEvent*);
00193
00194
virtual QPopupMenu *createPopupMenu();
00195
00196
private slots:
00197
void editRecentAddresses();
00198
00199
private:
00200 KMComposeWin* mComposer;
00201 };
00202
00203
00204
class KMLineEditSpell :
public KMLineEdit
00205 {
00206 Q_OBJECT
00207
public:
00208 KMLineEditSpell(KMComposeWin* composer,
bool useCompletion,
QWidget *parent = 0,
00209
const char *name = 0);
00210
void highLightWord(
unsigned int length,
unsigned int pos );
00211
void spellCheckDone(
const QString &s );
00212
void spellCheckerMisspelling(
const QString &text,
const QStringList &,
unsigned int pos);
00213
void spellCheckerCorrected(
const QString &old,
const QString &corr,
unsigned int pos);
00214
00215 signals:
00216
void subjectTextSpellChecked();
00217 };
00218
00219
00220
00221
class KMAtmListViewItem :
public QObject,
public QListViewItem
00222 {
00223 Q_OBJECT
00224
friend class KMComposeWin;
00225
friend class MessageComposer;
00226
00227
public:
00228 KMAtmListViewItem(
QListView * parent);
00229
virtual ~KMAtmListViewItem();
00230
virtual void paintCell(
QPainter * p,
const QColorGroup & cg,
00231
int column,
int width,
int align );
00232
00233
protected:
00234
void enableCryptoCBs(
bool on);
00235
void setEncrypt(
bool on);
00236
bool isEncrypt();
00237
void setSign(
bool on);
00238
bool isSign();
00239
00240
private:
00241
QListView* mListview;
00242
QCheckBox* mCBEncrypt;
00243
QCheckBox* mCBSign;
00244
bool mCBSignEnabled, mCBEncryptEnabled;
00245 };
00246
00247
00248
class KMHeaders;
00249
00250
00251
class KMComposeWin :
public KMail::
SecondaryWindow,
virtual public MailComposerIface
00252 {
00253 Q_OBJECT
00254
friend class KMHeaders;
00255
friend class MessageComposer;
00256
00257
public:
00258 KMComposeWin( KMMessage* msg=0, uint identity=0 );
00259 ~KMComposeWin();
00260
00264
void send(
int how);
00265
void addAttachment(KURL url,
QString comment);
00266
void addAttachment(
const QString &name,
00267
const QCString &cte,
00268
const QByteArray &data,
00269
const QCString &type,
00270
const QCString &subType,
00271
const QCString ¶mAttr,
00272
const QString ¶mValue,
00273
const QCString &contDisp);
00274
void setBody (
QString body);
00275
00279
virtual bool event(
QEvent *e);
00280
00284
void readColorConfig();
00285
00289
void writeConfig(
void);
00290
00295
void verifyWordWrapLengthIsAdequate(
const QString&);
00296
00301
void setMsg(KMMessage* newMsg,
bool mayAutoSign=TRUE,
00302
bool allowDecryption=FALSE,
bool isModified=FALSE);
00303
00308 KMMessage* msg(
void)
const {
return mMsg; }
00309
00314
inline void setAutoDelete(
bool f) { mAutoDeleteMsg = f; }
00315
00320
void setFolder(
KMFolder* aFolder) { mFolder = aFolder; }
00321
00325
void setCharset(
const QCString& aCharset,
bool forceDefault = FALSE);
00326
00332
void setReplyFocus(
bool hasMessage =
true );
00333
00338
void setFocusToSubject();
00339
00343
bool inlineSigningEncryptionSelected();
00344
00350
static QString prettyMimeType(
const QString& type );
00351
QString quotePrefixName() const;
00352
00353 KMLineEditSpell *sujectLineWidget()
const {
return mEdtSubject;}
00354
void setSubjectTextWasSpellChecked(
bool _spell ) {
00355 mSubjectTextWasSpellChecked = _spell;
00356 }
00357
bool subjectTextWasSpellChecked()
const {
return mSubjectTextWasSpellChecked; }
00358
public slots:
00362
void slotPrint();
00363
void slotAttachFile();
00364
void slotSendNow();
00365
void slotSendLater();
00369
void slotSaveDraft();
00370
void slotNewComposer();
00371
void slotNewMailReader();
00372
void slotClose();
00373
void slotHelp();
00374
00375
void slotFind();
00376
void slotSearchAgain();
00377
void slotReplace();
00378
void slotUndo();
00379
void slotRedo();
00380
void slotCut();
00381
void slotCopy();
00382
void slotPaste();
00383
void slotPasteAsQuotation();
00384
void slotAddQuotes();
00385
void slotRemoveQuotes();
00386
00387
void slotMarkAll();
00388
00389
void slotFolderRemoved(
KMFolder*);
00390
00397
void slotSetAlwaysSend(
bool bAlwaysSend );
00398
00402
void slotUpdateFont();
00403
00407
void slotAddrBook();
00411
void slotInsertFile();
00412
00413
void slotSetCharset();
00417
void slotSpellcheck();
00418
void slotSpellcheckConfig();
00419
void slotSubjectTextSpellChecked();
00420
00425
void slotSelectCryptoModule();
00426
00430
void slotStatusMessage(
const QString &message);
00431
void slotEditToolbars();
00432
void slotUpdateToolbars();
00433
void slotEditKeys();
00437
void readConfig(
void);
00441
void slotUpdWinTitle(
const QString& );
00442
00447
void slotEncryptToggled(
bool);
00448
00452
void slotSignToggled(
bool);
00453
00457
void slotWordWrapToggled(
bool);
00458
00462
void slotAppendSignature();
00463
00467
void slotInsertMyPublicKey();
00468
00472
void slotInsertPublicKey();
00473
00477
void slotUpdateAttachActions();
00478
00482
void slotAttachPopupMenu(
QListViewItem *,
const QPoint &,
int);
00483
00488
int currentAttachmentNum();
00489
00493
void slotAttachView();
00494
void slotAttachRemove();
00495
void slotAttachSave();
00496
void slotAttachProperties();
00497
00498
00503
void slotAddrBookTo();
00504
void slotAddrBookFrom();
00505
void slotAddrBookReplyTo();
00506
00507
void slotCleanSpace();
00508
00509
void slotToggleMarkup();
00510
void toggleMarkup(
bool markup);
00511
00512
00513
void slotSpellcheckDone(
int result);
00514
void slotSpellcheckDoneClearStatus();
00515
00519
void deadLetter(
void);
00520
00521
void updateCursorPosition();
00522
00523
void slotView();
00524
00528
void focusNextPrevEdit(
const QWidget* current,
bool next);
00529
00533
void slotIdentityChanged(uint);
00534
00538
void slotAttachFileData(KIO::Job *,
const QByteArray &);
00539
void slotAttachFileResult(KIO::Job *);
00540
00541
void slotListAction(
const QString &);
00542
void slotFontAction(
const QString &);
00543
void slotSizeAction(
int);
00544
void slotAlignLeft();
00545
void slotAlignCenter();
00546
void slotAlignRight();
00547
void slotTextBold();
00548
void slotTextItalic();
00549
void slotTextUnder();
00550
void slotFormatReset();
00551
void slotTextColor();
00552
void fontChanged(
const QFont & );
00553
void alignmentChanged(
int );
00554
00555
void addAttach(
const KURL url);
00556
00560
void addAttach(
const KMMessagePart* msgPart);
00561
00562
public:
00563
const KPIM::Identity & identity() const;
00564 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00565
bool encryptToSelf() const;
00566
00567 signals:
00571
void messageQueuedOrDrafted();
00572
00573
void applyChangesDone(
bool );
00574
00575 protected:
00583
void applyChanges(
bool dontSignNorEncrypt,
bool dontDisable=false );
00584
00590
void rethinkFields(
bool fromslot=false);
00591
00596
void rethinkHeaderLine(
int aValue,
int aMask,
int& aRow,
00597 const
QString &aLabelStr,
QLabel* aLbl,
00598
QLineEdit* aEdt,
QPushButton* aBtn = 0,
00599 const
QString &toolTip =
QString::null,
00600 const
QString &whatsThis =
QString::null );
00601
00602
void rethinkHeaderLine(
int value,
int mask,
int& row,
00603 const
QString& labelStr,
QLabel* lbl,
00604
QComboBox* cbx,
QCheckBox *chk );
00605
00609
void setupActions();
00610
void setupStatusBar();
00611
void setupEditor();
00612
00613
00617
QString subject() const;
00618
QString to() const;
00619
QString cc() const;
00620
QString bcc() const;
00621
QString from() const;
00622
QString replyTo() const;
00623
00629
void setFcc( const
QString &idString );
00630
00634 virtual
bool queryClose ();
00638 virtual
bool queryExit ();
00639
00643
void viewAttach(
int index );
00644
00648
void removeAttach(const
QString &url);
00649
void removeAttach(
int idx);
00650
00654
void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi);
00655
00660
void addrBookSelInto();
00661
00662 private:
00667
void setEncryption(
bool encrypt,
bool setByUser = false );
00668
00673
void setSigning(
bool sign,
bool setByUser = false );
00674
00678
bool userForgotAttachment();
00679
00684
bool encryptFlagOfAttachment(
int idx);
00685
00690
bool signFlagOfAttachment(
int idx);
00691
00692
00700 static
void decryptOrStripOffCleartextSignature(
QCString& );
00701
00705
void doSend(
int sendNow=-1,
bool saveInDrafts = false);
00706
00707 protected:
00708
QWidget *mMainWidget;
00709
QComboBox *mTransport;
00710 KMail::DictionaryComboBox *mDictionaryCombo;
00711 KPIM::IdentityCombo *mIdentity;
00712 KMFolderComboBox *mFcc;
00713 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00714 KMLineEditSpell *mEdtSubject;
00715
QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00716
QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00717
QLabel *mDictionaryLabel;
00718
QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00719
QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00720
bool mSpellCheckInProgress;
00721
bool mDone;
00722
bool mAtmModified;
00723
00724 KMEdit* mEditor;
00725
QGridLayout* mGrid;
00726 KMMessage *mMsg;
00727
QValueVector<KMMessage*> mComposedMessages;
00728 KMail::AttachmentListView* mAtmListView;
00729
int mAtmColEncrypt;
00730
int mAtmColSign;
00731
int mAtmEncryptColWidth;
00732
int mAtmSignColWidth;
00733
QPtrList<
QListViewItem> mAtmItemList;
00734
QPtrList<KMMessagePart> mAtmList;
00735
QPopupMenu *mAttachMenu;
00736
int mViewId, mRemoveId, mSaveAsId, mPropertiesId;
00737
bool mAutoSign, mAutoPgpSign, mAutoPgpEncrypt, mAutoDeleteMsg;
00738
bool mNeverSignWhenSavingInDrafts, mNeverEncryptWhenSavingInDrafts;
00739
bool mAutoRequestMDN;
00740
bool mLastSignActionState, mLastEncryptActionState;
00741
bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00742
KMFolder *mFolder;
00743
long mShowHeaders;
00744
QString mExtEditor;
00745
bool mUseHTMLEditor;
00746
bool mUseExtEditor;
00747
QPtrList<_StringPair> mCustHeaders;
00748
bool mConfirmSend;
00749
bool mDisableBreaking;
00750
int mNumHeaders;
00751
int mLineBreak;
00752
int mWordWrap;
00753
bool mUseFixedFont;
00754
QFont mBodyFont, mFixedFont;
00755
00756
QPtrList<
QWidget> mEdtList;
00757
QPtrList<KTempFile> mAtmTempList;
00758
QPalette mPalette;
00759 uint mId;
00760
QString mOldSigText;
00761
QStringList mTransportHistory;
00762
00763 KAction *mAttachPK, *mAttachMPK,
00764 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction;
00765
00766 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00767 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00768 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00769 KToggleAction *mSubjectAction;
00770 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00771 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00772 KToggleAction *mDictionaryAction;
00773
00774 KSelectAction *listAction;
00775 KFontAction *fontAction;
00776 KFontSizeAction *fontSizeAction;
00777 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00778 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00779 KToggleAction *plainTextAction, *markupAction;
00780 KAction *actionFormatColor, *actionFormatReset;
00781 KAction *mHtmlToolbar;
00782
00783 KSelectAction *mEncodingAction;
00784 KSelectAction *mCryptoModuleAction;
00785
00786 QCString mCharset;
00787 QCString mDefCharset;
00788
QStringList mCharsets;
00789
bool mAutoCharset;
00790
00791
bool mAlwaysSend;
00792
bool mOutlookCompatible;
00793
00794
QStringList mFolderNames;
00795
QValueList<
QGuardedPtr<
KMFolder> > mFolderList;
00796
00797 private:
00798
00799
void startPublicKeyExport();
00800
bool canSignEncryptAttachments()
const {
00801
return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00802 }
00803
00804
bool mSubjectTextWasSpellChecked;
00805
00806
private slots:
00807
void slotCompletionModeChanged( KGlobalSettings::Completion );
00808
void slotConfigChanged();
00809
00810
void slotComposerDone(
bool );
00811
00812
void slotContinueDoSend(
bool );
00813
void slotContinuePrint(
bool );
00814
void slotContinueDeadLetter(
bool );
00815
00820
void slotPublicKeyExportResult(
const GpgME::Error & err,
const QByteArray & keydata );
00821
00825
void slotAutoSpellCheckingToggled(
bool);
00826
00827
private:
00828
QColor mForeColor,mBackColor;
00829
QFont mSaveFont;
00830
struct atmLoadData
00831 {
00832 KURL url;
00833
QByteArray data;
00834
bool insert;
00835
QCString encoding;
00836 };
00837
QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00838
bool mForceReplyCharset;
00839
00840
00841
int mSendNow;
00842
bool mSaveInDrafts;
00843
00844
00845
00846 MessageComposer* mComposer;
00847
00848
00849
bool mMessageWasModified;
00850
00851
00852
QString mFingerprint;
00853 };
00854
00855
#endif
00856