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

« back to all changes in this revision

Viewing changes to plasma/generic/applets/quicklaunch/launcherdata.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 (C) 2010 - 2011 by Ingomar Wesp <ingomar@wesp.name>        *
 
3
 *                                                                         *
 
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.                                   *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 ***************************************************************************/
 
19
#ifndef QUICKLAUNCH_LAUNCHERDATA_H
 
20
#define QUICKLAUNCH_LAUNCHERDATA_H
 
21
 
 
22
// Qt
 
23
#include <Qt>
 
24
#include <QtGlobal>
 
25
#include <QtCore/QMimeData>
 
26
#include <QtCore/QList>
 
27
#include <QtCore/QString>
 
28
 
 
29
// KDE
 
30
#include <KBookmark>
 
31
#include <KUrl>
 
32
 
 
33
class QMimeData;
 
34
class KBookmarkGroup;
 
35
 
 
36
namespace Quicklaunch {
 
37
 
 
38
/**
 
39
 * The LauncherData class encapsulates all the data necessary to display a
 
40
 * launcher in quicklaunch (url, name, description and an icon). It also
 
41
 * provides methods to read / write from / to QMimeData objects or
 
42
 * KBookmarks.
 
43
 */
 
44
class LauncherData {
 
45
 
 
46
public:
 
47
    /**
 
48
     * Creates an ItemData object from the given @a url and tries to determine
 
49
     * name, description and icon automatically.
 
50
     *
 
51
     * @param url the url for the ItemData object
 
52
     */
 
53
    LauncherData(const KUrl& url);
 
54
 
 
55
    /**
 
56
     * Creates a null ItemData object.
 
57
     */
 
58
    LauncherData();
 
59
 
 
60
    KUrl url() const;
 
61
    QString name() const;
 
62
    QString description() const;
 
63
    QString icon() const;
 
64
 
 
65
    bool operator == (const LauncherData& other) const;
 
66
    bool operator != (const LauncherData& other) const;
 
67
 
 
68
    void populateMimeData(QMimeData *mimeData);
 
69
 
 
70
    static bool canDecode(const QMimeData *mimeData);
 
71
    static QList<LauncherData> fromMimeData(const QMimeData *mimeData);
 
72
 
 
73
private:
 
74
    KUrl m_url;
 
75
    QString m_name;
 
76
    QString m_description;
 
77
    QString m_icon;
 
78
 
 
79
    /**
 
80
     * Determines whether the given @a bookmarkList contains URLs
 
81
     * (non-empty elements that are neither separators nor groups).
 
82
     *
 
83
     * @param bookmarkList a list of bookmarks
 
84
     *
 
85
     * @return whether the given @a bookmarkList contains URLs that
 
86
     *  can be used to create ItemData objects.
 
87
     */
 
88
    static bool hasUrls(const QList<KBookmark> &bookmarkList);
 
89
 
 
90
    /**
 
91
     * Determines whether the given @a bookmarkGroup contains URLs
 
92
     * (non-empty elements that are neither separators nor groups).
 
93
     *
 
94
     * @param a bookmark group
 
95
     *
 
96
     * @return whether the given @a bookmarkGroup contains URLs that
 
97
     *  can be used to create ItemData objects.
 
98
     */
 
99
    static bool hasUrls(const KBookmarkGroup &bookmarkGroup);
 
100
 
 
101
    static QList<KUrl> extractUrls(const QList<KBookmark> &bookmarkList);
 
102
    static QList<KUrl> extractUrls(const KBookmarkGroup &bookmarkGroup);
 
103
};
 
104
}
 
105
 
 
106
#endif /* QUICKLAUNCH_LAUNCHERDATA_H */