From 640696db728ad3163384e19f789ebc022d183da6 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 25 Apr 2012 23:01:15 +0200 Subject: Places panel: Internal cleanup Move the bookmark handling into a custom model, so that the PlacesPanel only contains UI + controller code. --- src/panels/places/placesitemmodel.h | 112 ++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/panels/places/placesitemmodel.h (limited to 'src/panels/places/placesitemmodel.h') diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h new file mode 100644 index 000000000..635ad116c --- /dev/null +++ b/src/panels/places/placesitemmodel.h @@ -0,0 +1,112 @@ +/*************************************************************************** + * Copyright (C) 2012 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef PLACESITEMMODEL_H +#define PLACESITEMMODEL_H + +#include + +#include + +#include +#include +#include +#include + +class KBookmarkManager; + +#ifdef HAVE_NEPOMUK + namespace Nepomuk + { + namespace Query + { + class Term; + } + } +#endif + +class PlacesItemModel: public KStandardItemModel +{ + Q_OBJECT + +public: + explicit PlacesItemModel(QObject* parent = 0); + virtual ~PlacesItemModel(); + +private: + void loadBookmarks(); + + void createDefaultBookmarks(); + + KUrl translatedDefaultBookmarkUrl(const KUrl& url) const; + + /** + * @return URL using the timeline-protocol for searching. + */ + static KUrl createTimelineUrl(const KUrl& url); + + /** + * Helper method for createTimelineUrl(). + * @return String that represents a date-path in the format that + * the timeline-protocol expects. + */ + static QString timelineDateString(int year, int month, int day = 0); + + /** + * @return URL that can be listed by KIO and results in searching + * for a given term. The URL \a url represents a places-internal + * URL like e.g. "search:/documents" + */ + static KUrl createSearchUrl(const KUrl& url); + +#ifdef HAVE_NEPOMUK + /** + * Helper method for createSearchUrl(). + * @return URL that can be listed by KIO and results in searching + * for the given term. + */ + static KUrl searchUrlForTerm(const Nepomuk::Query::Term& term); +#endif + +private: + bool m_nepomukRunning; + + QSet m_availableDevices; + KBookmarkManager* m_bookmarkManager; + + struct DefaultBookmarkData + { + DefaultBookmarkData(const KUrl& url, + const QString& icon, + const QString& text, + const QString& group) : + url(url), icon(icon), text(text), group(group) {} + KUrl url; + QString icon; + QString text; + QString group; + }; + + QList m_defaultBookmarks; + QHash m_defaultBookmarksIndexes; +}; + +#endif + + -- cgit v1.3.1