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