aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/debugger/qquick2/myplugin/mytype.cpp
blob: a3719a9c44e53ab344eba002a65c7772b5dca0e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <QtCore/QTimer>
#include <QtCore/QTime>
#include <QtDeclarative/qdeclarative.h>

#include "mytype.h"

MyType::MyType(QObject *parent)
    : QObject(parent)
{
    updateTimerText();
    m_timer = new QTimer(this);
    m_timer->setInterval(1000);
    connect(m_timer, SIGNAL(timeout()), SLOT(updateTimerText()));
    m_timer->start();
}

QString MyType::timeText() const
{
    // bp here should be hit on every second
    return m_timeText;
}

void MyType::setTimeText(const QString &text)
{
    if (m_timeText != text) {
        m_timeText = text;
        emit timeChanged(m_timeText);
    }
}

void MyType::updateTimerText()
{
    const QTime t = QTime::currentTime();
    setTimeText(t.toString(QLatin1String("HH:mm:ss")));
}

QML_DECLARE_TYPE(MyType)