31 lines
934 B
C++
31 lines
934 B
C++
#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);
|
|
}
|