~ubuntu-branches/ubuntu/trusty/kdeplasma-addons/trusty

« back to all changes in this revision

Viewing changes to libs/lancelot-datamodels/BaseMergedModel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-05-25 09:50:14 UTC
  • mfrom: (1.1.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100525095014-6mlrm9z9bkws0zkt
Tags: 4:4.4.80-0ubuntu1
* New upstream beta release:
  - Bump kde-sc-dev-latest build-dep version to 4.4.80
  - Refresh kubuntu_04_kimpanel_disable_scim.diff
  - Update various .install files
  - Drop liblancelot0a and liblancelot-dev packages; Upstream has broken ABI
    without an .so version bump, and after discussion with Debian it was
    decided it was not worth it to ship an unstable library.
  - Add liblancelot files to plasma-widget-lancelot, adding appropriate
    Replaces: entries
* Switch to source format 3.0 (quilt):
  - Bump debhelper build-depend version to 7.3.16 or greater

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright (C) 2007, 2008, 2009, 2010 Ivan Cukic <ivan.cukic(at)kde.org>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Lesser/Library General Public License version 2,
 
6
 *   or (at your option) any later version, as published by the Free
 
7
 *   Software Foundation
 
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 Lesser/Library General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Lesser/Library General Public
 
15
 *   License 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
 
 
20
#include "BaseMergedModel.h"
 
21
#include "Serializator.h"
 
22
 
 
23
#include <KUrl>
 
24
#include <KTemporaryFile>
 
25
 
 
26
namespace Lancelot {
 
27
namespace Models {
 
28
 
 
29
class BaseMergedModel::Private {
 
30
public:
 
31
    QList < QString > modelIDs;
 
32
};
 
33
 
 
34
BaseMergedModel::BaseMergedModel()
 
35
    : Lancelot::MergedActionListModel(),
 
36
      d(new Private())
 
37
{
 
38
 
 
39
}
 
40
 
 
41
BaseMergedModel::~BaseMergedModel()
 
42
{
 
43
    delete d;
 
44
}
 
45
 
 
46
void BaseMergedModel::addModel(const QString & id, ActionListModel * model)
 
47
{
 
48
    addModel(id, model->selfIcon(), model->selfTitle(), model);
 
49
}
 
50
 
 
51
void BaseMergedModel::addModel(const QString & id, QIcon icon,
 
52
        const QString & title, ActionListModel * model)
 
53
{
 
54
    d->modelIDs.append(id);
 
55
    Lancelot::MergedActionListModel::addModel(icon, title, model);
 
56
}
 
57
 
 
58
QMimeData * BaseMergedModel::modelMimeData(int index) const
 
59
{
 
60
    if ((index < 0) || (index >= d->modelIDs.size())) {
 
61
        return NULL;
 
62
    }
 
63
 
 
64
    QMap < QString , QString > map;
 
65
    map["version"] = "1.0";
 
66
    map["type"]    = "list";
 
67
    map["model"]   = d->modelIDs.at(index);
 
68
 
 
69
    QMimeData * data = new QMimeData();
 
70
    data->setData("text/x-lancelotpart", Serializator::serialize(map).toAscii());
 
71
    return data;
 
72
}
 
73
 
 
74
void BaseMergedModel::setModelDropActions(int index, Qt::DropActions & actions,
 
75
        Qt::DropAction & defaultAction)
 
76
{
 
77
    Q_UNUSED(index);
 
78
    actions = Qt::CopyAction;
 
79
    defaultAction = Qt::CopyAction;
 
80
}
 
81
 
 
82
} // namespace Models
 
83
} // namespace Lancelot