From a14b4e3d4dec804ec9989ca168ad3a6683f2e5ba Mon Sep 17 00:00:00 2001 From: ExMix Date: Thu, 23 May 2013 15:26:57 +0300 Subject: Looped drawing in tests --- qt_tstfrm/gui_test_widget.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'qt_tstfrm') diff --git a/qt_tstfrm/gui_test_widget.hpp b/qt_tstfrm/gui_test_widget.hpp index 3e1ffb6747..f595202fa0 100644 --- a/qt_tstfrm/gui_test_widget.hpp +++ b/qt_tstfrm/gui_test_widget.hpp @@ -4,6 +4,8 @@ #include "../../gui/controller.hpp" #include "../../base/strings_bundle.hpp" #include +#include +#include template struct init_with_controller_fn_bind @@ -34,6 +36,9 @@ private: shared_ptr m_cacheScreen; shared_ptr m_stringBundle; + shared_ptr m_timerObj; + int m_timerID; + public: void invalidate() @@ -43,6 +48,10 @@ public: void initializeGL() { + m_timerObj.reset(new QObject()); + m_timerObj->installEventFilter(this); + m_timerID = m_timerObj->startTimer(1000 / 60); + base_t::initializeGL(); m_controller.reset(new gui::Controller()); @@ -113,6 +122,20 @@ public: m_controller->OnTapMoved(m2::PointU(e->pos().x(), e->pos().y())); } + + bool eventFilter(QObject * obj, QEvent *event) + { + if (obj == m_timerObj.get() && event->type() == QEvent::Timer) + { + if (((QTimerEvent *)event)->timerId() == m_timerID) + { + invalidate(); + return true; + } + } + + return false; + } }; template QWidget * create_gui_test_widget() -- cgit v1.2.3