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:
2026-02-15 16:36:13 +01:00
parent b28a35280c
commit dac9ac46f2
12 changed files with 157 additions and 10 deletions

View File

@ -0,0 +1,30 @@
#include "summarywidget.h"
#include <QLabel>
#include <QProperty>
#include <QVBoxLayout>
#include <model/modelsummary.h>
SummaryWidget::SummaryWidget(std::shared_ptr<ModelSummary> modelSummary, QWidget* parent)
: QWidget{parent}
, m_modelSummary(modelSummary) {
QVBoxLayout* mainLayout = new QVBoxLayout(this);
QProperty<int> nRows(-1);
QHBoxLayout* footerLayout = new QHBoxLayout();
QLabel* rowCountLabel = new QLabel("Row count:");
m_rowCoundValueLabel = new QLabel(QString::number(nRows));
QObject::connect(m_modelSummary.get(), &ModelSummary::rowCountChanged, [&]() {
m_rowCoundValueLabel->setText(QString::number(m_modelSummary->rowCount()));
});
m_modelSummary->bindableRowCount().setBinding([&]() { return nRows.value(); });
footerLayout->addWidget(rowCountLabel);
footerLayout->addWidget(m_rowCoundValueLabel);
mainLayout->addLayout(footerLayout);
setLayout(mainLayout);
}

View File

@ -0,0 +1,21 @@
#ifndef SUMMARYWIDGET_H
#define SUMMARYWIDGET_H
#include <QWidget>
class ModelSummary;
class QLabel;
class SummaryWidget : public QWidget {
Q_OBJECT
public:
explicit SummaryWidget(std::shared_ptr<ModelSummary> modelSummary, QWidget* parent = nullptr);
private:
std::shared_ptr<ModelSummary> m_modelSummary;
QLabel* m_rowCoundValueLabel;
};
#endif // SUMMARYWIDGET_H