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

« back to all changes in this revision

Viewing changes to khotkeys/libkhotkeysprivate/action_data/simple_action_data.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 (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
 
3
 * Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
 
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 version 2 as published by the Free Software Foundation.
 
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
#include "simple_action_data.h"
 
21
 
 
22
#include "action_data/action_data_visitor.h"
 
23
#include "conditions/conditions.h"
 
24
#include "conditions/conditions_list.h"
 
25
 
 
26
#include <KDE/KConfigGroup>
 
27
 
 
28
 
 
29
namespace KHotKeys {
 
30
 
 
31
 
 
32
SimpleActionData::SimpleActionData(
 
33
        ActionDataGroup* parent_P,
 
34
        const QString& name_P,
 
35
        const QString& comment_P)
 
36
    : ActionData(
 
37
        parent_P,
 
38
        name_P,
 
39
        comment_P,
 
40
        0,
 
41
        new Condition_list( "", this ),
 
42
        0)
 
43
    {}
 
44
 
 
45
 
 
46
void SimpleActionData::accept(ActionDataVisitor *visitor)
 
47
    {
 
48
    visitor->visitSimpleActionData(this);
 
49
    }
 
50
 
 
51
 
 
52
void SimpleActionData::accept(ActionDataConstVisitor *visitor) const
 
53
    {
 
54
    visitor->visitSimpleActionData(this);
 
55
    }
 
56
 
 
57
 
 
58
void SimpleActionData::doEnable()
 
59
    {
 
60
    if (trigger())
 
61
        {
 
62
        trigger()->enable();
 
63
        update_triggers();
 
64
        }
 
65
    }
 
66
 
 
67
 
 
68
void SimpleActionData::doDisable()
 
69
    {
 
70
    if (trigger())
 
71
        {
 
72
        trigger()->disable();
 
73
        update_triggers();
 
74
        }
 
75
    }
 
76
 
 
77
 
 
78
void SimpleActionData::set_action( Action* action_P )
 
79
    {
 
80
    ActionList* tmp = new ActionList( "Simple_action_data" );
 
81
    tmp->append( action_P );
 
82
    set_actions( tmp );
 
83
    }
 
84
 
 
85
 
 
86
void SimpleActionData::set_trigger( Trigger* trigger_P )
 
87
    {
 
88
    Trigger_list* tmp = new Trigger_list( "Simple_action" );
 
89
    tmp->append( trigger_P );
 
90
    set_triggers( tmp );
 
91
    }
 
92
 
 
93
 
 
94
const Action* SimpleActionData::action() const
 
95
    {
 
96
    if( actions() == 0 || actions()->isEmpty() )
 
97
        return 0;
 
98
    return actions()->first();
 
99
    }
 
100
 
 
101
 
 
102
Action* SimpleActionData::action()
 
103
    {
 
104
    if( actions() == 0 || actions()->isEmpty() )
 
105
        return 0;
 
106
    return actions()->first();
 
107
    }
 
108
 
 
109
 
 
110
const Trigger* SimpleActionData::trigger() const
 
111
    {
 
112
    if( triggers() == 0 || triggers()->isEmpty() )
 
113
        return NULL;
 
114
 
 
115
    return triggers()->first();
 
116
    }
 
117
 
 
118
 
 
119
Trigger* SimpleActionData::trigger()
 
120
    {
 
121
    if( triggers() == 0 || triggers()->isEmpty() )
 
122
        return NULL;
 
123
 
 
124
    return triggers()->first();
 
125
    }
 
126
 
 
127
} // namespace KHotKeys