Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/interfaces/bodypartformatter.h
Show All 29 Lines | 1 | /* -*- mode: C++; c-file-style: "gnu" -*- | |||
---|---|---|---|---|---|
30 | you do not wish to do so, delete this exception statement from | 30 | you do not wish to do so, delete this exception statement from | ||
31 | your version. | 31 | your version. | ||
32 | */ | 32 | */ | ||
33 | 33 | | |||
34 | #ifndef __KMAIL_INTERFACE_BODYPARTFORMATTER_H__ | 34 | #ifndef __KMAIL_INTERFACE_BODYPARTFORMATTER_H__ | ||
35 | #define __KMAIL_INTERFACE_BODYPARTFORMATTER_H__ | 35 | #define __KMAIL_INTERFACE_BODYPARTFORMATTER_H__ | ||
36 | 36 | | |||
37 | #include <QObject> | 37 | #include <QObject> | ||
38 | #include <QSharedPointer> | ||||
39 | | ||||
40 | #include <messageviewer/bodypart.h> | ||||
41 | #include <htmlwriter/queuehtmlwriter.h> | ||||
38 | 42 | | |||
39 | namespace MessageViewer | 43 | namespace MessageViewer | ||
40 | { | 44 | { | ||
41 | 45 | | |||
42 | class HtmlWriter; | | |||
43 | 46 | | |||
44 | namespace Interface | 47 | namespace Interface | ||
45 | { | 48 | { | ||
46 | 49 | | |||
47 | class BodyPart; | 50 | class HtmlWriter; | ||
48 | class BodyPartURLHandler; | 51 | class BodyPartURLHandler; | ||
49 | 52 | | |||
53 | class MessagePart | ||||
knauss: we need the MessagePart in Interface to have the process function with MessagePart as return… | |||||
54 | { | ||||
55 | public: | ||||
56 | typedef QSharedPointer<MessagePart> Ptr; | ||||
57 | explicit MessagePart() | ||||
58 | : mHtmlWriter(0) | ||||
59 | , mPart(0) | ||||
60 | { | ||||
61 | } | ||||
62 | | ||||
63 | explicit MessagePart(const BodyPart &part) | ||||
64 | : mHtmlWriter(0) | ||||
65 | , mPart(&part) | ||||
66 | { | ||||
67 | | ||||
68 | } | ||||
69 | virtual ~MessagePart() {} | ||||
70 | | ||||
71 | virtual void html(bool decorate); | ||||
knauss: is used to descide if we have the interface or a propper messagepart. | |||||
Can't you use dynamic_cast for that? That would use the already existing type information rather than something string-based. To the very least, use an enum for this, not a string. vkrause: Can't you use dynamic_cast for that? That would use the already existing type information… | |||||
72 | virtual QString text() const | ||||
73 | { | ||||
74 | return QString(); | ||||
75 | } | ||||
76 | | ||||
it is defined in viewer/bodyforamtter.cpp this is really not a way to go - but it is working... knauss: it is defined in viewer/bodyforamtter.cpp
this is really not a way to go - but it is working... | |||||
77 | private: | ||||
78 | HtmlWriter *htmlWriter(); | ||||
79 | | ||||
80 | HtmlWriter *mHtmlWriter; | ||||
81 | const BodyPart *mPart; | ||||
82 | | ||||
83 | friend class BodyPartFormatter; | ||||
84 | }; | ||||
85 | | ||||
50 | class BodyPartFormatter | 86 | class BodyPartFormatter | ||
51 | { | 87 | { | ||
52 | public: | 88 | public: | ||
53 | virtual ~BodyPartFormatter() {} | 89 | virtual ~BodyPartFormatter() {} | ||
54 | 90 | | |||
55 | /** | 91 | /** | ||
56 | @li Ok returned when format() generated some HTML | 92 | @li Ok returned when format() generated some HTML | ||
57 | @li NeedContent returned when format() needs the body of the part | 93 | @li NeedContent returned when format() needs the body of the part | ||
Show All 16 Lines | 107 | /** | |||
74 | 110 | | |||
75 | @return the result code (see above) | 111 | @return the result code (see above) | ||
76 | */ | 112 | */ | ||
77 | virtual Result format(BodyPart *part, HtmlWriter *writer, QObject *asyncResultObserver) const | 113 | virtual Result format(BodyPart *part, HtmlWriter *writer, QObject *asyncResultObserver) const | ||
78 | { | 114 | { | ||
79 | Q_UNUSED(asyncResultObserver); | 115 | Q_UNUSED(asyncResultObserver); | ||
80 | return format(part, writer); | 116 | return format(part, writer); | ||
81 | } | 117 | } | ||
118 | | ||||
119 | virtual MessagePart::Ptr process(BodyPart &part) const | ||||
120 | { | ||||
121 | qDebug() << "should never happen tm"; | ||||
122 | auto mp = MessagePart::Ptr(new MessagePart(part)); | ||||
123 | const auto ret = format(&part,mp->htmlWriter()); | ||||
124 | if (ret != Failed) { | ||||
125 | return mp; | ||||
126 | } | ||||
127 | return MessagePart::Ptr(); | ||||
128 | } | ||||
82 | }; | 129 | }; | ||
83 | 130 | | |||
84 | /** | 131 | /** | ||
85 | @short interface for BodyPartFormatter plugins | 132 | @short interface for BodyPartFormatter plugins | ||
86 | 133 | | |||
87 | The interface is queried by for types, subtypes, and the | 134 | The interface is queried by for types, subtypes, and the | ||
88 | corresponding bodypart formatter, and the result inserted into | 135 | corresponding bodypart formatter, and the result inserted into | ||
89 | the bodypart formatter factory. | 136 | the bodypart formatter factory. | ||
Show All 23 Lines |
we need the MessagePart in Interface to have the process function with MessagePart as return value