fixed some bugs with the httpTitle stuff...
[basket4.git] / src / notecontent.h
blob7fa49ec04b300a596dbde1f9058ae27e945cfb85
1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
3 * slaout@linux62.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef NOTECONTENT_H
22 #define NOTECONTENT_H
24 #include <qobject.h>
25 #include <qstring.h>
26 #include <qsimplerichtext.h>
27 #include <qpixmap.h>
28 #include <qmovie.h>
29 #include <qcolor.h>
30 #include <kurl.h>
31 #include <qhttp.h>
33 #include "linklabel.h"
35 class QDomDocument;
36 class QDomElement;
37 class QPainter;
38 class QWidget;
39 class QPoint;
40 class QRect;
41 class QStringList;
42 class KMultipleDrag;
44 class KFileItem;
45 namespace KIO { class PreviewJob; }
47 class Note;
48 class Basket;
49 class FilterData;
50 class HtmlExporter;
52 /** A list of numeric identifier for each note type.
53 * Declare a varible with the type NoteType::Id and assign a value like NoteType::Text...
54 * @author S�astien Laot
56 namespace NoteType
58 enum Id { Group = 255, Text = 1, Html, Image, Animation, Sound, File, Link, Launcher, Color, Unknown }; // Always positive
61 /** Abstract base class for every content type of basket note.
62 * It's a base class to represent those types: Text, Html, Image, Animation, Sound, File, Link, Launcher, Color, Unknown.
63 * @author S�astien Laot
65 class NoteContent // TODO: Mark some methods as const! and some (like typeName() as static!
67 public:
68 // Constructor and destructor:
69 NoteContent(Note *parent, const QString &fileName = ""); /// << Constructor. Inherited notes should call it to initialize the parent note.
70 virtual ~NoteContent() {} /// << Virtual destructor. Reimplement it if you should destroy some data your custom types.
71 // Simple Abstract Generic Methods:
72 virtual NoteType::Id type() = 0; /// << @return the internal number that identify that note type.
73 virtual QString typeName() = 0; /// << @return the translated type name to display in the user interface.
74 virtual QString lowerTypeName() = 0; /// << @return the type name in lowercase without space, for eg. saving.
75 virtual QString toText(const QString &cuttedFullPath); /// << @return a plain text equivalent of the content.
76 virtual QString toHtml(const QString &imageName, const QString &cuttedFullPath) = 0; /// << @return an HTML text equivalent of the content. @param imageName Save image in this Qt ressource.
77 virtual QPixmap toPixmap() { return QPixmap(); } /// << @return an image equivalent of the content.
78 virtual void toLink(KURL *url, QString *title, const QString &cuttedFullPath); /// << Set the link to the content. By default, it set them to fullPath() if useFile().
79 virtual bool useFile() = 0; /// << @return true if it use a file to store the content.
80 virtual bool canBeSavedAs() = 0; /// << @return true if the content can be saved as a file by the user.
81 virtual QString saveAsFilters() = 0; /// << @return the filters for the user to choose a file destination to save the note as.
82 virtual bool match(const FilterData &data) = 0; /// << @return true if the content match the filter criterias.
83 // Complexe Abstract Generic Methods:
84 virtual void exportToHTML(HTMLExporter *exporter, int indent) = 0; /// << Export the note in an HTML file.
85 virtual QString cssClass() = 0; /// << @return the CSS class of the note when exported to HTML
86 virtual int setWidthAndGetHeight(int width) = 0; /// << Relayout content with @p width (never less than minWidth()). @return its new height.
87 virtual void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered) = 0; /// << Paint the content on @p painter, at coordinate (0, 0) and with the size (@p width, @p height).
88 virtual bool loadFromFile(bool /*lazyLoad*/) { return false; } /// << Load the content from the file. The default implementation does nothing. @see fileName().
89 virtual bool finishLazyLoad() { return false; } /// << Load what was not loaded by loadFromFile() if it was lazy-loaded
90 virtual bool saveToFile() { return false; } /// << Save the content to the file. The default implementation does nothing. @see fileName().
91 virtual QString linkAt(const QPoint &/*pos*/) { return ""; } /// << @return the link anchor at position @p pos or "" if there is no link.
92 virtual void saveToNode(QDomDocument &doc, QDomElement &content); /// << Save the note in the basket XML file. By default it store the filename if a file is used.
93 virtual void fontChanged() = 0; /// << If your content display textual data, called when the font have changed (from tags or basket font)
94 virtual void linkLookChanged() {} /// << If your content use LinkDisplay with preview enabled, reload the preview (can have changed size)
95 virtual QString editToolTipText() = 0; /// << @return "Edit this [text|image|...]" to put in the tooltip for the note's content zone.
96 virtual void toolTipInfos(QStringList */*keys*/, QStringList */*values*/) {} /// << Get "key: value" couples to put in the tooltip for the note's content zone.
97 // Custom Zones: /// Implement this if you want to store custom data.
98 virtual int zoneAt(const QPoint &/*pos*/) { return 0; } /// << If your note-type have custom zones, @return the zone at @p pos or 0 if it's not a custom zone!
99 virtual QRect zoneRect(int zone, const QPoint &/*pos*/); /// << Idem, @return the rect of the custom zone
100 virtual QString zoneTip(int /*zone*/) { return ""; } /// << Idem, @return the toolTip of the custom zone
101 virtual void setCursor(QWidget */*widget*/, int /*zone*/) {} /// << Idem, set the mouse cursor for widget @p widget when it is over zone @p zone!
102 virtual void setHoveredZone(int /*oldZone*/, int /*newZone*/) {} /// << If your note type need some feedback, you get notified of hovering changes here.
103 virtual QString statusBarMessage(int /*zone*/) { return ""; } /// << @return the statusBar message to show for zone @p zone, or "" if nothing special have to be said.
104 // Drag and Drop Content:
105 virtual void serialize(QDataStream &/*stream*/) {} /// << Serialize the content in a QDragObject. If it consists of a file, it can be serialized for you.
106 virtual bool shouldSerializeFile() { return useFile(); } /// << @return true if the dragging process should serialize the filename (and move the file if cutting).
107 virtual void addAlternateDragObjects(KMultipleDrag*/*dragObj*/) {} /// << If you offer more than toText/Html/Image/Link(), this will be called if this is the only selected.
108 virtual QPixmap feedbackPixmap(int width, int height) = 0; /// << @return the pixmap to put under the cursor while dragging this object.
109 virtual bool needSpaceForFeedbackPixmap() { return false; } /// << @return true if a space must be inserted before and after the DND feedback pixmap.
110 // Content Edition:
111 virtual int xEditorIndent() { return 0; } /// << If the editor should be indented (eg. to not cover an icon), return the number of pixels.
112 // Open Content or File:
113 virtual KURL urlToOpen(bool /*with*/); /// << @return the URL to open the note, or an invalid KURL if it's not openable. If @p with if false, it's a normal "Open". If it's true, it's for an "Open with..." action. The default implementation return the fullPath() if the note useFile() and nothing if not.
114 enum OpenMessage {
115 OpenOne, /// << Message to send to the statusbar when opening this note.
116 OpenSeveral, /// << Message to send to the statusbar when opening several notes of this type.
117 OpenOneWith, /// << Message to send to the statusbar when doing "Open With..." on this note.
118 OpenSeveralWith, /// << Message to send to the statusbar when doing "Open With..." several notes of this type.
119 OpenOneWithDialog, /// << Prompt-message of the "Open With..." dialog for this note.
120 OpenSeveralWithDialog /// << Prompt-message of the "Open With..." dialog for several notes of this type.
122 virtual QString messageWhenOpenning(OpenMessage /*where*/) { return QString(); } /// << @return the message to display according to @p where or nothing if it can't be done. @see OpenMessage describing the nature of the message that should be returned... The default implementation return an empty string. NOTE: If urlToOpen() is invalid and messageWhenOpenning() is not empty, then the user will be prompted to edit the note (with the message returned by messageWhenOpenning()) for eg. being able to edit URL of a link if it's empty when opening it...
123 virtual QString customOpenCommand() { return QString(); } /// << Reimplement this if your urlToOpen() should be opened with another application instead of the default KDE one. This choice should be left to the users in the setting (choice to use a custom app or not, and which app).
124 // Common File Management: /// (and do save changes) and optionnaly hide the toolbar.
125 virtual void setFileName(const QString &fileName); /// << Set the filename. Reimplement it if you eg. want to update the view when the filename is changed.
126 bool trySetFileName(const QString &fileName); /// << Set the new filename and return true. Can fail and return false if a file with this fileName already exists.
127 QString fullPath(); /// << Get the absolute path of the file where this content is stored on disk.
128 QString fileName() { return m_fileName; } /// << Get the file name where this content is stored (relative to the basket folder). @see fullPath().
129 int minWidth() { return m_minWidth; } /// << Get the minimum width for this content.
130 Note *note() { return m_note; } /// << Get the note managing this content.
131 Basket *basket(); /// << Get the basket containing the note managing this content.
132 public:
133 void setEdited(); /// << Mark the note as edited NOW: change the "last modification time and time" AND save the basket to XML file.
134 protected:
135 void contentChanged(int newMinWidth); /// << When the content has changed, inherited classes should call this to specify its new minimum size and trigger a basket relayout.
136 private:
137 Note *m_note;
138 QString m_fileName;
139 int m_minWidth;
140 public:
141 static const int FEEDBACK_DARKING;
144 /** Real implementation of plain text notes:
145 * @author S�astien Laot
147 class TextContent : public NoteContent
149 public:
150 // Constructor and destructor:
151 TextContent(Note *parent, const QString &fileName, bool lazyLoad = false);
152 ~TextContent();
153 // Simple Generic Methods:
154 NoteType::Id type();
155 QString typeName();
156 QString lowerTypeName();
157 QString toText(const QString &/*cuttedFullPath*/);
158 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
159 bool useFile();
160 bool canBeSavedAs();
161 QString saveAsFilters();
162 bool match(const FilterData &data);
163 // Complexe Generic Methods:
164 void exportToHTML(HTMLExporter *exporter, int indent);
165 QString cssClass();
166 int setWidthAndGetHeight(int width);
167 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
168 bool loadFromFile(bool lazyLoad);
169 bool finishLazyLoad();
170 bool saveToFile();
171 QString linkAt(const QPoint &pos);
172 void fontChanged();
173 QString editToolTipText();
174 // Drag and Drop Content:
175 QPixmap feedbackPixmap(int width, int height);
176 // Open Content or File:
177 QString messageWhenOpenning(OpenMessage where);
178 // QString customOpenCommand();
179 // Content-Specific Methods:
180 void setText(const QString &text, bool lazyLoad = false); /// << Change the text note-content and relayout the note.
181 QString text() { return m_text; } /// << @return the text note-content.
182 protected:
183 QString m_text;
184 QSimpleRichText *m_simpleRichText;
187 /** Real implementation of rich text (HTML) notes:
188 * @author S�astien Laot
190 class HtmlContent : public NoteContent
192 public:
193 // Constructor and destructor:
194 HtmlContent(Note *parent, const QString &fileName, bool lazyLoad = false);
195 ~HtmlContent();
196 // Simple Generic Methods:
197 NoteType::Id type();
198 QString typeName();
199 QString lowerTypeName();
200 QString toText(const QString &/*cuttedFullPath*/);
201 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
202 bool useFile();
203 bool canBeSavedAs();
204 QString saveAsFilters();
205 bool match(const FilterData &data);
206 // Complexe Generic Methods:
207 void exportToHTML(HTMLExporter *exporter, int indent);
208 QString cssClass();
209 int setWidthAndGetHeight(int width);
210 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
211 bool loadFromFile(bool lazyLoad);
212 bool finishLazyLoad();
213 bool saveToFile();
214 QString linkAt(const QPoint &pos);
215 void fontChanged();
216 QString editToolTipText();
217 // Drag and Drop Content:
218 QPixmap feedbackPixmap(int width, int height);
219 // Open Content or File:
220 QString messageWhenOpenning(OpenMessage where);
221 QString customOpenCommand();
222 // Content-Specific Methods:
223 void setHtml(const QString &html, bool lazyLoad = false); /// << Change the HTML note-content and relayout the note.
224 QString html() { return m_html; } /// << @return the HTML note-content.
225 protected:
226 QString m_html;
227 QString m_textEquivalent; //OPTIM_FILTER
228 QSimpleRichText *m_simpleRichText;
231 /** Real implementation of image notes:
232 * @author S�astien Laot
234 class ImageContent : public NoteContent
236 public:
237 // Constructor and destructor:
238 ImageContent(Note *parent, const QString &fileName, bool lazyLoad = false);
239 // Simple Generic Methods:
240 NoteType::Id type();
241 QString typeName();
242 QString lowerTypeName();
243 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
244 QPixmap toPixmap();
245 bool useFile();
246 bool canBeSavedAs();
247 QString saveAsFilters();
248 bool match(const FilterData &data);
249 // Complexe Generic Methods:
250 void exportToHTML(HTMLExporter *exporter, int indent);
251 QString cssClass();
252 int setWidthAndGetHeight(int width);
253 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
254 bool loadFromFile(bool lazyLoad);
255 bool finishLazyLoad();
256 bool saveToFile();
257 void fontChanged();
258 QString editToolTipText();
259 void toolTipInfos(QStringList *keys, QStringList *values);
260 // Drag and Drop Content:
261 QPixmap feedbackPixmap(int width, int height);
262 bool needSpaceForFeedbackPixmap() { return true; }
263 // Open Content or File:
264 QString messageWhenOpenning(OpenMessage where);
265 QString customOpenCommand();
266 // Content-Specific Methods:
267 void setPixmap(const QPixmap &pixmap); /// << Change the pixmap note-content and relayout the note.
268 QPixmap pixmap() { return m_pixmap; } /// << @return the pixmap note-content.
269 protected:
270 QPixmap m_pixmap;
271 char *m_format;
274 /** Real implementation of animated image (GIF, MNG) notes:
275 * @author S�astien Laot
277 class AnimationContent : public QObject, public NoteContent // QObject to be able to receive QMovie signals
279 Q_OBJECT
280 public:
281 // Constructor and destructor:
282 AnimationContent(Note *parent, const QString &fileName, bool lazyLoad = false);
283 // Simple Generic Methods:
284 NoteType::Id type();
285 QString typeName();
286 QString lowerTypeName();
287 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
288 QPixmap toPixmap();
289 bool useFile();
290 bool canBeSavedAs();
291 QString saveAsFilters();
292 bool match(const FilterData &data);
293 void fontChanged();
294 QString editToolTipText();
295 // Drag and Drop Content:
296 QPixmap feedbackPixmap(int width, int height);
297 bool needSpaceForFeedbackPixmap() { return true; }
298 // Complexe Generic Methods:
299 void exportToHTML(HTMLExporter *exporter, int indent);
300 QString cssClass();
301 int setWidthAndGetHeight(int width);
302 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
303 bool loadFromFile(bool lazyLoad);
304 bool finishLazyLoad();
305 bool saveToFile();
306 // Open Content or File:
307 QString messageWhenOpenning(OpenMessage where);
308 QString customOpenCommand();
309 // Content-Specific Methods:
310 bool setMovie(const QMovie &movie); /// << Change the movie note-content and relayout the note.
311 QMovie movie() { return m_movie; } /// << @return the movie note-content.
312 protected slots:
313 void movieUpdated(const QRect&);
314 void movieResized(const QSize&);
315 void movieStatus(int status);
316 protected:
317 QMovie m_movie;
318 int m_oldStatus;
319 static int INVALID_STATUS;
322 /** Real implementation of file notes:
323 * @author S�astien Laot
325 class FileContent : public QObject, public NoteContent
327 Q_OBJECT
328 public:
329 // Constructor and destructor:
330 FileContent(Note *parent, const QString &fileName);
331 // Simple Generic Methods:
332 NoteType::Id type();
333 QString typeName();
334 QString lowerTypeName();
335 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
336 bool useFile();
337 bool canBeSavedAs();
338 QString saveAsFilters();
339 bool match(const FilterData &data);
340 // Complexe Generic Methods:
341 void exportToHTML(HTMLExporter *exporter, int indent);
342 QString cssClass();
343 int setWidthAndGetHeight(int width);
344 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
345 bool loadFromFile(bool /*lazyLoad*/);
346 void fontChanged();
347 void linkLookChanged();
348 QString editToolTipText();
349 void toolTipInfos(QStringList *keys, QStringList *values);
350 // Drag and Drop Content:
351 QPixmap feedbackPixmap(int width, int height);
352 // Custom Zones:
353 int zoneAt(const QPoint &pos);
354 QRect zoneRect(int zone, const QPoint &/*pos*/);
355 QString zoneTip(int zone);
356 void setCursor(QWidget *widget, int zone);
357 // Content Edition:
358 int xEditorIndent();
359 // Open Content or File:
360 QString messageWhenOpenning(OpenMessage where);
361 // Content-Specific Methods:
362 void setFileName(const QString &fileName); /// << Reimplemented to be able to relayout the note.
363 virtual LinkLook* linkLook() { return LinkLook::fileLook; }
364 protected:
365 LinkDisplay m_linkDisplay;
366 // File Preview Management:
367 protected slots:
368 void newPreview(const KFileItem*, const QPixmap &preview);
369 void removePreview(const KFileItem*);
370 void startFetchingUrlPreview();
371 protected:
372 KIO::PreviewJob *m_previewJob;
375 /** Real implementation of sound notes:
376 * @author S�astien Laot
378 class SoundContent : public FileContent // A sound is a file with just a bit different user interaction
380 Q_OBJECT
381 public:
382 // Constructor and destructor:
383 SoundContent(Note *parent, const QString &fileName);
384 // Simple Generic Methods:
385 NoteType::Id type();
386 QString typeName();
387 QString lowerTypeName();
388 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
389 bool useFile();
390 bool canBeSavedAs();
391 QString saveAsFilters();
392 bool match(const FilterData &data);
393 QString editToolTipText();
394 // Complexe Generic Methods:
395 QString cssClass();
396 // Custom Zones:
397 QString zoneTip(int zone);
398 void setHoveredZone(int oldZone, int newZone);
399 // Open Content or File:
400 QString messageWhenOpenning(OpenMessage where);
401 QString customOpenCommand();
402 // Content-Specific Methods:
403 LinkLook* linkLook() { return LinkLook::soundLook; }
406 /** Real implementation of link notes:
407 * @author S�astien Laot
409 class LinkContent : public QObject, public NoteContent
411 Q_OBJECT
412 public:
413 // Constructor and destructor:
414 LinkContent(Note *parent, const KURL &url, const QString &title, const QString &icon, bool autoTitle, bool autoIcon);
415 ~LinkContent();
416 // Simple Generic Methods:
417 NoteType::Id type();
418 QString typeName();
419 QString lowerTypeName();
420 QString toText(const QString &/*cuttedFullPath*/);
421 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
422 void toLink(KURL *url, QString *title, const QString &cuttedFullPath);
423 bool useFile();
424 bool canBeSavedAs();
425 QString saveAsFilters();
426 bool match(const FilterData &data);
427 // Complexe Generic Methods:
428 void exportToHTML(HTMLExporter *exporter, int indent);
429 QString cssClass();
430 int setWidthAndGetHeight(int width);
431 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
432 void saveToNode(QDomDocument &doc, QDomElement &content);
433 void fontChanged();
434 void linkLookChanged();
435 QString editToolTipText();
436 void toolTipInfos(QStringList *keys, QStringList *values);
437 // Drag and Drop Content:
438 void serialize(QDataStream &stream);
439 QPixmap feedbackPixmap(int width, int height);
440 // Custom Zones:
441 int zoneAt(const QPoint &pos);
442 QRect zoneRect(int zone, const QPoint &/*pos*/);
443 QString zoneTip(int zone);
444 void setCursor(QWidget *widget, int zone);
445 QString statusBarMessage(int zone);
446 // Open Content or File:
447 KURL urlToOpen(bool /*with*/);
448 QString messageWhenOpenning(OpenMessage where);
449 // Content-Specific Methods:
450 void setLink(const KURL &url, const QString &title, const QString &icon, bool autoTitle, bool autoIcon); /// << Change the link and relayout the note.
451 KURL url() { return m_url; } /// << @return the URL of the link note-content.
452 QString title() { return m_title; } /// << @return the displayed title of the link note-content.
453 QString icon() { return m_icon; } /// << @return the displayed icon of the link note-content.
454 bool autoTitle() { return m_autoTitle; } /// << @return if the title is auto-computed from the URL.
455 bool autoIcon() { return m_autoIcon; } /// << @return if the icon is auto-computed from the URL.
456 void startFetchingLinkTitle();
457 protected:
458 KURL m_url;
459 QString m_title;
460 QString m_icon;
461 bool m_autoTitle;
462 bool m_autoIcon;
463 LinkDisplay m_linkDisplay;
464 QHttp* m_http;
465 QString* m_httpBuff;
466 // File Preview Management:
467 protected slots:
468 void httpDone(bool err);
469 void httpReadyRead(const QHttpResponseHeader& resp);
470 void newPreview(const KFileItem*, const QPixmap &preview);
471 void removePreview(const KFileItem*);
472 void startFetchingUrlPreview();
473 protected:
474 KIO::PreviewJob *m_previewJob;
477 /** Real implementation of launcher notes:
478 * @author S�astien Laot
480 class LauncherContent : public NoteContent
482 public:
483 // Constructor and destructor:
484 LauncherContent(Note *parent, const QString &fileName);
485 // Simple Generic Methods:
486 NoteType::Id type();
487 QString typeName();
488 QString lowerTypeName();
489 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
490 void toLink(KURL *url, QString *title, const QString &cuttedFullPath);
491 bool useFile();
492 bool canBeSavedAs();
493 QString saveAsFilters();
494 bool match(const FilterData &data);
495 // Complexe Generic Methods:
496 void exportToHTML(HTMLExporter *exporter, int indent);
497 QString cssClass();
498 int setWidthAndGetHeight(int width);
499 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
500 bool loadFromFile(bool /*lazyLoad*/);
501 void fontChanged();
502 QString editToolTipText();
503 void toolTipInfos(QStringList *keys, QStringList *values);
504 // Drag and Drop Content:
505 QPixmap feedbackPixmap(int width, int height);
506 // Custom Zones:
507 int zoneAt(const QPoint &pos);
508 QRect zoneRect(int zone, const QPoint &/*pos*/);
509 QString zoneTip(int zone);
510 void setCursor(QWidget *widget, int zone);
511 // Open Content or File:
512 KURL urlToOpen(bool with);
513 QString messageWhenOpenning(OpenMessage where);
514 // Content-Specific Methods:
515 void setLauncher(const QString &name, const QString &icon, const QString &exec); /// << Change the launcher note-content and relayout the note. Normally called by loadFromFile (no save done).
516 QString name() { return m_name; } /// << @return the URL of the launcher note-content.
517 QString icon() { return m_icon; } /// << @return the displayed icon of the launcher note-content.
518 QString exec() { return m_exec; } /// << @return the execute command line of the launcher note-content.
519 // TODO: KService *service() ??? And store everything in thta service ?
520 protected:
521 QString m_name; // TODO: Store them in linkDisplay to gain place (idem for Link notes)
522 QString m_icon;
523 QString m_exec;
524 LinkDisplay m_linkDisplay;
527 /** Real implementation of color notes:
528 * @author S�astien Laot
530 class ColorContent : public NoteContent
532 public:
533 // Constructor and destructor:
534 ColorContent(Note *parent, const QColor &color);
535 // Simple Generic Methods:
536 NoteType::Id type();
537 QString typeName();
538 QString lowerTypeName();
539 QString toText(const QString &/*cuttedFullPath*/);
540 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
541 bool useFile();
542 bool canBeSavedAs();
543 QString saveAsFilters();
544 bool match(const FilterData &data);
545 // Complexe Generic Methods:
546 void exportToHTML(HTMLExporter *exporter, int indent);
547 QString cssClass();
548 int setWidthAndGetHeight(int width);
549 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
550 void saveToNode(QDomDocument &doc, QDomElement &content);
551 void fontChanged();
552 QString editToolTipText();
553 void toolTipInfos(QStringList *keys, QStringList *values);
554 // Drag and Drop Content:
555 void serialize(QDataStream &stream);
556 QPixmap feedbackPixmap(int width, int height);
557 bool needSpaceForFeedbackPixmap() { return true; }
558 void addAlternateDragObjects(KMultipleDrag *dragObject);
559 // Content-Specific Methods:
560 void setColor(const QColor &color); /// << Change the color note-content and relayout the note.
561 QColor color() { return m_color; } /// << @return the color note-content.
562 protected:
563 QColor m_color;
564 static const int RECT_MARGIN;
567 /** Real implementation of unknown MIME-types dropped notes:
568 * @author S�astien Laot
570 class UnknownContent : public NoteContent
572 public:
573 // Constructor and destructor:
574 UnknownContent(Note *parent, const QString &fileName);
575 // Simple Generic Methods:
576 NoteType::Id type();
577 QString typeName();
578 QString lowerTypeName();
579 QString toText(const QString &/*cuttedFullPath*/);
580 QString toHtml(const QString &imageName, const QString &cuttedFullPath);
581 void toLink(KURL *url, QString *title, const QString &cuttedFullPath);
582 bool useFile();
583 bool canBeSavedAs();
584 QString saveAsFilters();
585 bool match(const FilterData &data);
586 // Complexe Generic Methods:
587 void exportToHTML(HTMLExporter *exporter, int indent);
588 QString cssClass();
589 int setWidthAndGetHeight(int width);
590 void paint(QPainter *painter, int width, int height, const QColorGroup &colorGroup, bool isDefaultColor, bool isSelected, bool isHovered);
591 bool loadFromFile(bool /*lazyLoad*/);
592 void fontChanged();
593 QString editToolTipText();
594 // Drag and Drop Content:
595 bool shouldSerializeFile() { return false; }
596 void addAlternateDragObjects(KMultipleDrag *dragObject);
597 QPixmap feedbackPixmap(int width, int height);
598 bool needSpaceForFeedbackPixmap() { return true; }
599 // Open Content or File:
600 KURL urlToOpen(bool /*with*/) { return KURL(); }
601 // Content-Specific Methods:
602 QString mimeTypes() { return m_mimeTypes; } /// << @return the list of MIME types this note-content contains.
603 protected:
604 QString m_mimeTypes;
605 static const int DECORATION_MARGIN;
608 void NoteFactory__loadNode(const QDomElement &content, const QString &lowerTypeName, Note *parent, bool lazyLoad);
610 #endif // NOTECONTENT_H