NOISSUE fix crash caused by missing instance view layout updates
Layout wasn't updated in some cases while deleting instances.
This commit is contained in:
parent
03d2858c62
commit
92bb001787
@ -45,6 +45,7 @@ void GroupView::setModel(QAbstractItemModel *model)
|
|||||||
{
|
{
|
||||||
QAbstractItemView::setModel(model);
|
QAbstractItemView::setModel(model);
|
||||||
connect(model, &QAbstractItemModel::modelReset, this, &GroupView::modelReset);
|
connect(model, &QAbstractItemModel::modelReset, this, &GroupView::modelReset);
|
||||||
|
connect(model, &QAbstractItemModel::rowsRemoved, this, &GroupView::rowsRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
void GroupView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
||||||
@ -62,6 +63,16 @@ void GroupView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e
|
|||||||
scheduleDelayedItemsLayout();
|
scheduleDelayedItemsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GroupView::modelReset()
|
||||||
|
{
|
||||||
|
scheduleDelayedItemsLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupView::rowsRemoved()
|
||||||
|
{
|
||||||
|
scheduleDelayedItemsLayout();
|
||||||
|
}
|
||||||
|
|
||||||
class LocaleString : public QString
|
class LocaleString : public QString
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -87,35 +98,28 @@ void GroupView::updateGeometries()
|
|||||||
|
|
||||||
for (int i = 0; i < model()->rowCount(); ++i)
|
for (int i = 0; i < model()->rowCount(); ++i)
|
||||||
{
|
{
|
||||||
const QString groupName =
|
const QString groupName = model()->index(i, 0).data(GroupViewRoles::GroupRole).toString();
|
||||||
model()->index(i, 0).data(GroupViewRoles::GroupRole).toString();
|
|
||||||
if (!cats.contains(groupName))
|
if (!cats.contains(groupName))
|
||||||
{
|
{
|
||||||
VisualGroup *old = this->category(groupName);
|
VisualGroup *old = this->category(groupName);
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
cats.insert(groupName, new VisualGroup(old));
|
auto cat = new VisualGroup(old);
|
||||||
|
cats.insert(groupName, cat);
|
||||||
|
cat->update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cats.insert(groupName, new VisualGroup(groupName, this));
|
auto cat = new VisualGroup(groupName, this);
|
||||||
|
cats.insert(groupName, cat);
|
||||||
|
cat->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (m_editedCategory)
|
|
||||||
{
|
|
||||||
m_editedCategory = cats[m_editedCategory->text];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
qDeleteAll(m_groups);
|
qDeleteAll(m_groups);
|
||||||
m_groups = cats.values();
|
m_groups = cats.values();
|
||||||
|
|
||||||
for (auto cat : m_groups)
|
|
||||||
{
|
|
||||||
cat->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_groups.isEmpty())
|
if (m_groups.isEmpty())
|
||||||
{
|
{
|
||||||
verticalScrollBar()->setRange(0, 0);
|
verticalScrollBar()->setRange(0, 0);
|
||||||
@ -152,12 +156,6 @@ void GroupView::updateGeometries()
|
|||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupView::modelReset()
|
|
||||||
{
|
|
||||||
scheduleDelayedItemsLayout();
|
|
||||||
executeDelayedItemsLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GroupView::isIndexHidden(const QModelIndex &index) const
|
bool GroupView::isIndexHidden(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
VisualGroup *cat = category(index);
|
VisualGroup *cat = category(index);
|
||||||
|
@ -60,6 +60,7 @@ protected slots:
|
|||||||
virtual void rowsInserted(const QModelIndex &parent, int start, int end) override;
|
virtual void rowsInserted(const QModelIndex &parent, int start, int end) override;
|
||||||
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
|
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
|
||||||
void modelReset();
|
void modelReset();
|
||||||
|
void rowsRemoved();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool isIndexHidden(const QModelIndex &index) const override;
|
virtual bool isIndexHidden(const QModelIndex &index) const override;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "GroupView.h"
|
#include "GroupView.h"
|
||||||
|
|
||||||
@ -53,7 +54,6 @@ void VisualGroup::update()
|
|||||||
|
|
||||||
QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
|
QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
int y = 0;
|
||||||
for (auto & row: rows)
|
for (auto & row: rows)
|
||||||
{
|
{
|
||||||
@ -66,7 +66,8 @@ QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
|
|||||||
}
|
}
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
return qMakePair(x, y);
|
qWarning() << "Item" << index.row() << index.data(Qt::DisplayRole).toString() << "not found in visual group" << text;
|
||||||
|
return qMakePair(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VisualGroup::rowTopOf(const QModelIndex &index) const
|
int VisualGroup::rowTopOf(const QModelIndex &index) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user