refs #319, refs #322 user can force reload and clearing the data in views

* context menu
* timer based component can fire directly
* View base class (non templated) so it can use Q_OBJECT
This commit is contained in:
Klaus Basan
2014-09-08 23:34:39 +02:00
parent b576e21b48
commit bce67b7873
8 changed files with 77 additions and 68 deletions

View File

@@ -100,9 +100,10 @@ namespace BlackGui
Q_ASSERT(this->getIContextNetwork());
QObject *sender = QObject::sender();
if (sender == this->ui->pb_ReloadAtcStationsBooked && this->getIContextNetwork())
if (sender == this->ui->tvp_AtcStationsBooked && this->getIContextNetwork())
{
// trigger new read, which takes some time. A signal will be received when this is done
this->sendStatusMessage(CStatusMessage::getInfoMessage("Requested new bookings", CStatusMessage::TypeTrafficNetwork));
this->getIContextNetwork()->readAtcBookingsFromSource();
}
else
@@ -199,7 +200,9 @@ namespace BlackGui
if (this->currentWidget() == this->ui->tb_AtcStationsOnline)
{
if (this->m_timestampLastReadBookedStations.isNull())
{
this->ps_reloadAtcStationsBooked();
}
}
}

View File

@@ -277,13 +277,6 @@
</attribute>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_ReloadAtcStationsBooked">
<property name="text">
<string>Reload</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@@ -16,8 +16,12 @@ namespace BlackGui
CTimerBasedComponent::CTimerBasedComponent(const char *slot, QObject *parent) :
QObject(parent), m_timer(nullptr)
{
Q_ASSERT(parent);
this->m_timer = new QTimer(this);
this->m_timerSingleShot = new QTimer(this);
this->m_timerSingleShot->setSingleShot(true);
this->connect(this->m_timer, SIGNAL(timeout()), parent, slot);
this->connect(this->m_timerSingleShot, SIGNAL(timeout()), parent, slot);
}
CTimerBasedComponent::~CTimerBasedComponent()
@@ -38,5 +42,11 @@ namespace BlackGui
if (!this->m_timer->isActive()) this->m_timer->start();
}
}
void CTimerBasedComponent::fireTimer()
{
Q_ASSERT(this->m_timerSingleShot);
this->m_timerSingleShot->start(10);
}
}
} // guard

View File

@@ -22,6 +22,8 @@ namespace BlackGui
//! Timer based componenet
class CTimerBasedComponent: public QObject
{
Q_OBJECT
public:
//! Constructor
CTimerBasedComponent(const char *slot, QObject *parent);
@@ -46,8 +48,12 @@ namespace BlackGui
//! Stop timer
void stopTimer() { this->setUpdateInterval(-1); }
//! Fire the timer straight away
void fireTimer();
private:
QTimer *m_timer;
QTimer *m_timerSingleShot;
};
}
}