mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-02 10:15:45 +00:00
Implementing the clear button
This commit is contained in:
@@ -101,6 +101,11 @@ namespace ComSquare::Debugger
|
|||||||
this->_proxy.refresh();
|
this->_proxy.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QMainWindow::connect(this->_ui.clearBtn, &QPushButton::pressed, [this]() {
|
||||||
|
this->_model.clearLogs();
|
||||||
|
this->_proxy.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
this->_window->show();
|
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();
|
int row = this->_logs.size();
|
||||||
this->beginInsertRows(QModelIndex(), row, row);
|
this->beginInsertRows(QModelIndex(), row, row);
|
||||||
@@ -218,9 +223,16 @@ ComSquare::Debugger::BusLog BusLogModel::getLogAt(int index)
|
|||||||
return this->_logs[index];
|
return this->_logs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BusLogModel::clearLogs()
|
||||||
|
{
|
||||||
|
this->beginResetModel();
|
||||||
|
this->_logs.clear();
|
||||||
|
this->endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
BusLoggerProxy::BusLoggerProxy(BusLogModel &parent) : QSortFilterProxyModel(), _parent(parent) {}
|
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);
|
ComSquare::Debugger::BusLog log = this->_parent.getLogAt(sourceRow);
|
||||||
|
|
||||||
|
|||||||
@@ -56,10 +56,12 @@ public:
|
|||||||
const int column = 6;
|
const int column = 6;
|
||||||
|
|
||||||
//! @brief Add a log to the model
|
//! @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.
|
//! @brief Get a log at an index.
|
||||||
ComSquare::Debugger::BusLog getLogAt(int index);
|
ComSquare::Debugger::BusLog getLogAt(int index);
|
||||||
|
//! @brief Clear all the logs
|
||||||
|
void clearLogs();
|
||||||
|
|
||||||
//! @brief The number of row the table has.
|
//! @brief The number of row the table has.
|
||||||
int rowCount(const QModelIndex &parent) const override;
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
|
|||||||
+1
-1
@@ -359,7 +359,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="clearBtn">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Clear</string>
|
<string>Clear</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user