]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinview.cpp
use KDirModel::mimeData() for cut/copy operations as suggested by David Faure
[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 void DolphinView::emitContentsMoved()
1056 {
1057 // only emit the contents moved signal if:
1058 // - no directory loading is ongoing (this would reset the contents position
1059 // always to (0, 0))
1060 // - if the Column View is active: the column view does an automatic
1061 // positioning during the loading operation, which must be remembered
1062 if (!m_loadingDirectory || isColumnViewActive()) {
1063 const QPoint pos(contentsPosition());
1064 emit contentsMoved(pos.x(), pos.y());
1065 }
1066 }
1067
1068 void DolphinView::showHoverInformation(const KFileItem& item)
1069 {
1070 emit requestItemInfo(item);
1071 }
1072
1073 void DolphinView::clearHoverInformation()
1074 {
1075 emit requestItemInfo(KFileItem());
1076 }
1077
1078 void DolphinView::slotDeleteFileFinished(KJob* job)
1079 {
1080 if (job->error() == 0) {
1081 emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1082 } else if (job->error() != KIO::ERR_USER_CANCELED) {
1083 emit errorMessage(job->errorString());
1084 }
1085 }
1086
1087 void DolphinView::slotRequestUrlChange(const KUrl& url)
1088 {
1089 emit requestUrlChange(url);
1090 m_controller->setUrl(url);
1091 }
1092
1093 void DolphinView::restoreCurrentItem()
1094 {
1095 const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl);
1096 if (dirIndex.isValid()) {
1097 const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
1098 QAbstractItemView* view = itemView();
1099 const bool clearSelection = !hasSelection();
1100 view->setCurrentIndex(proxyIndex);
1101 if (clearSelection) {
1102 view->clearSelection();
1103 }
1104 }
1105 }
1106
1107 void DolphinView::enterDir(const QModelIndex& index, QAbstractItemView* view)
1108 {
1109 // Deleting a view that is the root of a drag operation is not allowed, otherwise
1110 // the dragging gets automatically cancelled by Qt. So before entering a new
1111 // directory, the current view is remembered in m_expandedViews and deleted
1112 // later when the drag operation has been finished (see DolphinView::eventFilter()).
1113 m_expandedViews.append(view);
1114 m_controller->triggerItem(index);
1115 }
1116
1117 void DolphinView::loadDirectory(const KUrl& url, bool reload)
1118 {
1119 if (!url.isValid()) {
1120 const QString location(url.pathOrUrl());
1121 if (location.isEmpty()) {
1122 emit errorMessage(i18nc("@info:status", "The location is empty."));
1123 } else {
1124 emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
1125 }
1126 return;
1127 }
1128
1129 m_loadingDirectory = true;
1130
1131 m_dirLister->stop();
1132 m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
1133
1134 if (isColumnViewActive()) {
1135 // adjusting the directory lister is not enough in the case of the
1136 // column view, as each column has its own directory lister internally...
1137 if (reload) {
1138 m_columnView->reload();
1139 } else {
1140 m_columnView->showColumn(url);
1141 }
1142 }
1143 }
1144
1145 KUrl DolphinView::viewPropertiesUrl() const
1146 {
1147 if (isColumnViewActive()) {
1148 return m_columnView->rootUrl();
1149 }
1150
1151 return url();
1152 }
1153
1154 void DolphinView::applyViewProperties(const KUrl& url)
1155 {
1156 if (isColumnViewActive() && rootUrl().isParentOf(url)) {
1157 // The column view is active, hence don't apply the view properties
1158 // of sub directories (represented by columns) to the view. The
1159 // view always represents the properties of the first column.
1160 return;
1161 }
1162
1163 const ViewProperties props(url);
1164
1165 const Mode mode = props.viewMode();
1166 if (m_mode != mode) {
1167 const int oldZoomLevel = m_controller->zoomLevel();
1168
1169 m_mode = mode;
1170 createView();
1171 emit modeChanged();
1172
1173 updateZoomLevel(oldZoomLevel);
1174 }
1175 if (itemView() == 0) {
1176 createView();
1177 }
1178 Q_ASSERT(itemView() != 0);
1179 Q_ASSERT(m_fileItemDelegate != 0);
1180
1181 const bool showHiddenFiles = props.showHiddenFiles();
1182 if (showHiddenFiles != m_dirLister->showingDotFiles()) {
1183 m_dirLister->setShowingDotFiles(showHiddenFiles);
1184 emit showHiddenFilesChanged();
1185 }
1186
1187 m_storedCategorizedSorting = props.categorizedSorting();
1188 const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
1189 if (categorized != m_proxyModel->isCategorizedModel()) {
1190 m_proxyModel->setCategorizedModel(categorized);
1191 emit categorizedSortingChanged();
1192 }
1193
1194 const DolphinView::Sorting sorting = props.sorting();
1195 if (sorting != m_proxyModel->sorting()) {
1196 m_proxyModel->setSorting(sorting);
1197 emit sortingChanged(sorting);
1198 }
1199
1200 const Qt::SortOrder sortOrder = props.sortOrder();
1201 if (sortOrder != m_proxyModel->sortOrder()) {
1202 m_proxyModel->setSortOrder(sortOrder);
1203 emit sortOrderChanged(sortOrder);
1204 }
1205
1206 KFileItemDelegate::InformationList info = props.additionalInfo();
1207 if (info != m_fileItemDelegate->showInformation()) {
1208 m_fileItemDelegate->setShowInformation(info);
1209 emit additionalInfoChanged();
1210 }
1211
1212 const bool showPreview = props.showPreview();
1213 if (showPreview != m_showPreview) {
1214 m_showPreview = showPreview;
1215 m_previewGenerator->setPreviewShown(showPreview);
1216
1217 const int oldZoomLevel = m_controller->zoomLevel();
1218 emit showPreviewChanged();
1219
1220 // Enabling or disabling the preview might change the icon size of the view.
1221 // As the view does not emit a signal when the icon size has been changed,
1222 // the used zoom level of the controller must be adjusted manually:
1223 updateZoomLevel(oldZoomLevel);
1224 }
1225 }
1226
1227 void DolphinView::createView()
1228 {
1229 deleteView();
1230 Q_ASSERT(m_iconsView == 0);
1231 Q_ASSERT(m_detailsView == 0);
1232 Q_ASSERT(m_columnView == 0);
1233
1234 QAbstractItemView* view = 0;
1235 switch (m_mode) {
1236 case IconsView: {
1237 m_iconsView = new DolphinIconsView(this, m_controller);
1238 view = m_iconsView;
1239 break;
1240 }
1241
1242 case DetailsView:
1243 m_detailsView = new DolphinDetailsView(this, m_controller);
1244 view = m_detailsView;
1245 break;
1246
1247 case ColumnView:
1248 m_columnView = new DolphinColumnView(this, m_controller);
1249 view = m_columnView;
1250 break;
1251 }
1252
1253 Q_ASSERT(view != 0);
1254 view->installEventFilter(this);
1255 view->viewport()->installEventFilter(this);
1256
1257 if (m_mode != ColumnView) {
1258 // Give the view the ability to auto-expand its directories on hovering
1259 // (the column view takes care about this itself). If the details view
1260 // uses expandable folders, the auto-expanding should be used always.
1261 DolphinSettings& settings = DolphinSettings::instance();
1262 const bool enabled = settings.generalSettings()->autoExpandFolders() ||
1263 ((m_detailsView != 0) && settings.detailsModeSettings()->expandableFolders());
1264
1265 FolderExpander* folderExpander = new FolderExpander(view, m_proxyModel);
1266 folderExpander->setEnabled(enabled);
1267 connect(folderExpander, SIGNAL(enterDir(const QModelIndex&, QAbstractItemView*)),
1268 this, SLOT(enterDir(const QModelIndex&, QAbstractItemView*)));
1269 }
1270
1271 m_controller->setItemView(view);
1272
1273 m_fileItemDelegate = new DolphinFileItemDelegate(view);
1274 m_fileItemDelegate->setShowToolTipWhenElided(false);
1275 m_fileItemDelegate->setMinimizedNameColumn(m_mode == DetailsView);
1276 view->setItemDelegate(m_fileItemDelegate);
1277
1278 view->setModel(m_proxyModel);
1279 if (m_selectionModel != 0) {
1280 view->setSelectionModel(m_selectionModel);
1281 } else {
1282 m_selectionModel = view->selectionModel();
1283 }
1284
1285 // reparent the selection model, as it should not be deleted
1286 // when deleting the model
1287 m_selectionModel->setParent(this);
1288
1289 view->setSelectionMode(QAbstractItemView::ExtendedSelection);
1290
1291 m_previewGenerator = new KFilePreviewGenerator(view);
1292 m_previewGenerator->setPreviewShown(m_showPreview);
1293
1294 if (DolphinSettings::instance().generalSettings()->showToolTips()) {
1295 m_toolTipManager = new ToolTipManager(view, m_proxyModel);
1296 connect(m_controller, SIGNAL(hideToolTip()),
1297 m_toolTipManager, SLOT(hideTip()));
1298 }
1299
1300 m_topLayout->insertWidget(1, view);
1301
1302 connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
1303 this, SLOT(emitSelectionChangedSignal()));
1304 connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
1305 this, SLOT(emitContentsMoved()));
1306 connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1307 this, SLOT(emitContentsMoved()));
1308 }
1309
1310 void DolphinView::deleteView()
1311 {
1312 QAbstractItemView* view = itemView();
1313 if (view != 0) {
1314 // It's important to set the keyboard focus to the parent
1315 // before deleting the view: Otherwise when having a split
1316 // view the other view will get the focus and will request
1317 // an activation (see DolphinView::eventFilter()).
1318 setFocus();
1319
1320 m_topLayout->removeWidget(view);
1321 view->close();
1322
1323 disconnect(view);
1324 m_controller->disconnect(view);
1325 view->disconnect();
1326
1327 bool deleteView = true;
1328 foreach (const QAbstractItemView* expandedView, m_expandedViews) {
1329 if (view == expandedView) {
1330 // the current view got already expanded and must stay alive
1331 // until the dragging has been completed
1332 deleteView = false;
1333 break;
1334 }
1335 }
1336 if (deleteView) {
1337 view->deleteLater();
1338 }
1339 view = 0;
1340
1341 m_iconsView = 0;
1342 m_detailsView = 0;
1343 m_columnView = 0;
1344 m_fileItemDelegate = 0;
1345 m_previewGenerator = 0;
1346 m_toolTipManager = 0;
1347 }
1348 }
1349
1350 QAbstractItemView* DolphinView::itemView() const
1351 {
1352 if (m_detailsView != 0) {
1353 return m_detailsView;
1354 } else if (m_columnView != 0) {
1355 return m_columnView;
1356 }
1357
1358 return m_iconsView;
1359 }
1360
1361 bool DolphinView::isCutItem(const KFileItem& item) const
1362 {
1363 const QMimeData* mimeData = QApplication::clipboard()->mimeData();
1364 const KUrl::List cutUrls = KUrl::List::fromMimeData(mimeData);
1365
1366 const KUrl& itemUrl = item.url();
1367 KUrl::List::const_iterator it = cutUrls.begin();
1368 const KUrl::List::const_iterator end = cutUrls.end();
1369 while (it != end) {
1370 if (*it == itemUrl) {
1371 return true;
1372 }
1373 ++it;
1374 }
1375
1376 return false;
1377 }
1378
1379 void DolphinView::pasteToUrl(const KUrl& url)
1380 {
1381 QClipboard* clipboard = QApplication::clipboard();
1382 const QMimeData* mimeData = clipboard->mimeData();
1383
1384 const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
1385 if (KonqMimeData::decodeIsCutSelection(mimeData)) {
1386 KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url);
1387 clipboard->clear();
1388 } else {
1389 KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url);
1390 }
1391 }
1392
1393 void DolphinView::updateZoomLevel(int oldZoomLevel)
1394 {
1395 const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(itemView()->iconSize());
1396 if (oldZoomLevel != newZoomLevel) {
1397 m_controller->setZoomLevel(newZoomLevel);
1398 emit zoomLevelChanged(newZoomLevel);
1399 }
1400 }
1401
1402 KUrl::List DolphinView::simplifiedSelectedUrls() const
1403 {
1404 KUrl::List list = selectedUrls();
1405 if (itemsExpandable() ) {
1406 list = KonqOperations::simplifiedUrlList(list);
1407 }
1408 return list;
1409 }
1410
1411 void DolphinView::deleteExpandedViews()
1412 {
1413 const QAbstractItemView* view = itemView();
1414 foreach (QAbstractItemView* expandedView, m_expandedViews) {
1415 if (expandedView != view) {
1416 expandedView->deleteLater();
1417 }
1418 }
1419 m_expandedViews.clear();
1420 }
1421
1422 bool DolphinView::itemsExpandable() const
1423 {
1424 return (m_detailsView != 0) && m_detailsView->itemsExpandable();
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"