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
void KFileItemListView::setItemLayout(Layout layout)
{
if (m_itemLayout != layout) {
void KFileItemListView::setItemLayout(Layout layout)
{
if (m_itemLayout != layout) {
+ const bool updateRoles = (m_itemLayout == DetailsLayout || layout == DetailsLayout);
+ 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();
updateLayoutOfVisibleItems();
+
+ setSupportsItemExpanding(m_itemLayout == DetailsLayout);
-bool KFileItemListView::supportsItemExpanding() const
-{
- return m_itemLayout == DetailsLayout;
-}
-
QPixmap KFileItemListView::createDragPixmap(const QSet<int>& indexes) const
{
if (!model()) {
QPixmap KFileItemListView::createDragPixmap(const QSet<int>& indexes) const
{
if (!model()) {
/** @reimp */
virtual QHash<QByteArray, QSizeF> visibleRolesSizes(const KItemRangeList& itemRanges) const;
/** @reimp */
virtual QHash<QByteArray, QSizeF> visibleRolesSizes(const KItemRangeList& itemRanges) const;
- /** @reimp */
- virtual bool supportsItemExpanding() const;
-
/** @reimp */
virtual QPixmap createDragPixmap(const QSet<int>& indexes) const;
/** @reimp */
virtual QPixmap createDragPixmap(const QSet<int>& indexes) const;
void KFileItemModel::setRoles(const QSet<QByteArray>& roles)
{
void KFileItemModel::setRoles(const QSet<QByteArray>& roles)
{
+ if (m_roles == roles) {
+ return;
+ }
m_roles = roles;
if (count() > 0) {
m_roles = roles;
if (count() > 0) {
void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
{
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();
+ }
QGraphicsWidget(parent),
m_enabledSelectionToggles(false),
m_grouped(false),
QGraphicsWidget(parent),
m_enabledSelectionToggles(false),
m_grouped(false),
+ m_supportsItemExpanding(false),
m_activeTransactions(0),
m_endTransactionAnimationHint(Animation),
m_itemSize(),
m_activeTransactions(0),
m_endTransactionAnimationHint(Animation),
m_itemSize(),
bool KItemListView::supportsItemExpanding() const
{
bool KItemListView::supportsItemExpanding() const
{
+ return m_supportsItemExpanding;
}
QRectF KItemListView::itemRect(int index) const
}
QRectF KItemListView::itemRect(int index) const
return m_visibleItems.values();
}
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);
void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
{
updateVisibleRolesSizes(itemRanges);
* has to take care itself how to visually represent the expanded items provided
* by the model.
*/
* 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
/**
* @return The rectangle of the item relative to the top/left of
QList<KItemListWidget*> visibleItemListWidgets() const;
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);
protected slots:
virtual void slotItemsInserted(const KItemRangeList& itemRanges);
virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
private:
bool m_enabledSelectionToggles;
bool m_grouped;
private:
bool m_enabledSelectionToggles;
bool m_grouped;
+ bool m_supportsItemExpanding;
int m_activeTransactions; // Counter for beginTransaction()/endTransaction()
LayoutAnimationHint m_endTransactionAnimationHint;
int m_activeTransactions; // Counter for beginTransaction()/endTransaction()
LayoutAnimationHint m_endTransactionAnimationHint;
const Mode mode = props.viewMode();
if (m_mode != mode) {
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;
const Mode previousMode = m_mode;
m_mode = mode;
if (m_container->zoomLevel() != oldZoomLevel) {
emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel);
}
if (m_container->zoomLevel() != oldZoomLevel) {
emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel);
}
-
- if (restoreModel) {
- loadDirectory(url());
- }
}
const bool hiddenFilesShown = props.hiddenFilesShown();
}
const bool hiddenFilesShown = props.hiddenFilesShown();