Ran qt3to4
[basket4.git] / src / noteedit.h
blob960c16d75c282d90ec6bcdab10ce5c966a694dd4
1 /***************************************************************************
2 * Copyright (C) 2003 by S�astien Laot *
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 NOTEEDIT_H
22 #define NOTEEDIT_H
24 #include <kdialogbase.h>
25 #include <q3textedit.h>
26 #include <qlineedit.h>
27 //Added by qt3to4:
28 #include <QKeyEvent>
30 class QWidget;
31 //class QLineEdit;
32 class QPushButton;
33 class KIconButton;
34 class KURLRequester;
35 class KTextEdit;
36 class KMainWindow;
37 class KTooolBar;
38 class KToggleAction;
40 class FontSizeCombo;
42 class Note;
43 class RunCommandRequester;
44 class FocusedFontCombo;
45 class FocusedColorCombo;
47 #include "notecontent.h"
49 /** The base class for every note editors.
50 * Scenario:
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
65 Q_OBJECT
66 public:
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; }
75 private:
76 bool m_isEmpty;
77 bool m_canceled;
78 QWidget *m_widget;
79 KTextEdit *m_textEdit;
80 QLineEdit *m_lineEdit;
81 NoteContent *m_noteContent;
83 public:
84 NoteContent* noteContent() { return m_noteContent; }
85 Note* note();
86 protected:
87 void setEmpty() { m_isEmpty = true; }
88 void cancel() { m_canceled = true; }
89 void setInlineEditor(QWidget *inlineEditor);
90 public:
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.
94 signals:
95 void askValidation();
96 void mouseEnteredEditorWidget();
98 public:
99 static NoteEditor* editNoteContent(NoteContent *noteContent, QWidget *parent);
102 class TextEditor : public NoteEditor
104 Q_OBJECT
105 public:
106 TextEditor(TextContent *textContent, QWidget *parent);
107 ~TextEditor();
108 void validate();
109 void autoSave(bool toFileToo);
110 protected:
111 TextContent *m_textContent;
114 class HtmlEditor : public NoteEditor
116 Q_OBJECT
117 public:
118 HtmlEditor(HtmlContent *htmlContent, QWidget *parent);
119 ~HtmlEditor();
120 void validate();
121 void autoSave(bool toFileToo);
122 protected:
123 HtmlContent *m_htmlContent;
124 public slots:
125 void cursorPositionChanged();
126 void textChanged();
127 void fontChanged(const QFont &font);
128 protected slots:
129 // void slotVerticalAlignmentChanged(QTextEdit::VerticalAlignment align);
130 // void setBold();
131 // void setItalic();
132 // void setUnderline();
133 void setLeft();
134 void setCentered();
135 void setRight();
136 void setBlock();
139 class ImageEditor : public NoteEditor
141 Q_OBJECT
142 public:
143 ImageEditor(ImageContent *imageContent, QWidget *parent);
146 class AnimationEditor : public NoteEditor
148 Q_OBJECT
149 public:
150 AnimationEditor(AnimationContent *animationContent, QWidget *parent);
153 class FileEditor : public NoteEditor
155 Q_OBJECT
156 public:
157 FileEditor(FileContent *fileContent, QWidget *parent);
158 ~FileEditor();
159 void validate();
160 void autoSave(bool toFileToo);
161 protected:
162 FileContent *m_fileContent;
165 class LinkEditor : public NoteEditor
167 Q_OBJECT
168 public:
169 LinkEditor(LinkContent *linkContent, QWidget *parent);
172 class LauncherEditor : public NoteEditor
174 Q_OBJECT
175 public:
176 LauncherEditor(LauncherContent *launcherContent, QWidget *parent);
179 class ColorEditor : public NoteEditor
181 Q_OBJECT
182 public:
183 ColorEditor(ColorContent *colorContent, QWidget *parent);
186 class UnknownEditor : public NoteEditor
188 Q_OBJECT
189 public:
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
200 Q_OBJECT
201 public:
202 DebuggedLineEdit(const QString &text, QWidget *parent = 0);
203 ~DebuggedLineEdit();
204 protected:
205 void keyPressEvent(QKeyEvent *event);
208 /** The dialog to edit Link Note content.
209 * @author S�astien Laot
211 class LinkEditDialog : public KDialogBase
213 Q_OBJECT
214 public:
215 LinkEditDialog(LinkContent *contentNote, QWidget *parent = 0);
216 ~LinkEditDialog();
217 void polish();
218 protected slots:
219 void slotOk();
220 void urlChanged(const QString&);
221 void doNotAutoTitle(const QString&);
222 void doNotAutoIcon(QString);
223 void guessTitle();
224 void guessIcon();
225 private:
226 LinkContent *m_noteContent;
227 bool m_isAutoModified;
228 KURLRequester *m_url;
229 QLineEdit *m_title;
230 KIconButton *m_icon;
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
241 Q_OBJECT
242 public:
243 LauncherEditDialog(LauncherContent *contentNote, QWidget *parent = 0);
244 ~LauncherEditDialog();
245 void polish();
246 protected slots:
247 void slotOk();
248 void guessIcon();
249 private:
250 LauncherContent *m_noteContent;
251 RunCommandRequester *m_command;
252 QLineEdit *m_name;
253 KIconButton *m_icon;
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
263 Q_OBJECT
264 public:
265 InlineEditors();
266 ~InlineEditors();
267 void initToolBars(KActionCollection *actionCollection);
268 static InlineEditors* instance();
270 public:
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;
291 #endif // NOTEEDIT_H