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);
}
}
return sizes;
}
-bool KFileItemListView::supportsItemExpanding() const
-{
- return m_itemLayout == DetailsLayout;
-}
-
QPixmap KFileItemListView::createDragPixmap(const QSet<int>& indexes) const
{
if (!model()) {
/** @reimp */
virtual QHash<QByteArray, QSizeF> visibleRolesSizes(const KItemRangeList& itemRanges) const;
- /** @reimp */
- virtual bool supportsItemExpanding() const;
-
/** @reimp */
virtual QPixmap createDragPixmap(const QSet<int>& indexes) const;
void KFileItemModel::setRoles(const QSet<QByteArray>& roles)
{
+ if (m_roles == roles) {
+ return;
+ }
m_roles = roles;
if (count() > 0) {
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),
+ m_supportsItemExpanding(false),
m_activeTransactions(0),
m_endTransactionAnimationHint(Animation),
m_itemSize(),
bool KItemListView::supportsItemExpanding() const
{
- return false;
+ return m_supportsItemExpanding;
}
QRectF KItemListView::itemRect(int index) 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);
* 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
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);
private:
bool m_enabledSelectionToggles;
bool m_grouped;
+ bool m_supportsItemExpanding;
int m_activeTransactions; // Counter for beginTransaction()/endTransaction()
LayoutAnimationHint m_endTransactionAnimationHint;
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;
if (m_container->zoomLevel() != oldZoomLevel) {
emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel);
}
-
- if (restoreModel) {
- loadDirectory(url());
- }
}
const bool hiddenFilesShown = props.hiddenFilesShown();