]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinview.cpp
assure that the size hint calculation and the painting code are consistent
[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 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 const QList<QAction*>& customActions)
916 {
917 KFileItem item;
918 if (isColumnViewActive()) {
919 item = m_columnView->itemAt(pos);
920 } else {
921 const QModelIndex index = itemView()->indexAt(pos);
922 if (index.isValid() && (index.column() == DolphinModel::Name)) {
923 const QModelIndex dolphinModelIndex = m_proxyModel->mapToSource(index);
924 item = m_dolphinModel->itemForIndex(dolphinModelIndex);
925 }
926 }
927
928 if (m_toolTipManager != 0) {
929 m_toolTipManager->hideTip();
930 }
931
932 m_isContextMenuOpen = true; // TODO: workaround for Qt-issue 207192
933 emit requestContextMenu(item, url(), customActions);
934 m_isContextMenuOpen = false;
935 }
936
937 void DolphinView::dropUrls(const KFileItem& destItem,
938 const KUrl& destPath,
939 QDropEvent* event)
940 {
941 DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
942 }
943
944 void DolphinView::updateSorting(DolphinView::Sorting sorting)
945 {
946 ViewProperties props(viewPropertiesUrl());
947 props.setSorting(sorting);
948
949 m_proxyModel->setSorting(sorting);
950
951 emit sortingChanged(sorting);
952 }
953
954 void DolphinView::updateSortOrder(Qt::SortOrder order)
955 {
956 ViewProperties props(viewPropertiesUrl());
957 props.setSortOrder(order);
958
959 m_proxyModel->setSortOrder(order);
960
961 emit sortOrderChanged(order);
962 }
963
964 void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& info)
965 {
966 ViewProperties props(viewPropertiesUrl());
967 props.setAdditionalInfo(info);
968 props.save();
969
970 m_fileItemDelegate->setShowInformation(info);
971
972 emit additionalInfoChanged();
973 }
974
975 void DolphinView::updateAdditionalInfoActions(KActionCollection* collection)
976 {
977 const bool enable = (m_mode == DolphinView::DetailsView) ||
978 (m_mode == DolphinView::IconsView);
979
980 QAction* showSizeInfo = collection->action("show_size_info");
981 QAction* showDateInfo = collection->action("show_date_info");
982 QAction* showPermissionsInfo = collection->action("show_permissions_info");
983 QAction* showOwnerInfo = collection->action("show_owner_info");
984 QAction* showGroupInfo = collection->action("show_group_info");
985 QAction* showMimeInfo = collection->action("show_mime_info");
986
987 showSizeInfo->setChecked(false);
988 showDateInfo->setChecked(false);
989 showPermissionsInfo->setChecked(false);
990 showOwnerInfo->setChecked(false);
991 showGroupInfo->setChecked(false);
992 showMimeInfo->setChecked(false);
993
994 showSizeInfo->setEnabled(enable);
995 showDateInfo->setEnabled(enable);
996 showPermissionsInfo->setEnabled(enable);
997 showOwnerInfo->setEnabled(enable);
998 showGroupInfo->setEnabled(enable);
999 showMimeInfo->setEnabled(enable);
1000
1001 foreach (KFileItemDelegate::Information info, m_fileItemDelegate->showInformation()) {
1002 switch (info) {
1003 case KFileItemDelegate::Size:
1004 showSizeInfo->setChecked(true);
1005 break;
1006 case KFileItemDelegate::ModificationTime:
1007 showDateInfo->setChecked(true);
1008 break;
1009 case KFileItemDelegate::Permissions:
1010 showPermissionsInfo->setChecked(true);
1011 break;
1012 case KFileItemDelegate::Owner:
1013 showOwnerInfo->setChecked(true);
1014 break;
1015 case KFileItemDelegate::OwnerAndGroup:
1016 showGroupInfo->setChecked(true);
1017 break;
1018 case KFileItemDelegate::FriendlyMimeType:
1019 showMimeInfo->setChecked(true);
1020 break;
1021 default:
1022 break;
1023 }
1024 }
1025 }
1026
1027 QPair<bool, QString> DolphinView::pasteInfo() const
1028 {
1029 QPair<bool, QString> ret;
1030 QClipboard* clipboard = QApplication::clipboard();
1031 const QMimeData* mimeData = clipboard->mimeData();
1032
1033 KUrl::List urls = KUrl::List::fromMimeData(mimeData);
1034 if (!urls.isEmpty()) {
1035 // disable the paste action if no writing is supported
1036 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url());
1037 ret.first = KonqFileItemCapabilities(KFileItemList() << item).supportsWriting();
1038
1039 if (urls.count() == 1) {
1040 const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(), true);
1041 ret.second = item.isDir() ? i18nc("@action:inmenu", "Paste One Folder") :
1042 i18nc("@action:inmenu", "Paste One File");
1043
1044 } else {
1045 ret.second = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count());
1046 }
1047 } else {
1048 ret.first = false;
1049 ret.second = i18nc("@action:inmenu", "Paste");
1050 }
1051
1052 return ret;
1053 }
1054
1055 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
1056 {
1057 m_tabsForFiles = tabsForFiles;
1058 }
1059
1060 bool DolphinView::isTabsForFilesEnabled() const
1061 {
1062 return m_tabsForFiles;
1063 }
1064
1065 bool DolphinView::itemsExpandable() const
1066 {
1067 return (m_detailsView != 0) && m_detailsView->itemsExpandable();
1068 }
1069
1070 void DolphinView::deleteWhenNotDragSource(QAbstractItemView *view)
1071 {
1072 if (view == 0)
1073 return;
1074
1075 if (DragAndDropHelper::instance().isDragSource(view)) {
1076 kDebug() << "Is current drag source";
1077 // We must store for later deletion.
1078 if (m_expandedDragSource != 0) {
1079 // The old stored view is obviously not the drag source anymore.
1080 kDebug() << "Deleted old view " << m_expandedDragSource;
1081 m_expandedDragSource->deleteLater();
1082 m_expandedDragSource = 0;
1083 }
1084 view->hide();
1085 m_expandedDragSource = view;
1086 }
1087 else {
1088 kDebug() << "Deleted new view " << view;
1089 view->deleteLater();
1090 }
1091 }
1092
1093 void DolphinView::emitContentsMoved()
1094 {
1095 // only emit the contents moved signal if:
1096 // - no directory loading is ongoing (this would reset the contents position
1097 // always to (0, 0))
1098 // - if the Column View is active: the column view does an automatic
1099 // positioning during the loading operation, which must be remembered
1100 if (!m_loadingDirectory || isColumnViewActive()) {
1101 const QPoint pos(contentsPosition());
1102 emit contentsMoved(pos.x(), pos.y());
1103 }
1104 }
1105
1106 void DolphinView::showHoverInformation(const KFileItem& item)
1107 {
1108 emit requestItemInfo(item);
1109 }
1110
1111 void DolphinView::clearHoverInformation()
1112 {
1113 emit requestItemInfo(KFileItem());
1114 }
1115
1116 void DolphinView::slotDeleteFileFinished(KJob* job)
1117 {
1118 if (job->error() == 0) {
1119 emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1120 } else if (job->error() != KIO::ERR_USER_CANCELED) {
1121 emit errorMessage(job->errorString());
1122 }
1123 }
1124
1125 void DolphinView::slotRequestUrlChange(const KUrl& url)
1126 {
1127 emit requestUrlChange(url);
1128 m_controller->setUrl(url);
1129 }
1130
1131 void DolphinView::restoreCurrentItem()
1132 {
1133 const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl);
1134 if (dirIndex.isValid()) {
1135 const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
1136 QAbstractItemView* view = itemView();
1137 const bool clearSelection = !hasSelection();
1138 view->setCurrentIndex(proxyIndex);
1139 if (clearSelection) {
1140 view->clearSelection();
1141 }
1142 }
1143 }
1144
1145 void DolphinView::loadDirectory(const KUrl& url, bool reload)
1146 {
1147 if (!url.isValid()) {
1148 const QString location(url.pathOrUrl());
1149 if (location.isEmpty()) {
1150 emit errorMessage(i18nc("@info:status", "The location is empty."));
1151 } else {
1152 emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
1153 }
1154 return;
1155 }
1156
1157 m_loadingDirectory = true;
1158
1159 m_dirLister->stop();
1160 m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
1161
1162 if (isColumnViewActive()) {
1163 // adjusting the directory lister is not enough in the case of the
1164 // column view, as each column has its own directory lister internally...
1165 if (reload) {
1166 m_columnView->reload();
1167 } else {
1168 m_columnView->showColumn(url);
1169 }
1170 }
1171 }
1172
1173 KUrl DolphinView::viewPropertiesUrl() const
1174 {
1175 if (isColumnViewActive()) {
1176 return m_columnView->rootUrl();
1177 }
1178
1179 return url();
1180 }
1181
1182 void DolphinView::applyViewProperties(const KUrl& url)
1183 {
1184 if (m_ignoreViewProperties) {
1185 return;
1186 }
1187
1188 if (isColumnViewActive() && rootUrl().isParentOf(url)) {
1189 // The column view is active, hence don't apply the view properties
1190 // of sub directories (represented by columns) to the view. The
1191 // view always represents the properties of the first column.
1192 return;
1193 }
1194
1195 const ViewProperties props(url);
1196
1197 const Mode mode = props.viewMode();
1198 if (m_mode != mode) {
1199 const int oldZoomLevel = m_controller->zoomLevel();
1200
1201 m_mode = mode;
1202 createView();
1203 emit modeChanged();
1204
1205 updateZoomLevel(oldZoomLevel);
1206 }
1207 if (itemView() == 0) {
1208 createView();
1209 }
1210 Q_ASSERT(itemView() != 0);
1211 Q_ASSERT(m_fileItemDelegate != 0);
1212
1213 const bool showHiddenFiles = props.showHiddenFiles();
1214 if (showHiddenFiles != m_dirLister->showingDotFiles()) {
1215 m_dirLister->setShowingDotFiles(showHiddenFiles);
1216 emit showHiddenFilesChanged();
1217 }
1218
1219 m_storedCategorizedSorting = props.categorizedSorting();
1220 const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
1221 if (categorized != m_proxyModel->isCategorizedModel()) {
1222 m_proxyModel->setCategorizedModel(categorized);
1223 emit categorizedSortingChanged();
1224 }
1225
1226 const DolphinView::Sorting sorting = props.sorting();
1227 if (sorting != m_proxyModel->sorting()) {
1228 m_proxyModel->setSorting(sorting);
1229 emit sortingChanged(sorting);
1230 }
1231
1232 const Qt::SortOrder sortOrder = props.sortOrder();
1233 if (sortOrder != m_proxyModel->sortOrder()) {
1234 m_proxyModel->setSortOrder(sortOrder);
1235 emit sortOrderChanged(sortOrder);
1236 }
1237
1238 KFileItemDelegate::InformationList info = props.additionalInfo();
1239 if (info != m_fileItemDelegate->showInformation()) {
1240 m_fileItemDelegate->setShowInformation(info);
1241 emit additionalInfoChanged();
1242 }
1243
1244 const bool showPreview = props.showPreview();
1245 if (showPreview != m_showPreview) {
1246 m_showPreview = showPreview;
1247 m_previewGenerator->setPreviewShown(showPreview);
1248
1249 const int oldZoomLevel = m_controller->zoomLevel();
1250 emit showPreviewChanged();
1251
1252 // Enabling or disabling the preview might change the icon size of the view.
1253 // As the view does not emit a signal when the icon size has been changed,
1254 // the used zoom level of the controller must be adjusted manually:
1255 updateZoomLevel(oldZoomLevel);
1256 }
1257
1258 if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
1259 // During the lifetime of a DolphinView instance the global view properties
1260 // should not be changed. This allows e. g. to split a view and use different
1261 // view properties for each view.
1262 m_ignoreViewProperties = true;
1263 }
1264 }
1265
1266 void DolphinView::createView()
1267 {
1268 deleteView();
1269 Q_ASSERT(m_iconsView == 0);
1270 Q_ASSERT(m_detailsView == 0);
1271 Q_ASSERT(m_columnView == 0);
1272
1273 QAbstractItemView* view = 0;
1274 switch (m_mode) {
1275 case IconsView: {
1276 m_iconsView = new DolphinIconsView(this, m_controller);
1277 view = m_iconsView;
1278 break;
1279 }
1280
1281 case DetailsView:
1282 m_detailsView = new DolphinDetailsView(this, m_controller);
1283 view = m_detailsView;
1284 break;
1285
1286 case ColumnView:
1287 m_columnView = new DolphinColumnView(this, m_controller);
1288 view = m_columnView;
1289 break;
1290 }
1291
1292 Q_ASSERT(view != 0);
1293 view->installEventFilter(this);
1294 view->viewport()->installEventFilter(this);
1295 setFocusProxy(view);
1296
1297 if (m_mode != ColumnView) {
1298 // Give the view the ability to auto-expand its directories on hovering
1299 // (the column view takes care about this itself). If the details view
1300 // uses expandable folders, the auto-expanding should be used always.
1301 DolphinSettings& settings = DolphinSettings::instance();
1302 const bool enabled = settings.generalSettings()->autoExpandFolders() ||
1303 ((m_detailsView != 0) && settings.detailsModeSettings()->expandableFolders());
1304
1305 FolderExpander* folderExpander = new FolderExpander(view, m_proxyModel);
1306 folderExpander->setEnabled(enabled);
1307 connect(folderExpander, SIGNAL(enterDir(const QModelIndex&)),
1308 m_controller, SLOT(triggerItem(const QModelIndex&)));
1309 }
1310 else {
1311 // Listen out for requests to delete the current column.
1312 connect(m_columnView, SIGNAL(requestColumnDeletion(QAbstractItemView*)),
1313 this, SLOT(deleteWhenNotDragSource(QAbstractItemView*)));
1314 }
1315
1316 m_controller->setItemView(view);
1317
1318 m_fileItemDelegate = new DolphinFileItemDelegate(view);
1319 m_fileItemDelegate->setShowToolTipWhenElided(false);
1320 m_fileItemDelegate->setMinimizedNameColumn(m_mode == DetailsView);
1321 view->setItemDelegate(m_fileItemDelegate);
1322
1323 view->setModel(m_proxyModel);
1324 if (m_selectionModel != 0) {
1325 view->setSelectionModel(m_selectionModel);
1326 } else {
1327 m_selectionModel = view->selectionModel();
1328 }
1329
1330 // reparent the selection model, as it should not be deleted
1331 // when deleting the model
1332 m_selectionModel->setParent(this);
1333
1334 view->setSelectionMode(QAbstractItemView::ExtendedSelection);
1335
1336 m_previewGenerator = new KFilePreviewGenerator(view);
1337 m_previewGenerator->setPreviewShown(m_showPreview);
1338
1339 if (DolphinSettings::instance().generalSettings()->showToolTips()) {
1340 m_toolTipManager = new ToolTipManager(view, m_proxyModel);
1341 connect(m_controller, SIGNAL(hideToolTip()),
1342 m_toolTipManager, SLOT(hideTip()));
1343 }
1344
1345 m_topLayout->insertWidget(1, view);
1346
1347 connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
1348 this, SLOT(emitSelectionChangedSignal()));
1349 connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
1350 this, SLOT(emitContentsMoved()));
1351 connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
1352 this, SLOT(emitContentsMoved()));
1353 }
1354
1355 void DolphinView::deleteView()
1356 {
1357 QAbstractItemView* view = itemView();
1358 if (view != 0) {
1359 // It's important to set the keyboard focus to the parent
1360 // before deleting the view: Otherwise when having a split
1361 // view the other view will get the focus and will request
1362 // an activation (see DolphinView::eventFilter()).
1363 setFocusProxy(0);
1364 setFocus();
1365
1366 m_topLayout->removeWidget(view);
1367 view->close();
1368
1369 // m_previewGenerator's parent is not always destroyed, and we
1370 // don't want two active at once - manually delete.
1371 delete m_previewGenerator;
1372 m_previewGenerator = 0;
1373
1374 disconnect(view);
1375 m_controller->disconnect(view);
1376 view->disconnect();
1377
1378 deleteWhenNotDragSource(view);
1379 view = 0;
1380
1381 m_iconsView = 0;
1382 m_detailsView = 0;
1383 m_columnView = 0;
1384 m_fileItemDelegate = 0;
1385 m_toolTipManager = 0;
1386 }
1387 }
1388
1389 QAbstractItemView* DolphinView::itemView() const
1390 {
1391 if (m_detailsView != 0) {
1392 return m_detailsView;
1393 } else if (m_columnView != 0) {
1394 return m_columnView;
1395 }
1396
1397 return m_iconsView;
1398 }
1399
1400 bool DolphinView::isCutItem(const KFileItem& item) const
1401 {
1402 const QMimeData* mimeData = QApplication::clipboard()->mimeData();
1403 const KUrl::List cutUrls = KUrl::List::fromMimeData(mimeData);
1404
1405 const KUrl& itemUrl = item.url();
1406 KUrl::List::const_iterator it = cutUrls.begin();
1407 const KUrl::List::const_iterator end = cutUrls.end();
1408 while (it != end) {
1409 if (*it == itemUrl) {
1410 return true;
1411 }
1412 ++it;
1413 }
1414
1415 return false;
1416 }
1417
1418 void DolphinView::pasteToUrl(const KUrl& url)
1419 {
1420 QClipboard* clipboard = QApplication::clipboard();
1421 const QMimeData* mimeData = clipboard->mimeData();
1422
1423 const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
1424 if (KonqMimeData::decodeIsCutSelection(mimeData)) {
1425 KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url);
1426 clipboard->clear();
1427 } else {
1428 KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url);
1429 }
1430 }
1431
1432 void DolphinView::updateZoomLevel(int oldZoomLevel)
1433 {
1434 const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(itemView()->iconSize());
1435 if (oldZoomLevel != newZoomLevel) {
1436 m_controller->setZoomLevel(newZoomLevel);
1437 emit zoomLevelChanged(newZoomLevel);
1438 }
1439 }
1440
1441 KUrl::List DolphinView::simplifiedSelectedUrls() const
1442 {
1443 KUrl::List list = selectedUrls();
1444 if (itemsExpandable() ) {
1445 list = KDirModel::simplifiedUrlList(list);
1446 }
1447 return list;
1448 }
1449
1450 QMimeData* DolphinView::selectionMimeData() const
1451 {
1452 if (isColumnViewActive()) {
1453 return m_columnView->selectionMimeData();
1454 }
1455
1456 const QAbstractItemView* view = itemView();
1457 Q_ASSERT((view != 0) && (view->selectionModel() != 0));
1458 const QItemSelection selection = m_proxyModel->mapSelectionToSource(view->selectionModel()->selection());
1459 return m_dolphinModel->mimeData(selection.indexes());
1460 }
1461
1462 #include "dolphinview.moc"