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

« back to all changes in this revision

Viewing changes to plasma/desktop/applets/kickoff/core/urlitemlauncher.h

  • 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
/*
 
2
    Copyright 2007 Robert Knight <robertknight@gmail.com>
 
3
    Copyright 2007 Kevin Ottens <ervin@kde.org>
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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.
 
19
*/
 
20
 
 
21
#ifndef URLITEMLAUNCHER_H
 
22
#define URLITEMLAUNCHER_H
 
23
 
 
24
#include "core/kickoff_export.h"
 
25
 
 
26
#include <QObject>
 
27
#include <solid/storageaccess.h>
 
28
 
 
29
class QModelIndex;
 
30
class KUrl;
 
31
 
 
32
namespace Kickoff
 
33
{
 
34
 
 
35
/**
 
36
 * UrlItemHandler is an abstract base class for handlers which can open particular
 
37
 * types of URL.
 
38
 *
 
39
 * @see UrlItemLauncher
 
40
 */
 
41
class UrlItemHandler
 
42
{
 
43
public:
 
44
    virtual ~UrlItemHandler() {}
 
45
    virtual bool openUrl(const KUrl& url) = 0;
 
46
};
 
47
 
 
48
/**
 
49
 * UrlItemLauncher provides facilities to open a item from a Kickoff model based on its UrlRole
 
50
 * data.
 
51
 *
 
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.
 
55
 */
 
56
class KICKOFF_EXPORT UrlItemLauncher : public QObject
 
57
{
 
58
    Q_OBJECT
 
59
 
 
60
public:
 
61
    UrlItemLauncher(QObject *parent = 0);
 
62
    virtual ~UrlItemLauncher();
 
63
 
 
64
    enum HandlerType {
 
65
        ProtocolHandler,
 
66
        ExtensionHandler
 
67
    };
 
68
    static void addGlobalHandler(HandlerType type,
 
69
                                 const QString& name,
 
70
                                 UrlItemHandler *handler);
 
71
 
 
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);
 
77
 
 
78
private Q_SLOTS:
 
79
    void onSetupDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
 
80
 
 
81
private:
 
82
    class Private;
 
83
    Private * const d;
 
84
};
 
85
 
 
86
}
 
87
 
 
88
#endif // URLITEMLAUNCHER_H
 
89