Skip to content

Commit

Permalink
Add a button to remove sources that have gone offline
Browse files Browse the repository at this point in the history
Receiver views now don't show offline sources when initially opened
and have a button to clear offline sources from their list.
  • Loading branch information
RichardTea committed May 3, 2024
1 parent 95c67cb commit 0e7effd
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 145 deletions.
40 changes: 39 additions & 1 deletion src/models/sacnsourcetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,44 @@ void SACNSourceTableModel::clear()
endResetModel();
}

void SACNSourceTableModel::clearOffline()
{
if (m_listeners.empty())
{
clear();
return;
}

// Clear the model and repopulate with the valid sources
beginResetModel();
m_rows.clear();
m_sourceToTableRow.clear();

// Now re-add pre-existing list sources and remove dead listeners
for (auto it = m_listeners.begin(); it != m_listeners.end(); /*iterate below*/)
{
const sACNManager::tListener listener = it->toStrongRef();
if (listener)
{
for (int i = 0; i < listener->sourceCount(); i++)
{
sACNSource* source = listener->source(i);
if (source->src_valid)
{
m_sourceToTableRow[source] = m_rows.size();
m_rows.emplace_back(source);
}
}
++it;
}
else
{
it = m_listeners.erase(it);
}
}
endResetModel();
}

void SACNSourceTableModel::resetTimeSummaryCounters()
{
for (auto it = m_sourceToTableRow.begin(); it != m_sourceToTableRow.end(); ++it)
Expand Down Expand Up @@ -432,7 +470,7 @@ void SACNSourceTableModel::sourceChanged(sACNSource* source)

void SACNSourceTableModel::sourceOnline(sACNSource* source)
{
if (!source)
if (!source || !source->src_valid)
return;

const int row = m_rows.size();
Expand Down
2 changes: 2 additions & 0 deletions src/models/sacnsourcetablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class SACNSourceTableModel : public QAbstractTableModel
void restart();
// Clear all data and remove all listeners
void clear();
// Remove all Offline sources
void clearOffline();

// Convenience
void resetTimeSummaryCounters();
Expand Down
6 changes: 6 additions & 0 deletions src/ui/multiview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ void MultiView::on_btnStartStop_clicked(bool checked)
}
}

void MultiView::on_btnClearOffline_clicked()
{
if (m_sourceTableModel)
m_sourceTableModel->clearOffline();
}

void MultiView::on_btnResetCounters_clicked()
{
m_sourceTableModel->resetCounters();
Expand Down
1 change: 1 addition & 0 deletions src/ui/multiview.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class MultiView : public QWidget

protected slots:
void on_btnStartStop_clicked(bool checked);
void on_btnClearOffline_clicked();
void on_btnResetCounters_clicked();
void on_btnExport_clicked();

Expand Down
6 changes: 6 additions & 0 deletions src/ui/universeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ void UniverseView::on_sbCompareUniverse_editingFinished()
}
}

void UniverseView::on_btnClearOffline_clicked()
{
if (m_sourceTableModel)
m_sourceTableModel->clearOffline();
}

void UniverseView::on_btnLogWindow_clicked()
{
MDIMainWindow *mainWindow = qobject_cast<MDIMainWindow *>(m_parentWindow);
Expand Down
1 change: 1 addition & 0 deletions src/ui/universeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected slots:
void on_btnStartFlickerFinder_clicked();
void on_btnCompareUniverse_clicked();
void on_sbCompareUniverse_editingFinished();
void on_btnClearOffline_clicked();
void on_btnLogWindow_clicked();
void on_btnExportSourceList_clicked();
void listenerStarted(int universe);
Expand Down
155 changes: 81 additions & 74 deletions ui/multiview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>540</width>
<height>274</height>
<width>875</width>
<height>299</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -41,23 +41,6 @@
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="lblEndUniverse">
<property name="text">
<string>End</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="lblStatic">
<property name="text">
<string>Static</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblStartUniverse">
<property name="sizePolicy">
Expand All @@ -74,27 +57,6 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="spinStatic">
<property name="suffix">
<string> ms</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QPushButton" name="btnResetCounters">
<property name="text">
<string>Reset Counters</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinUniverseMin">
<property name="sizePolicy">
Expand All @@ -117,7 +79,21 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="11" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="lblStatic">
<property name="text">
<string>Static</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="spinShort">
<property name="suffix">
<string> ms</string>
Expand All @@ -127,33 +103,31 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="btnStartStop">
<item row="8" column="0">
<widget class="QLabel" name="lblLong">
<property name="text">
<string>Start</string>
</property>
<property name="checkable">
<bool>true</bool>
<string>Long</string>
</property>
</widget>
</item>
<item row="12" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<item row="8" column="1">
<widget class="QSpinBox" name="spinLong">
<property name="suffix">
<string> ms</string>
</property>
</spacer>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QPushButton" name="btnExport">
<item row="7" column="0">
<widget class="QLabel" name="lblShortInt">
<property name="text">
<string>Export CSV...</string>
<string>Short</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
Expand All @@ -176,28 +150,51 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="spinLong">
<item row="12" column="0" colspan="2">
<widget class="QPushButton" name="btnExport">
<property name="text">
<string>Export CSV...</string>
</property>
</widget>
</item>
<item row="13" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="1">
<widget class="QSpinBox" name="spinStatic">
<property name="suffix">
<string> ms</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lblShortInt">
<item row="10" column="0" colspan="2">
<widget class="QPushButton" name="btnResetCounters">
<property name="text">
<string>Short</string>
<string>Reset Counters</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="lblLong">
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="btnStartStop">
<property name="text">
<string>Long</string>
<string>Start</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="lblTime">
<property name="text">
<string>Time Summary</string>
Expand All @@ -207,10 +204,20 @@
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="2" column="0">
<widget class="QLabel" name="lblEndUniverse">
<property name="text">
<string>End</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="btnClearOffline">
<property name="text">
<string>Clear Offline</string>
</property>
</widget>
</item>
Expand Down
Loading

0 comments on commit 0e7effd

Please sign in to comment.