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