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

« back to all changes in this revision

Viewing changes to plasma/desktop/applets/kickoff/core/kickoffabstractmodel.cpp

  • 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 2008  Marco Martin  <notmart@gmail.com>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2 of the License, or (at your option) any later version.
 
8
 
 
9
    This library 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 GNU
 
12
    Library General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to
 
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
// Own
 
21
#include "core/kickoffabstractmodel.h"
 
22
 
 
23
// Qt
 
24
#include <QMimeData>
 
25
 
 
26
// KDE
 
27
#include <KUrl>
 
28
#include <KDebug>
 
29
 
 
30
// Local
 
31
#include "core/models.h"
 
32
 
 
33
using namespace Kickoff;
 
34
 
 
35
KickoffAbstractModel::KickoffAbstractModel(QObject *parent)
 
36
        : QAbstractItemModel(parent)
 
37
{}
 
38
 
 
39
KickoffAbstractModel::~KickoffAbstractModel()
 
40
{}
 
41
 
 
42
Qt::ItemFlags KickoffAbstractModel::flags(const QModelIndex &index) const
 
43
{
 
44
    Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
 
45
 
 
46
    if (index.isValid()) {
 
47
        return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
 
48
    } else {
 
49
        return 0;
 
50
    }
 
51
}
 
52
 
 
53
QMimeData *KickoffAbstractModel::mimeData(const QModelIndexList &indexes) const
 
54
{
 
55
    KUrl::List urls;
 
56
    QByteArray itemData;
 
57
 
 
58
    foreach(const QModelIndex &index, indexes) {
 
59
        KUrl itemUrl = KUrl(data(index, UrlRole).toString());
 
60
        if (itemUrl.isValid()) {
 
61
            urls << itemUrl;
 
62
        }
 
63
    }
 
64
 
 
65
    QMimeData *mimeData = new QMimeData();
 
66
 
 
67
    if (!urls.isEmpty()) {
 
68
        urls.populateMimeData(mimeData);
 
69
    }
 
70
 
 
71
    return mimeData;
 
72
}
 
73
 
 
74
QStringList KickoffAbstractModel::mimeTypes() const
 
75
{
 
76
    QStringList types;
 
77
    types << QLatin1String("text/uri-list");
 
78
    return types;
 
79
}
 
80
 
 
81
Qt::DropActions KickoffAbstractModel::supportedDropActions() const
 
82
{
 
83
    return 0;
 
84
}
 
85
 
 
86
Qt::DropActions KickoffAbstractModel::supportedDragActions() const
 
87
{
 
88
    return Qt::CopyAction;
 
89
}
 
90
 
 
91
#include "kickoffabstractmodel.moc"
 
92