~ubuntu-branches/debian/jessie/basket/jessie

« back to all changes in this revision

Viewing changes to src/itemedit.h

  • Committer: Bazaar Package Importer
  • Author(s): Sune Vuorela
  • Date: 2008-06-25 20:11:23 UTC
  • mfrom: (4.1.11 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080625201123-06wsi9dla3rs3486
Tags: 1.0.2-5
* Also allow automake 1.10 usage - and just build-dep on automake i
  (Closes: #487981)
* Bye bye ana

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2003 by S�bastien Lao�t                                 *
3
 
 *   sebastien.laout@tuxfamily.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
 
 ***************************************************************************/
20
 
 
21
 
#ifndef ITEMEDIT_H
22
 
#define ITEMEDIT_H
23
 
 
24
 
#include <qobject.h>
25
 
#include <qwidget.h>
26
 
#include <kdialogbase.h>
27
 
#include <kaction.h>
28
 
#include <qiconset.h>
29
 
 
30
 
#include "focusedwidgets.h"
31
 
#include "variouswidgets.h"
32
 
 
33
 
class QRadioButton;
34
 
class KColorButton;
35
 
class KURLRequester;
36
 
class QLabel;
37
 
class QLineEdit;
38
 
class QCheckBox;
39
 
class KService;
40
 
class QKeyEvent;
41
 
 
42
 
class KToolBar;
43
 
class KIconButton;
44
 
 
45
 
class Item;
46
 
class IconSizeCombo;
47
 
 
48
 
class ColorIconFactory : public QIconFactory
49
 
{
50
 
  public:
51
 
        ColorIconFactory();
52
 
        ~ColorIconFactory();
53
 
        QPixmap* createPixmap(const QIconSet &iconSet, QIconSet::Size size, QIconSet::Mode mode, QIconSet::State state);
54
 
 
55
 
        static ColorIconFactory *globalColorIconFactory;
56
 
};
57
 
 
58
 
class ColorIconSet : public QIconSet
59
 
{
60
 
  public:
61
 
        ColorIconSet(const QColor &color);
62
 
        ~ColorIconSet();
63
 
//      QPixmap pixmap(Size size, Mode mode, State state = Off);
64
 
        QColor color() const;
65
 
        void setColor(const QColor &color);
66
 
  private:
67
 
        QColor m_color;
68
 
};
69
 
 
70
 
class ColorAction : public KAction
71
 
{
72
 
  Q_OBJECT
73
 
  public:
74
 
        ColorAction(const QColor &color, const QString &text, const KShortcut &cut,
75
 
                    KActionCollection *parent, const char *name);
76
 
        ~ColorAction();
77
 
//      QIconSet iconSet(KIcon::Group, int size = 0) /*const*/;
78
 
  signals:
79
 
        void colorChanged(const QColor &color);
80
 
  private slots:
81
 
        void selectColor();
82
 
  private:
83
 
        QColor m_color;
84
 
};
85
 
 
86
 
/** A simple widget, that all Item content edit widget must inherit
87
 
  * for have various methods such as saveChanges() (must be reimplemented).
88
 
  * @author S�bastien Lao�t
89
 
  */
90
 
class ItemEditWidgetBase : public QWidget
91
 
{
92
 
  Q_OBJECT
93
 
  public:
94
 
        ItemEditWidgetBase(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
95
 
        ~ItemEditWidgetBase();
96
 
  public slots:
97
 
        virtual void saveChanges()  = 0;
98
 
        virtual void goFirstFocus() = 0;
99
 
  private:
100
 
        virtual void show();
101
 
 
102
 
  protected:
103
 
        Item *m_item;
104
 
        bool  m_isAlreadyFirstFocused;
105
 
};
106
 
 
107
 
/** The base class for content item editors.
108
 
  * It connect and manage the widgets and provide pointers to them.
109
 
  * Different editors then can be designed : a dialog that layout them
110
 
  * or an inline editor that place toolbar in a MainWindow, and editor in another place...
111
 
  * @author S�bastien Lao�t
112
 
  */
113
 
class ItemEditorBase : public QObject
114
 
{
115
 
  Q_OBJECT
116
 
  public:
117
 
        ItemEditorBase(Item *item);
118
 
        Item*     editedItem()   { return m_item;         }
119
 
        KToolBar* toolbar()      { return m_toolbar;      }
120
 
        QWidget*  editorWidget() { return m_editorWidget; }
121
 
        QWidget*  extraWidget()  { return m_extraWidget;  }
122
 
  public slots:
123
 
        virtual void saveChanges()  = 0;
124
 
        virtual void goFirstFocus() = 0;
125
 
  signals:
126
 
        void focusOut();
127
 
  protected:
128
 
        Item     *m_item;
129
 
        KToolBar *m_toolbar;
130
 
        QWidget  *m_editorWidget;
131
 
        QWidget  *m_extraWidget;
132
 
};
133
 
 
134
 
/** Editor to edit Text Item content.
135
 
  * @author S�bastien Lao�t
136
 
  */
137
 
class ItemTextEditor : public ItemEditorBase
138
 
{
139
 
  Q_OBJECT
140
 
  public:
141
 
        ItemTextEditor(Item *item, QWidget *toolbarParent, QWidget *widgetsParent, QKeyEvent *ke = 0L);
142
 
        ~ItemTextEditor();
143
 
  public slots:
144
 
        void saveChanges();
145
 
        void goFirstFocus();
146
 
  protected slots:
147
 
        void changeFont(int fontType);
148
 
        void changeColor(const QColor &color);
149
 
        void slotFocusOut();
150
 
        void slotEscapePressed();
151
 
  private:
152
 
        FocusedTextEdit   *m_text;
153
 
        FocusedComboBox   *m_font;
154
 
        FocusedColorCombo *m_color;
155
 
};
156
 
 
157
 
/** The widget to edit Text Item content.
158
 
  * @author S�bastien Lao�t
159
 
  */
160
 
class ItemTextEditWidget : public ItemEditWidgetBase
161
 
{
162
 
  Q_OBJECT
163
 
  public:
164
 
        ItemTextEditWidget(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0, QKeyEvent *ke = 0L);
165
 
        ~ItemTextEditWidget();
166
 
  public slots:
167
 
        void saveChanges();
168
 
        void goFirstFocus();
169
 
 
170
 
  private:
171
 
        ItemTextEditor *m_editor;
172
 
};
173
 
 
174
 
/** Editor to edit Rich text Item content.
175
 
  * @author S�bastien Lao�t
176
 
  */
177
 
class ItemHtmlEditor : public ItemEditorBase
178
 
{
179
 
  Q_OBJECT
180
 
  public:
181
 
        ItemHtmlEditor(Item *item, QWidget *toolbarParent, QWidget *widgetsParent, QKeyEvent *ke = 0L);
182
 
        ~ItemHtmlEditor();
183
 
  public slots:
184
 
        void saveChanges();
185
 
        void goFirstFocus();
186
 
  protected slots:
187
 
//      void slotShowSource(bool on);
188
 
        void cursorPositionChanged(int, int);
189
 
        void buttonToggled(int);
190
 
        void slotVerticalAlignmentChanged(QTextEdit::VerticalAlignment align);
191
 
        void slotFocusOut();
192
 
        void slotEscapePressed();
193
 
  private:
194
 
        FocusedTextEdit   *m_text;
195
 
        FocusedFontCombo  *m_font;
196
 
        FocusedColorCombo *m_color;
197
 
//      QCheckBox         *m_showHtmlSource;
198
 
        QWidget           *m_wid;
199
 
 
200
 
        // QTextView : The text edit may be able to provide some meta-information.
201
 
        //  For example, the documentTitle() function will return the text from within HTML <title> tags.
202
 
};
203
 
 
204
 
/** The widget to edit Html Item content.
205
 
  * FIXME: The same as ItemTextEditWidget : merge ?
206
 
  * @author S�bastien Lao�t
207
 
  */
208
 
class ItemHtmlEditWidget : public ItemEditWidgetBase
209
 
{
210
 
  Q_OBJECT
211
 
  public:
212
 
        ItemHtmlEditWidget(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0, QKeyEvent *ke = 0L);
213
 
        ~ItemHtmlEditWidget();
214
 
  public slots:
215
 
        void saveChanges();
216
 
        void goFirstFocus();
217
 
 
218
 
  private:
219
 
        ItemHtmlEditor *m_editor;
220
 
};
221
 
 
222
 
/** The widget to edit Link Item content.
223
 
  * @author S�bastien Lao�t
224
 
  */
225
 
class ItemLinkEditWidget : public ItemEditWidgetBase
226
 
{
227
 
  Q_OBJECT
228
 
  public:
229
 
        ItemLinkEditWidget(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0, QKeyEvent *ke = 0L);
230
 
        ~ItemLinkEditWidget();
231
 
  public slots:
232
 
        void saveChanges();
233
 
        void goFirstFocus();
234
 
  protected slots:
235
 
        void urlChanged(const QString&);
236
 
        void doNotAutoTitle(const QString&);
237
 
        void doNotAutoIcon(QString);
238
 
        void guessTitle();
239
 
        void guessIcon();
240
 
        void emptyIcon();
241
 
 
242
 
  private:
243
 
        bool           m_isAutoModified;
244
 
        KURLRequester *m_url;
245
 
        QLineEdit     *m_title;
246
 
        KIconButton   *m_icon;
247
 
        QPushButton   *m_autoTitle;
248
 
        QPushButton   *m_autoIcon;
249
 
};
250
 
 
251
 
/** The widget to edit Launcher Item content.
252
 
  * @author S�bastien Lao�t
253
 
  */
254
 
class ItemLauncherEditWidget : public ItemEditWidgetBase
255
 
{
256
 
  Q_OBJECT
257
 
  public:
258
 
        ItemLauncherEditWidget(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
259
 
        ~ItemLauncherEditWidget();
260
 
  public slots:
261
 
        void saveChanges();
262
 
        void goFirstFocus();
263
 
  protected slots:
264
 
        void guessIcon();
265
 
        void emptyIcon();
266
 
 
267
 
  private:
268
 
        bool                 m_isAutoModified;
269
 
        RunCommandRequester *m_command;
270
 
        QLineEdit           *m_name;
271
 
        KIconButton         *m_icon;
272
 
        KService            *m_service;
273
 
};
274
 
 
275
 
/** The widget to edit Image Item content.
276
 
  * @author S�bastien Lao�t
277
 
  */
278
 
class ItemImageEditWidget : public ItemEditWidgetBase
279
 
{
280
 
  Q_OBJECT
281
 
  public:
282
 
        ItemImageEditWidget(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
283
 
        ~ItemImageEditWidget();
284
 
  public slots:
285
 
        void saveChanges();
286
 
        void goFirstFocus();
287
 
  private:
288
 
        QPushButton *m_open;
289
 
};
290
 
 
291
 
/** The widget to edit Color Item content.
292
 
  * @author S�bastien Lao�t
293
 
  */
294
 
class ItemColorEditWidget : public ItemEditWidgetBase
295
 
{
296
 
  Q_OBJECT
297
 
  public:
298
 
        ItemColorEditWidget(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
299
 
        ~ItemColorEditWidget();
300
 
  public slots:
301
 
        void saveChanges();
302
 
        void goFirstFocus();
303
 
 
304
 
  private:
305
 
        KColorButton *m_color;
306
 
};
307
 
 
308
 
/** Widget to edit annotations of a Item, and check it.
309
 
  * @author S�bastien Lao�t
310
 
  */
311
 
class ItemEditWidget : public ItemEditWidgetBase
312
 
{
313
 
  Q_OBJECT
314
 
  public:
315
 
        ItemEditWidget(Item *item, QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
316
 
        ~ItemEditWidget();
317
 
  public slots:
318
 
        void saveChanges();
319
 
        void goFirstFocus();
320
 
        void slotUnmirror();
321
 
 
322
 
  private:
323
 
        KTextEdit   *m_annotations;
324
 
        QLabel      *m_fileLabel;
325
 
        QLineEdit   *m_fileName;
326
 
        QPushButton *m_unmirror;
327
 
};
328
 
 
329
 
/** Show a dialog with tabs to edit Item properties.
330
 
  * @author S�bastien Lao�t
331
 
  */
332
 
class ItemEditDialog : public KDialogBase//QTabDialog
333
 
{
334
 
  Q_OBJECT
335
 
  public:
336
 
        ItemEditDialog(Item *item, bool editAnnotations = false, QWidget *parent = 0L, QKeyEvent *ke = 0L);
337
 
        ~ItemEditDialog();
338
 
  protected slots:
339
 
        void slotApply();
340
 
        void slotOk();
341
 
 
342
 
  private:
343
 
        Item               *m_item;
344
 
        ItemEditWidgetBase *m_editContent;
345
 
        ItemEditWidget     *m_itemEdit;
346
 
};
347
 
 
348
 
#endif // ITEMEDIT_H