From 09f6266123ca3022b131144fd6c5a655809ae2d6 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 18 Dec 2015 13:54:44 +0100 Subject: [PATCH] Fixed bug when adding record to empty table. Fixed empty row after delete record. --- core/autotablemodel.h | 12 ++++-------- core/gridform.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/core/autotablemodel.h b/core/autotablemodel.h index 0f465e6..b70f3c3 100644 --- a/core/autotablemodel.h +++ b/core/autotablemodel.h @@ -34,15 +34,11 @@ public: { Q_UNUSED(parent) - if (m_list.isEmpty()) - { - return 0; - } - - QSharedPointer entity = m_list.at(0); - QObject *rawEntity = (QObject*)entity.data(); + QObject *entity = (QObject*)new T(); + int colCount = entity->metaObject()->propertyCount() - 1; + delete entity; - return rawEntity->metaObject()->propertyCount() - 1; + return colCount; } QVariant data(const QModelIndex &index, int role) const diff --git a/core/gridform.h b/core/gridform.h index 27b43e3..ab3bf4d 100644 --- a/core/gridform.h +++ b/core/gridform.h @@ -139,7 +139,7 @@ protected: { QSharedPointer entity = m_tableModel->itemFromIndex(tableView()->currentIndex()); service()->erase(entity); - fillData(); + m_tableModel->removeRowAt(tableView()->currentIndex()); emit dataChanged(); } }