1 /***************************************************************************
2 * Copyright (C) 2003 by S�astien Laot *
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 ***************************************************************************/
24 #include <kdialogbase.h>
25 #include <q3textedit.h>
26 #include <qlineedit.h>
43 class RunCommandRequester
;
44 class FocusedFontCombo
;
45 class FocusedColorCombo
;
47 #include "notecontent.h"
49 /** The base class for every note editors.
51 * The Basket class calls NoteEditor::editNoteContent() with the NoteContent to edit.
52 * This method create the good child NoteEditor depending
53 * on the note content type and return it to the Basket.
54 * This custom NoteEditor have two choices regarding what to do in its constructor:
55 * - Display a dialog and then call cancel() if the user canceled the dialog;
56 * - Create an inline editor and call setInlineEditor() with that editor as parameter.
57 * When the user exit the edition, validate() is called by the Basket.
58 * You should then call setEmpty() is the user cleared the content.
59 * The custom editor SHOULD call the NoteEditor constructor.
60 * If the user cleared the content OR if the user canceled the dialog whereas he/she
61 * JUST ADDED the note, then the note will be deleted by the Basket.
63 class NoteEditor
: public QObject
67 NoteEditor(NoteContent
*noteContent
);
68 bool isEmpty() { return m_isEmpty
; }
69 bool canceled() { return m_canceled
; }
70 bool isInline() { return m_widget
!= 0; }
71 QWidget
* widget() { return m_widget
; }
72 KTextEdit
* textEdit() { return m_textEdit
; }
73 QLineEdit
* lineEdit() { return m_lineEdit
; }
79 KTextEdit
*m_textEdit
;
80 QLineEdit
*m_lineEdit
;
81 NoteContent
*m_noteContent
;
84 NoteContent
* noteContent() { return m_noteContent
; }
87 void setEmpty() { m_isEmpty
= true; }
88 void cancel() { m_canceled
= true; }
89 void setInlineEditor(QWidget
*inlineEditor
);
91 virtual void validate() {}
92 virtual void autoSave(bool /*toFileToo*/) {} // Same as validate(), but does not precede editor close and is triggered either while the editor widget changed size or after 3 seconds of inactivity.
96 void mouseEnteredEditorWidget();
99 static NoteEditor
* editNoteContent(NoteContent
*noteContent
, QWidget
*parent
);
102 class TextEditor
: public NoteEditor
106 TextEditor(TextContent
*textContent
, QWidget
*parent
);
109 void autoSave(bool toFileToo
);
111 TextContent
*m_textContent
;
114 class HtmlEditor
: public NoteEditor
118 HtmlEditor(HtmlContent
*htmlContent
, QWidget
*parent
);
121 void autoSave(bool toFileToo
);
123 HtmlContent
*m_htmlContent
;
125 void cursorPositionChanged();
127 void fontChanged(const QFont
&font
);
129 // void slotVerticalAlignmentChanged(QTextEdit::VerticalAlignment align);
132 // void setUnderline();
139 class ImageEditor
: public NoteEditor
143 ImageEditor(ImageContent
*imageContent
, QWidget
*parent
);
146 class AnimationEditor
: public NoteEditor
150 AnimationEditor(AnimationContent
*animationContent
, QWidget
*parent
);
153 class FileEditor
: public NoteEditor
157 FileEditor(FileContent
*fileContent
, QWidget
*parent
);
160 void autoSave(bool toFileToo
);
162 FileContent
*m_fileContent
;
165 class LinkEditor
: public NoteEditor
169 LinkEditor(LinkContent
*linkContent
, QWidget
*parent
);
172 class LauncherEditor
: public NoteEditor
176 LauncherEditor(LauncherContent
*launcherContent
, QWidget
*parent
);
179 class ColorEditor
: public NoteEditor
183 ColorEditor(ColorContent
*colorContent
, QWidget
*parent
);
186 class UnknownEditor
: public NoteEditor
190 UnknownEditor(UnknownContent
*unknownContent
, QWidget
*parent
);
193 /** QLineEdit behavior:
194 * Create a new QLineEdit with a text, then the user select a part of it and press ONE letter key.
195 * The signal textChanged() is not emitted!
196 * This class correct that!
198 class DebuggedLineEdit
: public QLineEdit
202 DebuggedLineEdit(const QString
&text
, QWidget
*parent
= 0);
205 void keyPressEvent(QKeyEvent
*event
);
208 /** The dialog to edit Link Note content.
209 * @author S�astien Laot
211 class LinkEditDialog
: public KDialogBase
215 LinkEditDialog(LinkContent
*contentNote
, QWidget
*parent
= 0);
220 void urlChanged(const QString
&);
221 void doNotAutoTitle(const QString
&);
222 void doNotAutoIcon(QString
);
226 LinkContent
*m_noteContent
;
227 bool m_isAutoModified
;
228 KURLRequester
*m_url
;
231 QPushButton
*m_autoTitle
;
232 QPushButton
*m_autoIcon
;
236 /** The dialog to edit Launcher Note content.
237 * @author S�astien Laot
239 class LauncherEditDialog
: public KDialogBase
243 LauncherEditDialog(LauncherContent
*contentNote
, QWidget
*parent
= 0);
244 ~LauncherEditDialog();
250 LauncherContent
*m_noteContent
;
251 RunCommandRequester
*m_command
;
256 /** This class manage toolbars for the inline editors.
257 * The toolbars should be created once at the application startup,
258 * then KXMLGUI can manage them and save theire state and position...
259 * @author S�astien Laot
261 class InlineEditors
: public QObject
267 void initToolBars(KActionCollection
*actionCollection
);
268 static InlineEditors
* instance();
271 // Rich Text ToolBar:
272 KToolBar
* richTextToolBar();
273 void enableRichTextToolBar();
274 void disableRichTextToolBar();
275 FocusedFontCombo
*richTextFont
;
276 FontSizeCombo
*richTextFontSize
;
277 FocusedColorCombo
*richTextColor
;
278 KToggleAction
*richTextBold
;
279 KToggleAction
*richTextItalic
;
280 KToggleAction
*richTextUnderline
;
281 // KToggleAction *richTextSuper;
282 // KToggleAction *richTextSub;
283 KToggleAction
*richTextLeft
;
284 KToggleAction
*richTextCenter
;
285 KToggleAction
*richTextRight
;
286 KToggleAction
*richTextJustified
;
287 KAction
*richTextUndo
;
288 KAction
*richTextRedo
;