]> cloud.milkyroute.net Git - dolphin.git/blob - src/tooltips/ktooltipitem.h
SVN_SILENT made messages (.desktop file)
[dolphin.git] / src / tooltips / ktooltipitem.h
1 /***************************************************************************
2 * Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef KTOOLTIPITEM_H
21 #define KTOOLTIPITEM_H
22
23 #include <QVariant>
24
25 class QString;
26 class QIcon;
27 class QSize;
28 class QPainter;
29 class QRegion;
30
31 class KToolTipItemPrivate;
32
33 /**
34 * KToolTipItem contains the data to be displayed in a tooltip.
35 *
36 * Custom data can be stored as QVariants in the object by calling
37 * setData() with a custom item role, and retrieved and displayed
38 * by a tooltip delegate by calling data().
39 *
40 * The default tooltip delegate uses Qt::DecorationRole and
41 * Qt::DisplayRole.
42 *
43 * To display the tooltip, call KToolTip::showTip() with a pointer
44 * to the KToolTipItem.
45 *
46 * You can reimplement the setData() and/or data() methods in this
47 * class to implement on-demand loading of data.
48 */
49 class KToolTipItem
50 {
51 public:
52 enum ItemType { DefaultType, UserType = 1000 };
53
54 /**
55 * Creates a KToolTipItem with @p text and no icon.
56 */
57 explicit KToolTipItem(const QString &text, int type = DefaultType);
58
59 /**
60 * Creates a KToolTipItem with an @p icon and @p text.
61 */
62 KToolTipItem(const QIcon &icon, const QString &text, int type = DefaultType);
63
64 /**
65 * Destroys the KToolTipItem.
66 */
67 virtual ~KToolTipItem();
68
69 /**
70 * Returns the item type.
71 */
72 int type() const;
73
74 QString text() const;
75 QIcon icon() const;
76
77 virtual QVariant data(int role) const;
78 virtual void setData(int role, const QVariant &data);
79
80 private:
81 KToolTipItemPrivate * const d;
82 };
83
84 #endif