Added a ModelSummary class to make the overview over the model content accessible via QProperty system & a SummaryWidget to show this information. Only property rowCount as a proof of concept. Other properties will follow.
This commit is contained in:
22
libs/BeetRoundCore/model/modelsummary.cpp
Normal file
22
libs/BeetRoundCore/model/modelsummary.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "modelsummary.h"
|
||||
|
||||
#include "tablemodel.h"
|
||||
|
||||
ModelSummary::ModelSummary(std::shared_ptr<TableModel> model, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_model(model) {
|
||||
Q_ASSERT(model);
|
||||
connect(m_model.get(), &TableModel::rowCountChanged, this, &ModelSummary::rowCountChanged);
|
||||
}
|
||||
|
||||
ModelSummary::~ModelSummary() {}
|
||||
|
||||
int ModelSummary::rowCount() const {
|
||||
const int nRows = m_model->rowCount();
|
||||
return nRows;
|
||||
}
|
||||
|
||||
QBindable<int> ModelSummary::bindableRowCount() {
|
||||
m_rowCount = m_model->rowCount();
|
||||
return &m_rowCount;
|
||||
}
|
||||
Reference in New Issue
Block a user