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