summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <peter.penz19@gmail.com>2012-02-21 15:46:56 (GMT)
committerPeter Penz <peter.penz19@gmail.com>2012-02-21 15:48:47 (GMT)
commitabd23c29110560dd893e0dc2b542fd04e1845a0f (patch)
tree1ff6994a7087bdfeaeef28e26665a32191343cd6
parent8de987c45a7fef0f1d36a9f575d5cf9a47b19fd0 (diff)
Don't trigger assert when switching to details-view
If the visible roles of the details-view are equal to the visible roles of other views, then switching to the details-view will trigger an assert because the invisible roles don't get updated. Thanks to Frank Reininghaus for the detailed analyses! In the context of this fix optimizations have been done when switching view-modes: The "don't-animate-workaround" could be removed. BUG: 294531 FIXED-IN: 4.8.1
-rw-r--r--dolphin/src/kitemviews/kfileitemlistview.cpp14
-rw-r--r--dolphin/src/kitemviews/kfileitemlistview.h3
-rw-r--r--dolphin/src/kitemviews/kfileitemmodel.cpp3
-rw-r--r--dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp25
-rw-r--r--dolphin/src/kitemviews/kitemlistview.cpp11
-rw-r--r--dolphin/src/kitemviews/kitemlistview.h10
-rw-r--r--dolphin/src/views/dolphinview.cpp17
7 files changed, 38 insertions, 45 deletions
diff --git a/dolphin/src/kitemviews/kfileitemlistview.cpp b/dolphin/src/kitemviews/kfileitemlistview.cpp
index 03f3798..25f7738 100644
--- a/dolphin/src/kitemviews/kfileitemlistview.cpp
+++ b/dolphin/src/kitemviews/kfileitemlistview.cpp
@@ -97,8 +97,17 @@ bool KFileItemListView::previewsShown() const
void KFileItemListView::setItemLayout(Layout layout)
{
if (m_itemLayout != layout) {
+ const bool updateRoles = (m_itemLayout == DetailsLayout || layout == DetailsLayout);
m_itemLayout = layout;
+ if (updateRoles) {
+ // The details-layout requires some invisible roles that
+ // must be added to the model if the new layout is "details".
+ // If the old layout was "details" the roles will get removed.
+ applyRolesToModel();
+ }
updateLayoutOfVisibleItems();
+
+ setSupportsItemExpanding(m_itemLayout == DetailsLayout);
}
}
@@ -234,11 +243,6 @@ QHash<QByteArray, QSizeF> KFileItemListView::visibleRolesSizes(const KItemRangeL
return sizes;
}
-bool KFileItemListView::supportsItemExpanding() const
-{
- return m_itemLayout == DetailsLayout;
-}
-
QPixmap KFileItemListView::createDragPixmap(const QSet<int>& indexes) const
{
if (!model()) {
diff --git a/dolphin/src/kitemviews/kfileitemlistview.h b/dolphin/src/kitemviews/kfileitemlistview.h
index ea84778..8970156 100644
--- a/dolphin/src/kitemviews/kfileitemlistview.h
+++ b/dolphin/src/kitemviews/kfileitemlistview.h
@@ -81,9 +81,6 @@ public:
virtual QHash<QByteArray, QSizeF> visibleRolesSizes(const KItemRangeList& itemRanges) const;
/** @reimp */
- virtual bool supportsItemExpanding() const;
-
- /** @reimp */
virtual QPixmap createDragPixmap(const QSet<int>& indexes) const;
protected:
diff --git a/dolphin/src/kitemviews/kfileitemmodel.cpp b/dolphin/src/kitemviews/kfileitemmodel.cpp
index ede3c36..9078cb8 100644
--- a/dolphin/src/kitemviews/kfileitemmodel.cpp
+++ b/dolphin/src/kitemviews/kfileitemmodel.cpp
@@ -372,6 +372,9 @@ void KFileItemModel::clear()
void KFileItemModel::setRoles(const QSet<QByteArray>& roles)
{
+ if (m_roles == roles) {
+ return;
+ }
m_roles = roles;
if (count() > 0) {
diff --git a/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp b/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 7050d21..01f07f1 100644
--- a/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -216,25 +216,14 @@ void KFileItemModelRolesUpdater::setPaused(bool paused)
void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
{
- if (roles.count() == m_roles.count()) {
- bool isEqual = true;
- foreach (const QByteArray& role, roles) {
- if (!m_roles.contains(role)) {
- isEqual = false;
- break;
- }
- }
- if (isEqual) {
- return;
- }
- }
-
- m_roles = roles;
+ if (m_roles != roles) {
+ m_roles = roles;
- if (m_paused) {
- m_rolesChangedDuringPausing = true;
- } else {
- sortAndResolveAllRoles();
+ if (m_paused) {
+ m_rolesChangedDuringPausing = true;
+ } else {
+ sortAndResolveAllRoles();
+ }
}
}
diff --git a/dolphin/src/kitemviews/kitemlistview.cpp b/dolphin/src/kitemviews/kitemlistview.cpp
index bee2f3d..3727269 100644
--- a/dolphin/src/kitemviews/kitemlistview.cpp
+++ b/dolphin/src/kitemviews/kitemlistview.cpp
@@ -54,6 +54,7 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
QGraphicsWidget(parent),
m_enabledSelectionToggles(false),
m_grouped(false),
+ m_supportsItemExpanding(false),
m_activeTransactions(0),
m_endTransactionAnimationHint(Animation),
m_itemSize(),
@@ -503,7 +504,7 @@ QHash<QByteArray, QSizeF> KItemListView::visibleRolesSizes(const KItemRangeList&
bool KItemListView::supportsItemExpanding() const
{
- return false;
+ return m_supportsItemExpanding;
}
QRectF KItemListView::itemRect(int index) const
@@ -767,6 +768,14 @@ QList<KItemListWidget*> KItemListView::visibleItemListWidgets() const
return m_visibleItems.values();
}
+void KItemListView::setSupportsItemExpanding(bool supportsExpanding)
+{
+ if (m_supportsItemExpanding != supportsExpanding) {
+ m_supportsItemExpanding = supportsExpanding;
+ updateSiblingsInformation();
+ }
+}
+
void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
{
updateVisibleRolesSizes(itemRanges);
diff --git a/dolphin/src/kitemviews/kitemlistview.h b/dolphin/src/kitemviews/kitemlistview.h
index 293f4b1..d524dbd 100644
--- a/dolphin/src/kitemviews/kitemlistview.h
+++ b/dolphin/src/kitemviews/kitemlistview.h
@@ -176,7 +176,7 @@ public:
* has to take care itself how to visually represent the expanded items provided
* by the model.
*/
- virtual bool supportsItemExpanding() const;
+ bool supportsItemExpanding() const;
/**
* @return The rectangle of the item relative to the top/left of
@@ -298,6 +298,13 @@ protected:
QList<KItemListWidget*> visibleItemListWidgets() const;
+ /**
+ * Must be called by the derived class if it supports the expanding
+ * of items.
+ * @see supportsItemExpanding()
+ */
+ void setSupportsItemExpanding(bool supportsExpanding);
+
protected slots:
virtual void slotItemsInserted(const KItemRangeList& itemRanges);
virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
@@ -547,6 +554,7 @@ private:
private:
bool m_enabledSelectionToggles;
bool m_grouped;
+ bool m_supportsItemExpanding;
int m_activeTransactions; // Counter for beginTransaction()/endTransaction()
LayoutAnimationHint m_endTransactionAnimationHint;
diff --git a/dolphin/src/views/dolphinview.cpp b/dolphin/src/views/dolphinview.cpp
index 80be1e5..54787d2 100644
--- a/dolphin/src/views/dolphinview.cpp
+++ b/dolphin/src/views/dolphinview.cpp
@@ -1168,19 +1168,6 @@ void DolphinView::applyViewProperties()
const Mode mode = props.viewMode();
if (m_mode != mode) {
- // Prevent an animated transition of the position and size of the items when switching
- // the view-mode by temporary clearing the model and updating it again after the view mode
- // has been modified.
- const bool restoreModel = (model->count() > 0);
- if (restoreModel) {
- const int currentItemIndex = m_container->controller()->selectionManager()->currentItem();
- if (currentItemIndex >= 0) {
- m_currentItemUrl = model->fileItem(currentItemIndex).url();
- }
- m_selectedUrls = selectedItems().urlList();
- model->clear();
- }
-
const Mode previousMode = m_mode;
m_mode = mode;
@@ -1201,10 +1188,6 @@ void DolphinView::applyViewProperties()
if (m_container->zoomLevel() != oldZoomLevel) {
emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel);
}
-
- if (restoreModel) {
- loadDirectory(url());
- }
}
const bool hiddenFilesShown = props.hiddenFilesShown();