~sil/ubuntu-keyboard/numbers-on-top-row

« back to all changes in this revision

Viewing changes to src/lib/logic/state-machines/deadkeymachine.cpp

  • Committer: Guenter Schwann
  • Date: 2013-11-13 15:36:39 UTC
  • mfrom: (101.4.5 keyboard-cleanups)
  • Revision ID: guenter.schwann@canonical.com-20131113153639-9i9irt1mle00vy1t
Remove some dead code

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; c-file-offsets: ((innamespace . 0)); -*-
2
 
/*
3
 
 * This file is part of Maliit Plugins
4
 
 *
5
 
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
6
 
 *
7
 
 * Contact: Mohammad Anwari <Mohammad.Anwari@nokia.com>
8
 
 *
9
 
 * Redistribution and use in source and binary forms, with or without modification,
10
 
 * are permitted provided that the following conditions are met:
11
 
 *
12
 
 * Redistributions of source code must retain the above copyright notice, this list
13
 
 * of conditions and the following disclaimer.
14
 
 * Redistributions in binary form must reproduce the above copyright notice, this list
15
 
 * of conditions and the following disclaimer in the documentation and/or other materials
16
 
 * provided with the distribution.
17
 
 * Neither the name of Nokia Corporation nor the names of its contributors may be
18
 
 * used to endorse or promote products derived from this software without specific
19
 
 * prior written permission.
20
 
 *
21
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
22
 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24
 
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
 
 *
31
 
 */
32
 
 
33
 
#include "deadkeymachine.h"
34
 
#include "logic/layoutupdater.h"
35
 
 
36
 
namespace MaliitKeyboard {
37
 
namespace Logic {
38
 
 
39
 
const char *const DeadkeyMachine::no_deadkey_state = "no-deadkey";
40
 
const char *const DeadkeyMachine::latched_deadkey_state = "latched-deadkey";
41
 
const char *const DeadkeyMachine::deadkey_state = "deadkey";
42
 
 
43
 
class DeadkeyMachinePrivate
44
 
{
45
 
public:
46
 
    Key accent_key;
47
 
 
48
 
    explicit DeadkeyMachinePrivate()
49
 
        : accent_key()
50
 
    {}
51
 
};
52
 
 
53
 
DeadkeyMachine::DeadkeyMachine(QObject *parent)
54
 
    : QStateMachine(parent)
55
 
    , d_ptr(new DeadkeyMachinePrivate)
56
 
{}
57
 
 
58
 
DeadkeyMachine::~DeadkeyMachine()
59
 
{}
60
 
 
61
 
void DeadkeyMachine::setup(LayoutUpdater *updater)
62
 
{
63
 
    if (not updater) {
64
 
        qCritical() << __PRETTY_FUNCTION__
65
 
                    << "No updater specified. Aborting setup.";
66
 
        return;
67
 
    }
68
 
 
69
 
    setChildMode(QState::ExclusiveStates);
70
 
 
71
 
    QState *no_deadkey = 0;
72
 
    QState *deadkey = 0;
73
 
    QState *latched_deadkey = 0;
74
 
 
75
 
    // addState makes state machine to be a parent of passed state,
76
 
    // so we don't have to care about deleting states explicitly.
77
 
    addState(no_deadkey = new QState);
78
 
    addState(deadkey = new QState);
79
 
    addState(latched_deadkey = new QState);
80
 
    setInitialState(no_deadkey);
81
 
 
82
 
    no_deadkey->setObjectName(no_deadkey_state);
83
 
    deadkey->setObjectName(deadkey_state);
84
 
    latched_deadkey->setObjectName(latched_deadkey_state);
85
 
 
86
 
    no_deadkey->addTransition(updater, SIGNAL(deadkeyPressed()), deadkey);
87
 
    connect(no_deadkey, SIGNAL(entered()),
88
 
            updater,    SLOT(switchToMainView()));
89
 
 
90
 
 
91
 
    deadkey->addTransition(updater, SIGNAL(deadkeyCancelled()), no_deadkey);
92
 
    deadkey->addTransition(updater, SIGNAL(deadkeyReleased()), latched_deadkey);
93
 
    connect(deadkey, SIGNAL(entered()),
94
 
            updater, SLOT(switchToAccentedView()));
95
 
 
96
 
    latched_deadkey->addTransition(updater, SIGNAL(deadkeyCancelled()), no_deadkey);
97
 
    latched_deadkey->addTransition(updater, SIGNAL(deadkeyPressed()), no_deadkey);
98
 
 
99
 
    // Defer to first main loop iteration:
100
 
    QTimer::singleShot(0, this, SLOT(start()));
101
 
}
102
 
 
103
 
void DeadkeyMachine::setAccentKey(const Key &accent_key)
104
 
{
105
 
    Q_D(DeadkeyMachine);
106
 
    d->accent_key = accent_key;
107
 
}
108
 
 
109
 
Key DeadkeyMachine::accentKey() const
110
 
{
111
 
    Q_D(const DeadkeyMachine);
112
 
    return d->accent_key;
113
 
}
114
 
 
115
 
}} // namespace Logic, MaliitKeyboard