00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef KNCOMPOSER_H
00016 #define KNCOMPOSER_H
00017
00018 #include <k3listview.h>
00019
00020 #include <kxmlguiwindow.h>
00021 #include <kdialog.h>
00022 #include <QRegExp>
00023 #include <QByteArray>
00024 #include <QCloseEvent>
00025 #include <QKeyEvent>
00026 #include <QEvent>
00027 #include <QDropEvent>
00028 #include <QLabel>
00029 #include <QList>
00030 #include <QContextMenuEvent>
00031 #include <QMenu>
00032 #include <QDragEnterEvent>
00033 #include <QSplitter>
00034
00035 #include <kdeversion.h>
00036 #include <kprocess.h>
00037 #include <kabc/addresslineedit.h>
00038
00039 class QGroupBox;
00040
00041 class KSelectAction;
00042 class KToggleAction;
00043 class KNLocalArticle;
00044 class KNAttachment;
00045 class KComboBox;
00046 class QComboBox;
00047 namespace KPIM {
00048 class KMeditor;
00049 }
00050 using KPIM::KMeditor;
00051
00052 namespace KPIMUtils { class SpellingFilter; }
00053 using KPIMUtils::SpellingFilter;
00054
00056 class KNComposer : public KXmlGuiWindow {
00057
00058 Q_OBJECT
00059 Q_CLASSINFO( "D-Bus Interface", "org.kde.knode.composer")
00060
00061 public:
00062 enum composerResult { CRsendNow, CRsendLater, CRdelAsk,
00063 CRdel, CRsave, CRcancel };
00064 enum MessageMode { news=0, mail=1, news_mail=2 };
00065
00066
00067
00068
00069 KNComposer( KNLocalArticle *a, const QString &text = QString(), const QString &sig = QString(),
00070 const QString &unwraped = QString(), bool firstEdit = false,
00071 bool dislikesCopies = false, bool createCopy = false, bool allowMail = true);
00072 ~KNComposer();
00073 void setConfig(bool onlyFonts);
00074 void setMessageMode(MessageMode mode);
00075
00076
00077 bool hasValidData();
00078 composerResult result() const { return r_esult; }
00079 KNLocalArticle* article()const { return a_rticle; }
00080 bool applyChanges();
00081
00082 void closeEvent(QCloseEvent *e);
00083
00084 public slots:
00085
00086 Q_SCRIPTABLE void initData(const QString &text);
00087
00088 public:
00089
00094 void insertFile( QFile *file, bool clear = false, bool box = false, const QString &boxTitle = QString() );
00095
00097 void insertFile(bool clear=false, bool box=false);
00098
00099 QMenu * popupMenu( const QString& name );
00100 int listOfResultOfCheckWord( const QStringList & lst , const QString & selectWord);
00101
00102
00103 class ComposerView;
00104 class Editor;
00105 class AttachmentView;
00106 class AttachmentViewItem;
00107 class AttachmentPropertiesDlg;
00108
00109
00110 ComposerView *v_iew;
00111 QMenu *a_ttPopup;
00112
00113
00114 composerResult r_esult;
00115 KNLocalArticle *a_rticle;
00116 QString s_ignature, u_nwraped;
00117 QByteArray c_harset;
00118 MessageMode m_ode;
00119 bool n_eeds8Bit,
00120 v_alidated,
00121 a_uthorDislikesMailCopies;
00122
00123
00124 bool e_xternalEdited;
00125 KProcess *e_xternalEditor;
00126 KTemporaryFile *e_ditorTempfile;
00127 SpellingFilter* mSpellingFilter;
00128
00129
00130 QList<KNAttachment*> mDeletedAttachments;
00131 QList<QAction*> m_listAction;
00132 bool a_ttChanged;
00133
00134
00135
00136 QAction *a_ctExternalEditor,
00137 *a_ctSpellCheck,
00138 *a_ctRemoveAttachment,
00139 *a_ctAttachmentProperties,
00140 *a_ctSetCharsetKeyb;
00141 KToggleAction *a_ctPGPsign,
00142 *a_ctDoPost, *a_ctDoMail, *a_ctWordWrap, *a_ctAutoSpellChecking;
00143 KSelectAction *a_ctSetCharset;
00144 bool spellLineEdit;
00145 protected slots:
00146 void slotSendNow();
00147 void slotSendLater();
00148 void slotSaveAsDraft();
00149 void slotArtDelete();
00150 void slotAppendSig();
00151 void slotInsertFile();
00152 void slotInsertFileBoxed();
00153 void slotAttachFile();
00154 void slotRemoveAttachment();
00155 void slotAttachmentProperties();
00156 void slotToggleDoPost();
00157 void slotToggleDoMail();
00158 void slotSetCharset(const QString &s);
00159 void slotSetCharsetKeyboard();
00160 void slotToggleWordWrap();
00161 void slotAutoSpellCheckingToggled();
00162 void slotUndoRewrap();
00163 void slotExternalEditor();
00164
00165 void slotUpdateStatusBar();
00166 void slotUpdateCursorPos();
00167 void slotConfKeys();
00168 void slotConfToolbar();
00169 void slotNewToolbarConfig();
00170 void slotUpdateCheckSpellChecking(bool _b);
00171
00172
00173
00174
00175 void slotSubjectChanged(const QString &t);
00176 void slotGroupsChanged(const QString &t);
00177 void slotToBtnClicked();
00178 void slotGroupsBtnClicked();
00179
00180
00181 void slotEditorFinished(int, QProcess::ExitStatus);
00182 void slotCancelEditor();
00183
00184
00185 void slotAttachmentPopup(K3ListView*, Q3ListViewItem *it, const QPoint &p);
00186 void slotAttachmentSelected(Q3ListViewItem *it);
00187 void slotAttachmentEdit(Q3ListViewItem *it);
00188 void slotAttachmentRemove(Q3ListViewItem *it);
00189
00190
00191
00192
00193
00194
00195
00196 virtual void slotDragEnterEvent(QDragEnterEvent *);
00197 virtual void slotDropEvent(QDropEvent *);
00198
00199 void slotUndo();
00200 void slotRedo();
00201 void slotCut();
00202 void slotCopy();
00203 void slotPaste();
00204 void slotSelectAll();
00205 void addRecentAddress();
00206
00207 protected:
00208
00209
00210 virtual void dragEnterEvent(QDragEnterEvent *);
00211 virtual void dropEvent(QDropEvent *);
00212
00213 signals:
00214 void composerDone(KNComposer*);
00215
00216 private:
00217 bool mFirstEdit;
00218
00219 };
00220
00221 #if 0
00222
00223 class KNComposer::Editor : public KEdit {
00224
00225 Q_OBJECT
00226
00227 public:
00228 Editor( KNComposer::ComposerView *_composerView, KNComposer *_composer, QWidget *parent = 0 );
00229 ~Editor();
00230 QStringList processedText();
00231
00232 public slots:
00233 void slotPasteAsQuotation();
00234 void slotFind();
00235 void slotSearchAgain();
00236 void slotReplace();
00237 void slotAddQuotes();
00238 void slotRemoveQuotes();
00239 void slotAddBox();
00240 void slotRemoveBox();
00241 void slotRot13();
00242 void slotCorrectWord();
00243
00244 protected slots:
00245 void slotSpellStarted( K3Spell *);
00246 void slotSpellDone(const QString &);
00247 void slotSpellFinished();
00248 virtual void cut();
00249 virtual void clear();
00250 virtual void del();
00251 signals:
00252 void sigDragEnterEvent(QDragEnterEvent *);
00253 void sigDropEvent(QDropEvent *);
00254
00255 protected:
00256
00257
00258 virtual void contentsDragEnterEvent(QDragEnterEvent *);
00259 virtual void contentsDropEvent(QDropEvent *);
00260 virtual void contentsContextMenuEvent( QContextMenuEvent *e );
00261 virtual void keyPressEvent ( QKeyEvent *e);
00262
00263 virtual bool eventFilter(QObject*, QEvent*);
00264 private:
00265 KNComposer *m_composer;
00266 KNComposer::ComposerView *m_composerView;
00267 K3Spell *spell;
00268 QMap<QString,QStringList> m_replacements;
00269 QRegExp m_bound;
00270 };
00271 #endif
00272
00274 class KNComposer::AttachmentView : public K3ListView {
00275
00276 Q_OBJECT
00277
00278 public:
00279 AttachmentView( QWidget *parent );
00280 ~AttachmentView();
00281
00282 protected:
00283 void keyPressEvent( QKeyEvent *e );
00284
00285 signals:
00286 void delPressed ( Q3ListViewItem * );
00287 };
00288
00289
00291 class KNComposer::AttachmentViewItem : public K3ListViewItem {
00292
00293 public:
00294 AttachmentViewItem(K3ListView *v, KNAttachment *a);
00295 ~AttachmentViewItem();
00296
00297 KNAttachment *attachment;
00298
00299 };
00300
00301
00303 class KNComposer::AttachmentPropertiesDlg : public KDialog {
00304
00305 Q_OBJECT
00306
00307 public:
00308 AttachmentPropertiesDlg( KNAttachment *a, QWidget *parent = 0 );
00309 ~AttachmentPropertiesDlg();
00310
00311 void apply();
00312
00313 protected:
00314 KLineEdit *m_imeType,
00315 *d_escription;
00316 QComboBox *e_ncoding;
00317
00318 KNAttachment *a_ttachment;
00319 bool n_onTextAsText;
00320
00321 protected slots:
00322 void accept();
00323 void slotMimeTypeTextChanged(const QString &text);
00324 };
00325
00326
00328 class KNLineEdit : public KABC::AddressLineEdit
00329 {
00330 Q_OBJECT
00331 typedef KABC::AddressLineEdit KNLineEditInherited;
00332 public:
00333
00334 KNLineEdit( KNComposer::ComposerView *_composerView, bool useCompletion, QWidget *parent = 0 );
00335 protected:
00336
00337 virtual void loadAddresses();
00338 void keyPressEvent(QKeyEvent *e);
00339 virtual void contextMenuEvent( QContextMenuEvent*e );
00340 private slots:
00341 void editRecentAddresses();
00342 private:
00343 KNComposer::ComposerView *composerView;
00344 };
00345
00347 class KNLineEditSpell : public KNLineEdit
00348 {
00349 Q_OBJECT
00350 public:
00351 KNLineEditSpell( KNComposer::ComposerView *_composerView, bool useCompletion, QWidget * parent );
00352 void highLightWord( unsigned int length, unsigned int pos );
00353 void spellCheckDone( const QString &s );
00354 void spellCheckerMisspelling( const QString &text, const QStringList &, unsigned int pos);
00355 void spellCheckerCorrected( const QString &old, const QString &corr, unsigned int pos);
00356 };
00357
00358 #endif