summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-03-07 15:59:46 +0100
committerPetr Mrázek <peterix@gmail.com>2014-03-07 15:59:46 +0100
commit737169d1d3ac62a7db99d51e892289aee8c1d3a3 (patch)
treef08e2c4ffcc68c1408fa0cdba4abb68707ebf05d
parent211a72e14498f9987dadac922312d22199f5c3a0 (diff)
parentcc1de6a64991a942fdbbb6cdfe24ea1ee268fffb (diff)
downloadMultiMC-737169d1d3ac62a7db99d51e892289aee8c1d3a3.tar
MultiMC-737169d1d3ac62a7db99d51e892289aee8c1d3a3.tar.gz
MultiMC-737169d1d3ac62a7db99d51e892289aee8c1d3a3.tar.lz
MultiMC-737169d1d3ac62a7db99d51e892289aee8c1d3a3.tar.xz
MultiMC-737169d1d3ac62a7db99d51e892289aee8c1d3a3.zip
Merge pull request #134 from MultiMC/feature_groupview
Fix another GroupView bug
-rw-r--r--gui/groupview/GroupView.cpp12
-rw-r--r--gui/groupview/GroupView.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/gui/groupview/GroupView.cpp b/gui/groupview/GroupView.cpp
index 5f3e3dec..b650efee 100644
--- a/gui/groupview/GroupView.cpp
+++ b/gui/groupview/GroupView.cpp
@@ -45,6 +45,12 @@ GroupView::~GroupView()
m_groups.clear();
}
+void GroupView::setModel(QAbstractItemModel *model)
+{
+ QAbstractItemView::setModel(model);
+ connect(model, &QAbstractItemModel::modelReset, this, &GroupView::modelReset);
+}
+
void GroupView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
const QVector<int> &roles)
{
@@ -133,6 +139,12 @@ void GroupView::updateGeometries()
viewport()->update();
}
+void GroupView::modelReset()
+{
+ scheduleDelayedItemsLayout();
+ executeDelayedItemsLayout();
+}
+
bool GroupView::isIndexHidden(const QModelIndex &index) const
{
Group *cat = category(index);
diff --git a/gui/groupview/GroupView.h b/gui/groupview/GroupView.h
index e8f9107c..b3ab5357 100644
--- a/gui/groupview/GroupView.h
+++ b/gui/groupview/GroupView.h
@@ -24,6 +24,8 @@ public:
GroupView(QWidget *parent = 0);
~GroupView();
+ void setModel(QAbstractItemModel *model) override;
+
/// return geometry rectangle occupied by the specified model item
QRect geometryRect(const QModelIndex &index) const;
/// return visual rectangle occupied by the specified model item
@@ -69,6 +71,7 @@ slots:
virtual void rowsInserted(const QModelIndex &parent, int start, int end) override;
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
virtual void updateGeometries() override;
+ void modelReset();
protected:
virtual bool isIndexHidden(const QModelIndex &index) const override;