00001
00002
00003
00004
00005
#ifndef KMREADERWIN_H
00006
#define KMREADERWIN_H
00007
00008
#include <qwidget.h>
00009
#include <qtimer.h>
00010
#include <qstringlist.h>
00011
#include <kurl.h>
00012
#include <kservice.h>
00013
#include "kmmsgbase.h"
00014
#include "kmmimeparttree.h"
00015
#include "iobserver.h"
00016
00017
class QFrame;
00018
class QSplitter;
00019
class QHBox;
00020
class QListViewItem;
00021
class QScrollBar;
00022
class QString;
00023
class QTabDialog;
00024
class QTextCodec;
00025
class DwHeaders;
00026
class DwMediaType;
00027
class KActionCollection;
00028
class KAction;
00029
class KActionMenu;
00030
class KToggleAction;
00031
class KConfigBase;
00032
class KHTMLPart;
00033
class KURL;
00034
class KMFolder;
00035
class KMMessage;
00036
class KMMessagePart;
00037
namespace KMail {
00038
class PartMetaData;
00039
class ObjectTreeParser;
00040
class AttachmentStrategy;
00041
class HeaderStrategy;
00042
class HeaderStyle;
00043
class HtmlWriter;
00044
class KHtmlPartHtmlWriter;
00045
class ISubject;
00046
class HtmlStatusBar;
00047
class FolderJob;
00048
class CSSHelper;
00049 }
00050
00051
class partNode;
00052
00053
00054
class NewByteArray;
00055
00056
namespace KParts {
00057
struct URLArgs;
00058 }
00059
00060
class KMReaderWin:
public QWidget,
public KMail::IObserver
00061 {
00062 Q_OBJECT
00063
00064
friend void KMMimePartTree::itemClicked( QListViewItem* item );
00065
friend void KMMimePartTree::itemRightClicked( QListViewItem* item,
const QPoint & );
00066
friend void KMMimePartTree::slotSaveAs();
00067
00068
friend class KMail::ObjectTreeParser;
00069
friend class KMail::KHtmlPartHtmlWriter;
00070
00071
public:
00072 KMReaderWin( QWidget *parent,
00073 QWidget *mainWindow,
00074 KActionCollection *actionCollection,
00075
const char *name=0,
00076
int f=0 );
00077
virtual ~KMReaderWin();
00078
00080
virtual bool update( KMail::ISubject * );
00081
00083
void readConfig();
00084
00086
void writeConfig(
bool withSync=
true )
const;
00087
00088
const KMail::HeaderStyle * headerStyle()
const {
00089
return mHeaderStyle;
00090 }
00093
void setHeaderStyleAndStrategy(
const KMail::HeaderStyle * style,
00094
const KMail::HeaderStrategy * strategy );
00095
00097
const KMail::HeaderStrategy * headerStrategy()
const {
00098
return mHeaderStrategy;
00099 }
00100
00102
const KMail::AttachmentStrategy * attachmentStrategy()
const {
00103
return mAttachmentStrategy;
00104 }
00105
void setAttachmentStrategy(
const KMail::AttachmentStrategy * strategy );
00106
00110
const QTextCodec * overrideCodec()
const {
return mOverrideCodec; }
00111
00114
void setOverrideCodec(
const QTextCodec * codec );
00115
00118
bool autoDetectEncoding()
const {
return !overrideCodec(); }
00119
00121
virtual void setPrinting(
bool enable) { mPrinting = enable; }
00122
00125
virtual void setMsg(KMMessage* msg,
bool force =
false);
00126
00129
void setMsgPart( KMMessagePart* aMsgPart,
bool aHTML,
00130
const QString& aFileName,
const QString& pname );
00131
00132
void setMsgPart( partNode * node );
00133
00136
void showHideMimeTree(
bool isPlainTextTopLevel );
00137
00142
void setIdOfLastViewedMessage(
const QString & msgId )
00143 { mIdOfLastViewedMessage = msgId; }
00144
00146
void clear(
bool force =
false) { setMsg(0, force); }
00147
00149
void update(
bool force =
false);
00150
00152
virtual void printMsg(
void);
00153
00155 QString copyText();
00156
00158
bool autoDelete(
void)
const {
return mAutoDelete; }
00159
void setAutoDelete(
bool f) { mAutoDelete=f; }
00160
00162
bool htmlOverride()
const {
return mHtmlOverride; }
00163
void setHtmlOverride(
bool override );
00164
00166
bool htmlMail();
00167
00169
void displayAboutPage();
00170
00172
void enableMsgDisplay();
00173
00175
void atmViewMsg(KMMessagePart* msgPart);
00176
00177
bool atBottom() const;
00178
00179
bool isFixedFont() {
return mUseFixedFont; }
00180
00182
KMail::HtmlWriter * htmlWriter() {
return mHtmlWriter; }
00183
00184
00185
00186 KToggleAction *toggleFixFontAction() {
return mToggleFixFontAction; }
00187 KAction *viewSourceAction() {
return mViewSourceAction; }
00188 KAction *mailToComposeAction() {
return mMailToComposeAction; }
00189 KAction *mailToReplyAction() {
return mMailToReplyAction; }
00190 KAction *mailToForwardAction() {
return mMailToForwardAction; }
00191 KAction *addAddrBookAction() {
return mAddAddrBookAction; }
00192 KAction *openAddrBookAction() {
return mOpenAddrBookAction; }
00193 KAction *copyAction() {
return mCopyAction; }
00194 KAction *copyURLAction() {
return mCopyURLAction; }
00195 KAction *urlOpenAction() {
return mUrlOpenAction; }
00196 KAction *urlSaveAsAction() {
return mUrlSaveAsAction; }
00197 KAction *addBookmarksAction() {
return mAddBookmarksAction;}
00198
00199
00200
00201
00202
void objectTreeToDecryptedMsg( partNode* node,
00203 NewByteArray& resultingData,
00204 KMMessage& theMessage,
00205
bool weAreReplacingTheRootNode =
false,
00206
int recCount = 0 );
00207
00209 partNode* partNodeFromUrl(
const KURL &url);
00210
00212
static int msgPartFromUrl(
const KURL &url);
00213
00214
void setUpdateAttachment() { mAtmUpdate =
true; }
00215
00218 KHTMLPart * htmlPart()
const {
return mViewer; }
00219
00221 KMMessage* message(
KMFolder** folder=0)
const;
00222
00223
void openAttachment(
int id,
const QString & name );
00224
00225
void emitUrlClicked(
const KURL & url,
int button ) {
00226 emit urlClicked( url, button );
00227 }
00228
00229
void emitPopupMenu(
const KURL & url,
const QPoint & p ) {
00230
if ( message() )
00231 emit popupMenu( *message(), url, p );
00232 }
00233
00234
void showAttachmentPopup(
int id,
const QString & name,
const QPoint & p );
00235
00236 signals:
00239
void replaceMsgByUnencryptedVersion();
00240
00242
void statusMsg(
const QString& text);
00243
00245
void popupMenu(KMMessage &msg,
const KURL &url,
const QPoint& mousePos);
00246
00248
void urlClicked(
const KURL &url,
int button);
00249
00251
void noDrag(
void);
00252
00254
void signalGroupwareShow(
bool);
00255
00256
public slots:
00257
00259
void selectAll();
00260
00262
void clearCache();
00263
00265
void updateReaderWin();
00266
00268
void slotScrollUp();
00269
void slotScrollDown();
00270
void slotScrollPrior();
00271
void slotScrollNext();
00272
void slotJumpDown();
00273
void slotDocumentChanged();
00274
void slotDocumentDone();
00275
void slotTextSelected(
bool);
00276
00278
void slotUrlOpen(
const KURL &url,
const KParts::URLArgs &args);
00279
00281
void slotUrlOn(
const QString &url);
00282
00284
void slotUrlPopup(
const QString &,
const QPoint& mousePos);
00285
00287
void slotFind();
00288
00290
void slotToggleFixedFont();
00291
00293
void slotCopySelectedText();
00294
00295
void slotUrlClicked();
00296
00298
void slotMailtoReply();
00299
void slotMailtoCompose();
00300
void slotMailtoForward();
00301
void slotMailtoAddAddrBook();
00302
void slotMailtoOpenAddrBook();
00305
void slotUrlCopy();
00306
void slotUrlOpen(
const KURL &url = KURL() );
00308
void slotUrlSave();
00309
void slotAddBookmarks();
00310
void slotShowMsgSrc();
00311
void slotSaveMsg();
00312
void slotSaveAttachments();
00313
00314
protected slots:
00316
void slotAtmOpen();
00317
void slotDoAtmOpen();
00318
void slotAtmOpenWith();
00319
void slotAtmView();
00320
void slotAtmSave();
00321
void slotAtmProperties();
00322
void slotDelayedResize();
00323
void slotTouchMessage();
00324
void slotAtmLoadPart(
int );
00325
void slotAtmDistributeClick();
00326
00327
protected:
00330
void styleChange( QStyle& oldStyle );
00331
00334
void setStyleDependantFrameWidth();
00335
00337
virtual bool event(QEvent *e);
00338
00340
int pointsToPixel(
int pointSize)
const;
00341
00344
void displayMessage();
00345
00347
virtual void parseMsg( KMMessage* msg );
00348
00351 QString writeMsgHeader(KMMessage* aMsg,
bool hasVCard=
false);
00352
00356 QString writeMessagePartToTempFile( KMMessagePart* msgPart,
int partNumber );
00357
00359
void showVCard(KMMessagePart *msgPart);
00360
00362
virtual void initHtmlWidget(
void);
00363
00365
virtual void closeEvent(QCloseEvent *);
00366
virtual void resizeEvent(QResizeEvent *);
00367
00369
virtual void removeTempFiles();
00370
00371
private:
00372
void adjustLayout();
00373
void createWidgets();
00374
void createActions( KActionCollection * ac );
00375
void saveSplitterSizes( KConfigBase & c )
const;
00376
00377
private:
00378
bool mHtmlMail, mHtmlOverride;
00379
int mAtmCurrent;
00380 QString mAtmCurrentName;
00381 KMMessage *mMessage;
00382
00383 QSplitter * mSplitter;
00384 QHBox *mBox;
00385
KMail::HtmlStatusBar *mColorBar;
00386 KMMimePartTree* mMimePartTree;
00387 KHTMLPart *mViewer;
00388
00389
const KMail::AttachmentStrategy * mAttachmentStrategy;
00390
const KMail::HeaderStrategy * mHeaderStrategy;
00391
const KMail::HeaderStyle * mHeaderStyle;
00392
bool mAutoDelete;
00394 QString mSaveAttachDir;
00395
static const int delay;
00396 QTimer updateReaderWinTimer;
00397 QTimer mResizeTimer;
00398 QTimer mDelayedMarkTimer;
00399
const QTextCodec * mOverrideCodec;
00400
bool mMsgDisplay;
00401
bool mDelayedMarkAsRead;
00402
unsigned long mLastSerNum;
00403 KMMsgStatus mLastStatus;
00404
00405 KMail::CSSHelper * mCSSHelper;
00406
bool mUseFixedFont;
00407
bool mPrinting;
00408
00409
bool mShowColorbar;
00410
00411 uint mDelayedMarkTimeout;
00412 QStringList mTempFiles;
00413 QStringList mTempDirs;
00414
int mMimeTreeMode;
00415
bool mMimeTreeAtBottom;
00416 QValueList<int> mSplitterSizes;
00417 partNode* mRootNode;
00418 QString mIdOfLastViewedMessage;
00419 QWidget *mMainWindow;
00420 KAction *mViewSourceAction, *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00421 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00422 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction;
00423
00424 KToggleAction *mToggleFixFontAction;
00425 KURL mUrlClicked;
00426
KMail::HtmlWriter * mHtmlWriter;
00427
00428
bool mAtmUpdate;
00429
int mChoice;
00430 KService::Ptr mOffer;
00431 };
00432
00433
00434
#endif
00435