mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Support changing the sorting type and sort order (TODO: does not work yet as the implementation in KDirModel is empty yet).
svn path=/trunk/playground/utils/dolphin/; revision=613696
This commit is contained in:
parent
dd8158e707
commit
70782d6bb4
|
@ -392,61 +392,43 @@ bool DolphinView::isZoomOutPossible() const
|
|||
void DolphinView::setSorting(Sorting sorting)
|
||||
{
|
||||
if (sorting != this->sorting()) {
|
||||
/*KFileView* view = fileView();
|
||||
int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
|
||||
|
||||
switch (sorting) {
|
||||
case SortByName: spec = spec | QDir::Name; break;
|
||||
case SortBySize: spec = spec | QDir::Size; break;
|
||||
case SortByDate: spec = spec | QDir::Time; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
ViewProperties props(url());
|
||||
props.setSorting(sorting);
|
||||
|
||||
view->setSorting(static_cast<QDir::SortFlags>(spec));
|
||||
KDirModel* dirModel = static_cast<KDirModel*>(m_iconsView->model());
|
||||
dirModel->sort(columnIndex(sorting), props.sortOrder());
|
||||
|
||||
emit signalSortingChanged(sorting);*/
|
||||
emit sortingChanged(sorting);
|
||||
}
|
||||
}
|
||||
|
||||
DolphinView::Sorting DolphinView::sorting() const
|
||||
{
|
||||
/*const QDir::SortFlags spec = fileView()->sorting();
|
||||
|
||||
if (spec & QDir::Time) {
|
||||
return SortByDate;
|
||||
}
|
||||
|
||||
if (spec & QDir::Size) {
|
||||
return SortBySize;
|
||||
}*/
|
||||
|
||||
return SortByName;
|
||||
// TODO: instead of getting the sorting from the properties just fetch
|
||||
// them from KDirModel, if such an interface will be offered (David?)
|
||||
ViewProperties props(url());
|
||||
return props.sorting();
|
||||
}
|
||||
|
||||
void DolphinView::setSortOrder(Qt::SortOrder order)
|
||||
{
|
||||
if (sortOrder() != order) {
|
||||
/*KFileView* view = fileView();
|
||||
int sorting = view->sorting();
|
||||
sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
|
||||
(sorting | QDir::Reversed);
|
||||
|
||||
ViewProperties props(url());
|
||||
props.setSortOrder(order);
|
||||
|
||||
view->setSorting(static_cast<QDir::SortFlags>(sorting));
|
||||
KDirModel* dirModel = static_cast<KDirModel*>(m_iconsView->model());
|
||||
dirModel->sort(columnIndex(props.sorting()), order);
|
||||
|
||||
emit signalSortOrderChanged(order);*/
|
||||
emit sortOrderChanged(order);
|
||||
}
|
||||
}
|
||||
|
||||
Qt::SortOrder DolphinView::sortOrder() const
|
||||
{
|
||||
//return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
|
||||
return Qt::Descending;
|
||||
// TODO: instead of getting the order from the properties just fetch
|
||||
// them from KDirModel, if such an interface will be offered (David?)
|
||||
ViewProperties props(url());
|
||||
return props.sortOrder();
|
||||
}
|
||||
|
||||
void DolphinView::goBack()
|
||||
|
@ -1054,4 +1036,16 @@ void DolphinView::applyModeToView()
|
|||
}
|
||||
}
|
||||
|
||||
int DolphinView::columnIndex(Sorting sorting) const
|
||||
{
|
||||
int index = 0;
|
||||
switch (sorting) {
|
||||
case SortByName: index = KDirModel::Name; break;
|
||||
case SortBySize: index = KDirModel::Size; break;
|
||||
case SortByDate: index = KDirModel::ModifiedTime; break;
|
||||
default: assert(false);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
#include "dolphinview.moc"
|
||||
|
|
|
@ -442,6 +442,12 @@ private:
|
|||
*/
|
||||
void applyModeToView();
|
||||
|
||||
/**
|
||||
* Returns the column index used in the KDirModel depending on \a sorting.
|
||||
*/
|
||||
int columnIndex(Sorting sorting) const;
|
||||
|
||||
private:
|
||||
bool m_refreshing;
|
||||
bool m_showProgress;
|
||||
Mode m_mode;
|
||||
|
|
Loading…
Reference in New Issue
Block a user