2009-11-17 07:45:06 -05:00
|
|
|
#include <iostream>
|
|
|
|
#include <QTimer>
|
|
|
|
#include "RsAutoUpdatePage.h"
|
|
|
|
|
2010-04-19 17:50:03 -04:00
|
|
|
bool RsAutoUpdatePage::_locked = false ;
|
|
|
|
|
2009-11-17 07:45:06 -05:00
|
|
|
RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent)
|
|
|
|
: MainPage(parent)
|
|
|
|
{
|
|
|
|
_timer = new QTimer ;
|
2010-07-20 15:45:07 -04:00
|
|
|
_timer->setInterval(ms_update_period);
|
|
|
|
_timer->setSingleShot(true);
|
2009-11-17 07:45:06 -05:00
|
|
|
|
|
|
|
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate())) ;
|
|
|
|
|
2010-07-20 15:45:07 -04:00
|
|
|
_timer->start() ;
|
2009-11-17 07:45:06 -05:00
|
|
|
}
|
|
|
|
|
2011-03-02 09:31:03 -05:00
|
|
|
RsAutoUpdatePage::~RsAutoUpdatePage()
|
|
|
|
{
|
|
|
|
if(_timer != NULL)
|
|
|
|
delete _timer ;
|
|
|
|
|
|
|
|
_timer = NULL ;
|
|
|
|
}
|
|
|
|
|
2009-11-17 07:45:06 -05:00
|
|
|
void RsAutoUpdatePage::showEvent(QShowEvent *event)
|
|
|
|
{
|
2010-02-07 18:01:18 -05:00
|
|
|
//std::cout << "RsAutoUpdatePage::showEvent() In show event !!" << std::endl ;
|
2010-04-19 17:50:03 -04:00
|
|
|
if(!_locked)
|
|
|
|
updateDisplay();
|
2009-11-17 07:45:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RsAutoUpdatePage::timerUpdate()
|
|
|
|
{
|
|
|
|
// only update when the widget is visible.
|
|
|
|
//
|
2010-07-20 15:45:07 -04:00
|
|
|
if(_locked == false && isVisible()) {
|
|
|
|
updateDisplay();
|
|
|
|
update() ; // Qt flush
|
|
|
|
}
|
|
|
|
|
|
|
|
_timer->start() ;
|
2009-11-17 07:45:06 -05:00
|
|
|
}
|
|
|
|
|
2010-04-19 17:50:03 -04:00
|
|
|
void RsAutoUpdatePage::lockAllEvents() { _locked = true ; }
|
|
|
|
void RsAutoUpdatePage::unlockAllEvents() { _locked = false ; }
|
|
|
|
bool RsAutoUpdatePage::eventsLocked() { return _locked ; }
|