on cfcde21 help sign in
unity8/tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock.cpp
52 lines 1.7 kB history raw
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "qinputdeviceinfo_mock_p.h"
19#include <QTimer>
20#include <QDebug>
22QInputDeviceManagerPrivate::QInputDeviceManagerPrivate(QObject *parent) :
23 QObject(parent),
24 currentFilter(QInputDevice::Unknown)
26 QTimer::singleShot(1, this, SIGNAL(ready()));
29QInputDeviceManagerPrivate::~QInputDeviceManagerPrivate()
33QInputDevice *QInputDeviceManagerPrivate::addMockDevice(const QString &devicePath, QInputDevice::InputType type)
35 QInputDevice *inputDevice = new QInputDevice(this);
36 inputDevice->setDevicePath(devicePath);
37 inputDevice->setName("Mock Device " + devicePath);
38 inputDevice->setType(type);
39 deviceMap.insert(devicePath, inputDevice);
40 Q_EMIT deviceAdded(devicePath);
41 return inputDevice;
44void QInputDeviceManagerPrivate::removeDevice(const QString &path)
46 Q_FOREACH (const QString devicePath, deviceMap.keys()) {
47 if (devicePath.contains(path)) {
48 deviceMap.remove(devicePath);
49 Q_EMIT deviceRemoved(devicePath);
50 }
51 }