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:
@ -46,7 +46,10 @@ QByteArray TableModel::generateExampleItems() {
|
||||
|
||||
TableModel::TableModel(QUndoStack* undoStack, QObject* parent)
|
||||
: QAbstractTableModel{parent}
|
||||
, m_undoStack(undoStack) {}
|
||||
, m_undoStack(undoStack) {
|
||||
connect(this, &TableModel::rowsInserted, this, &TableModel::onRowCountChanged);
|
||||
connect(this, &TableModel::rowsRemoved, this, &TableModel::onRowCountChanged);
|
||||
}
|
||||
|
||||
Qt::ItemFlags TableModel::flags(const QModelIndex& index) const {
|
||||
if (!index.isValid()) {
|
||||
@ -279,6 +282,16 @@ void TableModel::insertItems(int startPosition,
|
||||
m_undoStack->push(insertCommand);
|
||||
}
|
||||
|
||||
void TableModel::onRowCountChanged(const QModelIndex& parent, int first, int last) {
|
||||
Q_UNUSED(first);
|
||||
Q_UNUSED(last);
|
||||
|
||||
if (parent != QModelIndex()) {
|
||||
return;
|
||||
}
|
||||
emit rowCountChanged();
|
||||
}
|
||||
|
||||
void TableModel::execInsertItems(const int firstRow, const QList<ModelItemValues> valueList) {
|
||||
const int nRows = valueList.size();
|
||||
qDebug() << "Inserting" << nRows << "items...";
|
||||
|
||||
Reference in New Issue
Block a user