mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-22 06:28:48 +00:00
Implementing the clear button
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user