]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinview.cpp
Sort the items in DolphinView::selectedItems()
[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 QList<int> sortedIndexes = selectedIndexes.toList();
343 qSort(sortedIndexes);
344
345 KFileItemList selectedItems;
346 QSetIterator<int> it(selectedIndexes);
347 while (it.hasNext()) {
348 const int index = it.next();
349 selectedItems.append(model->fileItem(index));
350 }
351 return selectedItems;
352 }
353
354 int DolphinView::selectedItemsCount() const
355 {
356 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
357 return selectionManager->selectedItems().count();
358 }
359
360 void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
361 {
362 m_selectedUrls = urls;
363 }
364
365 void DolphinView::setItemSelectionEnabled(const QRegExp& pattern, bool enabled)
366 {
367 const KItemListSelectionManager::SelectionMode mode = enabled
368 ? KItemListSelectionManager::Select
369 : KItemListSelectionManager::Deselect;
370 const KFileItemModel* model = fileItemModel();
371 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
372
373 for (int index = 0; index < model->count(); index++) {
374 const KFileItem item = model->fileItem(index);
375 if (pattern.exactMatch(item.name())) {
376 // An alternative approach would be to store the matching items in a QSet<int> and
377 // select them in one go after the loop, but we'd need a new function
378 // KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode)
379 // for that.
380 selectionManager->setSelected(index, 1, mode);
381 }
382 }
383 }
384
385 void DolphinView::setZoomLevel(int level)
386 {
387 const int oldZoomLevel = zoomLevel();
388 m_container->setZoomLevel(level);
389 if (zoomLevel() != oldZoomLevel) {
390 emit zoomLevelChanged(zoomLevel(), oldZoomLevel);
391 }
392 }
393
394 int DolphinView::zoomLevel() const
395 {
396 return m_container->zoomLevel();
397 }
398
399 void DolphinView::setSorting(Sorting sorting)
400 {
401 if (sorting != this->sorting()) {
402 updateSorting(sorting);
403 }
404 }
405
406 DolphinView::Sorting DolphinView::sorting() const
407 {
408 KItemModelBase* model = m_container->controller()->model();
409 return sortingForSortRole(model->sortRole());
410 }
411
412 void DolphinView::setSortOrder(Qt::SortOrder order)
413 {
414 if (sortOrder() != order) {
415 updateSortOrder(order);
416 }
417 }
418
419 Qt::SortOrder DolphinView::sortOrder() const
420 {
421 KItemModelBase* model = fileItemModel();
422 return model->sortOrder();
423 }
424
425 void DolphinView::setSortFoldersFirst(bool foldersFirst)
426 {
427 if (sortFoldersFirst() != foldersFirst) {
428 updateSortFoldersFirst(foldersFirst);
429 }
430 }
431
432 bool DolphinView::sortFoldersFirst() const
433 {
434 KFileItemModel* model = fileItemModel();
435 return model->sortFoldersFirst();
436 }
437
438 void DolphinView::setAdditionalInfoList(const QList<AdditionalInfo>& info)
439 {
440 const QList<AdditionalInfo> previousList = info;
441
442 ViewProperties props(url());
443 props.setAdditionalInfoList(info);
444
445 m_additionalInfoList = info;
446 applyAdditionalInfoListToView();
447
448 emit additionalInfoListChanged(m_additionalInfoList, previousList);
449 }
450
451 QList<DolphinView::AdditionalInfo> DolphinView::additionalInfoList() const
452 {
453 return m_additionalInfoList;
454 }
455
456 void DolphinView::reload()
457 {
458 QByteArray viewState;
459 QDataStream saveStream(&viewState, QIODevice::WriteOnly);
460 saveState(saveStream);
461
462 const KFileItemList itemList = selectedItems();
463 m_selectedUrls.clear();
464 m_selectedUrls = itemList.urlList();
465
466 setUrl(url());
467 loadDirectory(url(), true);
468
469 QDataStream restoreStream(viewState);
470 restoreState(restoreStream);
471 }
472
473 void DolphinView::stopLoading()
474 {
475 m_dirLister->stop();
476 }
477
478 void DolphinView::refresh()
479 {
480 const bool oldActivationState = m_active;
481 const int oldZoomLevel = zoomLevel();
482 m_active = true;
483
484 applyViewProperties();
485 reload();
486
487 setActive(oldActivationState);
488 updateZoomLevel(oldZoomLevel);
489 }
490
491 void DolphinView::setNameFilter(const QString& nameFilter)
492 {
493 Q_UNUSED(nameFilter);
494 //m_viewModeController->setNameFilter(nameFilter);
495 }
496
497 QString DolphinView::nameFilter() const
498 {
499 return QString(); //m_viewModeController->nameFilter();
500 }
501
502 void DolphinView::calculateItemCount(int& fileCount,
503 int& folderCount,
504 KIO::filesize_t& totalFileSize) const
505 {
506 foreach (const KFileItem& item, m_dirLister->items()) {
507 if (item.isDir()) {
508 ++folderCount;
509 } else {
510 ++fileCount;
511 totalFileSize += item.size();
512 }
513 }
514 }
515
516 QString DolphinView::statusBarText() const
517 {
518 QString text;
519 int folderCount = 0;
520 int fileCount = 0;
521 KIO::filesize_t totalFileSize = 0;
522
523 if (hasSelection()) {
524 // give a summary of the status of the selected files
525 const KFileItemList list = selectedItems();
526 if (list.isEmpty()) {
527 // when an item is triggered, it is temporary selected but selectedItems()
528 // will return an empty list
529 return text;
530 }
531
532 KFileItemList::const_iterator it = list.begin();
533 const KFileItemList::const_iterator end = list.end();
534 while (it != end) {
535 const KFileItem& item = *it;
536 if (item.isDir()) {
537 ++folderCount;
538 } else {
539 ++fileCount;
540 totalFileSize += item.size();
541 }
542 ++it;
543 }
544
545 if (folderCount + fileCount == 1) {
546 // if only one item is selected, show the filename
547 const QString name = list.first().text();
548 text = (folderCount == 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name) :
549 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
550 name, KIO::convertSize(totalFileSize));
551 } else {
552 // at least 2 items are selected
553 const QString foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
554 const QString filesText = i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount);
555 if ((folderCount > 0) && (fileCount > 0)) {
556 text = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
557 foldersText, filesText, KIO::convertSize(totalFileSize));
558 } else if (fileCount > 0) {
559 text = i18nc("@info:status files (size)", "%1 (%2)", filesText, KIO::convertSize(totalFileSize));
560 } else {
561 Q_ASSERT(folderCount > 0);
562 text = foldersText;
563 }
564 }
565 } else {
566 calculateItemCount(fileCount, folderCount, totalFileSize);
567 text = KIO::itemsSummaryString(fileCount + folderCount,
568 fileCount, folderCount,
569 totalFileSize, true);
570 }
571
572 return text;
573 }
574
575 QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
576 {
577 QList<QAction*> actions;
578
579 if (items.isEmpty()) {
580 const KFileItem item = fileItemModel()->rootItem();
581 actions = m_versionControlObserver->actions(KFileItemList() << item);
582 } else {
583 actions = m_versionControlObserver->actions(items);
584 }
585
586 return actions;
587 }
588
589 void DolphinView::setUrl(const KUrl& url)
590 {
591 if (url == m_url) {
592 return;
593 }
594
595 emit urlAboutToBeChanged(url);
596 m_url = url;
597
598 if (GeneralSettings::showToolTips()) {
599 m_toolTipManager->hideToolTip();
600 }
601
602 // It is important to clear the items from the model before
603 // applying the view properties, otherwise expensive operations
604 // might be done on the existing items although they get cleared
605 // anyhow afterwards by loadDirectory().
606 fileItemModel()->clear();
607 applyViewProperties();
608 loadDirectory(url);
609
610 emit urlChanged(url);
611 }
612
613 void DolphinView::selectAll()
614 {
615 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
616 selectionManager->setSelected(0, fileItemModel()->count());
617 }
618
619 void DolphinView::invertSelection()
620 {
621 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
622 selectionManager->setSelected(0, fileItemModel()->count(), KItemListSelectionManager::Toggle);
623 }
624
625 void DolphinView::clearSelection()
626 {
627 m_container->controller()->selectionManager()->clearSelection();
628 }
629
630 void DolphinView::renameSelectedItems()
631 {
632 KFileItemList items = selectedItems();
633 const int itemCount = items.count();
634 if (itemCount < 1) {
635 return;
636 }
637
638 /*if ((itemCount == 1) && DolphinSettings::instance().generalSettings()->renameInline()) {
639 const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForItem(items.first());
640 const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
641 m_viewAccessor.itemView()->edit(proxyIndex);
642 } else {*/
643 RenameDialog* dialog = new RenameDialog(this, items);
644 dialog->setAttribute(Qt::WA_DeleteOnClose);
645 dialog->show();
646 dialog->raise();
647 dialog->activateWindow();
648 //}
649
650 // assure that the current index remains visible when KDirLister
651 // will notify the view about changed items
652 m_assureVisibleCurrentIndex = true;
653 }
654
655 void DolphinView::trashSelectedItems()
656 {
657 const KUrl::List list = simplifiedSelectedUrls();
658 KonqOperations::del(this, KonqOperations::TRASH, list);
659 }
660
661 void DolphinView::deleteSelectedItems()
662 {
663 const KUrl::List list = simplifiedSelectedUrls();
664 const bool del = KonqOperations::askDeleteConfirmation(list,
665 KonqOperations::DEL,
666 KonqOperations::DEFAULT_CONFIRMATION,
667 this);
668
669 if (del) {
670 KIO::Job* job = KIO::del(list);
671 connect(job, SIGNAL(result(KJob*)),
672 this, SLOT(slotDeleteFileFinished(KJob*)));
673 }
674 }
675
676 void DolphinView::cutSelectedItems()
677 {
678 QMimeData* mimeData = selectionMimeData();
679 KonqMimeData::addIsCutSelection(mimeData, true);
680 QApplication::clipboard()->setMimeData(mimeData);
681 }
682
683 void DolphinView::copySelectedItems()
684 {
685 QMimeData* mimeData = selectionMimeData();
686 QApplication::clipboard()->setMimeData(mimeData);
687 }
688
689 void DolphinView::paste()
690 {
691 pasteToUrl(url());
692 }
693
694 void DolphinView::pasteIntoFolder()
695 {
696 const KFileItemList items = selectedItems();
697 if ((items.count() == 1) && items.first().isDir()) {
698 pasteToUrl(items.first().url());
699 }
700 }
701
702 bool DolphinView::eventFilter(QObject* watched, QEvent* event)
703 {
704 switch (event->type()) {
705 case QEvent::FocusIn:
706 if (watched == m_container) {
707 setActive(true);
708 }
709 break;
710
711 default:
712 break;
713 }
714
715 return QWidget::eventFilter(watched, event);
716 }
717
718 void DolphinView::wheelEvent(QWheelEvent* event)
719 {
720 if (event->modifiers().testFlag(Qt::ControlModifier)) {
721 const int numDegrees = event->delta() / 8;
722 const int numSteps = numDegrees / 15;
723
724 setZoomLevel(zoomLevel() + numSteps);
725 event->accept();
726 } else {
727 event->ignore();
728 }
729 }
730
731 void DolphinView::activate()
732 {
733 setActive(true);
734 }
735
736 void DolphinView::slotItemActivated(int index)
737 {
738 Q_UNUSED(index);
739
740 const KFileItemList items = selectedItems();
741 if (items.isEmpty()) {
742 return;
743 }
744
745 if (items.count() == 1) {
746 emit itemActivated(items.at(0)); // caught by DolphinViewContainer or DolphinPart
747 } else {
748 foreach (const KFileItem& item, items) {
749 if (item.isDir()) {
750 emit tabRequested(item.url());
751 } else {
752 emit itemActivated(item);
753 }
754 }
755 }
756 }
757
758 void DolphinView::slotItemMiddleClicked(int index)
759 {
760 const KFileItem item = fileItemModel()->fileItem(index);
761 if (item.isDir() || isTabsForFilesEnabled()) {
762 emit tabRequested(item.url());
763 }
764 }
765
766 void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos)
767 {
768 if (GeneralSettings::showToolTips()) {
769 m_toolTipManager->hideToolTip();
770 }
771 const KFileItem item = fileItemModel()->fileItem(index);
772 emit requestContextMenu(pos.toPoint(), item, url(), QList<QAction*>());
773 }
774
775 void DolphinView::slotViewContextMenuRequested(const QPointF& pos)
776 {
777 if (GeneralSettings::showToolTips()) {
778 m_toolTipManager->hideToolTip();
779 }
780 emit requestContextMenu(pos.toPoint(), KFileItem(), url(), QList<QAction*>());
781 }
782
783 void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
784 {
785 QWeakPointer<KMenu> menu = new KMenu(QApplication::activeWindow());
786
787 KItemListView* view = m_container->controller()->view();
788 const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
789
790 // Add all roles to the menu that can be shown or hidden by the user
791 const AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
792 const QList<DolphinView::AdditionalInfo> keys = infoAccessor.keys();
793 foreach (const DolphinView::AdditionalInfo info, keys) {
794 const QByteArray& role = infoAccessor.role(info);
795 if (role != "name") {
796 const QString text = fileItemModel()->roleDescription(role);
797
798 QAction* action = menu.data()->addAction(text);
799 action->setCheckable(true);
800 action->setChecked(visibleRolesSet.contains(role));
801 action->setData(info);
802 }
803 }
804
805 QAction* action = menu.data()->exec(pos.toPoint());
806 if (action) {
807 // Show or hide the selected role
808 const DolphinView::AdditionalInfo info =
809 static_cast<DolphinView::AdditionalInfo>(action->data().toInt());
810
811 ViewProperties props(url());
812 QList<DolphinView::AdditionalInfo> infoList = props.additionalInfoList();
813
814 const QByteArray selectedRole = infoAccessor.role(info);
815 QList<QByteArray> visibleRoles = view->visibleRoles();
816
817 if (action->isChecked()) {
818 const int index = keys.indexOf(info) + 1;
819 visibleRoles.insert(index, selectedRole);
820 infoList.insert(index, info);
821 } else {
822 visibleRoles.removeOne(selectedRole);
823 infoList.removeOne(info);
824 }
825
826 view->setVisibleRoles(visibleRoles);
827 props.setAdditionalInfoList(infoList);
828 }
829
830 delete menu.data();
831 }
832
833 void DolphinView::slotItemExpansionToggleClicked(int index)
834 {
835 // TODO: When doing a model->setExpanded(false) it should
836 // be checked here whether the current index is part of the
837 // closed sub-tree. If this is the case, the current index
838 // should be adjusted to the parent index.
839 KFileItemModel* model = fileItemModel();
840 const bool expanded = model->isExpanded(index);
841 model->setExpanded(index, !expanded);
842 }
843
844 void DolphinView::slotItemHovered(int index)
845 {
846 const KFileItem item = fileItemModel()->fileItem(index);
847
848 if (GeneralSettings::showToolTips()) {
849 QRectF itemRect = m_container->controller()->view()->itemBoundingRect(index);
850 const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint());
851 itemRect.moveTo(pos);
852
853 m_toolTipManager->showToolTip(item, itemRect);
854 }
855
856 emit requestItemInfo(item);
857 }
858
859 void DolphinView::slotItemUnhovered(int index)
860 {
861 Q_UNUSED(index);
862 if (GeneralSettings::showToolTips()) {
863 m_toolTipManager->hideToolTip();
864 }
865 emit requestItemInfo(KFileItem());
866 }
867
868 void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
869 {
870 const KFileItem destItem = fileItemModel()->fileItem(index);
871
872 QDropEvent dropEvent(event->pos().toPoint(),
873 event->possibleActions(),
874 event->mimeData(),
875 event->buttons(),
876 event->modifiers());
877
878 DragAndDropHelper::dropUrls(destItem, url(), &dropEvent, this);
879 }
880
881 void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
882 {
883 if (previous != 0) {
884 disconnect(previous, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
885 }
886
887 Q_ASSERT(qobject_cast<KFileItemModel*>(current));
888 connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
889
890 KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current);
891 m_versionControlObserver->setModel(fileItemModel);
892 }
893
894 void DolphinView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
895 {
896 const int currentCount = current.count();
897 const int previousCount = previous.count();
898 const bool selectionStateChanged = (currentCount == 0 && previousCount > 0) ||
899 (currentCount > 0 && previousCount == 0);
900
901 // If nothing has been selected before and something got selected (or if something
902 // was selected before and now nothing is selected) the selectionChangedSignal must
903 // be emitted asynchronously as fast as possible to update the edit-actions.
904 m_selectionChangedTimer->setInterval(selectionStateChanged ? 0 : 300);
905 m_selectionChangedTimer->start();
906 }
907
908 void DolphinView::emitSelectionChangedSignal()
909 {
910 m_selectionChangedTimer->stop();
911 emit selectionChanged(selectedItems());
912 }
913
914 void DolphinView::dropUrls(const KFileItem& destItem,
915 const KUrl& destPath,
916 QDropEvent* event)
917 {
918 Q_UNUSED(destItem);
919 Q_UNUSED(destPath);
920 markPastedUrlsAsSelected(event->mimeData());
921 //DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
922 }
923
924 void DolphinView::updateSorting(DolphinView::Sorting sorting)
925 {
926 ViewProperties props(url());
927 props.setSorting(sorting);
928
929 KItemModelBase* model = m_container->controller()->model();
930 model->setSortRole(sortRoleForSorting(sorting));
931
932 emit sortingChanged(sorting);
933 }
934
935 void DolphinView::updateSortOrder(Qt::SortOrder order)
936 {
937 ViewProperties props(url());
938 props.setSortOrder(order);
939
940 KItemModelBase* model = fileItemModel();
941 model->setSortOrder(order);
942
943 emit sortOrderChanged(order);
944 }
945
946 void DolphinView::updateSortFoldersFirst(bool foldersFirst)
947 {
948 ViewProperties props(url());
949 props.setSortFoldersFirst(foldersFirst);
950
951 KFileItemModel* model = fileItemModel();
952 model->setSortFoldersFirst(foldersFirst);
953
954 emit sortFoldersFirstChanged(foldersFirst);
955 }
956
957 QPair<bool, QString> DolphinView::pasteInfo() const
958 {
959 return KonqOperations::pasteInfo(url());
960 }
961
962 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
963 {
964 m_tabsForFiles = tabsForFiles;
965 }
966
967 bool DolphinView::isTabsForFilesEnabled() const
968 {
969 return m_tabsForFiles;
970 }
971
972 bool DolphinView::itemsExpandable() const
973 {
974 return m_mode == DetailsView;
975 }
976
977 void DolphinView::restoreState(QDataStream& stream)
978 {
979 // Restore the current item that had the keyboard focus
980 stream >> m_currentItemUrl;
981
982 // Restore the view position
983 stream >> m_restoredContentsPosition;
984
985 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
986 QSet<KUrl> urls;
987 stream >> urls;
988 fileItemModel()->restoreExpandedUrls(urls);
989 }
990
991 void DolphinView::saveState(QDataStream& stream)
992 {
993 // Save the current item that has the keyboard focus
994 const int currentIndex = m_container->controller()->selectionManager()->currentItem();
995 if (currentIndex != -1) {
996 KFileItem item = fileItemModel()->fileItem(currentIndex);
997 KUrl currentItemUrl = item.url();
998 stream << currentItemUrl;
999 } else {
1000 stream << KUrl();
1001 }
1002
1003 // Save view position
1004 const qreal x = m_container->horizontalScrollBar()->value();
1005 const qreal y = m_container->verticalScrollBar()->value();
1006 stream << QPoint(x, y);
1007
1008 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
1009 stream << fileItemModel()->expandedUrls();
1010 }
1011
1012 bool DolphinView::hasSelection() const
1013 {
1014 return m_container->controller()->selectionManager()->hasSelection();
1015 }
1016
1017 KFileItem DolphinView::rootItem() const
1018 {
1019 return m_dirLister->rootItem();
1020 }
1021
1022 void DolphinView::observeCreatedItem(const KUrl& url)
1023 {
1024 m_createdItemUrl = url;
1025 //connect(m_dirModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
1026 // this, SLOT(selectAndScrollToCreatedItem()));
1027 }
1028
1029 void DolphinView::selectAndScrollToCreatedItem()
1030 {
1031 /*const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_createdItemUrl);
1032 if (dirIndex.isValid()) {
1033 const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
1034 QAbstractItemView* view = m_viewAccessor.itemView();
1035 if (view) {
1036 view->setCurrentIndex(proxyIndex);
1037 }
1038 }
1039
1040 disconnect(m_viewAccessor.dirModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
1041 this, SLOT(selectAndScrollToCreatedItem()));*/
1042 m_createdItemUrl = KUrl();
1043 }
1044
1045 void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
1046 {
1047 if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
1048 emit redirection(oldUrl, newUrl);
1049 m_url = newUrl; // #186947
1050 }
1051 }
1052
1053 void DolphinView::updateViewState()
1054 {
1055 if (m_currentItemUrl != KUrl()) {
1056 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1057 const int currentIndex = fileItemModel()->index(m_currentItemUrl);
1058 if (currentIndex != -1) {
1059 selectionManager->setCurrentItem(currentIndex);
1060 } else {
1061 selectionManager->setCurrentItem(0);
1062 }
1063 m_currentItemUrl = KUrl();
1064 }
1065
1066 if (!m_restoredContentsPosition.isNull()) {
1067 const int x = m_restoredContentsPosition.x();
1068 const int y = m_restoredContentsPosition.y();
1069 m_restoredContentsPosition = QPoint();
1070
1071 m_container->horizontalScrollBar()->setValue(x);
1072 m_container->verticalScrollBar()->setValue(y);
1073 }
1074
1075 if (!m_selectedUrls.isEmpty()) {
1076 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1077 QSet<int> selectedItems = selectionManager->selectedItems();
1078 const KFileItemModel* model = fileItemModel();
1079
1080 foreach (const KUrl& url, m_selectedUrls) {
1081 const int index = model->index(url);
1082 if (index >= 0) {
1083 selectedItems.insert(index);
1084 }
1085 }
1086
1087 selectionManager->setSelectedItems(selectedItems);
1088 m_selectedUrls.clear();
1089 }
1090 }
1091
1092 void DolphinView::showHoverInformation(const KFileItem& item)
1093 {
1094 emit requestItemInfo(item);
1095 }
1096
1097 void DolphinView::clearHoverInformation()
1098 {
1099 emit requestItemInfo(KFileItem());
1100 }
1101
1102 void DolphinView::slotDeleteFileFinished(KJob* job)
1103 {
1104 if (job->error() == 0) {
1105 emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1106 } else if (job->error() != KIO::ERR_USER_CANCELED) {
1107 emit errorMessage(job->errorString());
1108 }
1109 }
1110
1111 void DolphinView::slotDirListerStarted(const KUrl& url)
1112 {
1113 // Disable the writestate temporary until it can be determined in a fast way
1114 // in DolphinView::slotLoadingCompleted()
1115 if (m_isFolderWritable) {
1116 m_isFolderWritable = false;
1117 emit writeStateChanged(m_isFolderWritable);
1118 }
1119
1120 emit startedPathLoading(url);
1121 }
1122
1123 void DolphinView::slotLoadingCompleted()
1124 {
1125 // Update the view-state. This has to be done using a Qt::QueuedConnection
1126 // because the view might not be in its final state yet (the view also
1127 // listens to the completed()-signal from KDirLister and the order of
1128 // of slots is undefined).
1129 QTimer::singleShot(0, this, SLOT(updateViewState()));
1130
1131 emit finishedPathLoading(url());
1132
1133 updateWritableState();
1134 }
1135
1136 void DolphinView::slotRefreshItems()
1137 {
1138 if (m_assureVisibleCurrentIndex) {
1139 m_assureVisibleCurrentIndex = false;
1140 //QAbstractItemView* view = m_viewAccessor.itemView();
1141 //if (view) {
1142 // m_viewAccessor.itemView()->scrollTo(m_viewAccessor.itemView()->currentIndex());
1143 //}
1144 }
1145 }
1146
1147 KFileItemModel* DolphinView::fileItemModel() const
1148 {
1149 return static_cast<KFileItemModel*>(m_container->controller()->model());
1150 }
1151
1152 void DolphinView::loadDirectory(const KUrl& url, bool reload)
1153 {
1154 if (!url.isValid()) {
1155 const QString location(url.pathOrUrl());
1156 if (location.isEmpty()) {
1157 emit errorMessage(i18nc("@info:status", "The location is empty."));
1158 } else {
1159 emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
1160 }
1161 return;
1162 }
1163
1164 m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
1165 }
1166
1167 void DolphinView::applyViewProperties()
1168 {
1169 m_container->beginTransaction();
1170
1171 const ViewProperties props(url());
1172
1173 const Mode mode = props.viewMode();
1174 if (m_mode != mode) {
1175 const Mode previousMode = m_mode;
1176 m_mode = mode;
1177
1178 // Changing the mode might result in changing
1179 // the zoom level. Remember the old zoom level so
1180 // that zoomLevelChanged() can get emitted.
1181 const int oldZoomLevel = m_container->zoomLevel();
1182
1183 switch (m_mode) {
1184 case IconsView: m_container->setItemLayout(KFileItemListView::IconsLayout); break;
1185 case CompactView: m_container->setItemLayout(KFileItemListView::CompactLayout); break;
1186 case DetailsView: m_container->setItemLayout(KFileItemListView::DetailsLayout); break;
1187 default: Q_ASSERT(false); break;
1188 }
1189
1190 emit modeChanged(m_mode, previousMode);
1191
1192 if (m_container->zoomLevel() != oldZoomLevel) {
1193 emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel);
1194 }
1195 }
1196
1197 const bool hiddenFilesShown = props.hiddenFilesShown();
1198 if (hiddenFilesShown != m_dirLister->showingDotFiles()) {
1199 m_dirLister->setShowingDotFiles(hiddenFilesShown);
1200 m_dirLister->emitChanges();
1201 emit hiddenFilesShownChanged(hiddenFilesShown);
1202 }
1203
1204 KFileItemModel* model = fileItemModel();
1205
1206 const bool groupedSorting = props.groupedSorting();
1207 if (groupedSorting != model->groupedSorting()) {
1208 model->setGroupedSorting(groupedSorting);
1209 emit groupedSortingChanged(groupedSorting);
1210 }
1211
1212 const DolphinView::Sorting sorting = props.sorting();
1213 const QByteArray newSortRole = sortRoleForSorting(sorting);
1214 if (newSortRole != model->sortRole()) {
1215 model->setSortRole(newSortRole);
1216 emit sortingChanged(sorting);
1217 }
1218
1219 const Qt::SortOrder sortOrder = props.sortOrder();
1220 if (sortOrder != model->sortOrder()) {
1221 model->setSortOrder(sortOrder);
1222 emit sortOrderChanged(sortOrder);
1223 }
1224
1225 const bool sortFoldersFirst = props.sortFoldersFirst();
1226 if (sortFoldersFirst != model->sortFoldersFirst()) {
1227 model->setSortFoldersFirst(sortFoldersFirst);
1228 emit sortFoldersFirstChanged(sortFoldersFirst);
1229 }
1230
1231 const QList<DolphinView::AdditionalInfo> infoList = props.additionalInfoList();
1232 if (infoList != m_additionalInfoList) {
1233 const QList<DolphinView::AdditionalInfo> previousList = m_additionalInfoList;
1234 m_additionalInfoList = infoList;
1235 applyAdditionalInfoListToView();
1236 emit additionalInfoListChanged(m_additionalInfoList, previousList);
1237 }
1238
1239 const bool previewsShown = props.previewsShown();
1240 if (previewsShown != m_container->previewsShown()) {
1241 const int oldZoomLevel = zoomLevel();
1242
1243 m_container->setPreviewsShown(previewsShown);
1244 emit previewsShownChanged(previewsShown);
1245
1246 // Changing the preview-state might result in a changed zoom-level
1247 if (oldZoomLevel != zoomLevel()) {
1248 emit zoomLevelChanged(zoomLevel(), oldZoomLevel);
1249 }
1250 }
1251
1252 m_container->endTransaction();
1253 }
1254
1255 void DolphinView::applyAdditionalInfoListToView()
1256 {
1257 const AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
1258
1259 QList<QByteArray> visibleRoles;
1260 visibleRoles.reserve(m_additionalInfoList.count() + 1);
1261 visibleRoles.append("name");
1262
1263 foreach (AdditionalInfo info, m_additionalInfoList) {
1264 visibleRoles.append(infoAccessor.role(info));
1265 }
1266
1267 m_container->setVisibleRoles(visibleRoles);
1268 }
1269
1270 void DolphinView::pasteToUrl(const KUrl& url)
1271 {
1272 markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
1273 KonqOperations::doPaste(this, url);
1274 }
1275
1276 void DolphinView::updateZoomLevel(int oldZoomLevel)
1277 {
1278 Q_UNUSED(oldZoomLevel);
1279 /* const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor.itemView()->iconSize());
1280 if (oldZoomLevel != newZoomLevel) {
1281 m_viewModeController->setZoomLevel(newZoomLevel);
1282 emit zoomLevelChanged(newZoomLevel);
1283 }*/
1284 }
1285
1286 KUrl::List DolphinView::simplifiedSelectedUrls() const
1287 {
1288 KUrl::List urls;
1289
1290 const KFileItemList items = selectedItems();
1291 foreach (const KFileItem &item, items) {
1292 urls.append(item.url());
1293 }
1294
1295 if (itemsExpandable()) {
1296 // TODO: Check if we still need KDirModel for this in KDE 5.0
1297 urls = KDirModel::simplifiedUrlList(urls);
1298 }
1299
1300 return urls;
1301 }
1302
1303 QMimeData* DolphinView::selectionMimeData() const
1304 {
1305 const KFileItemModel* model = fileItemModel();
1306 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1307 const QSet<int> selectedIndexes = selectionManager->selectedItems();
1308
1309 return model->createMimeData(selectedIndexes);
1310 }
1311
1312 void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
1313 {
1314 const KUrl::List urls = KUrl::List::fromMimeData(mimeData);
1315 markUrlsAsSelected(urls);
1316 }
1317
1318 void DolphinView::updateWritableState()
1319 {
1320 const bool wasFolderWritable = m_isFolderWritable;
1321 m_isFolderWritable = true;
1322
1323 const KFileItem item = m_dirLister->rootItem();
1324 if (!item.isNull()) {
1325 KFileItemListProperties capabilities(KFileItemList() << item);
1326 m_isFolderWritable = capabilities.supportsWriting();
1327 }
1328 if (m_isFolderWritable != wasFolderWritable) {
1329 emit writeStateChanged(m_isFolderWritable);
1330 }
1331 }
1332
1333 QByteArray DolphinView::sortRoleForSorting(Sorting sorting) const
1334 {
1335 switch (sorting) {
1336 case SortByName: return "name";
1337 case SortBySize: return "size";
1338 case SortByDate: return "date";
1339 case SortByPermissions: return "permissions";
1340 case SortByOwner: return "owner";
1341 case SortByGroup: return "group";
1342 case SortByType: return "type";
1343 case SortByDestination: return "destination";
1344 case SortByPath: return "path";
1345 default: break;
1346 }
1347
1348 return QByteArray();
1349 }
1350
1351 DolphinView::Sorting DolphinView::sortingForSortRole(const QByteArray& sortRole) const
1352 {
1353 static QHash<QByteArray, DolphinView::Sorting> sortHash;
1354 if (sortHash.isEmpty()) {
1355 sortHash.insert("name", SortByName);
1356 sortHash.insert("size", SortBySize);
1357 sortHash.insert("date", SortByDate);
1358 sortHash.insert("permissions", SortByPermissions);
1359 sortHash.insert("owner", SortByOwner);
1360 sortHash.insert("group", SortByGroup);
1361 sortHash.insert("type", SortByType);
1362 sortHash.insert("destination", SortByDestination);
1363 sortHash.insert("path", SortByPath);
1364 }
1365 return sortHash.value(sortRole);
1366 }
1367
1368 void DolphinView::markUrlAsCurrent(const KUrl& url)
1369 {
1370 m_currentItemUrl = url;
1371 }
1372
1373 #include "dolphinview.moc"