add more spacing
[personal-kdebase.git] / workspace / plasma / applets / kickoff / core / urlitemlauncher.h
blob26b638fc02f42505e29857b5c18736e6778a580e
1 /*
2 Copyright 2007 Robert Knight <robertknight@gmail.com>
3 Copyright 2007 Kevin Ottens <ervin@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef URLITEMLAUNCHER_H
22 #define URLITEMLAUNCHER_H
24 #include "core/kickoff_export.h"
26 #include <QObject>
27 #include <solid/storageaccess.h>
29 class QModelIndex;
30 class KUrl;
32 namespace Kickoff
35 /**
36 * UrlItemHandler is an abstract base class for handlers which can open particular
37 * types of URL.
39 * @see UrlItemLauncher
41 class UrlItemHandler
43 public:
44 virtual ~UrlItemHandler() {}
45 virtual bool openUrl(const KUrl& url) = 0;
48 /**
49 * UrlItemLauncher provides facilities to open a item from a Kickoff model based on its UrlRole
50 * data.
52 * By default, a UrlItemLauncher opens all URLs using the KRun class. Additional handlers can be created
53 * to handle URLs with particular protocols or extensions differently. Handlers can be
54 * registered using the static addGlobalHandler() method.
56 class KICKOFF_EXPORT UrlItemLauncher : public QObject
58 Q_OBJECT
60 public:
61 UrlItemLauncher(QObject *parent = 0);
62 virtual ~UrlItemLauncher();
64 enum HandlerType {
65 ProtocolHandler,
66 ExtensionHandler
68 static void addGlobalHandler(HandlerType type,
69 const QString& name,
70 UrlItemHandler *handler);
72 public Q_SLOTS:
73 /** Open the specified @p index from a Kickoff model. */
74 bool openItem(const QModelIndex& index);
75 /** Open the specified @p url */
76 bool openUrl(const QString& url);
78 private Q_SLOTS:
79 void onSetupDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
81 private:
82 class Private;
83 Private * const d;
88 #endif // URLITEMLAUNCHER_H