]>
cloud.milkyroute.net Git - dolphin.git/blob - src/tooltips/ktooltipitem.cpp
1 /***************************************************************************
2 * Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org> *
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. *
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. *
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 ***************************************************************************/
20 #include "ktooltipitem.h"
21 #include "ktooltip_p.h"
25 class KToolTipItemPrivate
28 QMap
<int, QVariant
> map
;
32 KToolTipItem::KToolTipItem(const QString
&text
, int type
)
33 : d(new KToolTipItemPrivate
)
35 d
->map
[Qt::DisplayRole
] = text
;
39 KToolTipItem::KToolTipItem(const QIcon
&icon
, const QString
&text
, int type
)
40 : d(new KToolTipItemPrivate
)
42 d
->map
[Qt::DecorationRole
] = icon
;
43 d
->map
[Qt::DisplayRole
] = text
;
47 KToolTipItem::~KToolTipItem()
52 int KToolTipItem::type() const
57 QString
KToolTipItem::text() const
59 return data(Qt::DisplayRole
).toString();
62 QIcon
KToolTipItem::icon() const
64 return qvariant_cast
<QIcon
>(data(Qt::DecorationRole
));
67 QVariant
KToolTipItem::data(int role
) const
69 return d
->map
.value(role
);
72 void KToolTipItem::setData(int role
, const QVariant
&data
)
75 KToolTipManager::instance()->update();