diff options
| author | Peter Penz <[email protected]> | 2006-12-14 19:12:05 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2006-12-14 19:12:05 +0000 |
| commit | 70782d6bb4d3b02c4c48c38ee2867561a706ed84 (patch) | |
| tree | 278ec21c0b631b3996fbe0441159c9f44de4bb5d /src/dolphinview.cpp | |
| parent | dd8158e70751d815305b50e3458835fce9e1574a (diff) | |
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
Diffstat (limited to 'src/dolphinview.cpp')
| -rw-r--r-- | src/dolphinview.cpp | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 7f0481eec..2f287f353 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -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" |
