Implementing the clear button

This commit is contained in:
Anonymus Raccoon
2020-03-24 23:15:33 +01:00
parent c007ce6fee
commit 15aa1a7dde
3 changed files with 18 additions and 4 deletions
+14 -2
View File
@@ -101,6 +101,11 @@ namespace ComSquare::Debugger
this->_proxy.refresh();
});
QMainWindow::connect(this->_ui.clearBtn, &QPushButton::pressed, [this]() {
this->_model.clearLogs();
this->_proxy.refresh();
});
this->_window->show();
}
@@ -204,7 +209,7 @@ QVariant BusLogModel::headerData(int section, Qt::Orientation orientation, int r
}
}
void BusLogModel::log(ComSquare::Debugger::BusLog log)
void BusLogModel::log(const ComSquare::Debugger::BusLog& log)
{
int row = this->_logs.size();
this->beginInsertRows(QModelIndex(), row, row);
@@ -218,9 +223,16 @@ ComSquare::Debugger::BusLog BusLogModel::getLogAt(int index)
return this->_logs[index];
}
void BusLogModel::clearLogs()
{
this->beginResetModel();
this->_logs.clear();
this->endResetModel();
}
BusLoggerProxy::BusLoggerProxy(BusLogModel &parent) : QSortFilterProxyModel(), _parent(parent) {}
bool BusLoggerProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
bool BusLoggerProxy::filterAcceptsRow(int sourceRow, const QModelIndex &) const
{
ComSquare::Debugger::BusLog log = this->_parent.getLogAt(sourceRow);
+3 -1
View File
@@ -56,10 +56,12 @@ public:
const int column = 6;
//! @brief Add a log to the model
void log(ComSquare::Debugger::BusLog log);
void log(const ComSquare::Debugger::BusLog& log);
//! @brief Get a log at an index.
ComSquare::Debugger::BusLog getLogAt(int index);
//! @brief Clear all the logs
void clearLogs();
//! @brief The number of row the table has.
int rowCount(const QModelIndex &parent) const override;
+1 -1
View File
@@ -359,7 +359,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="clearBtn">
<property name="text">
<string>Clear</string>
</property>