| 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 | */ |
| 16 | |
| 17 | #include "timer_p.h"cxx . . $ `<file>/src/LomiriGestures/timer_p.h`/ |
| 18 | |
| 19 | UG_NAMESPACE_BEGINcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:30:9`! |
| 20 | |
| 21 | Timercxx . . $ LomiriGestures/Timer#::Timercxx . . $ LomiriGestures/Timer#Timer(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) : AbstractTimercxx . . $ LomiriGestures/AbstractTimer#(parent) |
| 22 | { |
| 23 | m_timer.setSingleShot(false); |
| 24 | connectcxx . . $ QObject#connect(835f87066c895669).(&m_timer, &QTimercxx . . $ QTimer#::timeoutcxx . . $ QTimer#timeout(32604d697c0ceadc)., this, &AbstractTimercxx . . $ LomiriGestures/AbstractTimer#::timeoutcxx . . $ LomiriGestures/AbstractTimer#timeout(49f6e7a06ebc5aa8).); |
| 25 | } |
| 26 | |
| 27 | int Timercxx . . $ LomiriGestures/Timer#::intervalcxx . . $ LomiriGestures/Timer#interval(455f465bc33b4cdf).() const |
| 28 | { |
| 29 | return m_timer.interval(); |
| 30 | } |
| 31 | |
| 32 | void Timercxx . . $ LomiriGestures/Timer#::setIntervalcxx . . $ LomiriGestures/Timer#setInterval(d4f767463ce0a6b3).(int msecs) |
| 33 | { |
| 34 | m_timer.setInterval(msecs); |
| 35 | } |
| 36 | |
| 37 | void Timercxx . . $ LomiriGestures/Timer#::startcxx . . $ LomiriGestures/Timer#start(49f6e7a06ebc5aa8).() |
| 38 | { |
| 39 | m_timer.start(); |
| 40 | AbstractTimercxx . . $ LomiriGestures/AbstractTimer#::startcxx . . $ LomiriGestures/AbstractTimer#start(49f6e7a06ebc5aa8).(); |
| 41 | } |
| 42 | |
| 43 | void Timercxx . . $ LomiriGestures/Timer#::stopcxx . . $ LomiriGestures/Timer#stop(49f6e7a06ebc5aa8).() |
| 44 | { |
| 45 | m_timer.stop(); |
| 46 | AbstractTimercxx . . $ LomiriGestures/AbstractTimer#::stopcxx . . $ LomiriGestures/AbstractTimer#stop(49f6e7a06ebc5aa8).(); |
| 47 | } |
| 48 | |
| 49 | bool Timercxx . . $ LomiriGestures/Timer#::isSingleShotcxx . . $ LomiriGestures/Timer#isSingleShot(50ce9a9e25b4a850).() const |
| 50 | { |
| 51 | return m_timer.isSingleShot(); |
| 52 | } |
| 53 | |
| 54 | void Timercxx . . $ LomiriGestures/Timer#::setSingleShotcxx . . $ LomiriGestures/Timer#setSingleShot(b45ddcbc8423892c).(bool value) |
| 55 | { |
| 56 | m_timer.setSingleShot(value); |
| 57 | } |
| 58 | |
| 59 | /////////////////////////////////// FakeTimer ////////////////////////////////// |
| 60 | |
| 61 | FakeTimercxx . . $ LomiriGestures/FakeTimer#::FakeTimercxx . . $ LomiriGestures/FakeTimer#FakeTimer(bbc2e51bb9d54f5f).(const SharedTimeSourcecxx . . $ LomiriGestures/SharedTimeSource# &timeSource, QObjectcxx . . $ QObject# *parent) |
| 62 | : UG_PREPEND_NAMESPACEcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:32:9`!(AbstractTimer(parent)) |
| 63 | , m_intervalcxx . . $ LomiriGestures/FakeTimer#m_interval.(0) |
| 64 | , m_singleShotcxx . . $ LomiriGestures/FakeTimer#m_singleShot.(false) |
| 65 | , m_timeSource(timeSource) |
| 66 | , m_nextTimeoutTimecxx . . $ LomiriGestures/FakeTimer#m_nextTimeoutTime.(0) |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | void FakeTimercxx . . $ LomiriGestures/FakeTimer#::updatecxx . . $ LomiriGestures/FakeTimer#update(49f6e7a06ebc5aa8).() |
| 71 | { |
| 72 | if (!isRunningcxx . . $ LomiriGestures/AbstractTimer#isRunning(50ce9a9e25b4a850).()) { |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | if (m_nextTimeoutTime <= m_timeSource->msecsSinceReference()) { |
| 77 | if (isSingleShotcxx . . $ LomiriGestures/FakeTimer#isSingleShot(50ce9a9e25b4a850).()) { |
| 78 | stopcxx . . $ LomiriGestures/AbstractTimer#stop(49f6e7a06ebc5aa8).(); |
| 79 | } else { |
| 80 | m_nextTimeoutTimecxx . . $ LomiriGestures/FakeTimer#m_nextTimeoutTime. += intervalcxx . . $ LomiriGestures/FakeTimer#interval(455f465bc33b4cdf).(); |
| 81 | } |
| 82 | Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! timeoutcxx . . $ LomiriGestures/AbstractTimer#timeout(49f6e7a06ebc5aa8).(); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | void FakeTimercxx . . $ LomiriGestures/FakeTimer#::startcxx . . $ LomiriGestures/FakeTimer#start(49f6e7a06ebc5aa8).() |
| 87 | { |
| 88 | AbstractTimercxx . . $ LomiriGestures/AbstractTimer#::startcxx . . $ LomiriGestures/AbstractTimer#start(49f6e7a06ebc5aa8).(); |
| 89 | m_nextTimeoutTime = m_timeSource->msecsSinceReference() + (qint64)interval(); |
| 90 | } |
| 91 | |
| 92 | int FakeTimercxx . . $ LomiriGestures/FakeTimer#::intervalcxx . . $ LomiriGestures/FakeTimer#interval(455f465bc33b4cdf).() const |
| 93 | { |
| 94 | return m_intervalcxx . . $ LomiriGestures/FakeTimer#m_interval.; |
| 95 | } |
| 96 | |
| 97 | void FakeTimercxx . . $ LomiriGestures/FakeTimer#::setIntervalcxx . . $ LomiriGestures/FakeTimer#setInterval(d4f767463ce0a6b3).(int msecs) |
| 98 | { |
| 99 | m_intervalcxx . . $ LomiriGestures/FakeTimer#m_interval. = msecs; |
| 100 | } |
| 101 | |
| 102 | bool FakeTimercxx . . $ LomiriGestures/FakeTimer#::isSingleShotcxx . . $ LomiriGestures/FakeTimer#isSingleShot(50ce9a9e25b4a850).() const |
| 103 | { |
| 104 | return m_singleShotcxx . . $ LomiriGestures/FakeTimer#m_singleShot.; |
| 105 | } |
| 106 | |
| 107 | void FakeTimercxx . . $ LomiriGestures/FakeTimer#::setSingleShotcxx . . $ LomiriGestures/FakeTimer#setSingleShot(b45ddcbc8423892c).(bool value) |
| 108 | { |
| 109 | m_singleShotcxx . . $ LomiriGestures/FakeTimer#m_singleShot. = value; |
| 110 | } |
| 111 | |
| 112 | /////////////////////////////////// FakeTimerFactory ////////////////////////////////// |
| 113 | |
| 114 | FakeTimerFactorycxx . . $ LomiriGestures/FakeTimerFactory#::FakeTimerFactorycxx . . $ LomiriGestures/FakeTimerFactory#FakeTimerFactory(49f6e7a06ebc5aa8).() |
| 115 | { |
| 116 | m_timeSource.reset(new FakeTimeSource); |
| 117 | } |
| 118 | |
| 119 | void FakeTimerFactorycxx . . $ LomiriGestures/FakeTimerFactory#::updateTimecxx . . $ LomiriGestures/FakeTimerFactory#updateTime(35cb52607f6af42f).(qint64cxx . . $ qint64# targetTime) |
| 120 | { |
| 121 | qint64cxx . . $ qint64# minTimeoutTime = targetTime; |
| 122 | |
| 123 | for (int i = 0; i < timers.count(); ++i) { |
| 124 | FakeTimercxx . . $ LomiriGestures/FakeTimer# *timer = timers[i].data(); |
| 125 | if (timer && timer->isRunningcxx . . $ LomiriGestures/AbstractTimer#isRunning(50ce9a9e25b4a850).() && timer->nextTimeoutTimecxx . . $ LomiriGestures/FakeTimer#nextTimeoutTime(98833e9ab7de59a4).() < minTimeoutTime) { |
| 126 | minTimeoutTime = timer->nextTimeoutTimecxx . . $ LomiriGestures/FakeTimer#nextTimeoutTime(98833e9ab7de59a4).(); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | m_timeSource->m_msecsSinceReference = minTimeoutTime; |
| 131 | |
| 132 | for (int i = 0; i < timers.count(); ++i) { |
| 133 | FakeTimercxx . . $ LomiriGestures/FakeTimer# *timer = timers[i].data(); |
| 134 | if (timer) { |
| 135 | timer->updatecxx . . $ LomiriGestures/FakeTimer#update(49f6e7a06ebc5aa8).(); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | if (m_timeSource->msecsSinceReference() < targetTime) { |
| 140 | updateTimecxx . . $ LomiriGestures/FakeTimerFactory#updateTime(35cb52607f6af42f).(targetTime); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | AbstractTimercxx . . $ LomiriGestures/AbstractTimer# *FakeTimerFactorycxx . . $ LomiriGestures/FakeTimerFactory#::createTimercxx . . $ LomiriGestures/FakeTimerFactory#createTimer(973ddefe3364e90).(QObjectcxx . . $ QObject# *parent) |
| 145 | { |
| 146 | FakeTimercxx . . $ LomiriGestures/FakeTimer# *fakeTimer = new FakeTimer(m_timeSource, parent); |
| 147 | |
| 148 | timers.append(fakeTimer); |
| 149 | |
| 150 | return fakeTimer; |
| 151 | } |
| 152 | |
| 153 | UG_NAMESPACE_ENDcxx . . $ `src/LomiriGestures/lomirigesturesglobal.h:31:9`! |