Update the IPB beacons table only when the dialog is visible

This commit is contained in:
Daniele Forsi 2023-08-07 22:36:24 +02:00
parent dac9b9a5b3
commit 230c461204
2 changed files with 16 additions and 2 deletions

View File

@ -32,7 +32,6 @@ MapIBPBeaconDialog::MapIBPBeaconDialog(MapGUI *gui, QWidget* parent) :
ui->setupUi(this); ui->setupUi(this);
connect(&m_timer, &QTimer::timeout, this, &MapIBPBeaconDialog::updateTime); connect(&m_timer, &QTimer::timeout, this, &MapIBPBeaconDialog::updateTime);
m_timer.setInterval(1000); m_timer.setInterval(1000);
m_timer.start();
ui->beacons->setRowCount(IBPBeacon::m_frequencies.size()); ui->beacons->setRowCount(IBPBeacon::m_frequencies.size());
for (int row = 0; row < IBPBeacon::m_frequencies.size(); row++) for (int row = 0; row < IBPBeacon::m_frequencies.size(); row++)
{ {
@ -44,7 +43,6 @@ MapIBPBeaconDialog::MapIBPBeaconDialog(MapGUI *gui, QWidget* parent) :
ui->beacons->setItem(row, IBP_BEACON_COL_DISTANCE, new QTableWidgetItem("")); ui->beacons->setItem(row, IBP_BEACON_COL_DISTANCE, new QTableWidgetItem(""));
} }
resizeTable(); resizeTable();
updateTable(QTime::currentTime());
} }
MapIBPBeaconDialog::~MapIBPBeaconDialog() MapIBPBeaconDialog::~MapIBPBeaconDialog()
@ -126,3 +124,17 @@ void MapIBPBeaconDialog::updateTime()
updateTable(t); updateTable(t);
} }
} }
void MapIBPBeaconDialog::showEvent(QShowEvent *event)
{
(void) event;
updateTable(QTime::currentTime());
updateTime();
m_timer.start();
}
void MapIBPBeaconDialog::hideEvent(QHideEvent *event)
{
(void) event;
m_timer.stop();
}

View File

@ -43,6 +43,8 @@ private slots:
void accept(); void accept();
void on_beacons_cellDoubleClicked(int row, int column); void on_beacons_cellDoubleClicked(int row, int column);
void updateTime(); void updateTime();
void showEvent(QShowEvent *event);
void hideEvent(QHideEvent *event);
private: private:
MapGUI *m_gui; MapGUI *m_gui;