1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
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. *
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. *
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 ***************************************************************************/
21 #include "dolphinview.h"
23 #include <QApplication>
26 #include <QItemSelection>
31 #include <kdirmodel.h>
32 #include <kdirlister.h>
33 #include <kfileitemdelegate.h>
34 #include <kglobalsettings.h>
36 #include <kiconeffect.h>
37 #include <kio/netaccess.h>
38 #include <kio/renamedialog.h>
39 #include <kio/previewjob.h>
40 #include <kmimetyperesolver.h>
41 #include <konqmimedata.h>
42 #include <konq_operations.h>
45 #include "dolphincolumnview.h"
46 #include "dolphincontroller.h"
47 #include "dolphinsortfilterproxymodel.h"
48 #include "dolphindetailsview.h"
49 #include "dolphiniconsview.h"
50 #include "dolphinitemcategorizer.h"
51 #include "renamedialog.h"
52 #include "viewproperties.h"
53 #include "dolphinsettings.h"
54 #include "dolphin_generalsettings.h"
56 DolphinView::DolphinView(QWidget
* parent
,
58 KDirLister
* dirLister
,
60 DolphinSortFilterProxyModel
* proxyModel
,
64 m_loadingDirectory(false),
65 m_initializeColumnView(false),
72 m_fileItemDelegate(0),
74 m_dirLister(dirLister
),
75 m_proxyModel(proxyModel
)
77 setFocusPolicy(Qt::StrongFocus
);
78 m_topLayout
= new QVBoxLayout(this);
79 m_topLayout
->setSpacing(0);
80 m_topLayout
->setMargin(0);
82 QClipboard
* clipboard
= QApplication::clipboard();
83 connect(clipboard
, SIGNAL(dataChanged()),
84 this, SLOT(updateCutItems()));
86 connect(m_dirLister
, SIGNAL(completed()),
87 this, SLOT(updateCutItems()));
88 connect(m_dirLister
, SIGNAL(newItems(const KFileItemList
&)),
89 this, SLOT(generatePreviews(const KFileItemList
&)));
91 m_controller
= new DolphinController(this);
92 m_controller
->setUrl(url
);
93 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&)),
94 this, SLOT(openContextMenu(const QPoint
&)));
95 connect(m_controller
, SIGNAL(urlsDropped(const KUrl::List
&, const QModelIndex
&, QWidget
*)),
96 this, SLOT(dropUrls(const KUrl::List
&, const QModelIndex
&, QWidget
*)));
97 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
98 this, SLOT(updateSorting(DolphinView::Sorting
)));
99 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
100 this, SLOT(updateSortOrder(Qt::SortOrder
)));
101 connect(m_controller
, SIGNAL(itemTriggered(const QModelIndex
&)),
102 this, SLOT(triggerItem(const QModelIndex
&)));
103 connect(m_controller
, SIGNAL(activated()),
104 this, SLOT(activate()));
105 connect(m_controller
, SIGNAL(itemEntered(const QModelIndex
&)),
106 this, SLOT(showHoverInformation(const QModelIndex
&)));
107 connect(m_controller
, SIGNAL(viewportEntered()),
108 this, SLOT(clearHoverInformation()));
111 m_topLayout
->addWidget(itemView());
114 DolphinView::~DolphinView()
118 const KUrl
& DolphinView::url() const
120 return m_controller
->url();
123 KUrl
DolphinView::rootUrl() const
125 return isColumnViewActive() ? m_dirLister
->url() : url();
128 void DolphinView::setActive(bool active
)
130 if (active
== m_active
) {
136 QColor color
= KGlobalSettings::baseColor();
138 emit
urlChanged(url());
139 emit
selectionChanged(selectedItems());
144 QWidget
* viewport
= itemView()->viewport();
146 palette
.setColor(viewport
->backgroundRole(), color
);
147 viewport
->setPalette(palette
);
156 bool DolphinView::isActive() const
161 void DolphinView::setMode(Mode mode
)
163 if (mode
== m_mode
) {
164 return; // the wished mode is already set
169 if (isColumnViewActive()) {
170 // When changing the mode in the column view, it makes sense
171 // to go back to the root URL of the column view automatically.
172 // Otherwise there it would not be possible to turn off the column view
173 // without focusing the first column.
174 setUrl(m_dirLister
->url());
175 m_controller
->setUrl(m_dirLister
->url());
178 ViewProperties
props(url());
179 props
.setViewMode(m_mode
);
182 startDirLister(url());
187 DolphinView::Mode
DolphinView::mode() const
192 void DolphinView::setShowPreview(bool show
)
194 ViewProperties
props(url());
195 props
.setShowPreview(show
);
197 m_controller
->setShowPreview(show
);
198 emit
showPreviewChanged();
200 startDirLister(url(), true);
203 bool DolphinView::showPreview() const
205 return m_controller
->showPreview();
208 void DolphinView::setShowHiddenFiles(bool show
)
210 if (m_dirLister
->showingDotFiles() == show
) {
214 ViewProperties
props(url());
215 props
.setShowHiddenFiles(show
);
217 m_dirLister
->setShowingDotFiles(show
);
218 emit
showHiddenFilesChanged();
220 startDirLister(url(), true);
223 bool DolphinView::showHiddenFiles() const
225 return m_dirLister
->showingDotFiles();
228 void DolphinView::setCategorizedSorting(bool categorized
)
230 if (!supportsCategorizedSorting() || (categorized
== categorizedSorting())) {
234 Q_ASSERT(m_iconsView
!= 0);
236 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
237 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
239 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
240 m_iconsView
->setItemCategorizer(0);
244 ViewProperties
props(url());
245 props
.setCategorizedSorting(categorized
);
248 emit
categorizedSortingChanged();
251 bool DolphinView::categorizedSorting() const
253 if (!supportsCategorizedSorting()) {
257 Q_ASSERT(m_iconsView
!= 0);
258 return m_iconsView
->itemCategorizer() != 0;
261 bool DolphinView::supportsCategorizedSorting() const
263 return m_iconsView
!= 0;
266 void DolphinView::selectAll()
268 selectAll(QItemSelectionModel::Select
);
271 void DolphinView::invertSelection()
273 selectAll(QItemSelectionModel::Toggle
);
276 bool DolphinView::hasSelection() const
278 return itemView()->selectionModel()->hasSelection();
281 void DolphinView::clearSelection()
283 itemView()->selectionModel()->clear();
286 KFileItemList
DolphinView::selectedItems() const
288 const QAbstractItemView
* view
= itemView();
290 // Our view has a selection, we will map them back to the DirModel
291 // and then fill the KFileItemList.
292 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
294 const QItemSelection selection
= m_proxyModel
->mapSelectionToSource(view
->selectionModel()->selection());
295 KFileItemList itemList
;
297 const QModelIndexList indexList
= selection
.indexes();
298 QModelIndexList::const_iterator end
= indexList
.end();
299 for (QModelIndexList::const_iterator it
= indexList
.begin(); it
!= end
; ++it
) {
300 Q_ASSERT((*it
).isValid());
302 KFileItem
* item
= m_dirModel
->itemForIndex(*it
);
304 itemList
.append(item
);
311 KUrl::List
DolphinView::selectedUrls() const
315 const KFileItemList list
= selectedItems();
316 KFileItemList::const_iterator it
= list
.begin();
317 const KFileItemList::const_iterator end
= list
.end();
319 KFileItem
* item
= *it
;
320 urls
.append(item
->url());
327 KFileItem
* DolphinView::fileItem(const QModelIndex index
) const
329 const QModelIndex dirModelIndex
= m_proxyModel
->mapToSource(index
);
330 return m_dirModel
->itemForIndex(dirModelIndex
);
333 void DolphinView::setContentsPosition(int x
, int y
)
335 QAbstractItemView
* view
= itemView();
336 view
->horizontalScrollBar()->setValue(x
);
337 view
->verticalScrollBar()->setValue(y
);
339 m_loadingDirectory
= false;
342 QPoint
DolphinView::contentsPosition() const
344 const int x
= itemView()->horizontalScrollBar()->value();
345 const int y
= itemView()->verticalScrollBar()->value();
349 void DolphinView::zoomIn()
351 m_controller
->triggerZoomIn();
354 void DolphinView::zoomOut()
356 m_controller
->triggerZoomOut();
359 bool DolphinView::isZoomInPossible() const
361 return m_controller
->isZoomInPossible();
364 bool DolphinView::isZoomOutPossible() const
366 return m_controller
->isZoomOutPossible();
369 void DolphinView::setSorting(Sorting sorting
)
371 if (sorting
!= this->sorting()) {
372 updateSorting(sorting
);
376 DolphinView::Sorting
DolphinView::sorting() const
378 return m_proxyModel
->sorting();
381 void DolphinView::setSortOrder(Qt::SortOrder order
)
383 if (sortOrder() != order
) {
384 updateSortOrder(order
);
388 Qt::SortOrder
DolphinView::sortOrder() const
390 return m_proxyModel
->sortOrder();
393 void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation info
)
395 ViewProperties
props(url());
396 props
.setAdditionalInfo(info
);
398 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
399 m_fileItemDelegate
->setAdditionalInformation(info
);
401 emit
additionalInfoChanged(info
);
402 startDirLister(url(), true);
405 KFileItemDelegate::AdditionalInformation
DolphinView::additionalInfo() const
407 return m_fileItemDelegate
->additionalInformation();
410 void DolphinView::reload()
413 startDirLister(url(), true);
416 void DolphinView::refresh()
422 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
424 QWidget::mouseReleaseEvent(event
);
427 void DolphinView::activate()
432 void DolphinView::triggerItem(const QModelIndex
& index
)
434 if (!isValidNameIndex(index
)) {
436 showHoverInformation(index
);
440 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
441 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
442 // items are selected by the user, hence don't trigger the
443 // item specified by 'index'
447 KFileItem
* item
= m_dirModel
->itemForIndex(m_proxyModel
->mapToSource(index
));
452 // Prefer the local path over the URL. This assures that the
453 // volume space information is correct. Assuming that the URL is media:/sda1,
454 // and the local path is /windows/C: For the URL the space info is related
455 // to the root partition (and hence wrong) and for the local path the space
456 // info is related to the windows partition (-> correct).
457 const QString
localPath(item
->localPath());
459 if (localPath
.isEmpty()) {
467 } else if (item
->isFile()) {
468 // allow to browse through ZIP and tar files
469 KMimeType::Ptr mime
= item
->mimeTypePtr();
470 if (mime
->is("application/zip")) {
471 url
.setProtocol("zip");
473 } else if (mime
->is("application/x-tar") ||
474 mime
->is("application/x-tarz") ||
475 mime
->is("application/x-bzip-compressed-tar") ||
476 mime
->is("application/x-compressed-tar") ||
477 mime
->is("application/x-tzo")) {
478 url
.setProtocol("tar");
488 void DolphinView::generatePreviews(const KFileItemList
& items
)
490 if (m_controller
->showPreview()) {
492 // Must turn QList<KFileItem *> to QList<KFileItem>...
493 QList
<KFileItem
> itemsToPreview
;
494 foreach( KFileItem
* it
, items
)
495 itemsToPreview
.append( *it
);
497 KIO::PreviewJob
* job
= KIO::filePreview(itemsToPreview
, 128);
498 connect(job
, SIGNAL(gotPreview(const KFileItem
&, const QPixmap
&)),
499 this, SLOT(showPreview(const KFileItem
&, const QPixmap
&)));
503 void DolphinView::showPreview(const KFileItem
& item
, const QPixmap
& pixmap
)
505 Q_ASSERT(!item
.isNull());
506 if (item
.url().directory() != m_dirLister
->url().path()) {
507 // the preview job is still working on items of an older URL, hence
508 // the item is not part of the directory model anymore
512 const QModelIndex idx
= m_dirModel
->indexForItem(item
);
513 if (idx
.isValid() && (idx
.column() == 0)) {
514 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
515 if (KonqMimeData::decodeIsCutSelection(mimeData
) && isCutItem(item
)) {
516 KIconEffect iconEffect
;
517 const QPixmap cutPixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
518 m_dirModel
->setData(idx
, QIcon(cutPixmap
), Qt::DecorationRole
);
520 m_dirModel
->setData(idx
, QIcon(pixmap
), Qt::DecorationRole
);
525 void DolphinView::emitSelectionChangedSignal()
527 emit
selectionChanged(DolphinView::selectedItems());
530 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
532 if (!url
.isValid()) {
533 const QString
location(url
.pathOrUrl());
534 if (location
.isEmpty()) {
535 emit
errorMessage(i18n("The location is empty."));
537 emit
errorMessage(i18n("The location '%1' is invalid.", location
));
542 m_cutItemsCache
.clear();
543 m_loadingDirectory
= true;
548 bool keepOldDirs
= isColumnViewActive() && !m_initializeColumnView
;
549 m_initializeColumnView
= false;
555 const KUrl
& dirListerUrl
= m_dirLister
->url();
556 if (dirListerUrl
.isValid()) {
557 const KUrl::List dirs
= m_dirLister
->directories();
560 m_dirLister
->updateDirectory(url
);
564 } else if (m_dirLister
->directories().contains(url
)) {
565 // The dir lister contains the directory already, so
566 // KDirLister::openUrl() may not been invoked twice.
567 m_dirLister
->updateDirectory(url
);
570 const KUrl
& dirListerUrl
= m_dirLister
->url();
571 if ((dirListerUrl
== url
) || !m_dirLister
->url().isParentOf(url
)) {
572 // The current URL is not a child of the dir lister
573 // URL. This may happen when e. g. a bookmark has been selected
574 // and hence the view must be reset.
581 m_dirLister
->openUrl(url
, keepOldDirs
, reload
);
585 void DolphinView::setUrl(const KUrl
& url
)
587 if (m_controller
->url() == url
) {
591 m_controller
->setUrl(url
);
593 const ViewProperties
props(url
);
595 const Mode mode
= props
.viewMode();
596 bool changeMode
= (m_mode
!= mode
);
597 if (changeMode
&& isColumnViewActive()) {
598 // The column view is active. Only change the
599 // mode if the current URL is no child of the column view.
600 if (m_dirLister
->url().isParentOf(url
)) {
610 if (m_mode
== ColumnView
) {
611 // The mode has been changed to the Column View. When starting the dir
612 // lister with DolphinView::startDirLister() it is important to give a
613 // hint that the dir lister may not keep the current directory
614 // although this is the default for showing a hierarchy.
615 m_initializeColumnView
= true;
619 const bool showHiddenFiles
= props
.showHiddenFiles();
620 if (showHiddenFiles
!= m_dirLister
->showingDotFiles()) {
621 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
622 emit
showHiddenFilesChanged();
625 const bool categorized
= props
.categorizedSorting();
626 if (categorized
!= categorizedSorting()) {
627 if (supportsCategorizedSorting()) {
628 Q_ASSERT(m_iconsView
!= 0);
630 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
631 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
633 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
634 m_iconsView
->setItemCategorizer(0);
638 emit
categorizedSortingChanged();
641 const DolphinView::Sorting sorting
= props
.sorting();
642 if (sorting
!= m_proxyModel
->sorting()) {
643 m_proxyModel
->setSorting(sorting
);
644 emit
sortingChanged(sorting
);
647 const Qt::SortOrder sortOrder
= props
.sortOrder();
648 if (sortOrder
!= m_proxyModel
->sortOrder()) {
649 m_proxyModel
->setSortOrder(sortOrder
);
650 emit
sortOrderChanged(sortOrder
);
653 KFileItemDelegate::AdditionalInformation info
= props
.additionalInfo();
654 if (info
!= m_fileItemDelegate
->additionalInformation()) {
655 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
656 m_fileItemDelegate
->setAdditionalInformation(info
);
657 emit
additionalInfoChanged(info
);
660 const bool showPreview
= props
.showPreview();
661 if (showPreview
!= m_controller
->showPreview()) {
662 m_controller
->setShowPreview(showPreview
);
663 emit
showPreviewChanged();
667 emit
urlChanged(url
);
670 void DolphinView::changeSelection(const KFileItemList
& selection
)
673 if (selection
.isEmpty()) {
676 const KUrl
& baseUrl
= url();
678 QItemSelection new_selection
;
679 foreach(KFileItem
* item
, selection
) {
680 url
= item
->url().upUrl();
681 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
682 QModelIndex index
= m_proxyModel
->mapFromSource(m_dirModel
->indexForItem(*item
));
683 new_selection
.select(index
, index
);
686 itemView()->selectionModel()->select(new_selection
,
687 QItemSelectionModel::ClearAndSelect
688 | QItemSelectionModel::Current
);
691 void DolphinView::openContextMenu(const QPoint
& pos
)
695 const QModelIndex index
= itemView()->indexAt(pos
);
696 if (isValidNameIndex(index
)) {
697 item
= fileItem(index
);
700 emit
requestContextMenu(item
, url());
703 void DolphinView::dropUrls(const KUrl::List
& urls
,
704 const QModelIndex
& index
,
707 KFileItem
* directory
= 0;
708 if (isValidNameIndex(index
)) {
709 KFileItem
* item
= fileItem(index
);
712 // the URLs are dropped above a directory
717 if ((directory
== 0) && (source
== itemView())) {
718 // The dropping is done into the same viewport where
719 // the dragging has been started. Just ignore this...
723 const KUrl
& destination
= (directory
== 0) ?
724 url() : directory
->url();
725 dropUrls(urls
, destination
);
728 void DolphinView::dropUrls(const KUrl::List
& urls
,
729 const KUrl
& destination
)
731 emit
urlsDropped(urls
, destination
);
734 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
736 ViewProperties
props(url());
737 props
.setSorting(sorting
);
739 m_proxyModel
->setSorting(sorting
);
741 emit
sortingChanged(sorting
);
744 void DolphinView::updateSortOrder(Qt::SortOrder order
)
746 ViewProperties
props(url());
747 props
.setSortOrder(order
);
749 m_proxyModel
->setSortOrder(order
);
751 emit
sortOrderChanged(order
);
754 void DolphinView::emitContentsMoved()
756 // only emit the contents moved signal if:
757 // - no directory loading is ongoing (this would reset the contents position
759 // - if the Column View is active: the column view does an automatic
760 // positioning during the loading operation, which must be remembered
761 if (!m_loadingDirectory
|| isColumnViewActive()) {
762 const QPoint
pos(contentsPosition());
763 emit
contentsMoved(pos
.x(), pos
.y());
767 void DolphinView::updateCutItems()
769 // restore the icons of all previously selected items to the
771 QList
<CutItem
>::const_iterator it
= m_cutItemsCache
.begin();
772 QList
<CutItem
>::const_iterator end
= m_cutItemsCache
.end();
774 const QModelIndex index
= m_dirModel
->indexForUrl((*it
).url
);
775 if (index
.isValid()) {
776 m_dirModel
->setData(index
, QIcon((*it
).pixmap
), Qt::DecorationRole
);
780 m_cutItemsCache
.clear();
782 // ... and apply an item effect to all currently cut items
783 applyCutItemEffect();
786 void DolphinView::showHoverInformation(const QModelIndex
& index
)
788 if (hasSelection()) {
792 const KFileItem
* item
= fileItem(index
);
794 emit
requestItemInfo(item
->url());
798 void DolphinView::clearHoverInformation()
800 emit
requestItemInfo(KUrl());
804 void DolphinView::createView()
806 // delete current view
807 QAbstractItemView
* view
= itemView();
809 m_topLayout
->removeWidget(view
);
811 if (view
== m_iconsView
) {
812 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
813 m_iconsView
->setItemCategorizer(0);
821 m_fileItemDelegate
= 0;
824 Q_ASSERT(m_iconsView
== 0);
825 Q_ASSERT(m_detailsView
== 0);
826 Q_ASSERT(m_columnView
== 0);
828 // ... and recreate it representing the current mode
831 m_iconsView
= new DolphinIconsView(this, m_controller
);
836 m_detailsView
= new DolphinDetailsView(this, m_controller
);
837 view
= m_detailsView
;
841 m_columnView
= new DolphinColumnView(this, m_controller
);
848 m_fileItemDelegate
= new KFileItemDelegate(view
);
849 view
->setItemDelegate(m_fileItemDelegate
);
851 view
->setModel(m_proxyModel
);
852 view
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
854 new KMimeTypeResolver(view
, m_dirModel
);
855 m_topLayout
->insertWidget(1, view
);
857 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
858 this, SLOT(emitSelectionChangedSignal()));
859 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
860 this, SLOT(emitContentsMoved()));
861 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
862 this, SLOT(emitContentsMoved()));
865 void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags
)
867 QItemSelectionModel
* selectionModel
= itemView()->selectionModel();
868 const QAbstractItemModel
* itemModel
= selectionModel
->model();
870 const QModelIndex topLeft
= itemModel
->index(0, 0);
871 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
872 itemModel
->columnCount() - 1);
874 QItemSelection
selection(topLeft
, bottomRight
);
875 selectionModel
->select(selection
, flags
);
878 QAbstractItemView
* DolphinView::itemView() const
880 if (m_detailsView
!= 0) {
881 return m_detailsView
;
882 } else if (m_columnView
!= 0) {
889 bool DolphinView::isValidNameIndex(const QModelIndex
& index
) const
891 return index
.isValid() && (index
.column() == KDirModel::Name
);
894 bool DolphinView::isCutItem(const KFileItem
& item
) const
896 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
897 const KUrl::List cutUrls
= KUrl::List::fromMimeData(mimeData
);
899 const KUrl
& itemUrl
= item
.url();
900 KUrl::List::const_iterator it
= cutUrls
.begin();
901 const KUrl::List::const_iterator end
= cutUrls
.end();
903 if (*it
== itemUrl
) {
912 void DolphinView::applyCutItemEffect()
914 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
915 if (!KonqMimeData::decodeIsCutSelection(mimeData
)) {
919 KFileItemList
items(m_dirLister
->items());
920 KFileItemList::const_iterator it
= items
.begin();
921 const KFileItemList::const_iterator end
= items
.end();
923 KFileItem
* item
= *it
;
924 if (isCutItem(*item
)) {
925 const QModelIndex index
= m_dirModel
->indexForItem(*item
);
926 const KFileItem
* item
= m_dirModel
->itemForIndex(index
);
927 const QVariant value
= m_dirModel
->data(index
, Qt::DecorationRole
);
928 if ((value
.type() == QVariant::Icon
) && (item
!= 0)) {
929 const QIcon
icon(qvariant_cast
<QIcon
>(value
));
930 QPixmap pixmap
= icon
.pixmap(128, 128);
932 // remember current pixmap for the item to be able
933 // to restore it when other items get cut
935 cutItem
.url
= item
->url();
936 cutItem
.pixmap
= pixmap
;
937 m_cutItemsCache
.append(cutItem
);
939 // apply icon effect to the cut item
940 KIconEffect iconEffect
;
941 pixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
942 m_dirModel
->setData(index
, QIcon(pixmap
), Qt::DecorationRole
);
949 #include "dolphinview.moc"