1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
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. *
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. *
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 ***************************************************************************/
29 #include <qstringlist.h>
40 /** Factory class to create (new, drop, past) or load BasketIem, and eventuelly save them (?)
41 * @author Sébastien Laoût
45 /** Functions to create a new note from a content.
46 * Content, if any, is saved to file but the note is not insterted in the basket, and the basket is not saved.
47 * Return 0 if the note has not been successfully created.
48 * In some cases, the returned note can be a group containing several notes or the first note of a chained list.
49 * The method Basket::TODO() can insert several grouped or chained notes without problem.
51 Note
* createNoteText( const QString
&text
, Basket
*parent
, bool reallyPlainText
= false);
52 Note
* createNoteHtml( const QString
&html
, Basket
*parent
);
53 Note
* createNoteLink( const KURL
&url
, Basket
*parent
);
54 Note
* createNoteLink( const KURL
&url
, const QString
&title
, Basket
*parent
);
55 Note
* createNoteImage( const QPixmap
&image
, Basket
*parent
);
56 Note
* createNoteColor( const QColor
&color
, Basket
*parent
);
57 Note
* createNoteFromText( const QString
&content
, Basket
*parent
); // Find automatically the type from the text meaning // TODO: Return Note::List?
58 Note
* createNoteLauncher( const KURL
&url
, Basket
*parent
);
59 Note
* createNoteLauncher( const QString
&command
, const QString
&name
, const QString
&icon
, Basket
*parent
);
60 Note
* createNoteUnknown( QMimeSource
*source
, Basket
*parent
);
61 /** Functions to create derived notes from a content */
62 Note
* createNoteLinkOrLauncher( const KURL
&url
, Basket
*parent
);
63 Note
* copyFileAndLoad( const KURL
&url
, Basket
*parent
);
64 Note
* moveFileAndLoad( const KURL
&url
, Basket
*parent
);
65 Note
* loadFile( const QString
&fileName
, Basket
*parent
); /// << Determine the content of the file (the file SHOULD exists) and return a note of the good type.
66 Note
* loadFile( const QString
&fileName
, NoteType::Id type
, Basket
*parent
); /// << Create a note of type @p type. The file is not obliged to exist.
67 /** Functions to create a new note from a drop or past event */
68 Note
* dropNote(QMimeSource
*source
, Basket
*parent
,
69 bool fromDrop
= false, QDropEvent::Action action
= QDropEvent::Copy
, Note
*noteSource
= 0);
70 bool movingNotesInTheSameBasket(QMimeSource
*source
, Basket
*parent
, QDropEvent::Action action
);
71 Note
* dropURLs(KURL::List urls
, Basket
*parent
, QDropEvent::Action action
, bool fromDrop
);
72 Note
* decodeContent(QDataStream
&stream
, NoteType::Id type
, Basket
*parent
); /// << Decode the @p stream to a note or return 0 if a general loadFile() is sufficient.
73 void consumeContent(QDataStream
&stream
, NoteType::Id type
); /// << Decode the @p stream to a note or return 0 if a general loadFile() is sufficient.
74 /** Functions to create a note file but not load it in a note object */
75 QString
createNoteLauncherFile(const QString
&command
, const QString
&name
, const QString
&icon
, Basket
*parent
);
76 /** Other useful functions */
77 NoteType::Id
typeForURL(const KURL
&url
, Basket
*parent
);
78 bool maybeText(const KURL
&url
);
79 bool maybeHtml(const KURL
&url
);
80 bool maybeImageOrAnimation(const KURL
&url
);
81 bool maybeAnimation(const KURL
&url
);
82 bool maybeSound(const KURL
&url
);
83 bool maybeLauncher(const KURL
&url
);
84 QString
fileNameForNewNote(Basket
*parent
, const QString
&wantedName
);
85 QString
createFileForNewNote(Basket
*parent
, const QString
&extension
, const QString
&wantedName
= "");
86 KURL
filteredURL(const KURL
&url
);
87 QString
titleForURL(const KURL
&url
);
88 QString
iconForURL(const KURL
&url
);
89 QString
iconForCommand(const QString
&command
);
90 bool isIconExist(const QString
&icon
);
91 QStringList
textToURLList(const QString
&text
); // @Return { url1, title1, url2, title2, url3, title3... }
92 /** Insert GUI menu */
93 Note
* createEmptyNote( NoteType::Id type
, Basket
*parent
); // Insert empty if of type Note::Type
94 Note
* importKMenuLauncher(Basket
*parent
);
95 Note
* importIcon(Basket
*parent
);
96 Note
* importFileContent(Basket
*parent
);
99 #endif // NOTEFACTORY_H