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