]>
cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitemmodel.h
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
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 #ifndef PLACESITEMMODEL_H
21 #define PLACESITEMMODEL_H
23 #include <config-nepomuk.h>
25 #include <kitemviews/kstandarditemmodel.h>
32 class KBookmarkManager
;
45 class PlacesItemModel
: public KStandardItemModel
50 explicit PlacesItemModel(QObject
* parent
= 0);
51 virtual ~PlacesItemModel();
53 void setHiddenItemsShown(bool show
);
54 bool hiddenItemsShown() const;
56 int hiddenCount() const;
59 * @return True if the item is a default item created by
60 * the system (e.g. the places for home, root, trash etc.)
62 bool isSystemItem(int index
) const;
65 * Search the item which is equal to the URL or at least
66 * is a parent URL. If there are more than one possible
67 * candidates, return the item which covers the biggest
68 * range of the URL. -1 is returned if no closest item
71 int closestItem(const KUrl
& url
) const;
74 * @return Name of the group where the item with the URL
77 QString
groupName(const KUrl
& url
) const;
79 QAction
* ejectAction(int index
) const;
80 QAction
* tearDownAction(int index
) const;
85 void createSystemBookmarks();
87 static QString
placesGroupName();
88 static QString
recentlyAccessedGroupName();
89 static QString
searchForGroupName();
91 static KUrl
translatedSystemBookmarkUrl(const KUrl
& url
);
94 * @return URL using the timeline-protocol for searching.
96 static KUrl
createTimelineUrl(const KUrl
& url
);
99 * Helper method for createTimelineUrl().
100 * @return String that represents a date-path in the format that
101 * the timeline-protocol expects.
103 static QString
timelineDateString(int year
, int month
, int day
= 0);
106 * @return URL that can be listed by KIO and results in searching
107 * for a given term. The URL \a url represents a places-internal
108 * URL like e.g. "search:/documents"
110 static KUrl
createSearchUrl(const KUrl
& url
);
114 * Helper method for createSearchUrl().
115 * @return URL that can be listed by KIO and results in searching
116 * for the given term.
118 static KUrl
searchUrlForTerm(const Nepomuk::Query::Term
& term
);
122 bool m_nepomukRunning
;
123 bool m_hiddenItemsShown
;
125 QSet
<QString
> m_availableDevices
;
126 KBookmarkManager
* m_bookmarkManager
;
128 struct SystemBookmarkData
130 SystemBookmarkData(const KUrl
& url
,
133 const QString
& group
) :
134 url(url
), icon(icon
), text(text
), group(group
) {}
141 QList
<SystemBookmarkData
> m_systemBookmarks
;
142 QHash
<KUrl
, int> m_systemBookmarksIndexes
;