]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinview.cpp
Interface cleanups to prepare the return of "grouped sorting"
[dolphin.git] / src / views / dolphinview.cpp
1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "dolphinview.h"
22
23 #include <QAbstractItemView>
24 #include <QApplication>
25 #include <QBoxLayout>
26 #include <QClipboard>
27 #include <QDropEvent>
28 #include <QGraphicsSceneDragDropEvent>
29 #include <QKeyEvent>
30 #include <QItemSelection>
31 #include <QTimer>
32 #include <QScrollBar>
33
34 #include <KActionCollection>
35 #include <KColorScheme>
36 #include <KDirLister>
37 #include <KDirModel>
38 #include <KIconEffect>
39 #include <KFileItem>
40 #include <KFileItemListProperties>
41 #include <KLocale>
42 #include <kitemviews/kfileitemmodel.h>
43 #include <kitemviews/kfileitemlistview.h>
44 #include <kitemviews/kitemlistselectionmanager.h>
45 #include <kitemviews/kitemlistview.h>
46 #include <kitemviews/kitemlistcontroller.h>
47 #include <KIO/DeleteJob>
48 #include <KIO/NetAccess>
49 #include <KIO/PreviewJob>
50 #include <KJob>
51 #include <KMenu>
52 #include <KMessageBox>
53 #include <konq_fileitemcapabilities.h>
54 #include <konq_operations.h>
55 #include <konqmimedata.h>
56 #include <KToggleAction>
57 #include <KUrl>
58
59 #include "additionalinfoaccessor.h"
60 #include "dolphindirlister.h"
61 #include "dolphinnewfilemenuobserver.h"
62 #include "dolphin_detailsmodesettings.h"
63 #include "dolphin_generalsettings.h"
64 #include "dolphinitemlistcontainer.h"
65 #include "draganddrophelper.h"
66 #include "renamedialog.h"
67 #include "settings/dolphinsettings.h"
68 #include "versioncontrol/versioncontrolobserver.h"
69 #include "viewmodecontroller.h"
70 #include "viewproperties.h"
71 #include "views/tooltips/tooltipmanager.h"
72 #include "zoomlevelinfo.h"
73
74 namespace {
75 const int MaxModeEnum = DolphinView::CompactView;
76 const int MaxSortingEnum = DolphinView::SortByPath;
77 };
78
79 DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
80 QWidget(parent),
81 m_active(true),
82 m_tabsForFiles(false),
83 m_assureVisibleCurrentIndex(false),
84 m_isFolderWritable(true),
85 m_url(url),
86 m_mode(DolphinView::IconsView),
87 m_additionalInfoList(),
88 m_topLayout(0),
89 m_dirLister(0),
90 m_container(0),
91 m_toolTipManager(0),
92 m_selectionChangedTimer(0),
93 m_currentItemUrl(),
94 m_restoredContentsPosition(),
95 m_createdItemUrl(),
96 m_selectedUrls(),
97 m_versionControlObserver(0)
98 {
99 m_topLayout = new QVBoxLayout(this);
100 m_topLayout->setSpacing(0);
101 m_topLayout->setMargin(0);
102
103 //m_dolphinViewController = new DolphinViewController(this);
104
105 //m_viewModeController = new ViewModeController(this);
106 //m_viewModeController->setUrl(url);
107
108 /*connect(m_viewModeController, SIGNAL(urlChanged(KUrl)),
109 this, SIGNAL(urlChanged(KUrl)));
110
111 connect(m_dolphinViewController, SIGNAL(requestContextMenu(QPoint,QList<QAction*>)),
112 this, SLOT(openContextMenu(QPoint,QList<QAction*>)));
113 connect(m_dolphinViewController, SIGNAL(urlsDropped(KFileItem,KUrl,QDropEvent*)),
114 this, SLOT(dropUrls(KFileItem,KUrl,QDropEvent*)));
115 connect(m_dolphinViewController, SIGNAL(sortingChanged(DolphinView::Sorting)),
116 this, SLOT(updateSorting(DolphinView::Sorting)));
117 connect(m_dolphinViewController, SIGNAL(sortOrderChanged(Qt::SortOrder)),
118 this, SLOT(updateSortOrder(Qt::SortOrder)));
119 connect(m_dolphinViewController, SIGNAL(sortFoldersFirstChanged(bool)),
120 this, SLOT(updateSortFoldersFirst(bool)));
121 connect(m_dolphinViewController, SIGNAL(additionalInfoChanged(QList<DolphinView::AdditionalInfo>)),
122 this, SLOT(updateAdditionalInfo(QList<DolphinView::AdditionalInfo>)));*/
123 //connect(m_dolphinViewController, SIGNAL(itemActivated(KFileItem)),
124 // this, SLOT(triggerItem(KFileItem)));
125 //connect(m_dolphinViewController, SIGNAL(tabRequested(KUrl)),
126 // this, SIGNAL(tabRequested(KUrl)));
127 /*connect(m_dolphinViewController, SIGNAL(activated()),
128 this, SLOT(activate()));
129 connect(m_dolphinViewController, SIGNAL(itemEntered(KFileItem)),
130 this, SLOT(showHoverInformation(KFileItem)));
131 connect(m_dolphinViewController, SIGNAL(viewportEntered()),
132 this, SLOT(clearHoverInformation()));
133 connect(m_dolphinViewController, SIGNAL(urlChangeRequested(KUrl)),
134 this, SLOT(slotUrlChangeRequested(KUrl)));*/
135
136 // When a new item has been created by the "Create New..." menu, the item should
137 // get selected and it must be assured that the item will get visible. As the
138 // creation is done asynchronously, several signals must be checked:
139 connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(KUrl)),
140 this, SLOT(observeCreatedItem(KUrl)));
141
142 m_selectionChangedTimer = new QTimer(this);
143 m_selectionChangedTimer->setSingleShot(true);
144 m_selectionChangedTimer->setInterval(300);
145 connect(m_selectionChangedTimer, SIGNAL(timeout()),
146 this, SLOT(emitSelectionChangedSignal()));
147
148 m_dirLister = new DolphinDirLister(this);
149 m_dirLister->setAutoUpdate(true);
150 m_dirLister->setDelayedMimeTypes(true);
151
152 connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(slotRedirection(KUrl,KUrl)));
153 connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotDirListerStarted(KUrl)));
154 connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)),
155 this, SLOT(slotRefreshItems()));
156
157 connect(m_dirLister, SIGNAL(clear()), this, SIGNAL(itemCountChanged()));
158 connect(m_dirLister, SIGNAL(newItems(KFileItemList)), this, SIGNAL(itemCountChanged()));
159 connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
160 connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(infoMessage(QString)));
161 connect(m_dirLister, SIGNAL(percent(int)), this, SIGNAL(pathLoadingProgress(int)));
162 connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
163 connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SIGNAL(itemCountChanged()));
164
165 m_container = new DolphinItemListContainer(m_dirLister, this);
166 m_container->setVisibleRoles(QList<QByteArray>() << "name");
167 m_container->installEventFilter(this);
168
169 KItemListController* controller = m_container->controller();
170 controller->setSelectionBehavior(KItemListController::MultiSelection);
171 connect(controller, SIGNAL(itemActivated(int)),
172 this, SLOT(slotItemActivated(int)));
173 connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
174 connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
175 connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
176 connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF)));
177 connect(controller, SIGNAL(itemExpansionToggleClicked(int)), this, SLOT(slotItemExpansionToggleClicked(int)));
178 connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
179 connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
180 connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
181 connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
182
183 KFileItemModel* model = fileItemModel();
184 if (model) {
185 connect(model, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
186 }
187
188 KItemListSelectionManager* selectionManager = controller->selectionManager();
189 connect(selectionManager, SIGNAL(selectionChanged(QSet<int>,QSet<int>)),
190 this, SLOT(slotSelectionChanged(QSet<int>,QSet<int>)));
191
192 m_toolTipManager = new ToolTipManager(this);
193
194 m_versionControlObserver = new VersionControlObserver(this);
195 m_versionControlObserver->setModel(model);
196 connect(m_versionControlObserver, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
197 connect(m_versionControlObserver, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
198 connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(QString)), this, SIGNAL(operationCompletedMessage(QString)));
199
200 applyViewProperties();
201 m_topLayout->addWidget(m_container);
202
203 loadDirectory(url);
204 }
205
206 DolphinView::~DolphinView()
207 {
208 }
209
210 KUrl DolphinView::url() const
211 {
212 return m_url;
213 }
214
215 void DolphinView::setActive(bool active)
216 {
217 if (active == m_active) {
218 return;
219 }
220
221 m_active = active;
222
223 QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
224 if (!active) {
225 color.setAlpha(150);
226 }
227
228 /*QAbstractItemView* view = m_viewAccessor.itemView();
229 QWidget* viewport = view ? view->viewport() : 0;
230 if (viewport) {
231 QPalette palette;
232 palette.setColor(viewport->backgroundRole(), color);
233 viewport->setPalette(palette);
234 }*/
235
236 update();
237
238 if (active) {
239 //if (view) {
240 // view->setFocus();
241 //}
242 emit activated();
243 emit writeStateChanged(m_isFolderWritable);
244 }
245
246 //m_viewModeController->indicateActivationChange(active);
247 }
248
249 bool DolphinView::isActive() const
250 {
251 return m_active;
252 }
253
254 void DolphinView::setMode(Mode mode)
255 {
256 if (mode != m_mode) {
257 ViewProperties props(url());
258 props.setViewMode(mode);
259 props.save();
260
261 applyViewProperties();
262 }
263 }
264
265 DolphinView::Mode DolphinView::mode() const
266 {
267 return m_mode;
268 }
269
270 void DolphinView::setPreviewsShown(bool show)
271 {
272 if (previewsShown() == show) {
273 return;
274 }
275
276 ViewProperties props(url());
277 props.setPreviewsShown(show);
278
279 m_container->setPreviewsShown(show);
280 emit previewsShownChanged(show);
281 }
282
283 bool DolphinView::previewsShown() const
284 {
285 return m_container->previewsShown();
286 }
287
288 void DolphinView::setHiddenFilesShown(bool show)
289 {
290 if (m_dirLister->showingDotFiles() == show) {
291 return;
292 }
293
294 const KFileItemList itemList = selectedItems();
295 m_selectedUrls.clear();
296 m_selectedUrls = itemList.urlList();
297
298 ViewProperties props(url());
299 props.setHiddenFilesShown(show);
300
301 m_dirLister->setShowingDotFiles(show);
302 m_dirLister->emitChanges();
303 emit hiddenFilesShownChanged(show);
304 }
305
306 bool DolphinView::hiddenFilesShown() const
307 {
308 return m_dirLister->showingDotFiles();
309 }
310
311 void DolphinView::setGroupedSorting(bool grouped)
312 {
313 if (grouped == groupedSorting()) {
314 return;
315 }
316
317 ViewProperties props(url());
318 props.setGroupedSorting(grouped);
319 props.save();
320
321 m_container->controller()->model()->setGroupedSorting(grouped);
322
323 emit groupedSortingChanged(grouped);
324 }
325
326 bool DolphinView::groupedSorting() const
327 {
328 return fileItemModel()->groupedSorting();
329 }
330
331 KFileItemList DolphinView::items() const
332 {
333 return m_dirLister->items();
334 }
335
336 KFileItemList DolphinView::selectedItems() const
337 {
338 const KFileItemModel* model = fileItemModel();
339 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
340 const QSet<int> selectedIndexes = selectionManager->selectedItems();
341
342 KFileItemList selectedItems;
343 QSetIterator<int> it(selectedIndexes);
344 while (it.hasNext()) {
345 const int index = it.next();
346 selectedItems.append(model->fileItem(index));
347 }
348 return selectedItems;
349 }
350
351 int DolphinView::selectedItemsCount() const
352 {
353 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
354 return selectionManager->selectedItems().count();
355 }
356
357 void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
358 {
359 m_selectedUrls = urls;
360 }
361
362 void DolphinView::setItemSelectionEnabled(const QRegExp& pattern, bool enabled)
363 {
364 const KItemListSelectionManager::SelectionMode mode = enabled
365 ? KItemListSelectionManager::Select
366 : KItemListSelectionManager::Deselect;
367 const KFileItemModel* model = fileItemModel();
368 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
369
370 for (int index = 0; index < model->count(); index++) {
371 const KFileItem item = model->fileItem(index);
372 if (pattern.exactMatch(item.name())) {
373 // An alternative approach would be to store the matching items in a QSet<int> and
374 // select them in one go after the loop, but we'd need a new function
375 // KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode)
376 // for that.
377 selectionManager->setSelected(index, 1, mode);
378 }
379 }
380 }
381
382 void DolphinView::setZoomLevel(int level)
383 {
384 const int oldZoomLevel = zoomLevel();
385 m_container->setZoomLevel(level);
386 if (zoomLevel() != oldZoomLevel) {
387 emit zoomLevelChanged(zoomLevel(), oldZoomLevel);
388 }
389 }
390
391 int DolphinView::zoomLevel() const
392 {
393 return m_container->zoomLevel();
394 }
395
396 void DolphinView::setSorting(Sorting sorting)
397 {
398 if (sorting != this->sorting()) {
399 updateSorting(sorting);
400 }
401 }
402
403 DolphinView::Sorting DolphinView::sorting() const
404 {
405 KItemModelBase* model = m_container->controller()->model();
406 return sortingForSortRole(model->sortRole());
407 }
408
409 void DolphinView::setSortOrder(Qt::SortOrder order)
410 {
411 if (sortOrder() != order) {
412 updateSortOrder(order);
413 }
414 }
415
416 Qt::SortOrder DolphinView::sortOrder() const
417 {
418 KItemModelBase* model = fileItemModel();
419 return model->sortOrder();
420 }
421
422 void DolphinView::setSortFoldersFirst(bool foldersFirst)
423 {
424 if (sortFoldersFirst() != foldersFirst) {
425 updateSortFoldersFirst(foldersFirst);
426 }
427 }
428
429 bool DolphinView::sortFoldersFirst() const
430 {
431 KFileItemModel* model = fileItemModel();
432 return model->sortFoldersFirst();
433 }
434
435 void DolphinView::setAdditionalInfoList(const QList<AdditionalInfo>& info)
436 {
437 const QList<AdditionalInfo> previousList = info;
438
439 ViewProperties props(url());
440 props.setAdditionalInfoList(info);
441
442 m_additionalInfoList = info;
443 applyAdditionalInfoListToView();
444
445 emit additionalInfoListChanged(m_additionalInfoList, previousList);
446 }
447
448 QList<DolphinView::AdditionalInfo> DolphinView::additionalInfoList() const
449 {
450 return m_additionalInfoList;
451 }
452
453 void DolphinView::reload()
454 {
455 QByteArray viewState;
456 QDataStream saveStream(&viewState, QIODevice::WriteOnly);
457 saveState(saveStream);
458
459 const KFileItemList itemList = selectedItems();
460 m_selectedUrls.clear();
461 m_selectedUrls = itemList.urlList();
462
463 setUrl(url());
464 loadDirectory(url(), true);
465
466 QDataStream restoreStream(viewState);
467 restoreState(restoreStream);
468 }
469
470 void DolphinView::stopLoading()
471 {
472 m_dirLister->stop();
473 }
474
475 void DolphinView::refresh()
476 {
477 const bool oldActivationState = m_active;
478 const int oldZoomLevel = zoomLevel();
479 m_active = true;
480
481 applyViewProperties();
482 reload();
483
484 setActive(oldActivationState);
485 updateZoomLevel(oldZoomLevel);
486 }
487
488 void DolphinView::setNameFilter(const QString& nameFilter)
489 {
490 Q_UNUSED(nameFilter);
491 //m_viewModeController->setNameFilter(nameFilter);
492 }
493
494 QString DolphinView::nameFilter() const
495 {
496 return QString(); //m_viewModeController->nameFilter();
497 }
498
499 void DolphinView::calculateItemCount(int& fileCount,
500 int& folderCount,
501 KIO::filesize_t& totalFileSize) const
502 {
503 foreach (const KFileItem& item, m_dirLister->items()) {
504 if (item.isDir()) {
505 ++folderCount;
506 } else {
507 ++fileCount;
508 totalFileSize += item.size();
509 }
510 }
511 }
512
513 QString DolphinView::statusBarText() const
514 {
515 QString text;
516 int folderCount = 0;
517 int fileCount = 0;
518 KIO::filesize_t totalFileSize = 0;
519
520 if (hasSelection()) {
521 // give a summary of the status of the selected files
522 const KFileItemList list = selectedItems();
523 if (list.isEmpty()) {
524 // when an item is triggered, it is temporary selected but selectedItems()
525 // will return an empty list
526 return text;
527 }
528
529 KFileItemList::const_iterator it = list.begin();
530 const KFileItemList::const_iterator end = list.end();
531 while (it != end) {
532 const KFileItem& item = *it;
533 if (item.isDir()) {
534 ++folderCount;
535 } else {
536 ++fileCount;
537 totalFileSize += item.size();
538 }
539 ++it;
540 }
541
542 if (folderCount + fileCount == 1) {
543 // if only one item is selected, show the filename
544 const QString name = list.first().text();
545 text = (folderCount == 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name) :
546 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
547 name, KIO::convertSize(totalFileSize));
548 } else {
549 // at least 2 items are selected
550 const QString foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
551 const QString filesText = i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount);
552 if ((folderCount > 0) && (fileCount > 0)) {
553 text = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
554 foldersText, filesText, KIO::convertSize(totalFileSize));
555 } else if (fileCount > 0) {
556 text = i18nc("@info:status files (size)", "%1 (%2)", filesText, KIO::convertSize(totalFileSize));
557 } else {
558 Q_ASSERT(folderCount > 0);
559 text = foldersText;
560 }
561 }
562 } else {
563 calculateItemCount(fileCount, folderCount, totalFileSize);
564 text = KIO::itemsSummaryString(fileCount + folderCount,
565 fileCount, folderCount,
566 totalFileSize, true);
567 }
568
569 return text;
570 }
571
572 QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
573 {
574 QList<QAction*> actions;
575
576 if (items.isEmpty()) {
577 const KFileItem item = fileItemModel()->rootItem();
578 actions = m_versionControlObserver->actions(KFileItemList() << item);
579 } else {
580 actions = m_versionControlObserver->actions(items);
581 }
582
583 return actions;
584 }
585
586 void DolphinView::setUrl(const KUrl& url)
587 {
588 if (url == m_url) {
589 return;
590 }
591
592 emit urlAboutToBeChanged(url);
593 m_url = url;
594
595 if (GeneralSettings::showToolTips()) {
596 m_toolTipManager->hideToolTip();
597 }
598
599 // It is important to clear the items from the model before
600 // applying the view properties, otherwise expensive operations
601 // might be done on the existing items although they get cleared
602 // anyhow afterwards by loadDirectory().
603 fileItemModel()->clear();
604 applyViewProperties();
605 loadDirectory(url);
606
607 emit urlChanged(url);
608 }
609
610 void DolphinView::selectAll()
611 {
612 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
613 selectionManager->setSelected(0, fileItemModel()->count());
614 }
615
616 void DolphinView::invertSelection()
617 {
618 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
619 selectionManager->setSelected(0, fileItemModel()->count(), KItemListSelectionManager::Toggle);
620 }
621
622 void DolphinView::clearSelection()
623 {
624 m_container->controller()->selectionManager()->clearSelection();
625 }
626
627 void DolphinView::renameSelectedItems()
628 {
629 KFileItemList items = selectedItems();
630 const int itemCount = items.count();
631 if (itemCount < 1) {
632 return;
633 }
634
635 /*if ((itemCount == 1) && DolphinSettings::instance().generalSettings()->renameInline()) {
636 const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForItem(items.first());
637 const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
638 m_viewAccessor.itemView()->edit(proxyIndex);
639 } else {*/
640 RenameDialog* dialog = new RenameDialog(this, items);
641 dialog->setAttribute(Qt::WA_DeleteOnClose);
642 dialog->show();
643 dialog->raise();
644 dialog->activateWindow();
645 //}
646
647 // assure that the current index remains visible when KDirLister
648 // will notify the view about changed items
649 m_assureVisibleCurrentIndex = true;
650 }
651
652 void DolphinView::trashSelectedItems()
653 {
654 const KUrl::List list = simplifiedSelectedUrls();
655 KonqOperations::del(this, KonqOperations::TRASH, list);
656 }
657
658 void DolphinView::deleteSelectedItems()
659 {
660 const KUrl::List list = simplifiedSelectedUrls();
661 const bool del = KonqOperations::askDeleteConfirmation(list,
662 KonqOperations::DEL,
663 KonqOperations::DEFAULT_CONFIRMATION,
664 this);
665
666 if (del) {
667 KIO::Job* job = KIO::del(list);
668 connect(job, SIGNAL(result(KJob*)),
669 this, SLOT(slotDeleteFileFinished(KJob*)));
670 }
671 }
672
673 void DolphinView::cutSelectedItems()
674 {
675 QMimeData* mimeData = selectionMimeData();
676 KonqMimeData::addIsCutSelection(mimeData, true);
677 QApplication::clipboard()->setMimeData(mimeData);
678 }
679
680 void DolphinView::copySelectedItems()
681 {
682 QMimeData* mimeData = selectionMimeData();
683 QApplication::clipboard()->setMimeData(mimeData);
684 }
685
686 void DolphinView::paste()
687 {
688 pasteToUrl(url());
689 }
690
691 void DolphinView::pasteIntoFolder()
692 {
693 const KFileItemList items = selectedItems();
694 if ((items.count() == 1) && items.first().isDir()) {
695 pasteToUrl(items.first().url());
696 }
697 }
698
699 bool DolphinView::eventFilter(QObject* watched, QEvent* event)
700 {
701 switch (event->type()) {
702 case QEvent::FocusIn:
703 if (watched == m_container) {
704 setActive(true);
705 }
706 break;
707
708 default:
709 break;
710 }
711
712 return QWidget::eventFilter(watched, event);
713 }
714
715 void DolphinView::wheelEvent(QWheelEvent* event)
716 {
717 if (event->modifiers().testFlag(Qt::ControlModifier)) {
718 const int numDegrees = event->delta() / 8;
719 const int numSteps = numDegrees / 15;
720
721 setZoomLevel(zoomLevel() + numSteps);
722 event->accept();
723 } else {
724 event->ignore();
725 }
726 }
727
728 void DolphinView::activate()
729 {
730 setActive(true);
731 }
732
733 void DolphinView::slotItemActivated(int index)
734 {
735 Q_UNUSED(index);
736
737 const KFileItemList items = selectedItems();
738 if (items.isEmpty()) {
739 return;
740 }
741
742 if (items.count() == 1) {
743 emit itemActivated(items.at(0)); // caught by DolphinViewContainer or DolphinPart
744 } else {
745 foreach (const KFileItem& item, items) {
746 if (item.isDir()) {
747 emit tabRequested(item.url());
748 } else {
749 emit itemActivated(item);
750 }
751 }
752 }
753 }
754
755 void DolphinView::slotItemMiddleClicked(int index)
756 {
757 const KFileItem item = fileItemModel()->fileItem(index);
758 if (item.isDir() || isTabsForFilesEnabled()) {
759 emit tabRequested(item.url());
760 }
761 }
762
763 void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos)
764 {
765 if (GeneralSettings::showToolTips()) {
766 m_toolTipManager->hideToolTip();
767 }
768 const KFileItem item = fileItemModel()->fileItem(index);
769 emit requestContextMenu(pos.toPoint(), item, url(), QList<QAction*>());
770 }
771
772 void DolphinView::slotViewContextMenuRequested(const QPointF& pos)
773 {
774 if (GeneralSettings::showToolTips()) {
775 m_toolTipManager->hideToolTip();
776 }
777 emit requestContextMenu(pos.toPoint(), KFileItem(), url(), QList<QAction*>());
778 }
779
780 void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
781 {
782 QWeakPointer<KMenu> menu = new KMenu(QApplication::activeWindow());
783
784 KItemListView* view = m_container->controller()->view();
785 const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
786
787 // Add all roles to the menu that can be shown or hidden by the user
788 const AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
789 const QList<DolphinView::AdditionalInfo> keys = infoAccessor.keys();
790 foreach (const DolphinView::AdditionalInfo info, keys) {
791 const QByteArray& role = infoAccessor.role(info);
792 if (role != "name") {
793 const QString text = fileItemModel()->roleDescription(role);
794
795 QAction* action = menu.data()->addAction(text);
796 action->setCheckable(true);
797 action->setChecked(visibleRolesSet.contains(role));
798 action->setData(info);
799 }
800 }
801
802 QAction* action = menu.data()->exec(pos.toPoint());
803 if (action) {
804 // Show or hide the selected role
805 const DolphinView::AdditionalInfo info =
806 static_cast<DolphinView::AdditionalInfo>(action->data().toInt());
807
808 ViewProperties props(url());
809 QList<DolphinView::AdditionalInfo> infoList = props.additionalInfoList();
810
811 const QByteArray selectedRole = infoAccessor.role(info);
812 QList<QByteArray> visibleRoles = view->visibleRoles();
813
814 if (action->isChecked()) {
815 const int index = keys.indexOf(info) + 1;
816 visibleRoles.insert(index, selectedRole);
817 infoList.insert(index, info);
818 } else {
819 visibleRoles.removeOne(selectedRole);
820 infoList.removeOne(info);
821 }
822
823 view->setVisibleRoles(visibleRoles);
824 props.setAdditionalInfoList(infoList);
825 }
826
827 delete menu.data();
828 }
829
830 void DolphinView::slotItemExpansionToggleClicked(int index)
831 {
832 // TODO: When doing a model->setExpanded(false) it should
833 // be checked here whether the current index is part of the
834 // closed sub-tree. If this is the case, the current index
835 // should be adjusted to the parent index.
836 KFileItemModel* model = fileItemModel();
837 const bool expanded = model->isExpanded(index);
838 model->setExpanded(index, !expanded);
839 }
840
841 void DolphinView::slotItemHovered(int index)
842 {
843 const KFileItem item = fileItemModel()->fileItem(index);
844
845 if (GeneralSettings::showToolTips()) {
846 QRectF itemRect = m_container->controller()->view()->itemBoundingRect(index);
847 const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint());
848 itemRect.moveTo(pos);
849
850 m_toolTipManager->showToolTip(item, itemRect);
851 }
852
853 emit requestItemInfo(item);
854 }
855
856 void DolphinView::slotItemUnhovered(int index)
857 {
858 Q_UNUSED(index);
859 if (GeneralSettings::showToolTips()) {
860 m_toolTipManager->hideToolTip();
861 }
862 emit requestItemInfo(KFileItem());
863 }
864
865 void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
866 {
867 const KFileItem destItem = fileItemModel()->fileItem(index);
868
869 QDropEvent dropEvent(event->pos().toPoint(),
870 event->possibleActions(),
871 event->mimeData(),
872 event->buttons(),
873 event->modifiers());
874
875 DragAndDropHelper::dropUrls(destItem, url(), &dropEvent, this);
876 }
877
878 void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
879 {
880 if (previous != 0) {
881 disconnect(previous, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
882 }
883
884 Q_ASSERT(qobject_cast<KFileItemModel*>(current));
885 connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
886
887 KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current);
888 m_versionControlObserver->setModel(fileItemModel);
889 }
890
891 void DolphinView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
892 {
893 const int currentCount = current.count();
894 const int previousCount = previous.count();
895 const bool selectionStateChanged = (currentCount == 0 && previousCount > 0) ||
896 (currentCount > 0 && previousCount == 0);
897
898 // If nothing has been selected before and something got selected (or if something
899 // was selected before and now nothing is selected) the selectionChangedSignal must
900 // be emitted asynchronously as fast as possible to update the edit-actions.
901 m_selectionChangedTimer->setInterval(selectionStateChanged ? 0 : 300);
902 m_selectionChangedTimer->start();
903 }
904
905 void DolphinView::emitSelectionChangedSignal()
906 {
907 m_selectionChangedTimer->stop();
908 emit selectionChanged(selectedItems());
909 }
910
911 void DolphinView::dropUrls(const KFileItem& destItem,
912 const KUrl& destPath,
913 QDropEvent* event)
914 {
915 Q_UNUSED(destItem);
916 Q_UNUSED(destPath);
917 markPastedUrlsAsSelected(event->mimeData());
918 //DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
919 }
920
921 void DolphinView::updateSorting(DolphinView::Sorting sorting)
922 {
923 ViewProperties props(url());
924 props.setSorting(sorting);
925
926 KItemModelBase* model = m_container->controller()->model();
927 model->setSortRole(sortRoleForSorting(sorting));
928
929 emit sortingChanged(sorting);
930 }
931
932 void DolphinView::updateSortOrder(Qt::SortOrder order)
933 {
934 ViewProperties props(url());
935 props.setSortOrder(order);
936
937 KItemModelBase* model = fileItemModel();
938 model->setSortOrder(order);
939
940 emit sortOrderChanged(order);
941 }
942
943 void DolphinView::updateSortFoldersFirst(bool foldersFirst)
944 {
945 ViewProperties props(url());
946 props.setSortFoldersFirst(foldersFirst);
947
948 KFileItemModel* model = fileItemModel();
949 model->setSortFoldersFirst(foldersFirst);
950
951 emit sortFoldersFirstChanged(foldersFirst);
952 }
953
954 QPair<bool, QString> DolphinView::pasteInfo() const
955 {
956 return KonqOperations::pasteInfo(url());
957 }
958
959 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
960 {
961 m_tabsForFiles = tabsForFiles;
962 }
963
964 bool DolphinView::isTabsForFilesEnabled() const
965 {
966 return m_tabsForFiles;
967 }
968
969 bool DolphinView::itemsExpandable() const
970 {
971 return m_mode == DetailsView;
972 }
973
974 void DolphinView::restoreState(QDataStream& stream)
975 {
976 // Restore the current item that had the keyboard focus
977 stream >> m_currentItemUrl;
978
979 // Restore the view position
980 stream >> m_restoredContentsPosition;
981
982 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
983 QSet<KUrl> urls;
984 stream >> urls;
985 fileItemModel()->restoreExpandedUrls(urls);
986 }
987
988 void DolphinView::saveState(QDataStream& stream)
989 {
990 // Save the current item that has the keyboard focus
991 const int currentIndex = m_container->controller()->selectionManager()->currentItem();
992 if (currentIndex != -1) {
993 KFileItem item = fileItemModel()->fileItem(currentIndex);
994 KUrl currentItemUrl = item.url();
995 stream << currentItemUrl;
996 } else {
997 stream << KUrl();
998 }
999
1000 // Save view position
1001 const qreal x = m_container->horizontalScrollBar()->value();
1002 const qreal y = m_container->verticalScrollBar()->value();
1003 stream << QPoint(x, y);
1004
1005 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
1006 stream << fileItemModel()->expandedUrls();
1007 }
1008
1009 bool DolphinView::hasSelection() const
1010 {
1011 return m_container->controller()->selectionManager()->hasSelection();
1012 }
1013
1014 KFileItem DolphinView::rootItem() const
1015 {
1016 return m_dirLister->rootItem();
1017 }
1018
1019 void DolphinView::observeCreatedItem(const KUrl& url)
1020 {
1021 m_createdItemUrl = url;
1022 //connect(m_dirModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
1023 // this, SLOT(selectAndScrollToCreatedItem()));
1024 }
1025
1026 void DolphinView::selectAndScrollToCreatedItem()
1027 {
1028 /*const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_createdItemUrl);
1029 if (dirIndex.isValid()) {
1030 const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
1031 QAbstractItemView* view = m_viewAccessor.itemView();
1032 if (view) {
1033 view->setCurrentIndex(proxyIndex);
1034 }
1035 }
1036
1037 disconnect(m_viewAccessor.dirModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
1038 this, SLOT(selectAndScrollToCreatedItem()));*/
1039 m_createdItemUrl = KUrl();
1040 }
1041
1042 void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
1043 {
1044 if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
1045 emit redirection(oldUrl, newUrl);
1046 m_url = newUrl; // #186947
1047 }
1048 }
1049
1050 void DolphinView::updateViewState()
1051 {
1052 if (m_currentItemUrl != KUrl()) {
1053 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1054 const int currentIndex = fileItemModel()->index(m_currentItemUrl);
1055 if (currentIndex != -1) {
1056 selectionManager->setCurrentItem(currentIndex);
1057 } else {
1058 selectionManager->setCurrentItem(0);
1059 }
1060 m_currentItemUrl = KUrl();
1061 }
1062
1063 if (!m_restoredContentsPosition.isNull()) {
1064 const int x = m_restoredContentsPosition.x();
1065 const int y = m_restoredContentsPosition.y();
1066 m_restoredContentsPosition = QPoint();
1067
1068 m_container->horizontalScrollBar()->setValue(x);
1069 m_container->verticalScrollBar()->setValue(y);
1070 }
1071
1072 if (!m_selectedUrls.isEmpty()) {
1073 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1074 QSet<int> selectedItems = selectionManager->selectedItems();
1075 const KFileItemModel* model = fileItemModel();
1076
1077 foreach (const KUrl& url, m_selectedUrls) {
1078 const int index = model->index(url);
1079 if (index >= 0) {
1080 selectedItems.insert(index);
1081 }
1082 }
1083
1084 selectionManager->setSelectedItems(selectedItems);
1085 m_selectedUrls.clear();
1086 }
1087 }
1088
1089 void DolphinView::showHoverInformation(const KFileItem& item)
1090 {
1091 emit requestItemInfo(item);
1092 }
1093
1094 void DolphinView::clearHoverInformation()
1095 {
1096 emit requestItemInfo(KFileItem());
1097 }
1098
1099 void DolphinView::slotDeleteFileFinished(KJob* job)
1100 {
1101 if (job->error() == 0) {
1102 emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1103 } else if (job->error() != KIO::ERR_USER_CANCELED) {
1104 emit errorMessage(job->errorString());
1105 }
1106 }
1107
1108 void DolphinView::slotDirListerStarted(const KUrl& url)
1109 {
1110 // Disable the writestate temporary until it can be determined in a fast way
1111 // in DolphinView::slotLoadingCompleted()
1112 if (m_isFolderWritable) {
1113 m_isFolderWritable = false;
1114 emit writeStateChanged(m_isFolderWritable);
1115 }
1116
1117 emit startedPathLoading(url);
1118 }
1119
1120 void DolphinView::slotLoadingCompleted()
1121 {
1122 // Update the view-state. This has to be done using a Qt::QueuedConnection
1123 // because the view might not be in its final state yet (the view also
1124 // listens to the completed()-signal from KDirLister and the order of
1125 // of slots is undefined).
1126 QTimer::singleShot(0, this, SLOT(updateViewState()));
1127
1128 emit finishedPathLoading(url());
1129
1130 updateWritableState();
1131 }
1132
1133 void DolphinView::slotRefreshItems()
1134 {
1135 if (m_assureVisibleCurrentIndex) {
1136 m_assureVisibleCurrentIndex = false;
1137 //QAbstractItemView* view = m_viewAccessor.itemView();
1138 //if (view) {
1139 // m_viewAccessor.itemView()->scrollTo(m_viewAccessor.itemView()->currentIndex());
1140 //}
1141 }
1142 }
1143
1144 KFileItemModel* DolphinView::fileItemModel() const
1145 {
1146 return static_cast<KFileItemModel*>(m_container->controller()->model());
1147 }
1148
1149 void DolphinView::loadDirectory(const KUrl& url, bool reload)
1150 {
1151 if (!url.isValid()) {
1152 const QString location(url.pathOrUrl());
1153 if (location.isEmpty()) {
1154 emit errorMessage(i18nc("@info:status", "The location is empty."));
1155 } else {
1156 emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
1157 }
1158 return;
1159 }
1160
1161 m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
1162 }
1163
1164 void DolphinView::applyViewProperties()
1165 {
1166 m_container->beginTransaction();
1167
1168 const ViewProperties props(url());
1169
1170 const Mode mode = props.viewMode();
1171 if (m_mode != mode) {
1172 const Mode previousMode = m_mode;
1173 m_mode = mode;
1174
1175 // Changing the mode might result in changing
1176 // the zoom level. Remember the old zoom level so
1177 // that zoomLevelChanged() can get emitted.
1178 const int oldZoomLevel = m_container->zoomLevel();
1179
1180 switch (m_mode) {
1181 case IconsView: m_container->setItemLayout(KFileItemListView::IconsLayout); break;
1182 case CompactView: m_container->setItemLayout(KFileItemListView::CompactLayout); break;
1183 case DetailsView: m_container->setItemLayout(KFileItemListView::DetailsLayout); break;
1184 default: Q_ASSERT(false); break;
1185 }
1186
1187 emit modeChanged(m_mode, previousMode);
1188
1189 if (m_container->zoomLevel() != oldZoomLevel) {
1190 emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel);
1191 }
1192 }
1193
1194 const bool hiddenFilesShown = props.hiddenFilesShown();
1195 if (hiddenFilesShown != m_dirLister->showingDotFiles()) {
1196 m_dirLister->setShowingDotFiles(hiddenFilesShown);
1197 m_dirLister->emitChanges();
1198 emit hiddenFilesShownChanged(hiddenFilesShown);
1199 }
1200
1201 KFileItemModel* model = fileItemModel();
1202
1203 const bool groupedSorting = props.groupedSorting();
1204 if (groupedSorting != model->groupedSorting()) {
1205 model->setGroupedSorting(groupedSorting);
1206 emit groupedSortingChanged(groupedSorting);
1207 }
1208
1209 const DolphinView::Sorting sorting = props.sorting();
1210 const QByteArray newSortRole = sortRoleForSorting(sorting);
1211 if (newSortRole != model->sortRole()) {
1212 model->setSortRole(newSortRole);
1213 emit sortingChanged(sorting);
1214 }
1215
1216 const Qt::SortOrder sortOrder = props.sortOrder();
1217 if (sortOrder != model->sortOrder()) {
1218 model->setSortOrder(sortOrder);
1219 emit sortOrderChanged(sortOrder);
1220 }
1221
1222 const bool sortFoldersFirst = props.sortFoldersFirst();
1223 if (sortFoldersFirst != model->sortFoldersFirst()) {
1224 model->setSortFoldersFirst(sortFoldersFirst);
1225 emit sortFoldersFirstChanged(sortFoldersFirst);
1226 }
1227
1228 const QList<DolphinView::AdditionalInfo> infoList = props.additionalInfoList();
1229 if (infoList != m_additionalInfoList) {
1230 const QList<DolphinView::AdditionalInfo> previousList = m_additionalInfoList;
1231 m_additionalInfoList = infoList;
1232 applyAdditionalInfoListToView();
1233 emit additionalInfoListChanged(m_additionalInfoList, previousList);
1234 }
1235
1236 const bool previewsShown = props.previewsShown();
1237 if (previewsShown != m_container->previewsShown()) {
1238 const int oldZoomLevel = zoomLevel();
1239
1240 m_container->setPreviewsShown(previewsShown);
1241 emit previewsShownChanged(previewsShown);
1242
1243 // Changing the preview-state might result in a changed zoom-level
1244 if (oldZoomLevel != zoomLevel()) {
1245 emit zoomLevelChanged(zoomLevel(), oldZoomLevel);
1246 }
1247 }
1248
1249 m_container->endTransaction();
1250 }
1251
1252 void DolphinView::applyAdditionalInfoListToView()
1253 {
1254 const AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
1255
1256 QList<QByteArray> visibleRoles;
1257 visibleRoles.reserve(m_additionalInfoList.count() + 1);
1258 visibleRoles.append("name");
1259
1260 foreach (AdditionalInfo info, m_additionalInfoList) {
1261 visibleRoles.append(infoAccessor.role(info));
1262 }
1263
1264 m_container->setVisibleRoles(visibleRoles);
1265 }
1266
1267 void DolphinView::pasteToUrl(const KUrl& url)
1268 {
1269 markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
1270 KonqOperations::doPaste(this, url);
1271 }
1272
1273 void DolphinView::updateZoomLevel(int oldZoomLevel)
1274 {
1275 Q_UNUSED(oldZoomLevel);
1276 /* const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor.itemView()->iconSize());
1277 if (oldZoomLevel != newZoomLevel) {
1278 m_viewModeController->setZoomLevel(newZoomLevel);
1279 emit zoomLevelChanged(newZoomLevel);
1280 }*/
1281 }
1282
1283 KUrl::List DolphinView::simplifiedSelectedUrls() const
1284 {
1285 KUrl::List urls;
1286
1287 const KFileItemList items = selectedItems();
1288 foreach (const KFileItem &item, items) {
1289 urls.append(item.url());
1290 }
1291
1292 if (itemsExpandable()) {
1293 // TODO: Check if we still need KDirModel for this in KDE 5.0
1294 urls = KDirModel::simplifiedUrlList(urls);
1295 }
1296
1297 return urls;
1298 }
1299
1300 QMimeData* DolphinView::selectionMimeData() const
1301 {
1302 const KFileItemModel* model = fileItemModel();
1303 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1304 const QSet<int> selectedIndexes = selectionManager->selectedItems();
1305
1306 return model->createMimeData(selectedIndexes);
1307 }
1308
1309 void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
1310 {
1311 const KUrl::List urls = KUrl::List::fromMimeData(mimeData);
1312 markUrlsAsSelected(urls);
1313 }
1314
1315 void DolphinView::updateWritableState()
1316 {
1317 const bool wasFolderWritable = m_isFolderWritable;
1318 m_isFolderWritable = true;
1319
1320 const KFileItem item = m_dirLister->rootItem();
1321 if (!item.isNull()) {
1322 KFileItemListProperties capabilities(KFileItemList() << item);
1323 m_isFolderWritable = capabilities.supportsWriting();
1324 }
1325 if (m_isFolderWritable != wasFolderWritable) {
1326 emit writeStateChanged(m_isFolderWritable);
1327 }
1328 }
1329
1330 QByteArray DolphinView::sortRoleForSorting(Sorting sorting) const
1331 {
1332 switch (sorting) {
1333 case SortByName: return "name";
1334 case SortBySize: return "size";
1335 case SortByDate: return "date";
1336 case SortByPermissions: return "permissions";
1337 case SortByOwner: return "owner";
1338 case SortByGroup: return "group";
1339 case SortByType: return "type";
1340 case SortByDestination: return "destination";
1341 case SortByPath: return "path";
1342 default: break;
1343 }
1344
1345 return QByteArray();
1346 }
1347
1348 DolphinView::Sorting DolphinView::sortingForSortRole(const QByteArray& sortRole) const
1349 {
1350 static QHash<QByteArray, DolphinView::Sorting> sortHash;
1351 if (sortHash.isEmpty()) {
1352 sortHash.insert("name", SortByName);
1353 sortHash.insert("size", SortBySize);
1354 sortHash.insert("date", SortByDate);
1355 sortHash.insert("permissions", SortByPermissions);
1356 sortHash.insert("owner", SortByOwner);
1357 sortHash.insert("group", SortByGroup);
1358 sortHash.insert("type", SortByType);
1359 sortHash.insert("destination", SortByDestination);
1360 sortHash.insert("path", SortByPath);
1361 }
1362 return sortHash.value(sortRole);
1363 }
1364
1365 void DolphinView::markUrlAsCurrent(const KUrl& url)
1366 {
1367 m_currentItemUrl = url;
1368 }
1369
1370 #include "dolphinview.moc"