not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / webbrowser / bookmarkitem.cpp
blobb6735edef4a737723b03ca5c3f792290cb5c9859
1 /* Copyright (C) 2008 Marco Martin <notmart@gmail.com>
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public
5 License version 2 as published by the Free Software Foundation.
7 This library is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 Library General Public License for more details.
12 You should have received a copy of the GNU Library General Public License
13 along with this library; see the file COPYING.LIB. If not, write to
14 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
15 Boston, MA 02110-1301, USA.
19 #include "bookmarkitem.h"
22 #include <kbookmarkmanager.h>
23 #include <kicon.h>
24 #include <kdebug.h>
26 BookmarkItem::BookmarkItem(KBookmark &bookmark)
27 : QStandardItem(),
28 m_bookmark(bookmark)
32 BookmarkItem::~BookmarkItem()
38 KBookmark BookmarkItem::bookmark() const
40 return m_bookmark;
43 void BookmarkItem::setBookmark(const KBookmark &bookmark)
45 m_bookmark = bookmark;
48 QVariant BookmarkItem::data(int role) const
50 if (m_bookmark.isNull()) {
51 return QStandardItem::data(role);
54 switch (role)
56 case Qt::DisplayRole:
57 return m_bookmark.text();
58 case Qt::DecorationRole:
59 if (m_bookmark.isGroup() && m_bookmark.icon().isNull()) {
60 return KIcon("folder-bookmarks");
61 } else {
62 return KIcon(m_bookmark.icon());
64 case UrlRole:
65 return m_bookmark.url().prettyUrl();
66 default:
67 return QStandardItem::data(role);