1/*
2 * Copyright (c) 2009 Chani Armitage <chani@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, 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 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 "containmentactionspluginsconfig.h"
21#include "private/containmentactionspluginsconfig_p.h"
22
23#include <QHash>
24#include <QEvent>
25#include <QGraphicsSceneMouseEvent>
26#include <QGraphicsSceneWheelEvent>
27#include <QString>
28
29#include <kdebug.h>
30
31#include "containmentactions.h"
32
33using namespace Plasma;
34
35namespace Plasma
36{
37
38ContainmentActionsPluginsConfig::ContainmentActionsPluginsConfig()
39 : d(new ContainmentActionsPluginsConfigPrivate(this))
40{
41}
42
43ContainmentActionsPluginsConfig::ContainmentActionsPluginsConfig(const ContainmentActionsPluginsConfig &other)
44 : d(new ContainmentActionsPluginsConfigPrivate(this))
45{
46 d->plugins = other.d->plugins;
47}
48
49ContainmentActionsPluginsConfig& ContainmentActionsPluginsConfig::operator=(const ContainmentActionsPluginsConfig &other)
50{
51 d->plugins = other.d->plugins;
52 return *this;
53}
54
55ContainmentActionsPluginsConfig::~ContainmentActionsPluginsConfig()
56{
57 delete d;
58}
59
60void ContainmentActionsPluginsConfig::clear()
61{
62 d->plugins.clear();
63}
64
65void ContainmentActionsPluginsConfig::remove(QEvent *trigger)
66{
67 QString s = ContainmentActions::eventToString(trigger);
68 d->plugins.remove(s);
69}
70
71void ContainmentActionsPluginsConfig::addPlugin(QEvent *trigger, const QString &name)
72{
73 QString s = ContainmentActions::eventToString(trigger);
74 d->plugins.insert(s, name);
75}
76
77void ContainmentActionsPluginsConfig::addPlugin(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, const QString &name)
78{
79 QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
80 event.setButton(button);
81 event.setModifiers(modifiers);
82 QString s = ContainmentActions::eventToString(&event);
83 d->plugins.insert(s, name);
84}
85
86void ContainmentActionsPluginsConfig::addPlugin(Qt::KeyboardModifiers modifiers, Qt::Orientation wheelDirection, const QString &name)
87{
88 QGraphicsSceneWheelEvent event(QEvent::GraphicsSceneWheel);
89 event.setOrientation(wheelDirection);
90 event.setModifiers(modifiers);
91 QString s = ContainmentActions::eventToString(&event);
92 d->plugins.insert(s, name);
93}
94
95} // namespace Plasma
96
97