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:
@ -37,6 +37,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
widgets/comboboxdelegate.h widgets/comboboxdelegate.cpp
|
||||
widgets/spinboxdelegate.h widgets/spinboxdelegate.cpp
|
||||
widgets/biddingroundcontrol.h widgets/biddingroundcontrol.cpp
|
||||
widgets/summarywidget.h widgets/summarywidget.cpp
|
||||
)
|
||||
# Define target properties for Android with Qt 6 as:
|
||||
# set_property(TARGET ${TARGET_APP} APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
|
||||
|
||||
@ -16,10 +16,12 @@
|
||||
#include "genericcore.h"
|
||||
#include "model/generalsortfiltermodel.h"
|
||||
#include "model/metadata.h"
|
||||
#include "model/modelsummary.h"
|
||||
#include "model/tablemodel.h"
|
||||
#include "widgets/biddingroundcontrol.h"
|
||||
#include "widgets/comboboxdelegate.h"
|
||||
#include "widgets/spinboxdelegate.h"
|
||||
#include "widgets/summarywidget.h"
|
||||
|
||||
static int intColumnWidth = 30;
|
||||
|
||||
@ -349,6 +351,8 @@ void MainWindow::setupModelViews() {
|
||||
ui->tableView->setModel((QAbstractItemModel*)m_proxyModel.get());
|
||||
ui->tableView->setSortingEnabled(true);
|
||||
ui->tableView->setColumnWidth(0, intColumnWidth);
|
||||
|
||||
m_modelSummary = m_core->getModelSummary();
|
||||
}
|
||||
|
||||
void MainWindow::createActions() {
|
||||
@ -554,5 +558,8 @@ void MainWindow::setupEventTab() {
|
||||
connect(m_core.get(), &GenericCore::currentBiddingRoundChanged, m_biddingRoundControl.get(),
|
||||
&BiddingRoundControl::onCurrentBiddingRoundChanged);
|
||||
|
||||
SummaryWidget* summaryWidget = new SummaryWidget(m_modelSummary, this);
|
||||
containerLayout->addWidget(summaryWidget);
|
||||
|
||||
ui->tabWidget->insertTab(0, containerWidget, "Event (&1)");
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ QT_END_NAMESPACE
|
||||
class GenericCore;
|
||||
class TableModel;
|
||||
class GeneralSortFilterModel;
|
||||
class ModelSummary;
|
||||
class NewItemDialog;
|
||||
class EditItemDialog;
|
||||
class BiddingRoundControl;
|
||||
@ -73,9 +74,12 @@ class MainWindow : public QMainWindow {
|
||||
|
||||
unique_ptr<GenericCore> m_core;
|
||||
shared_ptr<GeneralSortFilterModel> m_proxyModel;
|
||||
shared_ptr<ModelSummary> m_modelSummary;
|
||||
|
||||
QUndoStack* m_modelUndoStack;
|
||||
unique_ptr<QUndoView> m_modelUndoView;
|
||||
unique_ptr<BiddingRoundControl> m_biddingRoundControl;
|
||||
|
||||
/// File actions
|
||||
unique_ptr<QAction> m_newFileAct;
|
||||
unique_ptr<QAction> m_openAct;
|
||||
|
||||
30
UIs/BeetRoundWidgets/widgets/summarywidget.cpp
Normal file
30
UIs/BeetRoundWidgets/widgets/summarywidget.cpp
Normal 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);
|
||||
}
|
||||
21
UIs/BeetRoundWidgets/widgets/summarywidget.h
Normal file
21
UIs/BeetRoundWidgets/widgets/summarywidget.h
Normal 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
|
||||
Reference in New Issue
Block a user