]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinview.cpp
hide the tooltips when a key is pressed (thanks to Shaun Reich for the initial patch)
[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 case QEvent::KeyPress:
867 if ((watched == itemView()) && (m_toolTipManager != 0)) {
868 m_toolTipManager->hideTip();
869 }
870 break;
871
872 default:
873 break;
874 }
875
876 return QWidget::eventFilter(watched, event);
877 }
878
879 void DolphinView::activate()
880 {
881 setActive(true);
882 }
883
884 void DolphinView::triggerItem(const KFileItem& item)
885 {
886 const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
887 if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
888 // items are selected by the user, hence don't trigger the
889 // item specified by 'index'
890 return;
891 }
892
893 // TODO: the m_isContextMenuOpen check is a workaround for Qt-issue 207192
894 if (item.isNull() || m_isContextMenuOpen) {
895 return;
896 }
897
898 if (m_toolTipManager != 0) {
899 m_toolTipManager->hideTip();
900 }
901 emit itemTriggered(item); // caught by DolphinViewContainer or DolphinPart
902 }
903
904 void DolphinView::emitSelectionChangedSignal()
905 {
906 emit selectionChanged(DolphinView::selectedItems());
907 }
908
909 void DolphinView::openContextMenu(const QPoint& pos)
910 {
911 KFileItem item;
912 if (isColumnViewActive()) {
913 item = m_columnView->itemAt(pos);
914 } else {
915 const QModelIndex index = itemView()->indexAt(pos);
916 if (index.isValid() && (index.column() == DolphinModel::Name)) {
917 const QModelIndex dolphinModelIndex = m_proxyModel->mapToSource(index);
918 item = m_dolphinModel->itemForIndex(dolphinModelIndex);
919 }
920 }
921
922 if (m_toolTipManager != 0) {
923 m_toolTipManager->hideTip();
924 }
925
926 m_isContextMenuOpen = true; // TODO: workaround for Qt-issue 207192
927 emit requestContextMenu(item, url());
928 m_isContextMenuOpen = false;
929 }
930
931 void DolphinView::dropUrls(const KFileItem& destItem,
932 const KUrl& destPath,
933 QDropEvent* event)
934 {
935 DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
936 }
937
938 void DolphinView::updateSorting(DolphinView::Sorting sorting)
939 {
940 ViewProperties props(viewPropertiesUrl());
941 props.setSorting(sorting);
942
943 m_proxyModel->setSorting(sorting);
944
945 emit sortingChanged(sorting);
946 }
947
948 void DolphinView::updateSortOrder(Qt::SortOrder order)
949 {
950 ViewProperties props(viewPropertiesUrl());
951 props.setSortOrder(order);
952
953 m_proxyModel->setSortOrder(order);
954
955 emit sortOrderChanged(order);
956 }
957
958 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& info)
959 {
960 ViewProperties props(viewPropertiesUrl());
961 props.setAdditionalInfo(info);
962 props.save();
963
964 m_fileItemDelegate->setShowInformation(info);
965
966 emit additionalInfoChanged();
967 }
968
969 void DolphinView::updateAdditionalInfoActions(KActionCollection* collection)
970 {
971 const bool enable = (m_mode == DolphinView::DetailsView) ||
972 (m_mode == DolphinView::IconsView);
973
974 QAction* showSizeInfo = collection->action("show_size_info");
975 QAction* showDateInfo = collection->action("show_date_info");
976 QAction* showPermissionsInfo = collection->action("show_permissions_info");
977 QAction* showOwnerInfo = collection->action("show_owner_info");
978 QAction* showGroupInfo = collection->action("show_group_info");
979 QAction* showMimeInfo = collection->action("show_mime_info");
980
981 showSizeInfo->setChecked(false);
982 showDateInfo->setChecked(false);
983 showPermissionsInfo->setChecked(false);
984 showOwnerInfo->setChecked(false);
985 showGroupInfo->setChecked(false);
986 showMimeInfo->setChecked(false);
987
988 showSizeInfo->setEnabled(enable);
989 showDateInfo->setEnabled(enable);
990 showPermissionsInfo->setEnabled(enable);
991 showOwnerInfo->setEnabled(enable);
992 showGroupInfo->setEnabled(enable);
993 showMimeInfo->setEnabled(enable);
994
995 foreach (KFileItemDelegate::Information info, m_fileItemDelegate->showInformation()) {
996 switch (info) {
997 case KFileItemDelegate::Size:
998 showSizeInfo->setChecked(true);
999 break;
1000 case KFileItemDelegate::ModificationTime:
1001 showDateInfo->setChecked(true);
1002 break;
1003 case KFileItemDelegate::Permissions:
1004 showPermissionsInfo->setChecked(true);
1005 break;
1006 case KFileItemDelegate::Owner:
1007 showOwnerInfo->setChecked(true);
1008 break;
1009 case KFileItemDelegate::OwnerAndGroup:
1010 showGroupInfo->setChecked(true);
1011 break;
1012 case KFileItemDelegate::FriendlyMimeType:
1013 showMimeInfo->setChecked(true);
1014 break;
1015 default:
1016 break;
1017 }
1018 }
1019 }
1020
1021 QPair<bool, QString> DolphinView::pasteInfo() const
1022 {
1023 QPair<bool, QString> ret;
1024 QClipboard* clipboard = QApplication::clipboard();
1025 const QMimeData* mimeData = clipboard->mimeData();
1026
1027 KUrl::List urls = KUrl::List::fromMimeData(mimeData);
1028 if (!urls.isEmpty()) {
1029 // disable the paste action if no writing is supported
1030 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url());
1031 ret.first = KonqFileItemCapabilities(KFileItemList() << item).supportsWriting();
1032
1033 if (urls.count() == 1) {
1034 const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(), true);
1035 ret.second = item.isDir() ? i18nc("@action:inmenu", "Paste One Folder") :
1036 i18nc("@action:inmenu", "Paste One File");
1037
1038 } else {
1039 ret.second = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count());
1040 }
1041 } else {
1042 ret.first = false;
1043 ret.second = i18nc("@action:inmenu", "Paste");
1044 }
1045
1046 return ret;
1047 }
1048
1049 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
1050 {
1051 m_tabsForFiles = tabsForFiles;
1052 }
1053
1054 bool DolphinView::isTabsForFilesEnabled() const
1055 {
1056 return m_tabsForFiles;
1057 }
1058
1059 bool DolphinView::itemsExpandable() const
1060 {
1061 return (m_detailsView != 0) && m_detailsView->itemsExpandable();
1062 }
1063
1064 void DolphinView::emitContentsMoved()
1065 {
1066 // only emit the contents moved signal if:
1067 // - no directory loading is ongoing (this would reset the contents position
1068 // always to (0, 0))
1069 // - if the Column View is active: the column view does an automatic
1070 // positioning during the loading operation, which must be remembered
1071 if (!m_loadingDirectory || isColumnViewActive()) {
1072 const QPoint pos(contentsPosition());
1073 emit contentsMoved(pos.x(), pos.y());
1074 }
1075 }
1076
1077 void DolphinView::showHoverInformation(const KFileItem& item)
1078 {
1079 emit requestItemInfo(item);
1080 }
1081
1082 void DolphinView::clearHoverInformation()
1083 {
1084 emit requestItemInfo(KFileItem());
1085 }
1086
1087 void DolphinView::slotDeleteFileFinished(KJob* job)
1088 {
1089 if (job->error() == 0) {
1090 emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1091 } else if (job->error() != KIO::ERR_USER_CANCELED) {
1092 emit errorMessage(job->errorString());
1093 }
1094 }
1095
1096 void DolphinView::slotRequestUrlChange(const KUrl& url)
1097 {
1098 emit requestUrlChange(url);
1099 m_controller->setUrl(url);
1100 }
1101
1102 void DolphinView::restoreCurrentItem()
1103 {
1104 const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl);
1105 if (dirIndex.isValid()) {
1106 const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
1107 QAbstractItemView* view = itemView();
1108 const bool clearSelection = !hasSelection();
1109 view->setCurrentIndex(proxyIndex);
1110 if (clearSelection) {
1111 view->clearSelection();
1112 }
1113 }
1114 }
1115
1116 void DolphinView::enterDir(const QModelIndex& index, QAbstractItemView* view)
1117 {
1118 // Deleting a view that is the root of a drag operation is not allowed, otherwise
1119 // the dragging gets automatically cancelled by Qt. So before entering a new
1120 // directory, the current view is remembered in m_expandedViews and deleted
1121 // later when the drag operation has been finished (see DolphinView::eventFilter()).
1122 m_expandedViews.append(view);
1123 m_controller->triggerItem(index);
1124 }
1125
1126 void DolphinView::loadDirectory(const KUrl& url, bool reload)
1127 {
1128 if (!url.isValid()) {
1129 const QString location(url.pathOrUrl());
1130 if (location.isEmpty()) {
1131 emit errorMessage(i18nc("@info:status", "The location is empty."));
1132 } else {
1133 emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
1134 }
1135 return;
1136 }
1137
1138 m_loadingDirectory = true;
1139
1140 m_dirLister->stop();
1141 m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
1142
1143 if (isColumnViewActive()) {
1144 // adjusting the directory lister is not enough in the case of the
1145 // column view, as each column has its own directory lister internally...
1146 if (reload) {
1147 m_columnView->reload();
1148 } else {
1149 m_columnView->showColumn(url);
1150 }
1151 }
1152 }
1153
1154 KUrl DolphinView::viewPropertiesUrl() const
1155 {
1156 if (isColumnViewActive()) {
1157 return m_columnView->rootUrl();
1158 }
1159
1160 return url();
1161 }
1162
1163 void DolphinView::applyViewProperties(const KUrl& url)
1164 {
1165 if (m_ignoreViewProperties) {
1166 return;
1167 }
1168
1169 if (isColumnViewActive() && rootUrl().isParentOf(url)) {
1170 // The column view is active, hence don't apply the view properties
1171 // of sub directories (represented by columns) to the view. The
1172 // view always represents the properties of the first column.
1173 return;
1174 }
1175
1176 const ViewProperties props(url);
1177
1178 const Mode mode = props.viewMode();
1179 if (m_mode != mode) {
1180 const int oldZoomLevel = m_controller->zoomLevel();
1181
1182 m_mode = mode;
1183 createView();
1184 emit modeChanged();
1185
1186 updateZoomLevel(oldZoomLevel);
1187 }
1188 if (itemView() == 0) {
1189 createView();
1190 }
1191 Q_ASSERT(itemView() != 0);
1192 Q_ASSERT(m_fileItemDelegate != 0);
1193
1194 const bool showHiddenFiles = props.showHiddenFiles();
1195 if (showHiddenFiles != m_dirLister->showingDotFiles()) {
1196 m_dirLister->setShowingDotFiles(showHiddenFiles);
1197 emit showHiddenFilesChanged();
1198 }
1199
1200 m_storedCategorizedSorting = props.categorizedSorting();
1201 const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
1202 if (categorized != m_proxyModel->isCategorizedModel()) {
1203 m_proxyModel->setCategorizedModel(categorized);
1204 emit categorizedSortingChanged();
1205 }
1206
1207 const DolphinView::Sorting sorting = props.sorting();
1208 if (sorting != m_proxyModel->sorting()) {
1209 m_proxyModel->setSorting(sorting);
1210 emit sortingChanged(sorting);
1211 }
1212
1213 const Qt::SortOrder sortOrder = props.sortOrder();
1214 if (sortOrder != m_proxyModel->sortOrder()) {
1215 m_proxyModel->setSortOrder(sortOrder);
1216 emit sortOrderChanged(sortOrder);
1217 }
1218
1219 KFileItemDelegate::InformationList info = props.additionalInfo();
1220 if (info != m_fileItemDelegate->showInformation()) {
1221 m_fileItemDelegate->setShowInformation(info);
1222 emit additionalInfoChanged();
1223 }
1224
1225 const bool showPreview = props.showPreview();
1226 if (showPreview != m_showPreview) {
1227 m_showPreview = showPreview;
1228 m_previewGenerator->setPreviewShown(showPreview);
1229
1230 const int oldZoomLevel = m_controller->zoomLevel();
1231 emit showPreviewChanged();
1232
1233 // Enabling or disabling the preview might change the icon size of the view.
1234 // As the view does not emit a signal when the icon size has been changed,
1235 // the used zoom level of the controller must be adjusted manually:
1236 updateZoomLevel(oldZoomLevel);
1237 }
1238
1239 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1240 // During the lifetime of a DolphinView instance the global view properties
1241 // should not be changed. This allows e. g. to split a view and use different
1242 // view properties for each view.
1243 m_ignoreViewProperties = true;
1244 }
1245 }
1246
1247 void DolphinView::createView()
1248 {
1249 deleteView();
1250 Q_ASSERT(m_iconsView == 0);
1251 Q_ASSERT(m_detailsView == 0);
1252 Q_ASSERT(m_columnView == 0);
1253
1254 QAbstractItemView* view = 0;
1255 switch (m_mode) {
1256 case IconsView: {
1257 m_iconsView = new DolphinIconsView(this, m_controller);
1258 view = m_iconsView;
1259 break;
1260 }
1261
1262 case DetailsView:
1263 m_detailsView = new DolphinDetailsView(this, m_controller);
1264 view = m_detailsView;
1265 break;
1266
1267 case ColumnView:
1268 m_columnView = new DolphinColumnView(this, m_controller);
1269 view = m_columnView;
1270 break;
1271 }
1272
1273 Q_ASSERT(view != 0);
1274 view->installEventFilter(this);
1275 view->viewport()->installEventFilter(this);
1276 setFocusProxy(view);
1277
1278 if (m_mode != ColumnView) {
1279 // Give the view the ability to auto-expand its directories on hovering
1280 // (the column view takes care about this itself). If the details view
1281 // uses expandable folders, the auto-expanding should be used always.
1282 DolphinSettings& settings = DolphinSettings::instance();
1283 const bool enabled = settings.generalSettings()->autoExpandFolders() ||
1284 ((m_detailsView != 0) && settings.detailsModeSettings()->expandableFolders());
1285
1286 FolderExpander* folderExpander = new FolderExpander(view, m_proxyModel);
1287 folderExpander->setEnabled(enabled);
1288 connect(folderExpander, SIGNAL(enterDir(const QModelIndex&, QAbstractItemView*)),
1289 this, SLOT(enterDir(const QModelIndex&, QAbstractItemView*)));
1290 }
1291
1292 m_controller->setItemView(view);
1293
1294 m_fileItemDelegate = new DolphinFileItemDelegate(view);
1295 m_fileItemDelegate->setShowToolTipWhenElided(false);
1296 m_fileItemDelegate->setMinimizedNameColumn(m_mode == DetailsView);
1297 view->setItemDelegate(m_fileItemDelegate);
1298
1299 view->setModel(m_proxyModel);
1300 if (m_selectionModel != 0) {
1301 view->setSelectionModel(m_selectionModel);
1302 } else {
1303 m_selectionModel = view->selectionModel();
1304 }
1305
1306 // reparent the selection model, as it should not be deleted
1307 // when deleting the model
1308 m_selectionModel->setParent(this);
1309
1310 view->setSelectionMode(QAbstractItemView::ExtendedSelection);
1311
1312 m_previewGenerator = new KFilePreviewGenerator(view);
1313 m_previewGenerator->setPreviewShown(m_showPreview);
1314
1315 if (DolphinSettings::instance().generalSettings()->showToolTips()) {
1316 m_toolTipManager = new ToolTipManager(view, m_proxyModel);
1317 connect(m_controller, SIGNAL(hideToolTip()),
1318 m_toolTipManager, SLOT(hideTip()));
1319 }
1320
1321 m_topLayout->insertWidget(1, view);
1322
1323 connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
1324 this, SLOT(emitSelectionChangedSignal()));
1325 connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
1326 this, SLOT(emitContentsMoved()));
1327 connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1328 this, SLOT(emitContentsMoved()));
1329 }
1330
1331 void DolphinView::deleteView()
1332 {
1333 QAbstractItemView* view = itemView();
1334 if (view != 0) {
1335 // It's important to set the keyboard focus to the parent
1336 // before deleting the view: Otherwise when having a split
1337 // view the other view will get the focus and will request
1338 // an activation (see DolphinView::eventFilter()).
1339 setFocusProxy(0);
1340 setFocus();
1341
1342 m_topLayout->removeWidget(view);
1343 view->close();
1344
1345 disconnect(view);
1346 m_controller->disconnect(view);
1347 view->disconnect();
1348
1349 bool deleteView = true;
1350 foreach (const QAbstractItemView* expandedView, m_expandedViews) {
1351 if (view == expandedView) {
1352 // the current view got already expanded and must stay alive
1353 // until the dragging has been completed
1354 deleteView = false;
1355 break;
1356 }
1357 }
1358 if (deleteView) {
1359 view->deleteLater();
1360 }
1361 view = 0;
1362
1363 m_iconsView = 0;
1364 m_detailsView = 0;
1365 m_columnView = 0;
1366 m_fileItemDelegate = 0;
1367 m_previewGenerator = 0;
1368 m_toolTipManager = 0;
1369 }
1370 }
1371
1372 QAbstractItemView* DolphinView::itemView() const
1373 {
1374 if (m_detailsView != 0) {
1375 return m_detailsView;
1376 } else if (m_columnView != 0) {
1377 return m_columnView;
1378 }
1379
1380 return m_iconsView;
1381 }
1382
1383 bool DolphinView::isCutItem(const KFileItem& item) const
1384 {
1385 const QMimeData* mimeData = QApplication::clipboard()->mimeData();
1386 const KUrl::List cutUrls = KUrl::List::fromMimeData(mimeData);
1387
1388 const KUrl& itemUrl = item.url();
1389 KUrl::List::const_iterator it = cutUrls.begin();
1390 const KUrl::List::const_iterator end = cutUrls.end();
1391 while (it != end) {
1392 if (*it == itemUrl) {
1393 return true;
1394 }
1395 ++it;
1396 }
1397
1398 return false;
1399 }
1400
1401 void DolphinView::pasteToUrl(const KUrl& url)
1402 {
1403 QClipboard* clipboard = QApplication::clipboard();
1404 const QMimeData* mimeData = clipboard->mimeData();
1405
1406 const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
1407 if (KonqMimeData::decodeIsCutSelection(mimeData)) {
1408 KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url);
1409 clipboard->clear();
1410 } else {
1411 KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url);
1412 }
1413 }
1414
1415 void DolphinView::updateZoomLevel(int oldZoomLevel)
1416 {
1417 const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(itemView()->iconSize());
1418 if (oldZoomLevel != newZoomLevel) {
1419 m_controller->setZoomLevel(newZoomLevel);
1420 emit zoomLevelChanged(newZoomLevel);
1421 }
1422 }
1423
1424 KUrl::List DolphinView::simplifiedSelectedUrls() const
1425 {
1426 KUrl::List list = selectedUrls();
1427 if (itemsExpandable() ) {
1428 list = KDirModel::simplifiedUrlList(list);
1429 }
1430 return list;
1431 }
1432
1433 void DolphinView::deleteExpandedViews()
1434 {
1435 const QAbstractItemView* view = itemView();
1436 foreach (QAbstractItemView* expandedView, m_expandedViews) {
1437 if (expandedView != view) {
1438 expandedView->deleteLater();
1439 }
1440 }
1441 m_expandedViews.clear();
1442 }
1443
1444 QMimeData* DolphinView::selectionMimeData() const
1445 {
1446 if (isColumnViewActive()) {
1447 return m_columnView->selectionMimeData();
1448 }
1449
1450 const QAbstractItemView* view = itemView();
1451 Q_ASSERT((view != 0) && (view->selectionModel() != 0));
1452 const QItemSelection selection = m_proxyModel->mapSelectionToSource(view->selectionModel()->selection());
1453 return m_dolphinModel->mimeData(selection.indexes());
1454 }
1455
1456 #include "dolphinview.moc"