1/* This file is part of the KDE project
2 Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17
18*/
19
20#ifndef KFILEPLACESITEM_P_H
21#define KFILEPLACESITEM_P_H
22
23
24#include <QtCore/QObject>
25#include <QtCore/QPointer>
26#include <QtCore/QModelIndex>
27#include <QtCore/QStringList>
28#include <kbookmark.h>
29#include <solid/device.h>
30
31class KDirLister;
32namespace Solid
33{
34class StorageAccess;
35class StorageVolume;
36class OpticalDisc;
37class PortableMediaPlayer;
38}
39
40class KFilePlacesItem : public QObject
41{
42 Q_OBJECT
43public:
44 KFilePlacesItem(KBookmarkManager *manager,
45 const QString &address,
46 const QString &udi = QString());
47 ~KFilePlacesItem();
48
49 QString id() const;
50
51 bool isDevice() const;
52 KBookmark bookmark() const;
53 void setBookmark(const KBookmark &bookmark);
54 Solid::Device device() const;
55 QVariant data(int role) const;
56
57 static KBookmark createBookmark(KBookmarkManager *manager,
58 const QString &label,
59 const KUrl &url,
60 const QString &iconName,
61 KFilePlacesItem *after = 0);
62 static KBookmark createSystemBookmark(KBookmarkManager *manager,
63 const QString &untranslatedLabel,
64 const QString &translatedLabel,
65 const KUrl &url,
66 const QString &iconName);
67 static KBookmark createDeviceBookmark(KBookmarkManager *manager,
68 const QString &udi);
69
70Q_SIGNALS:
71 void itemChanged(const QString &id);
72
73private Q_SLOTS:
74 void onAccessibilityChanged(bool);
75 void onListerCompleted();
76
77private:
78 QVariant bookmarkData(int role) const;
79 QVariant deviceData(int role) const;
80
81 bool hasFullIcon(const KBookmark &bookmark) const;
82 QString iconNameForBookmark(const KBookmark &bookmark) const;
83
84 static QString generateNewId();
85
86 KBookmarkManager *m_manager;
87 KBookmark m_bookmark;
88 KDirLister *m_lister;
89 bool m_folderIsEmpty;
90 bool m_isCdrom;
91 bool m_isAccessible;
92 QString m_text;
93 mutable Solid::Device m_device;
94 mutable QPointer<Solid::StorageAccess> m_access;
95 mutable QPointer<Solid::StorageVolume> m_volume;
96 mutable QPointer<Solid::OpticalDisc> m_disc;
97 mutable QPointer<Solid::PortableMediaPlayer> m_mtp;
98 QString m_iconPath;
99 QStringList m_emblems;
100};
101
102#endif
103