]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinview.cpp
Group classes into folders, Dolphin is too big in the meantime for having a flat...
[dolphin.git] / src / dolphinview.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
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 <QApplication>
24 #include <QClipboard>
25 #include <QKeyEvent>
26 #include <QItemSelection>
27 #include <QBoxLayout>
28 #include <QTimer>
29 #include <QScrollBar>
30
31 #include <kactioncollection.h>
32 #include <kcolorscheme.h>
33 #include <kdirlister.h>
34 #include <kfilepreviewgenerator.h>
35 #include <kiconeffect.h>
36 #include <kfileitem.h>
37 #include <klocale.h>
38 #include <kio/deletejob.h>
39 #include <kio/netaccess.h>
40 #include <kio/previewjob.h>
41 #include <kjob.h>
42 #include <kmenu.h>
43 #include <kmessagebox.h>
44 #include <kmimetyperesolver.h>
45 #include <konq_fileitemcapabilities.h>
46 #include <konq_operations.h>
47 #include <konqmimedata.h>
48 #include <kstringhandler.h>
49 #include <ktoggleaction.h>
50 #include <kurl.h>
51
52 #include "dolphinmodel.h"
53 #include "dolphincolumnview.h"
54 #include "dolphincontroller.h"
55 #include "dolphinfileitemdelegate.h"
56 #include "dolphinsortfilterproxymodel.h"
57 #include "dolphindetailsview.h"
58 #include "dolphin_detailsmodesettings.h"
59 #include "dolphiniconsview.h"
60 #include "settings/dolphinsettings.h"
61 #include "dolphin_generalsettings.h"
62 #include "draganddrophelper.h"
63 #include "folderexpander.h"
64 #include "renamedialog.h"
65 #include "tooltips/tooltipmanager.h"
66 #include "viewproperties.h"
67 #include "zoomlevelinfo.h"
68
69 /**
70 * Helper function for sorting items with qSort() in
71 * DolphinView::renameSelectedItems().
72 */
73 bool lessThan(const KFileItem& item1, const KFileItem& item2)
74 {
75 return KStringHandler::naturalCompare(item1.name(), item2.name()) < 0;
76 }
77
78 DolphinView::DolphinView(QWidget* parent,
79 const KUrl& url,
80 KDirLister* dirLister,
81 DolphinModel* dolphinModel,
82 DolphinSortFilterProxyModel* proxyModel) :
83 QWidget(parent),
84 m_active(true),
85 m_showPreview(false),
86 m_loadingDirectory(false),
87 m_storedCategorizedSorting(false),
88 m_tabsForFiles(false),
89 m_isContextMenuOpen(false),
90 m_ignoreViewProperties(false),
91 m_mode(DolphinView::IconsView),
92 m_topLayout(0),
93 m_controller(0),
94 m_iconsView(0),
95 m_detailsView(0),
96 m_columnView(0),
97 m_fileItemDelegate(0),
98 m_selectionModel(0),
99 m_dolphinModel(dolphinModel),
100 m_dirLister(dirLister),
101 m_proxyModel(proxyModel),
102 m_previewGenerator(0),
103 m_toolTipManager(0),
104 m_rootUrl(),
105 m_currentItemUrl(),
106 m_expandedViews()
107 {
108 m_topLayout = new QVBoxLayout(this);
109 m_topLayout->setSpacing(0);
110 m_topLayout->setMargin(0);
111
112 m_controller = new DolphinController(this);
113 m_controller->setUrl(url);
114
115 connect(m_controller, SIGNAL(urlChanged(const KUrl&)),
116 this, SIGNAL(urlChanged(const KUrl&)));
117 connect(m_controller, SIGNAL(requestUrlChange(const KUrl&)),
118 this, SLOT(slotRequestUrlChange(const KUrl&)));
119
120 connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
121 this, SLOT(openContextMenu(const QPoint&)));
122 connect(m_controller, SIGNAL(urlsDropped(const KFileItem&, const KUrl&, QDropEvent*)),
123 this, SLOT(dropUrls(const KFileItem&, const KUrl&, QDropEvent*)));
124 connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
125 this, SLOT(updateSorting(DolphinView::Sorting)));
126 connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
127 this, SLOT(updateSortOrder(Qt::SortOrder)));
128 connect(m_controller, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
129 this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList&)));
130 connect(m_controller, SIGNAL(itemTriggered(const KFileItem&)),
131 this, SLOT(triggerItem(const KFileItem&)));
132 connect(m_controller, SIGNAL(tabRequested(const KUrl&)),
133 this, SIGNAL(tabRequested(const KUrl&)));
134 connect(m_controller, SIGNAL(activated()),
135 this, SLOT(activate()));
136 connect(m_controller, SIGNAL(itemEntered(const KFileItem&)),
137 this, SLOT(showHoverInformation(const KFileItem&)));
138 connect(m_controller, SIGNAL(viewportEntered()),
139 this, SLOT(clearHoverInformation()));
140
141 connect(m_dirLister, SIGNAL(redirection(KUrl, KUrl)),
142 this, SIGNAL(redirection(KUrl, KUrl)));
143 connect(m_dirLister, SIGNAL(completed()),
144 this, SLOT(restoreCurrentItem()));
145
146 applyViewProperties(url);
147 m_topLayout->addWidget(itemView());
148 }
149
150 DolphinView::~DolphinView()
151 {
152 deleteExpandedViews();
153 }
154
155 const KUrl& DolphinView::url() const
156 {
157 return m_controller->url();
158 }
159
160 KUrl DolphinView::rootUrl() const
161 {
162 return isColumnViewActive() ? m_columnView->rootUrl() : url();
163 }
164
165 void DolphinView::setActive(bool active)
166 {
167 if (active == m_active) {
168 return;
169 }
170
171 m_active = active;
172
173 QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
174 if (active) {
175 // TODO: emitting urlChanged() is a hack, as the URL hasn't really changed. It
176 // bypasses the problem when having a split view and changing the active view to
177 // update the some URL dependent states. A nicer approach should be no big deal...
178 emit urlChanged(url());
179 emit selectionChanged(selectedItems());
180 } else {
181 color.setAlpha(150);
182 }
183
184 QWidget* viewport = itemView()->viewport();
185 QPalette palette;
186 palette.setColor(viewport->backgroundRole(), color);
187 viewport->setPalette(palette);
188
189 update();
190
191 if (active) {
192 itemView()->setFocus();
193 emit activated();
194 }
195
196 m_controller->indicateActivationChange(active);
197 }
198
199 bool DolphinView::isActive() const
200 {
201 return m_active;
202 }
203
204 void DolphinView::setMode(Mode mode)
205 {
206 if (mode == m_mode) {
207 return; // the wished mode is already set
208 }
209
210 const int oldZoomLevel = m_controller->zoomLevel();
211 m_mode = mode;
212
213 deleteView();
214
215 const KUrl viewPropsUrl = viewPropertiesUrl();
216 ViewProperties props(viewPropsUrl);
217 props.setViewMode(m_mode);
218 createView();
219
220 // the file item delegate has been recreated, apply the current
221 // additional information manually
222 const KFileItemDelegate::InformationList infoList = props.additionalInfo();
223 m_fileItemDelegate->setShowInformation(infoList);
224 emit additionalInfoChanged();
225
226 // Not all view modes support categorized sorting. Adjust the sorting model
227 // if changing the view mode results in a change of the categorized sorting
228 // capabilities.
229 m_storedCategorizedSorting = props.categorizedSorting();
230 const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
231 if (categorized != m_proxyModel->isCategorizedModel()) {
232 m_proxyModel->setCategorizedModel(categorized);
233 emit categorizedSortingChanged();
234 }
235
236 emit modeChanged();
237
238 updateZoomLevel(oldZoomLevel);
239 if (m_showPreview) {
240 loadDirectory(viewPropsUrl);
241 }
242 }
243
244 DolphinView::Mode DolphinView::mode() const
245 {
246 return m_mode;
247 }
248
249 bool DolphinView::showPreview() const
250 {
251 return m_showPreview;
252 }
253
254 bool DolphinView::showHiddenFiles() const
255 {
256 return m_dirLister->showingDotFiles();
257 }
258
259 bool DolphinView::categorizedSorting() const
260 {
261 // If all view modes would support categorized sorting, returning
262 // m_proxyModel->isCategorizedModel() would be the way to go. As
263 // currently only the icons view supports caterized sorting, we remember
264 // the stored view properties state in m_storedCategorizedSorting and
265 // return this state. The application takes care to disable the corresponding
266 // checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
267 // that this setting is not applied to the current view mode.
268 return m_storedCategorizedSorting;
269 }
270
271 bool DolphinView::supportsCategorizedSorting() const
272 {
273 return m_iconsView != 0;
274 }
275
276 void DolphinView::selectAll()
277 {
278 QAbstractItemView* view = itemView();
279 // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
280 // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
281 // selection instead of selecting all items. This is bypassed for KDE 4.0
282 // by invoking clearSelection() first.
283 view->clearSelection();
284 view->selectAll();
285 }
286
287 void DolphinView::invertSelection()
288 {
289 if (isColumnViewActive()) {
290 // QAbstractItemView does not offer a virtual method invertSelection()
291 // as counterpart to QAbstractItemView::selectAll(). This makes it
292 // necessary to delegate the inverting of the selection to the
293 // column view, as only the selection of the active column should
294 // get inverted.
295 m_columnView->invertSelection();
296 } else {
297 QItemSelectionModel* selectionModel = itemView()->selectionModel();
298 const QAbstractItemModel* itemModel = selectionModel->model();
299
300 const QModelIndex topLeft = itemModel->index(0, 0);
301 const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
302 itemModel->columnCount() - 1);
303
304 const QItemSelection selection(topLeft, bottomRight);
305 selectionModel->select(selection, QItemSelectionModel::Toggle);
306 }
307 }
308
309 bool DolphinView::hasSelection() const
310 {
311 return itemView()->selectionModel()->hasSelection();
312 }
313
314 void DolphinView::clearSelection()
315 {
316 itemView()->selectionModel()->clear();
317 }
318
319 KFileItemList DolphinView::selectedItems() const
320 {
321 if (isColumnViewActive()) {
322 return m_columnView->selectedItems();
323 }
324
325 const QAbstractItemView* view = itemView();
326
327 // Our view has a selection, we will map them back to the DolphinModel
328 // and then fill the KFileItemList.
329 Q_ASSERT((view != 0) && (view->selectionModel() != 0));
330
331 const QItemSelection selection = m_proxyModel->mapSelectionToSource(view->selectionModel()->selection());
332 KFileItemList itemList;
333
334 const QModelIndexList indexList = selection.indexes();
335 foreach (const QModelIndex &index, indexList) {
336 KFileItem item = m_dolphinModel->itemForIndex(index);
337 if (!item.isNull()) {
338 itemList.append(item);
339 }
340 }
341
342 return itemList;
343 }
344
345 KUrl::List DolphinView::selectedUrls() const
346 {
347 KUrl::List urls;
348 const KFileItemList list = selectedItems();
349 foreach (const KFileItem &item, list) {
350 urls.append(item.url());
351 }
352 return urls;
353 }
354
355 int DolphinView::selectedItemsCount() const
356 {
357 if (isColumnViewActive()) {
358 // TODO: get rid of this special case by adjusting the dir lister
359 // to the current column
360 return m_columnView->selectedItems().count();
361 }
362
363 return itemView()->selectionModel()->selection().count();
364 }
365
366 void DolphinView::setContentsPosition(int x, int y)
367 {
368 QAbstractItemView* view = itemView();
369
370 // the ColumnView takes care itself for the horizontal scrolling
371 if (!isColumnViewActive()) {
372 view->horizontalScrollBar()->setValue(x);
373 }
374 view->verticalScrollBar()->setValue(y);
375
376 m_loadingDirectory = false;
377 }
378
379 QPoint DolphinView::contentsPosition() const
380 {
381 const int x = itemView()->horizontalScrollBar()->value();
382 const int y = itemView()->verticalScrollBar()->value();
383 return QPoint(x, y);
384 }
385
386 void DolphinView::setZoomLevel(int level)
387 {
388 if (level < ZoomLevelInfo::minimumLevel()) {
389 level = ZoomLevelInfo::minimumLevel();
390 } else if (level > ZoomLevelInfo::maximumLevel()) {
391 level = ZoomLevelInfo::maximumLevel();
392 }
393
394 if (level != zoomLevel()) {
395 m_controller->setZoomLevel(level);
396 m_previewGenerator->updatePreviews();
397 emit zoomLevelChanged(level);
398 }
399 }
400
401 int DolphinView::zoomLevel() const
402 {
403 return m_controller->zoomLevel();
404 }
405
406 void DolphinView::setSorting(Sorting sorting)
407 {
408 if (sorting != this->sorting()) {
409 updateSorting(sorting);
410 }
411 }
412
413 DolphinView::Sorting DolphinView::sorting() const
414 {
415 return m_proxyModel->sorting();
416 }
417
418 void DolphinView::setSortOrder(Qt::SortOrder order)
419 {
420 if (sortOrder() != order) {
421 updateSortOrder(order);
422 }
423 }
424
425 Qt::SortOrder DolphinView::sortOrder() const
426 {
427 return m_proxyModel->sortOrder();
428 }
429
430 void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info)
431 {
432 const KUrl viewPropsUrl = viewPropertiesUrl();
433 ViewProperties props(viewPropsUrl);
434 props.setAdditionalInfo(info);
435 m_fileItemDelegate->setShowInformation(info);
436
437 emit additionalInfoChanged();
438
439 if (itemView() != m_detailsView) {
440 // the details view requires no reloading of the directory, as it maps
441 // the file item delegate info to its columns internally
442 loadDirectory(viewPropsUrl);
443 }
444 }
445
446 KFileItemDelegate::InformationList DolphinView::additionalInfo() const
447 {
448 return m_fileItemDelegate->showInformation();
449 }
450
451 void DolphinView::reload()
452 {
453 setUrl(url());
454 loadDirectory(url(), true);
455 }
456
457 void DolphinView::refresh()
458 {
459 m_ignoreViewProperties = false;
460
461 const bool oldActivationState = m_active;
462 const int oldZoomLevel = m_controller->zoomLevel();
463 m_active = true;
464
465 createView();
466 applyViewProperties(m_controller->url());
467 reload();
468
469 setActive(oldActivationState);
470 updateZoomLevel(oldZoomLevel);
471 }
472
473 void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
474 {
475 if (m_controller->url() == url) {
476 return;
477 }
478
479 m_previewGenerator->cancelPreviews();
480 m_controller->setUrl(url); // emits urlChanged, which we forward
481
482 if (!rootUrl.isEmpty() && rootUrl.isParentOf(url)) {
483 applyViewProperties(rootUrl);
484 loadDirectory(rootUrl);
485 if (itemView() == m_columnView) {
486 m_columnView->setRootUrl(rootUrl);
487 m_columnView->showColumn(url);
488 }
489 } else {
490 applyViewProperties(url);
491 loadDirectory(url);
492 }
493
494 emit startedPathLoading(url);
495 }
496
497 void DolphinView::setNameFilter(const QString& nameFilter)
498 {
499 m_proxyModel->setFilterRegExp(nameFilter);
500
501 if (isColumnViewActive()) {
502 // adjusting the directory lister is not enough in the case of the
503 // column view, as each column has its own directory lister internally...
504 m_columnView->setNameFilter(nameFilter);
505 }
506 }
507
508 void DolphinView::calculateItemCount(int& fileCount,
509 int& folderCount,
510 KIO::filesize_t& totalFileSize) const
511 {
512 foreach (const KFileItem& item, m_dirLister->items()) {
513 if (item.isDir()) {
514 ++folderCount;
515 } else {
516 ++fileCount;
517 totalFileSize += item.size();
518 }
519 }
520 }
521
522 QString DolphinView::statusBarText() const
523 {
524 QString text;
525 int folderCount = 0;
526 int fileCount = 0;
527 KIO::filesize_t totalFileSize = 0;
528
529 if (hasSelection()) {
530 // give a summary of the status of the selected files
531 const KFileItemList list = selectedItems();
532 if (list.isEmpty()) {
533 // when an item is triggered, it is temporary selected but selectedItems()
534 // will return an empty list
535 return text;
536 }
537
538 KFileItemList::const_iterator it = list.begin();
539 const KFileItemList::const_iterator end = list.end();
540 while (it != end) {
541 const KFileItem& item = *it;
542 if (item.isDir()) {
543 ++folderCount;
544 } else {
545 ++fileCount;
546 totalFileSize += item.size();
547 }
548 ++it;
549 }
550
551 if (folderCount + fileCount == 1) {
552 // if only one item is selected, show the filename
553 const QString name = list.first().name();
554 text = (folderCount == 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name) :
555 i18nc("@info:status", "<filename>%1</filename> selected (%2)",
556 name, KIO::convertSize(totalFileSize));
557 } else {
558 // at least 2 items are selected
559 const QString foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
560 const QString filesText = i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount);
561 if ((folderCount > 0) && (fileCount > 0)) {
562 text = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
563 foldersText, filesText, KIO::convertSize(totalFileSize));
564 } else if (fileCount > 0) {
565 text = i18nc("@info:status files (size)", "%1 (%2)", filesText, KIO::convertSize(totalFileSize));
566 } else {
567 Q_ASSERT(folderCount > 0);
568 text = foldersText;
569 }
570 }
571 } else {
572 calculateItemCount(fileCount, folderCount, totalFileSize);
573 text = KIO::itemsSummaryString(fileCount + folderCount,
574 fileCount, folderCount,
575 totalFileSize, true);
576 }
577
578 return text;
579 }
580
581 void DolphinView::setUrl(const KUrl& url)
582 {
583 // remember current item candidate (see restoreCurrentItem())
584 m_currentItemUrl = url;
585 updateView(url, KUrl());
586 }
587
588 void DolphinView::changeSelection(const KFileItemList& selection)
589 {
590 clearSelection();
591 if (selection.isEmpty()) {
592 return;
593 }
594 const KUrl& baseUrl = url();
595 KUrl url;
596 QItemSelection new_selection;
597 foreach(const KFileItem& item, selection) {
598 url = item.url().upUrl();
599 if (baseUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
600 QModelIndex index = m_proxyModel->mapFromSource(m_dolphinModel->indexForItem(item));
601 new_selection.select(index, index);
602 }
603 }
604 itemView()->selectionModel()->select(new_selection,
605 QItemSelectionModel::ClearAndSelect
606 | QItemSelectionModel::Current);
607 }
608
609 void DolphinView::renameSelectedItems()
610 {
611 KFileItemList items = selectedItems();
612 const int itemCount = items.count();
613 if (itemCount < 1) {
614 return;
615 }
616
617 if (itemCount > 1) {
618 // More than one item has been selected for renaming. Open
619 // a rename dialog and rename all items afterwards.
620 RenameDialog dialog(this, items);
621 if (dialog.exec() == QDialog::Rejected) {
622 return;
623 }
624
625 const QString newName = dialog.newName();
626 if (newName.isEmpty()) {
627 emit errorMessage(dialog.errorString());
628 } else {
629 // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
630 // as one operation instead of n rename operations like it is done now...
631 Q_ASSERT(newName.contains('#'));
632
633 // currently the items are sorted by the selection order, resort
634 // them by the file name
635 qSort(items.begin(), items.end(), lessThan);
636
637 // iterate through all selected items and rename them...
638 int index = 1;
639 foreach (const KFileItem& item, items) {
640 const KUrl& oldUrl = item.url();
641 QString number;
642 number.setNum(index++);
643
644 QString name = newName;
645 name.replace('#', number);
646
647 if (oldUrl.fileName() != name) {
648 KUrl newUrl = oldUrl;
649 newUrl.setFileName(name);
650 KonqOperations::rename(this, oldUrl, newUrl);
651 }
652 }
653 }
654 } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
655 Q_ASSERT(itemCount == 1);
656
657 if (isColumnViewActive()) {
658 m_columnView->editItem(items.first());
659 } else {
660 const QModelIndex dirIndex = m_dolphinModel->indexForItem(items.first());
661 const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
662 itemView()->edit(proxyIndex);
663 }
664 } else {
665 Q_ASSERT(itemCount == 1);
666
667 RenameDialog dialog(this, items);
668 if (dialog.exec() == QDialog::Rejected) {
669 return;
670 }
671
672 const QString& newName = dialog.newName();
673 if (newName.isEmpty()) {
674 emit errorMessage(dialog.errorString());
675 } else {
676 const KUrl& oldUrl = items.first().url();
677 KUrl newUrl = oldUrl;
678 newUrl.setFileName(newName);
679 KonqOperations::rename(this, oldUrl, newUrl);
680 }
681 }
682 }
683
684 void DolphinView::trashSelectedItems()
685 {
686 const KUrl::List list = simplifiedSelectedUrls();
687 KonqOperations::del(this, KonqOperations::TRASH, list);
688 }
689
690 void DolphinView::deleteSelectedItems()
691 {
692 const KUrl::List list = simplifiedSelectedUrls();
693 const bool del = KonqOperations::askDeleteConfirmation(list,
694 KonqOperations::DEL,
695 KonqOperations::DEFAULT_CONFIRMATION,
696 this);
697
698 if (del) {
699 KIO::Job* job = KIO::del(list);
700 connect(job, SIGNAL(result(KJob*)),
701 this, SLOT(slotDeleteFileFinished(KJob*)));
702 }
703 }
704
705 void DolphinView::cutSelectedItems()
706 {
707 QMimeData* mimeData = selectionMimeData();
708 KonqMimeData::addIsCutSelection(mimeData, true);
709 QApplication::clipboard()->setMimeData(mimeData);
710 }
711
712 void DolphinView::copySelectedItems()
713 {
714 QMimeData* mimeData = selectionMimeData();
715 QApplication::clipboard()->setMimeData(mimeData);
716 }
717
718 void DolphinView::paste()
719 {
720 pasteToUrl(url());
721 }
722
723 void DolphinView::pasteIntoFolder()
724 {
725 const KFileItemList items = selectedItems();
726 if ((items.count() == 1) && items.first().isDir()) {
727 pasteToUrl(items.first().url());
728 }
729 }
730
731 void DolphinView::setShowPreview(bool show)
732 {
733 if (m_showPreview == show) {
734 return;
735 }
736
737 const KUrl viewPropsUrl = viewPropertiesUrl();
738 ViewProperties props(viewPropsUrl);
739 props.setShowPreview(show);
740
741 m_showPreview = show;
742 m_previewGenerator->setPreviewShown(show);
743
744 const int oldZoomLevel = m_controller->zoomLevel();
745 emit showPreviewChanged();
746
747 // Enabling or disabling the preview might change the icon size of the view.
748 // As the view does not emit a signal when the icon size has been changed,
749 // the used zoom level of the controller must be adjusted manually:
750 updateZoomLevel(oldZoomLevel);
751
752 loadDirectory(viewPropsUrl);
753 }
754
755 void DolphinView::setShowHiddenFiles(bool show)
756 {
757 if (m_dirLister->showingDotFiles() == show) {
758 return;
759 }
760
761 const KUrl viewPropsUrl = viewPropertiesUrl();
762 ViewProperties props(viewPropsUrl);
763 props.setShowHiddenFiles(show);
764
765 m_dirLister->setShowingDotFiles(show);
766 emit showHiddenFilesChanged();
767
768 loadDirectory(viewPropsUrl);
769 }
770
771 void DolphinView::setCategorizedSorting(bool categorized)
772 {
773 if (categorized == categorizedSorting()) {
774 return;
775 }
776
777 // setCategorizedSorting(true) may only get invoked
778 // if the view supports categorized sorting
779 Q_ASSERT(!categorized || supportsCategorizedSorting());
780
781 ViewProperties props(viewPropertiesUrl());
782 props.setCategorizedSorting(categorized);
783 props.save();
784
785 m_storedCategorizedSorting = categorized;
786 m_proxyModel->setCategorizedModel(categorized);
787
788 emit categorizedSortingChanged();
789 }
790
791 void DolphinView::toggleSortOrder()
792 {
793 const Qt::SortOrder order = (sortOrder() == Qt::AscendingOrder) ?
794 Qt::DescendingOrder :
795 Qt::AscendingOrder;
796 setSortOrder(order);
797 }
798
799 void DolphinView::toggleAdditionalInfo(QAction* action)
800 {
801 const KFileItemDelegate::Information info =
802 static_cast<KFileItemDelegate::Information>(action->data().toInt());
803
804 KFileItemDelegate::InformationList list = additionalInfo();
805
806 const bool show = action->isChecked();
807
808 const int index = list.indexOf(info);
809 const bool containsInfo = (index >= 0);
810 if (show && !containsInfo) {
811 list.append(info);
812 setAdditionalInfo(list);
813 } else if (!show && containsInfo) {
814 list.removeAt(index);
815 setAdditionalInfo(list);
816 Q_ASSERT(list.indexOf(info) < 0);
817 }
818 }
819
820 void DolphinView::mouseReleaseEvent(QMouseEvent* event)
821 {
822 QWidget::mouseReleaseEvent(event);
823 setActive(true);
824 }
825
826 void DolphinView::wheelEvent(QWheelEvent* event)
827 {
828 if (event->modifiers() & Qt::ControlModifier) {
829 const int delta = event->delta();
830 const int level = zoomLevel();
831 if (delta > 0) {
832 setZoomLevel(level + 1);
833 } else if (delta < 0) {
834 setZoomLevel(level - 1);
835 }
836 event->accept();
837 }
838 }
839
840 bool DolphinView::eventFilter(QObject* watched, QEvent* event)
841 {
842 switch (event->type()) {
843 case QEvent::FocusIn:
844 if (watched == itemView()) {
845 m_controller->requestActivation();
846 }
847 break;
848
849 case QEvent::MouseButtonPress:
850 if ((watched == itemView()->viewport()) && (m_expandedViews.count() > 0)) {
851 // Listening to a mousebutton press event to delete expanded views is a
852 // workaround, as it seems impossible for the FolderExpander to know when
853 // a dragging outside a view has been finished. However it works quite well:
854 // A mousebutton press event indicates that a drag operation must be
855 // finished already.
856 deleteExpandedViews();
857 }
858 break;
859
860 case QEvent::DragEnter:
861 if (watched == itemView()->viewport()) {
862 setActive(true);
863 }
864 break;
865
866 default:
867 break;
868 }
869
870 return QWidget::eventFilter(watched, event);
871 }
872
873 void DolphinView::activate()
874 {
875 setActive(true);
876 }
877
878 void DolphinView::triggerItem(const KFileItem& item)
879 {
880 const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
881 if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
882 // items are selected by the user, hence don't trigger the
883 // item specified by 'index'
884 return;
885 }
886
887 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
888 if (item.isNull() || m_isContextMenuOpen) {
889 return;
890 }
891
892 if (m_toolTipManager != 0) {
893 m_toolTipManager->hideTip();
894 }
895 emit itemTriggered(item); // caught by DolphinViewContainer or DolphinPart
896 }
897
898 void DolphinView::emitSelectionChangedSignal()
899 {
900 emit selectionChanged(DolphinView::selectedItems());
901 }
902
903 void DolphinView::openContextMenu(const QPoint& pos)
904 {
905 KFileItem item;
906 if (isColumnViewActive()) {
907 item = m_columnView->itemAt(pos);
908 } else {
909 const QModelIndex index = itemView()->indexAt(pos);
910 if (index.isValid() && (index.column() == DolphinModel::Name)) {
911 const QModelIndex dolphinModelIndex = m_proxyModel->mapToSource(index);
912 item = m_dolphinModel->itemForIndex(dolphinModelIndex);
913 }
914 }
915
916 if (m_toolTipManager != 0) {
917 m_toolTipManager->hideTip();
918 }
919
920 m_isContextMenuOpen = true; // TODO: workaround for Qt-issue 207192
921 emit requestContextMenu(item, url());
922 m_isContextMenuOpen = false;
923 }
924
925 void DolphinView::dropUrls(const KFileItem& destItem,
926 const KUrl& destPath,
927 QDropEvent* event)
928 {
929 DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
930 }
931
932 void DolphinView::updateSorting(DolphinView::Sorting sorting)
933 {
934 ViewProperties props(viewPropertiesUrl());
935 props.setSorting(sorting);
936
937 m_proxyModel->setSorting(sorting);
938
939 emit sortingChanged(sorting);
940 }
941
942 void DolphinView::updateSortOrder(Qt::SortOrder order)
943 {
944 ViewProperties props(viewPropertiesUrl());
945 props.setSortOrder(order);
946
947 m_proxyModel->setSortOrder(order);
948
949 emit sortOrderChanged(order);
950 }
951
952 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& info)
953 {
954 ViewProperties props(viewPropertiesUrl());
955 props.setAdditionalInfo(info);
956 props.save();
957
958 m_fileItemDelegate->setShowInformation(info);
959
960 emit additionalInfoChanged();
961 }
962
963 void DolphinView::updateAdditionalInfoActions(KActionCollection* collection)
964 {
965 const bool enable = (m_mode == DolphinView::DetailsView) ||
966 (m_mode == DolphinView::IconsView);
967
968 QAction* showSizeInfo = collection->action("show_size_info");
969 QAction* showDateInfo = collection->action("show_date_info");
970 QAction* showPermissionsInfo = collection->action("show_permissions_info");
971 QAction* showOwnerInfo = collection->action("show_owner_info");
972 QAction* showGroupInfo = collection->action("show_group_info");
973 QAction* showMimeInfo = collection->action("show_mime_info");
974
975 showSizeInfo->setChecked(false);
976 showDateInfo->setChecked(false);
977 showPermissionsInfo->setChecked(false);
978 showOwnerInfo->setChecked(false);
979 showGroupInfo->setChecked(false);
980 showMimeInfo->setChecked(false);
981
982 showSizeInfo->setEnabled(enable);
983 showDateInfo->setEnabled(enable);
984 showPermissionsInfo->setEnabled(enable);
985 showOwnerInfo->setEnabled(enable);
986 showGroupInfo->setEnabled(enable);
987 showMimeInfo->setEnabled(enable);
988
989 foreach (KFileItemDelegate::Information info, m_fileItemDelegate->showInformation()) {
990 switch (info) {
991 case KFileItemDelegate::Size:
992 showSizeInfo->setChecked(true);
993 break;
994 case KFileItemDelegate::ModificationTime:
995 showDateInfo->setChecked(true);
996 break;
997 case KFileItemDelegate::Permissions:
998 showPermissionsInfo->setChecked(true);
999 break;
1000 case KFileItemDelegate::Owner:
1001 showOwnerInfo->setChecked(true);
1002 break;
1003 case KFileItemDelegate::OwnerAndGroup:
1004 showGroupInfo->setChecked(true);
1005 break;
1006 case KFileItemDelegate::FriendlyMimeType:
1007 showMimeInfo->setChecked(true);
1008 break;
1009 default:
1010 break;
1011 }
1012 }
1013 }
1014
1015 QPair<bool, QString> DolphinView::pasteInfo() const
1016 {
1017 QPair<bool, QString> ret;
1018 QClipboard* clipboard = QApplication::clipboard();
1019 const QMimeData* mimeData = clipboard->mimeData();
1020
1021 KUrl::List urls = KUrl::List::fromMimeData(mimeData);
1022 if (!urls.isEmpty()) {
1023 // disable the paste action if no writing is supported
1024 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url());
1025 ret.first = KonqFileItemCapabilities(KFileItemList() << item).supportsWriting();
1026
1027 if (urls.count() == 1) {
1028 const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(), true);
1029 ret.second = item.isDir() ? i18nc("@action:inmenu", "Paste One Folder") :
1030 i18nc("@action:inmenu", "Paste One File");
1031
1032 } else {
1033 ret.second = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count());
1034 }
1035 } else {
1036 ret.first = false;
1037 ret.second = i18nc("@action:inmenu", "Paste");
1038 }
1039
1040 return ret;
1041 }
1042
1043 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
1044 {
1045 m_tabsForFiles = tabsForFiles;
1046 }
1047
1048 bool DolphinView::isTabsForFilesEnabled() const
1049 {
1050 return m_tabsForFiles;
1051 }
1052
1053 bool DolphinView::itemsExpandable() const
1054 {
1055 return (m_detailsView != 0) && m_detailsView->itemsExpandable();
1056 }
1057
1058 void DolphinView::emitContentsMoved()
1059 {
1060 // only emit the contents moved signal if:
1061 // - no directory loading is ongoing (this would reset the contents position
1062 // always to (0, 0))
1063 // - if the Column View is active: the column view does an automatic
1064 // positioning during the loading operation, which must be remembered
1065 if (!m_loadingDirectory || isColumnViewActive()) {
1066 const QPoint pos(contentsPosition());
1067 emit contentsMoved(pos.x(), pos.y());
1068 }
1069 }
1070
1071 void DolphinView::showHoverInformation(const KFileItem& item)
1072 {
1073 emit requestItemInfo(item);
1074 }
1075
1076 void DolphinView::clearHoverInformation()
1077 {
1078 emit requestItemInfo(KFileItem());
1079 }
1080
1081 void DolphinView::slotDeleteFileFinished(KJob* job)
1082 {
1083 if (job->error() == 0) {
1084 emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1085 } else if (job->error() != KIO::ERR_USER_CANCELED) {
1086 emit errorMessage(job->errorString());
1087 }
1088 }
1089
1090 void DolphinView::slotRequestUrlChange(const KUrl& url)
1091 {
1092 emit requestUrlChange(url);
1093 m_controller->setUrl(url);
1094 }
1095
1096 void DolphinView::restoreCurrentItem()
1097 {
1098 const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl);
1099 if (dirIndex.isValid()) {
1100 const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
1101 QAbstractItemView* view = itemView();
1102 const bool clearSelection = !hasSelection();
1103 view->setCurrentIndex(proxyIndex);
1104 if (clearSelection) {
1105 view->clearSelection();
1106 }
1107 }
1108 }
1109
1110 void DolphinView::enterDir(const QModelIndex& index, QAbstractItemView* view)
1111 {
1112 // Deleting a view that is the root of a drag operation is not allowed, otherwise
1113 // the dragging gets automatically cancelled by Qt. So before entering a new
1114 // directory, the current view is remembered in m_expandedViews and deleted
1115 // later when the drag operation has been finished (see DolphinView::eventFilter()).
1116 m_expandedViews.append(view);
1117 m_controller->triggerItem(index);
1118 }
1119
1120 void DolphinView::loadDirectory(const KUrl& url, bool reload)
1121 {
1122 if (!url.isValid()) {
1123 const QString location(url.pathOrUrl());
1124 if (location.isEmpty()) {
1125 emit errorMessage(i18nc("@info:status", "The location is empty."));
1126 } else {
1127 emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
1128 }
1129 return;
1130 }
1131
1132 m_loadingDirectory = true;
1133
1134 m_dirLister->stop();
1135 m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
1136
1137 if (isColumnViewActive()) {
1138 // adjusting the directory lister is not enough in the case of the
1139 // column view, as each column has its own directory lister internally...
1140 if (reload) {
1141 m_columnView->reload();
1142 } else {
1143 m_columnView->showColumn(url);
1144 }
1145 }
1146 }
1147
1148 KUrl DolphinView::viewPropertiesUrl() const
1149 {
1150 if (isColumnViewActive()) {
1151 return m_columnView->rootUrl();
1152 }
1153
1154 return url();
1155 }
1156
1157 void DolphinView::applyViewProperties(const KUrl& url)
1158 {
1159 if (m_ignoreViewProperties) {
1160 return;
1161 }
1162
1163 if (isColumnViewActive() && rootUrl().isParentOf(url)) {
1164 // The column view is active, hence don't apply the view properties
1165 // of sub directories (represented by columns) to the view. The
1166 // view always represents the properties of the first column.
1167 return;
1168 }
1169
1170 const ViewProperties props(url);
1171
1172 const Mode mode = props.viewMode();
1173 if (m_mode != mode) {
1174 const int oldZoomLevel = m_controller->zoomLevel();
1175
1176 m_mode = mode;
1177 createView();
1178 emit modeChanged();
1179
1180 updateZoomLevel(oldZoomLevel);
1181 }
1182 if (itemView() == 0) {
1183 createView();
1184 }
1185 Q_ASSERT(itemView() != 0);
1186 Q_ASSERT(m_fileItemDelegate != 0);
1187
1188 const bool showHiddenFiles = props.showHiddenFiles();
1189 if (showHiddenFiles != m_dirLister->showingDotFiles()) {
1190 m_dirLister->setShowingDotFiles(showHiddenFiles);
1191 emit showHiddenFilesChanged();
1192 }
1193
1194 m_storedCategorizedSorting = props.categorizedSorting();
1195 const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
1196 if (categorized != m_proxyModel->isCategorizedModel()) {
1197 m_proxyModel->setCategorizedModel(categorized);
1198 emit categorizedSortingChanged();
1199 }
1200
1201 const DolphinView::Sorting sorting = props.sorting();
1202 if (sorting != m_proxyModel->sorting()) {
1203 m_proxyModel->setSorting(sorting);
1204 emit sortingChanged(sorting);
1205 }
1206
1207 const Qt::SortOrder sortOrder = props.sortOrder();
1208 if (sortOrder != m_proxyModel->sortOrder()) {
1209 m_proxyModel->setSortOrder(sortOrder);
1210 emit sortOrderChanged(sortOrder);
1211 }
1212
1213 KFileItemDelegate::InformationList info = props.additionalInfo();
1214 if (info != m_fileItemDelegate->showInformation()) {
1215 m_fileItemDelegate->setShowInformation(info);
1216 emit additionalInfoChanged();
1217 }
1218
1219 const bool showPreview = props.showPreview();
1220 if (showPreview != m_showPreview) {
1221 m_showPreview = showPreview;
1222 m_previewGenerator->setPreviewShown(showPreview);
1223
1224 const int oldZoomLevel = m_controller->zoomLevel();
1225 emit showPreviewChanged();
1226
1227 // Enabling or disabling the preview might change the icon size of the view.
1228 // As the view does not emit a signal when the icon size has been changed,
1229 // the used zoom level of the controller must be adjusted manually:
1230 updateZoomLevel(oldZoomLevel);
1231 }
1232
1233 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1234 // During the lifetime of a DolphinView instance the global view properties
1235 // should not be changed. This allows e. g. to split a view and use different
1236 // view properties for each view.
1237 m_ignoreViewProperties = true;
1238 }
1239 }
1240
1241 void DolphinView::createView()
1242 {
1243 deleteView();
1244 Q_ASSERT(m_iconsView == 0);
1245 Q_ASSERT(m_detailsView == 0);
1246 Q_ASSERT(m_columnView == 0);
1247
1248 QAbstractItemView* view = 0;
1249 switch (m_mode) {
1250 case IconsView: {
1251 m_iconsView = new DolphinIconsView(this, m_controller);
1252 view = m_iconsView;
1253 break;
1254 }
1255
1256 case DetailsView:
1257 m_detailsView = new DolphinDetailsView(this, m_controller);
1258 view = m_detailsView;
1259 break;
1260
1261 case ColumnView:
1262 m_columnView = new DolphinColumnView(this, m_controller);
1263 view = m_columnView;
1264 break;
1265 }
1266
1267 Q_ASSERT(view != 0);
1268 view->installEventFilter(this);
1269 view->viewport()->installEventFilter(this);
1270 setFocusProxy(view);
1271
1272 if (m_mode != ColumnView) {
1273 // Give the view the ability to auto-expand its directories on hovering
1274 // (the column view takes care about this itself). If the details view
1275 // uses expandable folders, the auto-expanding should be used always.
1276 DolphinSettings& settings = DolphinSettings::instance();
1277 const bool enabled = settings.generalSettings()->autoExpandFolders() ||
1278 ((m_detailsView != 0) && settings.detailsModeSettings()->expandableFolders());
1279
1280 FolderExpander* folderExpander = new FolderExpander(view, m_proxyModel);
1281 folderExpander->setEnabled(enabled);
1282 connect(folderExpander, SIGNAL(enterDir(const QModelIndex&, QAbstractItemView*)),
1283 this, SLOT(enterDir(const QModelIndex&, QAbstractItemView*)));
1284 }
1285
1286 m_controller->setItemView(view);
1287
1288 m_fileItemDelegate = new DolphinFileItemDelegate(view);
1289 m_fileItemDelegate->setShowToolTipWhenElided(false);
1290 m_fileItemDelegate->setMinimizedNameColumn(m_mode == DetailsView);
1291 view->setItemDelegate(m_fileItemDelegate);
1292
1293 view->setModel(m_proxyModel);
1294 if (m_selectionModel != 0) {
1295 view->setSelectionModel(m_selectionModel);
1296 } else {
1297 m_selectionModel = view->selectionModel();
1298 }
1299
1300 // reparent the selection model, as it should not be deleted
1301 // when deleting the model
1302 m_selectionModel->setParent(this);
1303
1304 view->setSelectionMode(QAbstractItemView::ExtendedSelection);
1305
1306 m_previewGenerator = new KFilePreviewGenerator(view);
1307 m_previewGenerator->setPreviewShown(m_showPreview);
1308
1309 if (DolphinSettings::instance().generalSettings()->showToolTips()) {
1310 m_toolTipManager = new ToolTipManager(view, m_proxyModel);
1311 connect(m_controller, SIGNAL(hideToolTip()),
1312 m_toolTipManager, SLOT(hideTip()));
1313 }
1314
1315 m_topLayout->insertWidget(1, view);
1316
1317 connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
1318 this, SLOT(emitSelectionChangedSignal()));
1319 connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
1320 this, SLOT(emitContentsMoved()));
1321 connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1322 this, SLOT(emitContentsMoved()));
1323 }
1324
1325 void DolphinView::deleteView()
1326 {
1327 QAbstractItemView* view = itemView();
1328 if (view != 0) {
1329 // It's important to set the keyboard focus to the parent
1330 // before deleting the view: Otherwise when having a split
1331 // view the other view will get the focus and will request
1332 // an activation (see DolphinView::eventFilter()).
1333 setFocusProxy(0);
1334 setFocus();
1335
1336 m_topLayout->removeWidget(view);
1337 view->close();
1338
1339 disconnect(view);
1340 m_controller->disconnect(view);
1341 view->disconnect();
1342
1343 bool deleteView = true;
1344 foreach (const QAbstractItemView* expandedView, m_expandedViews) {
1345 if (view == expandedView) {
1346 // the current view got already expanded and must stay alive
1347 // until the dragging has been completed
1348 deleteView = false;
1349 break;
1350 }
1351 }
1352 if (deleteView) {
1353 view->deleteLater();
1354 }
1355 view = 0;
1356
1357 m_iconsView = 0;
1358 m_detailsView = 0;
1359 m_columnView = 0;
1360 m_fileItemDelegate = 0;
1361 m_previewGenerator = 0;
1362 m_toolTipManager = 0;
1363 }
1364 }
1365
1366 QAbstractItemView* DolphinView::itemView() const
1367 {
1368 if (m_detailsView != 0) {
1369 return m_detailsView;
1370 } else if (m_columnView != 0) {
1371 return m_columnView;
1372 }
1373
1374 return m_iconsView;
1375 }
1376
1377 bool DolphinView::isCutItem(const KFileItem& item) const
1378 {
1379 const QMimeData* mimeData = QApplication::clipboard()->mimeData();
1380 const KUrl::List cutUrls = KUrl::List::fromMimeData(mimeData);
1381
1382 const KUrl& itemUrl = item.url();
1383 KUrl::List::const_iterator it = cutUrls.begin();
1384 const KUrl::List::const_iterator end = cutUrls.end();
1385 while (it != end) {
1386 if (*it == itemUrl) {
1387 return true;
1388 }
1389 ++it;
1390 }
1391
1392 return false;
1393 }
1394
1395 void DolphinView::pasteToUrl(const KUrl& url)
1396 {
1397 QClipboard* clipboard = QApplication::clipboard();
1398 const QMimeData* mimeData = clipboard->mimeData();
1399
1400 const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
1401 if (KonqMimeData::decodeIsCutSelection(mimeData)) {
1402 KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url);
1403 clipboard->clear();
1404 } else {
1405 KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url);
1406 }
1407 }
1408
1409 void DolphinView::updateZoomLevel(int oldZoomLevel)
1410 {
1411 const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(itemView()->iconSize());
1412 if (oldZoomLevel != newZoomLevel) {
1413 m_controller->setZoomLevel(newZoomLevel);
1414 emit zoomLevelChanged(newZoomLevel);
1415 }
1416 }
1417
1418 KUrl::List DolphinView::simplifiedSelectedUrls() const
1419 {
1420 KUrl::List list = selectedUrls();
1421 if (itemsExpandable() ) {
1422 list = KDirModel::simplifiedUrlList(list);
1423 }
1424 return list;
1425 }
1426
1427 void DolphinView::deleteExpandedViews()
1428 {
1429 const QAbstractItemView* view = itemView();
1430 foreach (QAbstractItemView* expandedView, m_expandedViews) {
1431 if (expandedView != view) {
1432 expandedView->deleteLater();
1433 }
1434 }
1435 m_expandedViews.clear();
1436 }
1437
1438 QMimeData* DolphinView::selectionMimeData() const
1439 {
1440 if (isColumnViewActive()) {
1441 return m_columnView->selectionMimeData();
1442 }
1443
1444 const QAbstractItemView* view = itemView();
1445 Q_ASSERT((view != 0) && (view->selectionModel() != 0));
1446 const QItemSelection selection = m_proxyModel->mapSelectionToSource(view->selectionModel()->selection());
1447 return m_dolphinModel->mimeData(selection.indexes());
1448 }
1449
1450 #include "dolphinview.moc"