]> cloud.milkyroute.net Git - dolphin.git/blob - src/tooltips/ktooltipitem.h
Fix forward declaration
[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
28 class KToolTipItemPrivate;
29
30 /**
31 * KToolTipItem contains the data to be displayed in a tooltip.
32 *
33 * Custom data can be stored as QVariants in the object by calling
34 * setData() with a custom item role, and retrieved and displayed
35 * by a tooltip delegate by calling data().
36 *
37 * The default tooltip delegate uses Qt::DecorationRole and
38 * Qt::DisplayRole.
39 *
40 * To display the tooltip, call KToolTip::showTip() with a pointer
41 * to the KToolTipItem.
42 *
43 * You can reimplement the setData() and/or data() methods in this
44 * class to implement on-demand loading of data.
45 */
46 class KToolTipItem
47 {
48 public:
49 enum ItemType { DefaultType, UserType = 1000 };
50
51 /**
52 * Creates a KToolTipItem with @p text and no icon.
53 */
54 explicit KToolTipItem(const QString &text, int type = DefaultType);
55
56 /**
57 * Creates a KToolTipItem with an @p icon and @p text.
58 */
59 KToolTipItem(const QIcon &icon, const QString &text, int type = DefaultType);
60
61 /**
62 * Destroys the KToolTipItem.
63 */
64 virtual ~KToolTipItem();
65
66 /**
67 * Returns the item type.
68 */
69 int type() const;
70
71 QString text() const;
72 QIcon icon() const;
73
74 virtual QVariant data(int role) const;
75 virtual void setData(int role, const QVariant &data);
76
77 private:
78 KToolTipItemPrivate * const d;
79 };
80
81 #endif