kmail Library API Documentation

kmcomposewin.h

00001 /* -*- mode: C++; c-file-style: "gnu" -*-
00002  * KMComposeWin Header File
00003  * Author: Markus Wuebben <markus.wuebben@kde.org>
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     // Inherited. Always called by the parent when this widget is created.
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;         // needed for the digest forward
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 &paramAttr,
00272                     const QString &paramValue,
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 setAutoDeleteWindow( bool f );
00321 
00326    void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00327 
00331    void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00332 
00338    void setReplyFocus( bool hasMessage = true );
00339 
00344    void setFocusToSubject();
00345 
00349    bool inlineSigningEncryptionSelected();
00350 
00356    static QString prettyMimeType( const QString& type );
00357     QString quotePrefixName() const;
00358 
00359     KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00360   void setSubjectTextWasSpellChecked( bool _spell ) {
00361     mSubjectTextWasSpellChecked = _spell;
00362   }
00363   bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00364 
00365 
00367   void setSigningAndEncryptionDisabled( bool v )
00368   {
00369     mSigningAndEncryptionExplicitlyDisabled = v;
00370   }
00371 
00372 public slots:
00376   void slotPrint();
00377   void slotAttachFile();
00378   void slotSendNow();
00379   void slotSendLater();
00383   void slotSaveDraft();
00384   void slotNewComposer();
00385   void slotNewMailReader();
00386   void slotClose();
00387   void slotHelp();
00388 
00389   void slotFind();
00390   void slotSearchAgain();
00391   void slotReplace();
00392   void slotUndo();
00393   void slotRedo();
00394   void slotCut();
00395   void slotCopy();
00396   void slotPaste();
00397   void slotPasteAsQuotation();
00398   void slotAddQuotes();
00399   void slotRemoveQuotes();
00400 
00401   void slotMarkAll();
00402 
00403   void slotFolderRemoved(KMFolder*);
00404 
00411   void slotSetAlwaysSend( bool bAlwaysSend );
00412 
00416   void slotUpdateFont();
00417 
00421   void slotAddrBook();
00425   void slotInsertFile();
00426 
00427   void slotSetCharset();
00431   void slotSpellcheck();
00432   void slotSpellcheckConfig();
00433   void slotSubjectTextSpellChecked();
00434 
00439   void slotSelectCryptoModule();
00440 
00444   void slotStatusMessage(const QString &message);
00445   void slotEditToolbars();
00446   void slotUpdateToolbars();
00447   void slotEditKeys();
00451   void readConfig(void);
00455   void slotUpdWinTitle(const QString& );
00456 
00461   void slotEncryptToggled(bool);
00462 
00466   void slotSignToggled(bool);
00467 
00471   void slotWordWrapToggled(bool);
00472 
00476   void slotAppendSignature();
00477 
00481   void slotInsertMyPublicKey();
00482 
00486   void slotInsertPublicKey();
00487 
00491   void slotUpdateAttachActions();
00492 
00496   void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00497 
00502   int currentAttachmentNum();
00503 
00507   void slotAttachView();
00508   void slotAttachRemove();
00509   void slotAttachSave();
00510   void slotAttachProperties();
00511 
00512 
00517   void slotAddrBookTo();
00518   void slotAddrBookFrom();
00519   void slotAddrBookReplyTo();
00520 
00521   void slotCleanSpace();
00522 
00523   void slotToggleMarkup();
00524   void toggleMarkup(bool markup);
00525 
00526 //  void slotSpellConfigure();
00527   void slotSpellcheckDone(int result);
00528   void slotSpellcheckDoneClearStatus();
00529 
00533   void deadLetter(void);
00534 
00535   void updateCursorPosition();
00536 
00537   void slotView();
00538 
00542   void focusNextPrevEdit(const QWidget* current, bool next);
00543 
00547   void slotIdentityChanged(uint);
00548 
00552   void slotAttachFileData(KIO::Job *, const QByteArray &);
00553   void slotAttachFileResult(KIO::Job *);
00554 
00555   void slotListAction(const QString &);
00556   void slotFontAction(const QString &);
00557   void slotSizeAction(int);
00558   void slotAlignLeft();
00559   void slotAlignCenter();
00560   void slotAlignRight();
00561   void slotTextBold();
00562   void slotTextItalic();
00563   void slotTextUnder();
00564   void slotFormatReset();
00565   void slotTextColor();
00566   void fontChanged( const QFont & );
00567   void alignmentChanged( int );
00568 
00569   void addAttach(const KURL url);
00570 
00574    void addAttach(const KMMessagePart* msgPart);
00575 
00576 public:
00577   const KPIM::Identity & identity() const;
00578   Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00579   bool encryptToSelf() const;
00580 
00581 signals:
00585   void messageQueuedOrDrafted();
00586 
00587   void applyChangesDone( bool );
00588 
00589 protected:
00597   void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00598 
00604   void rethinkFields(bool fromslot=false);
00605 
00610   void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00611                           const QString &aLabelStr, QLabel* aLbl,
00612                           QLineEdit* aEdt, QPushButton* aBtn = 0,
00613                           const QString &toolTip = QString::null,
00614                           const QString &whatsThis = QString::null );
00615 
00616   void rethinkHeaderLine( int value, int mask, int& row,
00617                           const QString& labelStr, QLabel* lbl,
00618                           QComboBox* cbx, QCheckBox *chk );
00619 
00623   void setupActions(int aCryptoMessageFormat=-1);
00624   void setupStatusBar();
00625   void setupEditor();
00626 
00627 
00631   QString subject() const;
00632   QString to() const;
00633   QString cc() const;
00634   QString bcc() const;
00635   QString from() const;
00636   QString replyTo() const;
00637 
00643   void setFcc( const QString &idString );
00644 
00648   virtual bool queryClose ();
00652   virtual bool queryExit ();
00653 
00657   void viewAttach( int index );
00658 
00662    void removeAttach(const QString &url);
00663    void removeAttach(int idx);
00664 
00668    void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi);
00669 
00674   void addrBookSelInto();
00675 
00676 private:
00681   void setEncryption( bool encrypt, bool setByUser = false );
00682 
00687   void setSigning( bool sign, bool setByUser = false );
00688 
00692   bool userForgotAttachment();
00693 
00698   bool encryptFlagOfAttachment(int idx);
00699 
00704   bool signFlagOfAttachment(int idx);
00705 
00706 
00714    static void decryptOrStripOffCleartextSignature( QCString& );
00715 
00719   void doSend(int sendNow=-1, bool saveInDrafts = false);
00720 
00721 protected:
00722   QWidget   *mMainWidget;
00723   QComboBox *mTransport;
00724   KMail::DictionaryComboBox *mDictionaryCombo;
00725   KPIM::IdentityCombo    *mIdentity;
00726   KMFolderComboBox *mFcc;
00727   KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00728   KMLineEditSpell *mEdtSubject;
00729   QLabel    *mLblIdentity, *mLblTransport, *mLblFcc;
00730   QLabel    *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00731   QLabel    *mDictionaryLabel;
00732   QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00733   QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo;
00734   bool mSpellCheckInProgress;
00735   bool mDone;
00736   bool mAtmModified;
00737 
00738   KMEdit* mEditor;
00739   QGridLayout* mGrid;
00740   KMMessage *mMsg;
00741   QValueVector<KMMessage*> mComposedMessages;
00742   KMail::AttachmentListView* mAtmListView;
00743   int mAtmColEncrypt;
00744   int mAtmColSign;
00745   int mAtmEncryptColWidth;
00746   int mAtmSignColWidth;
00747   QPtrList<QListViewItem> mAtmItemList;
00748   QPtrList<KMMessagePart> mAtmList;
00749   QPopupMenu *mAttachMenu;
00750   int mViewId, mRemoveId, mSaveAsId, mPropertiesId;
00751   bool mAutoSign, mAutoPgpSign, mAutoPgpEncrypt, mAutoDeleteMsg;
00752   bool mNeverSignWhenSavingInDrafts, mNeverEncryptWhenSavingInDrafts;
00753   bool mSigningAndEncryptionExplicitlyDisabled;
00754   bool mAutoRequestMDN;
00755   bool mLastSignActionState, mLastEncryptActionState;
00756   bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00757   KMFolder *mFolder;
00758   long mShowHeaders;
00759   QString mExtEditor;
00760   bool mUseHTMLEditor;
00761   bool mUseExtEditor;
00762   QPtrList<_StringPair> mCustHeaders;
00763   bool mConfirmSend;
00764   bool mDisableBreaking; // Move
00765   int mNumHeaders;
00766   int mLineBreak;
00767   int mWordWrap;
00768   bool mUseFixedFont;
00769   QFont mBodyFont, mFixedFont;
00770   //  QList<QLineEdit> mEdtList;
00771   QPtrList<QWidget> mEdtList;
00772   QPtrList<KTempFile> mAtmTempList;
00773   QPalette mPalette;
00774   uint mId;
00775   QString mOldSigText;
00776   QStringList mTransportHistory;
00777 
00778   KAction *mAttachPK, *mAttachMPK,
00779           *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction;
00780 
00781   KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00782   KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00783   KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00784   KToggleAction *mSubjectAction;
00785   KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00786   KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00787   KToggleAction *mDictionaryAction;
00788 
00789   KSelectAction *listAction;
00790   KFontAction *fontAction;
00791   KFontSizeAction *fontSizeAction;
00792   KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00793   KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00794   KToggleAction *plainTextAction, *markupAction;
00795   KAction *actionFormatColor, *actionFormatReset;
00796   KAction *mHtmlToolbar;
00797 
00798   KSelectAction *mEncodingAction;
00799   KSelectAction *mCryptoModuleAction;
00800 
00801   QCString mCharset;
00802   QCString mDefCharset;
00803   QStringList mCharsets;
00804   bool mAutoCharset;
00805 
00806   bool mAlwaysSend;
00807   bool mOutlookCompatible;
00808 
00809   QStringList mFolderNames;
00810   QValueList<QGuardedPtr<KMFolder> > mFolderList;
00811 
00812 private:
00813   // helper method for slotInsert(My)PublicKey()
00814   void startPublicKeyExport();
00815   bool canSignEncryptAttachments() const {
00816     return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00817   }
00818 
00819   bool mSubjectTextWasSpellChecked;
00820 
00821 private slots:
00822   void slotCompletionModeChanged( KGlobalSettings::Completion );
00823   void slotConfigChanged();
00824 
00825   void slotComposerDone( bool );
00826 
00827   void slotContinueDoSend( bool );
00828   void slotContinuePrint( bool );
00829   void slotContinueDeadLetter( bool );
00830 
00835   void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00836 
00840   void slotAutoSpellCheckingToggled(bool);
00841 
00842 private:
00843   QColor mForeColor,mBackColor;
00844   QFont mSaveFont;
00845   struct atmLoadData
00846   {
00847     KURL url;
00848     QByteArray data;
00849     bool insert;
00850     QCString encoding;
00851   };
00852   QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00853   bool mForceReplyCharset;
00854 
00855   // These are for passing on methods over the applyChanges calls
00856   int mSendNow;
00857   bool mSaveInDrafts;
00858 
00859   // This is the temporary object that constructs the message out of the
00860   // window
00861   MessageComposer* mComposer;
00862 
00863   // Temp var for slotPrint:
00864   bool mMessageWasModified;
00865 
00866   // Temp var for slotInsert(My)PublicKey():
00867   QString mFingerprint;
00868 };
00869 
00870 #endif
00871 
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 22:43:45 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003