If the user has changed the sort-role or sort-order by clicking on the view-header of the details-view, the settings have been adjusted to the model but not remembered in the directory settings.
const int sortRoleIndex = m_visibleRoles.indexOf(sortRole);
if (m_pressedRoleIndex == sortRoleIndex) {
// Toggle the sort order
- const Qt::SortOrder toggled = (m_model->sortOrder() == Qt::AscendingOrder) ?
+ const Qt::SortOrder previous = m_model->sortOrder();
+ const Qt::SortOrder current = (m_model->sortOrder() == Qt::AscendingOrder) ?
Qt::DescendingOrder : Qt::AscendingOrder;
- m_model->setSortOrder(toggled);
+ m_model->setSortOrder(current);
+ emit sortOrderChanged(current, previous);
} else {
// Change the sort role
- const QByteArray sortRole = m_visibleRoles.at(m_pressedRoleIndex);
- m_model->setSortRole(sortRole);
+ const QByteArray previous = m_model->sortRole();
+ const QByteArray current = m_visibleRoles.at(m_pressedRoleIndex);
+ m_model->setSortRole(current);
+ emit sortRoleChanged(current, previous);
}
}
qreal currentWidth,
qreal previousWidth);
+ /**
+ * Is emitted if the user has changed the sort order by clicking on a
+ * header item. The sort order of the model has already been adjusted to
+ * the current sort order. Note that no signal will be emitted if the
+ * sort order of the model has been changed without user interaction.
+ */
+ void sortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
+
+ /**
+ * Is emitted if the user has changed the sort role by clicking on a
+ * header item. The sort role of the model has already been adjusted to
+ * the current sort role. Note that no signal will be emitted if the
+ * sort role of the model has been changed without user interaction.
+ */
+ void sortRoleChanged(const QByteArray& current, const QByteArray& previous);
+
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
m_header->setVisibleRolesWidths(headerRolesWidths());
m_header->setZValue(1);
- m_useHeaderWidths = false;
-
connect(m_header, SIGNAL(visibleRoleWidthChanged(QByteArray,qreal,qreal)),
this, SLOT(slotVisibleRoleWidthChanged(QByteArray,qreal,qreal)));
+ connect(m_header, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
+ this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
+ connect(m_header, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
+ this, SIGNAL(sortRoleChanged(QByteArray,QByteArray)));
+
+ m_useHeaderWidths = false;
m_layouter->setHeaderHeight(m_header->size().height());
} else if (!show && m_header) {
void maximumItemOffsetChanged(qreal current, qreal previous);
void scrollTo(qreal newOffset);
+ /**
+ * Is emitted if the user has changed the sort order by clicking on a
+ * header item (see KItemListView::setHeaderShown()). The sort order
+ * of the model has already been adjusted to
+ * the current sort order. Note that no signal will be emitted if the
+ * sort order of the model has been changed without user interaction.
+ */
+ void sortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
+
+ /**
+ * Is emitted if the user has changed the sort role by clicking on a
+ * header item (see KItemListView::setHeaderShown()). The sort role
+ * of the model has already been adjusted to
+ * the current sort role. Note that no signal will be emitted if the
+ * sort role of the model has been changed without user interaction.
+ */
+ void sortRoleChanged(const QByteArray& current, const QByteArray& previous);
+
protected:
virtual void initializeItemListWidget(KItemListWidget* item);
connect(model, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
}
+ KItemListView* view = controller->view();
+ connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
+ this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder,Qt::SortOrder)));
+ connect(view, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
+ this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
+
KItemListSelectionManager* selectionManager = controller->selectionManager();
connect(selectionManager, SIGNAL(selectionChanged(QSet<int>,QSet<int>)),
this, SLOT(slotSelectionChanged(QSet<int>,QSet<int>)));
}
}
+void DolphinView::slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous)
+{
+ Q_UNUSED(previous);
+ Q_ASSERT(fileItemModel()->sortOrder() == current);
+
+ ViewProperties props(url());
+ props.setSortOrder(current);
+
+ emit sortOrderChanged(current);
+}
+
+void DolphinView::slotSortRoleChangedByHeader(const QByteArray& current, const QByteArray& previous)
+{
+ Q_UNUSED(previous);
+ Q_ASSERT(fileItemModel()->sortRole() == current);
+
+ ViewProperties props(url());
+ const Sorting sorting = sortingForSortRole(current);
+ props.setSorting(sorting);
+
+ emit sortingChanged(sorting);
+}
+
KFileItemModel* DolphinView::fileItemModel() const
{
return static_cast<KFileItemModel*>(m_container->controller()->model());
*/
void slotRefreshItems();
+ /**
+ * Is invoked when the sort order has been changed by the user by clicking
+ * on a header item. The view properties of the directory will get updated.
+ */
+ void slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous);
+
+ /**
+ * Is invoked when the sort role has been changed by the user by clicking
+ * on a header item. The view properties of the directory will get updated.
+ */
+ void slotSortRoleChangedByHeader(const QByteArray& current, const QByteArray& previous);
+
/**
* Observes the item with the URL \a url. As soon as the directory
* model indicates that the item is available, the item will