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 public slots: 00368 void slotPrint(); 00369 void slotAttachFile(); 00370 void slotSendNow(); 00371 void slotSendLater(); 00375 void slotSaveDraft(); 00376 void slotNewComposer(); 00377 void slotNewMailReader(); 00378 void slotClose(); 00379 void slotHelp(); 00380 00381 void slotFind(); 00382 void slotSearchAgain(); 00383 void slotReplace(); 00384 void slotUndo(); 00385 void slotRedo(); 00386 void slotCut(); 00387 void slotCopy(); 00388 void slotPaste(); 00389 void slotPasteAsQuotation(); 00390 void slotAddQuotes(); 00391 void slotRemoveQuotes(); 00392 00393 void slotMarkAll(); 00394 00395 void slotFolderRemoved(KMFolder*); 00396 00403 void slotSetAlwaysSend( bool bAlwaysSend ); 00404 00408 void slotUpdateFont(); 00409 00413 void slotAddrBook(); 00417 void slotInsertFile(); 00418 00419 void slotSetCharset(); 00423 void slotSpellcheck(); 00424 void slotSpellcheckConfig(); 00425 void slotSubjectTextSpellChecked(); 00426 00431 void slotSelectCryptoModule(); 00432 00436 void slotStatusMessage(const QString &message); 00437 void slotEditToolbars(); 00438 void slotUpdateToolbars(); 00439 void slotEditKeys(); 00443 void readConfig(void); 00447 void slotUpdWinTitle(const QString& ); 00448 00453 void slotEncryptToggled(bool); 00454 00458 void slotSignToggled(bool); 00459 00463 void slotWordWrapToggled(bool); 00464 00468 void slotAppendSignature(); 00469 00473 void slotInsertMyPublicKey(); 00474 00478 void slotInsertPublicKey(); 00479 00483 void slotUpdateAttachActions(); 00484 00488 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int); 00489 00494 int currentAttachmentNum(); 00495 00499 void slotAttachView(); 00500 void slotAttachRemove(); 00501 void slotAttachSave(); 00502 void slotAttachProperties(); 00503 00504 00509 void slotAddrBookTo(); 00510 void slotAddrBookFrom(); 00511 void slotAddrBookReplyTo(); 00512 00513 void slotCleanSpace(); 00514 00515 void slotToggleMarkup(); 00516 void toggleMarkup(bool markup); 00517 00518 // void slotSpellConfigure(); 00519 void slotSpellcheckDone(int result); 00520 void slotSpellcheckDoneClearStatus(); 00521 00525 void deadLetter(void); 00526 00527 void updateCursorPosition(); 00528 00529 void slotView(); 00530 00534 void focusNextPrevEdit(const QWidget* current, bool next); 00535 00539 void slotIdentityChanged(uint); 00540 00544 void slotAttachFileData(KIO::Job *, const QByteArray &); 00545 void slotAttachFileResult(KIO::Job *); 00546 00547 void slotListAction(const QString &); 00548 void slotFontAction(const QString &); 00549 void slotSizeAction(int); 00550 void slotAlignLeft(); 00551 void slotAlignCenter(); 00552 void slotAlignRight(); 00553 void slotTextBold(); 00554 void slotTextItalic(); 00555 void slotTextUnder(); 00556 void slotFormatReset(); 00557 void slotTextColor(); 00558 void fontChanged( const QFont & ); 00559 void alignmentChanged( int ); 00560 00561 void addAttach(const KURL url); 00562 00566 void addAttach(const KMMessagePart* msgPart); 00567 00568 public: 00569 const KPIM::Identity & identity() const; 00570 Kleo::CryptoMessageFormat cryptoMessageFormat() const; 00571 bool encryptToSelf() const; 00572 00573 signals: 00577 void messageQueuedOrDrafted(); 00578 00579 void applyChangesDone( bool ); 00580 00581 protected: 00589 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false ); 00590 00596 void rethinkFields(bool fromslot=false); 00597 00602 void rethinkHeaderLine( int aValue, int aMask, int& aRow, 00603 const QString &aLabelStr, QLabel* aLbl, 00604 QLineEdit* aEdt, QPushButton* aBtn = 0, 00605 const QString &toolTip = QString::null, 00606 const QString &whatsThis = QString::null ); 00607 00608 void rethinkHeaderLine( int value, int mask, int& row, 00609 const QString& labelStr, QLabel* lbl, 00610 QComboBox* cbx, QCheckBox *chk ); 00611 00615 void setupActions(); 00616 void setupStatusBar(); 00617 void setupEditor(); 00618 00619 00623 QString subject() const; 00624 QString to() const; 00625 QString cc() const; 00626 QString bcc() const; 00627 QString from() const; 00628 QString replyTo() const; 00629 00635 void setFcc( const QString &idString ); 00636 00640 virtual bool queryClose (); 00644 virtual bool queryExit (); 00645 00649 void viewAttach( int index ); 00650 00654 void removeAttach(const QString &url); 00655 void removeAttach(int idx); 00656 00660 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi); 00661 00666 void addrBookSelInto(); 00667 00668 private: 00673 void setEncryption( bool encrypt, bool setByUser = false ); 00674 00679 void setSigning( bool sign, bool setByUser = false ); 00680 00684 bool userForgotAttachment(); 00685 00690 bool encryptFlagOfAttachment(int idx); 00691 00696 bool signFlagOfAttachment(int idx); 00697 00698 00706 static void decryptOrStripOffCleartextSignature( QCString& ); 00707 00711 void doSend(int sendNow=-1, bool saveInDrafts = false); 00712 00713 protected: 00714 QWidget *mMainWidget; 00715 QComboBox *mTransport; 00716 KMail::DictionaryComboBox *mDictionaryCombo; 00717 KPIM::IdentityCombo *mIdentity; 00718 KMFolderComboBox *mFcc; 00719 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc; 00720 KMLineEditSpell *mEdtSubject; 00721 QLabel *mLblIdentity, *mLblTransport, *mLblFcc; 00722 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject; 00723 QLabel *mDictionaryLabel; 00724 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc; 00725 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo; 00726 bool mSpellCheckInProgress; 00727 bool mDone; 00728 bool mAtmModified; 00729 00730 KMEdit* mEditor; 00731 QGridLayout* mGrid; 00732 KMMessage *mMsg; 00733 QValueVector<KMMessage*> mComposedMessages; 00734 KMail::AttachmentListView* mAtmListView; 00735 int mAtmColEncrypt; 00736 int mAtmColSign; 00737 int mAtmEncryptColWidth; 00738 int mAtmSignColWidth; 00739 QPtrList<QListViewItem> mAtmItemList; 00740 QPtrList<KMMessagePart> mAtmList; 00741 QPopupMenu *mAttachMenu; 00742 int mViewId, mRemoveId, mSaveAsId, mPropertiesId; 00743 bool mAutoSign, mAutoPgpSign, mAutoPgpEncrypt, mAutoDeleteMsg; 00744 bool mNeverSignWhenSavingInDrafts, mNeverEncryptWhenSavingInDrafts; 00745 bool mAutoRequestMDN; 00746 bool mLastSignActionState, mLastEncryptActionState; 00747 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey; 00748 KMFolder *mFolder; 00749 long mShowHeaders; 00750 QString mExtEditor; 00751 bool mUseHTMLEditor; 00752 bool mUseExtEditor; 00753 QPtrList<_StringPair> mCustHeaders; 00754 bool mConfirmSend; 00755 bool mDisableBreaking; // Move 00756 int mNumHeaders; 00757 int mLineBreak; 00758 int mWordWrap; 00759 bool mUseFixedFont; 00760 QFont mBodyFont, mFixedFont; 00761 // QList<QLineEdit> mEdtList; 00762 QPtrList<QWidget> mEdtList; 00763 QPtrList<KTempFile> mAtmTempList; 00764 QPalette mPalette; 00765 uint mId; 00766 QString mOldSigText; 00767 QStringList mTransportHistory; 00768 00769 KAction *mAttachPK, *mAttachMPK, 00770 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction; 00771 00772 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction; 00773 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction; 00774 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction; 00775 KToggleAction *mSubjectAction; 00776 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction; 00777 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction; 00778 KToggleAction *mDictionaryAction; 00779 00780 KSelectAction *listAction; 00781 KFontAction *fontAction; 00782 KFontSizeAction *fontSizeAction; 00783 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction; 00784 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction; 00785 KToggleAction *plainTextAction, *markupAction; 00786 KAction *actionFormatColor, *actionFormatReset; 00787 KAction *mHtmlToolbar; 00788 00789 KSelectAction *mEncodingAction; 00790 KSelectAction *mCryptoModuleAction; 00791 00792 QCString mCharset; 00793 QCString mDefCharset; 00794 QStringList mCharsets; 00795 bool mAutoCharset; 00796 00797 bool mAlwaysSend; 00798 bool mOutlookCompatible; 00799 00800 QStringList mFolderNames; 00801 QValueList<QGuardedPtr<KMFolder> > mFolderList; 00802 00803 private: 00804 // helper method for slotInsert(My)PublicKey() 00805 void startPublicKeyExport(); 00806 bool canSignEncryptAttachments() const { 00807 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat; 00808 } 00809 00810 bool mSubjectTextWasSpellChecked; 00811 00812 private slots: 00813 void slotCompletionModeChanged( KGlobalSettings::Completion ); 00814 void slotConfigChanged(); 00815 00816 void slotComposerDone( bool ); 00817 00818 void slotContinueDoSend( bool ); 00819 void slotContinuePrint( bool ); 00820 void slotContinueDeadLetter( bool ); 00821 00826 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata ); 00827 00831 void slotAutoSpellCheckingToggled(bool); 00832 00833 private: 00834 QColor mForeColor,mBackColor; 00835 QFont mSaveFont; 00836 struct atmLoadData 00837 { 00838 KURL url; 00839 QByteArray data; 00840 bool insert; 00841 QCString encoding; 00842 }; 00843 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData; 00844 bool mForceReplyCharset; 00845 00846 // These are for passing on methods over the applyChanges calls 00847 int mSendNow; 00848 bool mSaveInDrafts; 00849 00850 // This is the temporary object that constructs the message out of the 00851 // window 00852 MessageComposer* mComposer; 00853 00854 // Temp var for slotPrint: 00855 bool mMessageWasModified; 00856 00857 // Temp var for slotInsert(My)PublicKey(): 00858 QString mFingerprint; 00859 }; 00860 00861 #endif 00862
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:47 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003