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_blockContentsMovedSignal(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(restoreContentsPos()));
88 connect(m_dirLister
, SIGNAL(completed()),
89 this, SLOT(updateCutItems()));
90 connect(m_dirLister
, SIGNAL(newItems(const KFileItemList
&)),
91 this, SLOT(generatePreviews(const KFileItemList
&)));
93 m_controller
= new DolphinController(this);
94 m_controller
->setUrl(url
);
95 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&)),
96 this, SLOT(openContextMenu(const QPoint
&)));
97 connect(m_controller
, SIGNAL(urlsDropped(const KUrl::List
&, const QModelIndex
&, QWidget
*)),
98 this, SLOT(dropUrls(const KUrl::List
&, const QModelIndex
&, QWidget
*)));
99 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
100 this, SLOT(updateSorting(DolphinView::Sorting
)));
101 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
102 this, SLOT(updateSortOrder(Qt::SortOrder
)));
103 connect(m_controller
, SIGNAL(itemTriggered(const QModelIndex
&)),
104 this, SLOT(triggerItem(const QModelIndex
&)));
105 connect(m_controller
, SIGNAL(activated()),
106 this, SLOT(activate()));
107 connect(m_controller
, SIGNAL(itemEntered(const QModelIndex
&)),
108 this, SLOT(showHoverInformation(const QModelIndex
&)));
109 connect(m_controller
, SIGNAL(viewportEntered()),
110 this, SLOT(clearHoverInformation()));
113 m_topLayout
->addWidget(itemView());
116 DolphinView::~DolphinView()
120 const KUrl
& DolphinView::url() const
122 return m_controller
->url();
125 KUrl
DolphinView::rootUrl() const
127 return isColumnViewActive() ? m_dirLister
->url() : url();
130 void DolphinView::setActive(bool active
)
132 if (active
== m_active
) {
138 QColor color
= KGlobalSettings::baseColor();
140 emit
urlChanged(url());
141 emit
selectionChanged(selectedItems());
146 QWidget
* viewport
= itemView()->viewport();
148 palette
.setColor(viewport
->backgroundRole(), color
);
149 viewport
->setPalette(palette
);
158 bool DolphinView::isActive() const
163 void DolphinView::setMode(Mode mode
)
165 if (mode
== m_mode
) {
166 return; // the wished mode is already set
171 if (isColumnViewActive()) {
172 // When changing the mode in the column view, it makes sense
173 // to go back to the root URL of the column view automatically.
174 // Otherwise there it would not be possible to turn off the column view
175 // without focusing the first column.
176 // TODO: reactivate again after DolphinView/DolphinViewController split works
177 //setUrl(m_dirLister->url());
178 //m_controller->setUrl(m_dirLister->url());
181 ViewProperties
props(url());
182 props
.setViewMode(m_mode
);
185 startDirLister(url());
190 DolphinView::Mode
DolphinView::mode() const
195 void DolphinView::setShowPreview(bool show
)
197 ViewProperties
props(url());
198 props
.setShowPreview(show
);
200 m_controller
->setShowPreview(show
);
201 emit
showPreviewChanged();
203 startDirLister(url(), true);
206 bool DolphinView::showPreview() const
208 return m_controller
->showPreview();
211 void DolphinView::setShowHiddenFiles(bool show
)
213 if (m_dirLister
->showingDotFiles() == show
) {
217 ViewProperties
props(url());
218 props
.setShowHiddenFiles(show
);
220 m_dirLister
->setShowingDotFiles(show
);
221 emit
showHiddenFilesChanged();
223 startDirLister(url(), true);
226 bool DolphinView::showHiddenFiles() const
228 return m_dirLister
->showingDotFiles();
231 void DolphinView::setCategorizedSorting(bool categorized
)
233 if (!supportsCategorizedSorting() || (categorized
== categorizedSorting())) {
237 Q_ASSERT(m_iconsView
!= 0);
239 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
240 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
242 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
243 m_iconsView
->setItemCategorizer(0);
247 ViewProperties
props(url());
248 props
.setCategorizedSorting(categorized
);
251 emit
categorizedSortingChanged();
254 bool DolphinView::categorizedSorting() const
256 if (!supportsCategorizedSorting()) {
260 Q_ASSERT(m_iconsView
!= 0);
261 return m_iconsView
->itemCategorizer() != 0;
264 bool DolphinView::supportsCategorizedSorting() const
266 return m_iconsView
!= 0;
269 void DolphinView::selectAll()
271 selectAll(QItemSelectionModel::Select
);
274 void DolphinView::invertSelection()
276 selectAll(QItemSelectionModel::Toggle
);
279 int DolphinView::contentsX() const
281 return itemView()->horizontalScrollBar()->value();
284 int DolphinView::contentsY() const
286 return itemView()->verticalScrollBar()->value();
289 void DolphinView::zoomIn()
291 m_controller
->triggerZoomIn();
294 void DolphinView::zoomOut()
296 m_controller
->triggerZoomOut();
299 bool DolphinView::isZoomInPossible() const
301 return m_controller
->isZoomInPossible();
304 bool DolphinView::isZoomOutPossible() const
306 return m_controller
->isZoomOutPossible();
309 void DolphinView::setSorting(Sorting sorting
)
311 if (sorting
!= this->sorting()) {
312 updateSorting(sorting
);
316 DolphinView::Sorting
DolphinView::sorting() const
318 return m_proxyModel
->sorting();
321 void DolphinView::setSortOrder(Qt::SortOrder order
)
323 if (sortOrder() != order
) {
324 updateSortOrder(order
);
328 Qt::SortOrder
DolphinView::sortOrder() const
330 return m_proxyModel
->sortOrder();
333 void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation info
)
335 ViewProperties
props(url());
336 props
.setAdditionalInfo(info
);
338 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
339 m_fileItemDelegate
->setAdditionalInformation(info
);
341 emit
additionalInfoChanged(info
);
342 startDirLister(url(), true);
345 KFileItemDelegate::AdditionalInformation
DolphinView::additionalInfo() const
347 return m_fileItemDelegate
->additionalInformation();
350 bool DolphinView::hasSelection() const
352 return itemView()->selectionModel()->hasSelection();
355 void DolphinView::clearSelection()
357 itemView()->selectionModel()->clear();
360 KFileItemList
DolphinView::selectedItems() const
362 const QAbstractItemView
* view
= itemView();
364 // Our view has a selection, we will map them back to the DirModel
365 // and then fill the KFileItemList.
366 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
368 const QItemSelection selection
= m_proxyModel
->mapSelectionToSource(view
->selectionModel()->selection());
369 KFileItemList itemList
;
371 const QModelIndexList indexList
= selection
.indexes();
372 QModelIndexList::const_iterator end
= indexList
.end();
373 for (QModelIndexList::const_iterator it
= indexList
.begin(); it
!= end
; ++it
) {
374 Q_ASSERT((*it
).isValid());
376 KFileItem
* item
= m_dirModel
->itemForIndex(*it
);
378 itemList
.append(item
);
385 KUrl::List
DolphinView::selectedUrls() const
389 const KFileItemList list
= selectedItems();
390 KFileItemList::const_iterator it
= list
.begin();
391 const KFileItemList::const_iterator end
= list
.end();
393 KFileItem
* item
= *it
;
394 urls
.append(item
->url());
401 KFileItem
* DolphinView::fileItem(const QModelIndex index
) const
403 const QModelIndex dirModelIndex
= m_proxyModel
->mapToSource(index
);
404 return m_dirModel
->itemForIndex(dirModelIndex
);
407 void DolphinView::reload()
410 startDirLister(url(), true);
413 void DolphinView::refresh()
419 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
421 QWidget::mouseReleaseEvent(event
);
424 void DolphinView::activate()
429 void DolphinView::triggerItem(const QModelIndex
& index
)
431 if (!isValidNameIndex(index
)) {
433 showHoverInformation(index
);
437 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
438 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
439 // items are selected by the user, hence don't trigger the
440 // item specified by 'index'
444 KFileItem
* item
= m_dirModel
->itemForIndex(m_proxyModel
->mapToSource(index
));
449 // Prefer the local path over the URL. This assures that the
450 // volume space information is correct. Assuming that the URL is media:/sda1,
451 // and the local path is /windows/C: For the URL the space info is related
452 // to the root partition (and hence wrong) and for the local path the space
453 // info is related to the windows partition (-> correct).
454 const QString
localPath(item
->localPath());
456 if (localPath
.isEmpty()) {
464 } else if (item
->isFile()) {
465 // allow to browse through ZIP and tar files
466 KMimeType::Ptr mime
= item
->mimeTypePtr();
467 if (mime
->is("application/zip")) {
468 url
.setProtocol("zip");
470 } else if (mime
->is("application/x-tar") ||
471 mime
->is("application/x-tarz") ||
472 mime
->is("application/x-bzip-compressed-tar") ||
473 mime
->is("application/x-compressed-tar") ||
474 mime
->is("application/x-tzo")) {
475 url
.setProtocol("tar");
485 void DolphinView::generatePreviews(const KFileItemList
& items
)
487 if (m_controller
->showPreview()) {
489 // Must turn QList<KFileItem *> to QList<KFileItem>...
490 QList
<KFileItem
> itemsToPreview
;
491 foreach( KFileItem
* it
, items
)
492 itemsToPreview
.append( *it
);
494 KIO::PreviewJob
* job
= KIO::filePreview(itemsToPreview
, 128);
495 connect(job
, SIGNAL(gotPreview(const KFileItem
&, const QPixmap
&)),
496 this, SLOT(showPreview(const KFileItem
&, const QPixmap
&)));
500 void DolphinView::showPreview(const KFileItem
& item
, const QPixmap
& pixmap
)
502 Q_ASSERT(!item
.isNull());
503 if (item
.url().directory() != m_dirLister
->url().path()) {
504 // the preview job is still working on items of an older URL, hence
505 // the item is not part of the directory model anymore
509 const QModelIndex idx
= m_dirModel
->indexForItem(item
);
510 if (idx
.isValid() && (idx
.column() == 0)) {
511 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
512 if (KonqMimeData::decodeIsCutSelection(mimeData
) && isCutItem(item
)) {
513 KIconEffect iconEffect
;
514 const QPixmap cutPixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
515 m_dirModel
->setData(idx
, QIcon(cutPixmap
), Qt::DecorationRole
);
517 m_dirModel
->setData(idx
, QIcon(pixmap
), Qt::DecorationRole
);
522 void DolphinView::restoreContentsPos()
524 m_blockContentsMovedSignal
= false;
525 if (!url().isEmpty()) {
526 QAbstractItemView
* view
= itemView();
527 // TODO #1: view->setCurrentItem(m_urlNavigator->currentFileName());
528 // TODO #2: temporary deactivated due to DolphinView/DolphinViewController split
529 //QPoint pos = m_urlNavigator->savedPosition();
531 view
->horizontalScrollBar()->setValue(pos
.x());
532 view
->verticalScrollBar()->setValue(pos
.y());
536 void DolphinView::emitSelectionChangedSignal()
538 emit
selectionChanged(DolphinView::selectedItems());
541 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
543 if (!url
.isValid()) {
544 const QString
location(url
.pathOrUrl());
545 if (location
.isEmpty()) {
546 emit
errorMessage(i18n("The location is empty."));
548 emit
errorMessage(i18n("The location '%1' is invalid.", location
));
553 m_cutItemsCache
.clear();
554 m_blockContentsMovedSignal
= true;
558 bool keepOldDirs
= isColumnViewActive() && !m_initializeColumnView
;
559 m_initializeColumnView
= false;
565 const KUrl
& dirListerUrl
= m_dirLister
->url();
566 if (dirListerUrl
.isValid()) {
567 const KUrl::List dirs
= m_dirLister
->directories();
570 m_dirLister
->updateDirectory(url
);
574 } else if (m_dirLister
->directories().contains(url
)) {
575 // The dir lister contains the directory already, so
576 // KDirLister::openUrl() may not been invoked twice.
577 m_dirLister
->updateDirectory(url
);
580 const KUrl
& dirListerUrl
= m_dirLister
->url();
581 if ((dirListerUrl
== url
) || !m_dirLister
->url().isParentOf(url
)) {
582 // The current URL is not a child of the dir lister
583 // URL. This may happen when e. g. a bookmark has been selected
584 // and hence the view must be reset.
591 m_dirLister
->openUrl(url
, keepOldDirs
, reload
);
595 void DolphinView::setUrl(const KUrl
& url
)
597 if (m_controller
->url() == url
) {
601 m_controller
->setUrl(url
);
603 const ViewProperties
props(url
);
605 const Mode mode
= props
.viewMode();
606 bool changeMode
= (m_mode
!= mode
);
607 if (changeMode
&& isColumnViewActive()) {
608 // The column view is active. Only change the
609 // mode if the current URL is no child of the column view.
610 if (m_dirLister
->url().isParentOf(url
)) {
620 if (m_mode
== ColumnView
) {
621 // The mode has been changed to the Column View. When starting the dir
622 // lister with DolphinView::startDirLister() it is important to give a
623 // hint that the dir lister may not keep the current directory
624 // although this is the default for showing a hierarchy.
625 m_initializeColumnView
= true;
629 const bool showHiddenFiles
= props
.showHiddenFiles();
630 if (showHiddenFiles
!= m_dirLister
->showingDotFiles()) {
631 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
632 emit
showHiddenFilesChanged();
635 const bool categorized
= props
.categorizedSorting();
636 if (categorized
!= categorizedSorting()) {
637 if (supportsCategorizedSorting()) {
638 Q_ASSERT(m_iconsView
!= 0);
640 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
641 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
643 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
644 m_iconsView
->setItemCategorizer(0);
648 emit
categorizedSortingChanged();
651 const DolphinView::Sorting sorting
= props
.sorting();
652 if (sorting
!= m_proxyModel
->sorting()) {
653 m_proxyModel
->setSorting(sorting
);
654 emit
sortingChanged(sorting
);
657 const Qt::SortOrder sortOrder
= props
.sortOrder();
658 if (sortOrder
!= m_proxyModel
->sortOrder()) {
659 m_proxyModel
->setSortOrder(sortOrder
);
660 emit
sortOrderChanged(sortOrder
);
663 KFileItemDelegate::AdditionalInformation info
= props
.additionalInfo();
664 if (info
!= m_fileItemDelegate
->additionalInformation()) {
665 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
666 m_fileItemDelegate
->setAdditionalInformation(info
);
667 emit
additionalInfoChanged(info
);
670 const bool showPreview
= props
.showPreview();
671 if (showPreview
!= m_controller
->showPreview()) {
672 m_controller
->setShowPreview(showPreview
);
673 emit
showPreviewChanged();
677 emit
urlChanged(url
);
680 void DolphinView::changeSelection(const KFileItemList
& selection
)
683 if (selection
.isEmpty()) {
686 const KUrl
& baseUrl
= url();
688 QItemSelection new_selection
;
689 foreach(KFileItem
* item
, selection
) {
690 url
= item
->url().upUrl();
691 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
692 QModelIndex index
= m_proxyModel
->mapFromSource(m_dirModel
->indexForItem(*item
));
693 new_selection
.select(index
, index
);
696 itemView()->selectionModel()->select(new_selection
,
697 QItemSelectionModel::ClearAndSelect
698 | QItemSelectionModel::Current
);
701 void DolphinView::openContextMenu(const QPoint
& pos
)
705 const QModelIndex index
= itemView()->indexAt(pos
);
706 if (isValidNameIndex(index
)) {
707 item
= fileItem(index
);
710 emit
requestContextMenu(item
, url());
713 void DolphinView::dropUrls(const KUrl::List
& urls
,
714 const QModelIndex
& index
,
717 KFileItem
* directory
= 0;
718 if (isValidNameIndex(index
)) {
719 KFileItem
* item
= fileItem(index
);
722 // the URLs are dropped above a directory
727 if ((directory
== 0) && (source
== itemView())) {
728 // The dropping is done into the same viewport where
729 // the dragging has been started. Just ignore this...
733 const KUrl
& destination
= (directory
== 0) ?
734 url() : directory
->url();
735 dropUrls(urls
, destination
);
738 void DolphinView::dropUrls(const KUrl::List
& urls
,
739 const KUrl
& destination
)
741 emit
urlsDropped(urls
, destination
);
744 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
746 ViewProperties
props(url());
747 props
.setSorting(sorting
);
749 m_proxyModel
->setSorting(sorting
);
751 emit
sortingChanged(sorting
);
754 void DolphinView::updateSortOrder(Qt::SortOrder order
)
756 ViewProperties
props(url());
757 props
.setSortOrder(order
);
759 m_proxyModel
->setSortOrder(order
);
761 emit
sortOrderChanged(order
);
764 void DolphinView::emitContentsMoved()
766 if (!m_blockContentsMovedSignal
) {
767 emit
contentsMoved(contentsX(), contentsY());
771 void DolphinView::updateCutItems()
773 // restore the icons of all previously selected items to the
775 QList
<CutItem
>::const_iterator it
= m_cutItemsCache
.begin();
776 QList
<CutItem
>::const_iterator end
= m_cutItemsCache
.end();
778 const QModelIndex index
= m_dirModel
->indexForUrl((*it
).url
);
779 if (index
.isValid()) {
780 m_dirModel
->setData(index
, QIcon((*it
).pixmap
), Qt::DecorationRole
);
784 m_cutItemsCache
.clear();
786 // ... and apply an item effect to all currently cut items
787 applyCutItemEffect();
790 void DolphinView::showHoverInformation(const QModelIndex
& index
)
792 if (hasSelection()) {
796 const KFileItem
* item
= fileItem(index
);
798 emit
requestItemInfo(item
->url());
802 void DolphinView::clearHoverInformation()
804 emit
requestItemInfo(KUrl());
808 void DolphinView::createView()
810 // delete current view
811 QAbstractItemView
* view
= itemView();
813 m_topLayout
->removeWidget(view
);
815 if (view
== m_iconsView
) {
816 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
817 m_iconsView
->setItemCategorizer(0);
825 m_fileItemDelegate
= 0;
828 Q_ASSERT(m_iconsView
== 0);
829 Q_ASSERT(m_detailsView
== 0);
830 Q_ASSERT(m_columnView
== 0);
832 // ... and recreate it representing the current mode
835 m_iconsView
= new DolphinIconsView(this, m_controller
);
840 m_detailsView
= new DolphinDetailsView(this, m_controller
);
841 view
= m_detailsView
;
845 m_columnView
= new DolphinColumnView(this, m_controller
);
852 m_fileItemDelegate
= new KFileItemDelegate(view
);
853 view
->setItemDelegate(m_fileItemDelegate
);
855 view
->setModel(m_proxyModel
);
856 view
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
858 new KMimeTypeResolver(view
, m_dirModel
);
859 m_topLayout
->insertWidget(1, view
);
861 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
862 this, SLOT(emitSelectionChangedSignal()));
863 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
864 this, SLOT(emitContentsMoved()));
865 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
866 this, SLOT(emitContentsMoved()));
869 void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags
)
871 QItemSelectionModel
* selectionModel
= itemView()->selectionModel();
872 const QAbstractItemModel
* itemModel
= selectionModel
->model();
874 const QModelIndex topLeft
= itemModel
->index(0, 0);
875 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
876 itemModel
->columnCount() - 1);
878 QItemSelection
selection(topLeft
, bottomRight
);
879 selectionModel
->select(selection
, flags
);
882 QAbstractItemView
* DolphinView::itemView() const
884 if (m_detailsView
!= 0) {
885 return m_detailsView
;
886 } else if (m_columnView
!= 0) {
893 bool DolphinView::isValidNameIndex(const QModelIndex
& index
) const
895 return index
.isValid() && (index
.column() == KDirModel::Name
);
898 bool DolphinView::isCutItem(const KFileItem
& item
) const
900 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
901 const KUrl::List cutUrls
= KUrl::List::fromMimeData(mimeData
);
903 const KUrl
& itemUrl
= item
.url();
904 KUrl::List::const_iterator it
= cutUrls
.begin();
905 const KUrl::List::const_iterator end
= cutUrls
.end();
907 if (*it
== itemUrl
) {
916 void DolphinView::applyCutItemEffect()
918 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
919 if (!KonqMimeData::decodeIsCutSelection(mimeData
)) {
923 KFileItemList
items(m_dirLister
->items());
924 KFileItemList::const_iterator it
= items
.begin();
925 const KFileItemList::const_iterator end
= items
.end();
927 KFileItem
* item
= *it
;
928 if (isCutItem(*item
)) {
929 const QModelIndex index
= m_dirModel
->indexForItem(*item
);
930 const KFileItem
* item
= m_dirModel
->itemForIndex(index
);
931 const QVariant value
= m_dirModel
->data(index
, Qt::DecorationRole
);
932 if ((value
.type() == QVariant::Icon
) && (item
!= 0)) {
933 const QIcon
icon(qvariant_cast
<QIcon
>(value
));
934 QPixmap pixmap
= icon
.pixmap(128, 128);
936 // remember current pixmap for the item to be able
937 // to restore it when other items get cut
939 cutItem
.url
= item
->url();
940 cutItem
.pixmap
= pixmap
;
941 m_cutItemsCache
.append(cutItem
);
943 // apply icon effect to the cut item
944 KIconEffect iconEffect
;
945 pixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
946 m_dirModel
->setData(index
, QIcon(pixmap
), Qt::DecorationRole
);
953 #include "dolphinview.moc"