~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/applets/webbrowser/bookmarkitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  Copyright (C) 2008 Marco Martin <notmart@gmail.com>
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
17
*/
 
18
 
 
19
#include "bookmarkitem.h"
 
20
 
 
21
 
 
22
#include <kbookmarkmanager.h>
 
23
#include <kicon.h>
 
24
#include <kdebug.h>
 
25
 
 
26
BookmarkItem::BookmarkItem(KBookmark &bookmark)
 
27
    : QStandardItem(),
 
28
      m_bookmark(bookmark)
 
29
{
 
30
}
 
31
 
 
32
BookmarkItem::~BookmarkItem()
 
33
{
 
34
}
 
35
 
 
36
 
 
37
 
 
38
KBookmark BookmarkItem::bookmark() const
 
39
{
 
40
    return m_bookmark;
 
41
}
 
42
 
 
43
void BookmarkItem::setBookmark(const KBookmark &bookmark)
 
44
{
 
45
    m_bookmark = bookmark;
 
46
}
 
47
 
 
48
QVariant BookmarkItem::data(int role) const
 
49
{
 
50
    if (m_bookmark.isNull()) {
 
51
        return QStandardItem::data(role);
 
52
    }
 
53
 
 
54
    switch (role)
 
55
    {
 
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());
 
63
        }
 
64
    case UrlRole:
 
65
        return m_bookmark.url().prettyUrl();
 
66
    default:
 
67
        return QStandardItem::data(role);
 
68
    }
 
69
}
 
70