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
) :
63 m_loadingDirectory(false),
64 m_initializeColumnView(false),
65 m_mode(DolphinView::IconsView
),
71 m_fileItemDelegate(0),
73 m_dirLister(dirLister
),
74 m_proxyModel(proxyModel
)
76 setFocusPolicy(Qt::StrongFocus
);
77 m_topLayout
= new QVBoxLayout(this);
78 m_topLayout
->setSpacing(0);
79 m_topLayout
->setMargin(0);
81 QClipboard
* clipboard
= QApplication::clipboard();
82 connect(clipboard
, SIGNAL(dataChanged()),
83 this, SLOT(updateCutItems()));
85 connect(m_dirLister
, SIGNAL(completed()),
86 this, SLOT(updateCutItems()));
87 connect(m_dirLister
, SIGNAL(newItems(const KFileItemList
&)),
88 this, SLOT(generatePreviews(const KFileItemList
&)));
90 m_controller
= new DolphinController(this);
91 m_controller
->setUrl(url
);
92 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&)),
93 this, SLOT(openContextMenu(const QPoint
&)));
94 connect(m_controller
, SIGNAL(urlsDropped(const KUrl::List
&, const QModelIndex
&, QWidget
*)),
95 this, SLOT(dropUrls(const KUrl::List
&, const QModelIndex
&, QWidget
*)));
96 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
97 this, SLOT(updateSorting(DolphinView::Sorting
)));
98 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
99 this, SLOT(updateSortOrder(Qt::SortOrder
)));
100 connect(m_controller
, SIGNAL(itemTriggered(const QModelIndex
&)),
101 this, SLOT(triggerItem(const QModelIndex
&)));
102 connect(m_controller
, SIGNAL(activated()),
103 this, SLOT(activate()));
104 connect(m_controller
, SIGNAL(itemEntered(const QModelIndex
&)),
105 this, SLOT(showHoverInformation(const QModelIndex
&)));
106 connect(m_controller
, SIGNAL(viewportEntered()),
107 this, SLOT(clearHoverInformation()));
109 applyViewProperties(url
);
110 m_topLayout
->addWidget(itemView());
113 DolphinView::~DolphinView()
117 const KUrl
& DolphinView::url() const
119 return m_controller
->url();
122 KUrl
DolphinView::rootUrl() const
124 return isColumnViewActive() ? m_dirLister
->url() : url();
127 void DolphinView::setActive(bool active
)
129 if (active
== m_active
) {
135 QColor color
= KGlobalSettings::baseColor();
137 emit
urlChanged(url());
138 emit
selectionChanged(selectedItems());
143 QWidget
* viewport
= itemView()->viewport();
145 palette
.setColor(viewport
->backgroundRole(), color
);
146 viewport
->setPalette(palette
);
155 bool DolphinView::isActive() const
160 void DolphinView::setMode(Mode mode
)
162 if (mode
== m_mode
) {
163 return; // the wished mode is already set
168 if (isColumnViewActive()) {
169 // When changing the mode in the column view, it makes sense
170 // to go back to the root URL of the column view automatically.
171 // Otherwise there it would not be possible to turn off the column view
172 // without focusing the first column.
173 setUrl(m_dirLister
->url());
174 m_controller
->setUrl(m_dirLister
->url());
177 ViewProperties
props(url());
178 props
.setViewMode(m_mode
);
181 startDirLister(url());
186 DolphinView::Mode
DolphinView::mode() const
191 void DolphinView::setShowPreview(bool show
)
193 ViewProperties
props(url());
194 props
.setShowPreview(show
);
196 m_controller
->setShowPreview(show
);
197 emit
showPreviewChanged();
199 startDirLister(url(), true);
202 bool DolphinView::showPreview() const
204 return m_controller
->showPreview();
207 void DolphinView::setShowHiddenFiles(bool show
)
209 if (m_dirLister
->showingDotFiles() == show
) {
213 ViewProperties
props(url());
214 props
.setShowHiddenFiles(show
);
216 m_dirLister
->setShowingDotFiles(show
);
217 emit
showHiddenFilesChanged();
219 startDirLister(url(), true);
222 bool DolphinView::showHiddenFiles() const
224 return m_dirLister
->showingDotFiles();
227 void DolphinView::setCategorizedSorting(bool categorized
)
229 if (!supportsCategorizedSorting() || (categorized
== categorizedSorting())) {
233 Q_ASSERT(m_iconsView
!= 0);
235 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
236 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
238 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
239 m_iconsView
->setItemCategorizer(0);
243 ViewProperties
props(url());
244 props
.setCategorizedSorting(categorized
);
247 emit
categorizedSortingChanged();
250 bool DolphinView::categorizedSorting() const
252 if (!supportsCategorizedSorting()) {
256 Q_ASSERT(m_iconsView
!= 0);
257 return m_iconsView
->itemCategorizer() != 0;
260 bool DolphinView::supportsCategorizedSorting() const
262 return m_iconsView
!= 0;
265 void DolphinView::selectAll()
267 selectAll(QItemSelectionModel::Select
);
270 void DolphinView::invertSelection()
272 selectAll(QItemSelectionModel::Toggle
);
275 bool DolphinView::hasSelection() const
277 return itemView()->selectionModel()->hasSelection();
280 void DolphinView::clearSelection()
282 itemView()->selectionModel()->clear();
285 KFileItemList
DolphinView::selectedItems() const
287 const QAbstractItemView
* view
= itemView();
289 // Our view has a selection, we will map them back to the DirModel
290 // and then fill the KFileItemList.
291 Q_ASSERT((view
!= 0) && (view
->selectionModel() != 0));
293 const QItemSelection selection
= m_proxyModel
->mapSelectionToSource(view
->selectionModel()->selection());
294 KFileItemList itemList
;
296 const QModelIndexList indexList
= selection
.indexes();
297 QModelIndexList::const_iterator end
= indexList
.end();
298 for (QModelIndexList::const_iterator it
= indexList
.begin(); it
!= end
; ++it
) {
299 Q_ASSERT((*it
).isValid());
301 KFileItem
* item
= m_dirModel
->itemForIndex(*it
);
303 itemList
.append(item
);
310 KUrl::List
DolphinView::selectedUrls() const
314 const KFileItemList list
= selectedItems();
315 KFileItemList::const_iterator it
= list
.begin();
316 const KFileItemList::const_iterator end
= list
.end();
318 KFileItem
* item
= *it
;
319 urls
.append(item
->url());
326 KFileItem
* DolphinView::fileItem(const QModelIndex index
) const
328 const QModelIndex dirModelIndex
= m_proxyModel
->mapToSource(index
);
329 return m_dirModel
->itemForIndex(dirModelIndex
);
332 void DolphinView::setContentsPosition(int x
, int y
)
334 QAbstractItemView
* view
= itemView();
335 view
->horizontalScrollBar()->setValue(x
);
336 view
->verticalScrollBar()->setValue(y
);
338 m_loadingDirectory
= false;
341 QPoint
DolphinView::contentsPosition() const
343 const int x
= itemView()->horizontalScrollBar()->value();
344 const int y
= itemView()->verticalScrollBar()->value();
348 void DolphinView::zoomIn()
350 m_controller
->triggerZoomIn();
353 void DolphinView::zoomOut()
355 m_controller
->triggerZoomOut();
358 bool DolphinView::isZoomInPossible() const
360 return m_controller
->isZoomInPossible();
363 bool DolphinView::isZoomOutPossible() const
365 return m_controller
->isZoomOutPossible();
368 void DolphinView::setSorting(Sorting sorting
)
370 if (sorting
!= this->sorting()) {
371 updateSorting(sorting
);
375 DolphinView::Sorting
DolphinView::sorting() const
377 return m_proxyModel
->sorting();
380 void DolphinView::setSortOrder(Qt::SortOrder order
)
382 if (sortOrder() != order
) {
383 updateSortOrder(order
);
387 Qt::SortOrder
DolphinView::sortOrder() const
389 return m_proxyModel
->sortOrder();
392 void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation info
)
394 ViewProperties
props(url());
395 props
.setAdditionalInfo(info
);
397 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
398 m_fileItemDelegate
->setAdditionalInformation(info
);
400 emit
additionalInfoChanged(info
);
401 startDirLister(url(), true);
404 KFileItemDelegate::AdditionalInformation
DolphinView::additionalInfo() const
406 return m_fileItemDelegate
->additionalInformation();
409 void DolphinView::reload()
412 startDirLister(url(), true);
415 void DolphinView::refresh()
421 void DolphinView::setUrl(const KUrl
& url
)
423 if (m_controller
->url() == url
) {
427 m_controller
->setUrl(url
);
429 applyViewProperties(url
);
432 emit
urlChanged(url
);
435 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
437 QWidget::mouseReleaseEvent(event
);
440 void DolphinView::activate()
445 void DolphinView::triggerItem(const QModelIndex
& index
)
447 if (!isValidNameIndex(index
)) {
449 showHoverInformation(index
);
453 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
454 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
455 // items are selected by the user, hence don't trigger the
456 // item specified by 'index'
460 KFileItem
* item
= m_dirModel
->itemForIndex(m_proxyModel
->mapToSource(index
));
465 // Prefer the local path over the URL. This assures that the
466 // volume space information is correct. Assuming that the URL is media:/sda1,
467 // and the local path is /windows/C: For the URL the space info is related
468 // to the root partition (and hence wrong) and for the local path the space
469 // info is related to the windows partition (-> correct).
470 const QString
localPath(item
->localPath());
472 if (localPath
.isEmpty()) {
480 } else if (item
->isFile()) {
481 // allow to browse through ZIP and tar files
482 KMimeType::Ptr mime
= item
->mimeTypePtr();
483 if (mime
->is("application/zip")) {
484 url
.setProtocol("zip");
486 } else if (mime
->is("application/x-tar") ||
487 mime
->is("application/x-tarz") ||
488 mime
->is("application/x-bzip-compressed-tar") ||
489 mime
->is("application/x-compressed-tar") ||
490 mime
->is("application/x-tzo")) {
491 url
.setProtocol("tar");
501 void DolphinView::generatePreviews(const KFileItemList
& items
)
503 if (m_controller
->showPreview()) {
505 // Must turn QList<KFileItem *> to QList<KFileItem>...
506 QList
<KFileItem
> itemsToPreview
;
507 foreach( KFileItem
* it
, items
)
508 itemsToPreview
.append( *it
);
510 KIO::PreviewJob
* job
= KIO::filePreview(itemsToPreview
, 128);
511 connect(job
, SIGNAL(gotPreview(const KFileItem
&, const QPixmap
&)),
512 this, SLOT(showPreview(const KFileItem
&, const QPixmap
&)));
516 void DolphinView::showPreview(const KFileItem
& item
, const QPixmap
& pixmap
)
518 Q_ASSERT(!item
.isNull());
519 if (item
.url().directory() != m_dirLister
->url().path()) {
520 // the preview job is still working on items of an older URL, hence
521 // the item is not part of the directory model anymore
525 const QModelIndex idx
= m_dirModel
->indexForItem(item
);
526 if (idx
.isValid() && (idx
.column() == 0)) {
527 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
528 if (KonqMimeData::decodeIsCutSelection(mimeData
) && isCutItem(item
)) {
529 KIconEffect iconEffect
;
530 const QPixmap cutPixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
531 m_dirModel
->setData(idx
, QIcon(cutPixmap
), Qt::DecorationRole
);
533 m_dirModel
->setData(idx
, QIcon(pixmap
), Qt::DecorationRole
);
538 void DolphinView::emitSelectionChangedSignal()
540 emit
selectionChanged(DolphinView::selectedItems());
543 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
545 if (!url
.isValid()) {
546 const QString
location(url
.pathOrUrl());
547 if (location
.isEmpty()) {
548 emit
errorMessage(i18n("The location is empty."));
550 emit
errorMessage(i18n("The location '%1' is invalid.", location
));
555 m_cutItemsCache
.clear();
556 m_loadingDirectory
= true;
561 bool keepOldDirs
= isColumnViewActive() && !m_initializeColumnView
;
562 m_initializeColumnView
= false;
568 const KUrl
& dirListerUrl
= m_dirLister
->url();
569 if (dirListerUrl
.isValid()) {
570 const KUrl::List dirs
= m_dirLister
->directories();
573 m_dirLister
->updateDirectory(url
);
577 } else if (m_dirLister
->directories().contains(url
)) {
578 // The dir lister contains the directory already, so
579 // KDirLister::openUrl() may not been invoked twice.
580 m_dirLister
->updateDirectory(url
);
583 const KUrl
& dirListerUrl
= m_dirLister
->url();
584 if ((dirListerUrl
== url
) || !m_dirLister
->url().isParentOf(url
)) {
585 // The current URL is not a child of the dir lister
586 // URL. This may happen when e. g. a bookmark has been selected
587 // and hence the view must be reset.
594 m_dirLister
->openUrl(url
, keepOldDirs
, reload
);
598 void DolphinView::applyViewProperties(const KUrl
& url
)
600 const ViewProperties
props(url
);
602 const Mode mode
= props
.viewMode();
603 bool changeMode
= (m_mode
!= mode
);
604 if (changeMode
&& isColumnViewActive()) {
605 // The column view is active. Only change the
606 // mode if the current URL is no child of the column view.
607 if (m_dirLister
->url().isParentOf(url
)) {
617 if (m_mode
== ColumnView
) {
618 // The mode has been changed to the Column View. When starting the dir
619 // lister with DolphinView::startDirLister() it is important to give a
620 // hint that the dir lister may not keep the current directory
621 // although this is the default for showing a hierarchy.
622 m_initializeColumnView
= true;
625 if (itemView() == 0) {
628 Q_ASSERT(itemView() != 0);
629 Q_ASSERT(m_fileItemDelegate
!= 0);
631 const bool showHiddenFiles
= props
.showHiddenFiles();
632 if (showHiddenFiles
!= m_dirLister
->showingDotFiles()) {
633 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
634 emit
showHiddenFilesChanged();
637 const bool categorized
= props
.categorizedSorting();
638 if (categorized
!= categorizedSorting()) {
639 if (supportsCategorizedSorting()) {
640 Q_ASSERT(m_iconsView
!= 0);
642 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
643 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
645 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
646 m_iconsView
->setItemCategorizer(0);
650 emit
categorizedSortingChanged();
653 const DolphinView::Sorting sorting
= props
.sorting();
654 if (sorting
!= m_proxyModel
->sorting()) {
655 m_proxyModel
->setSorting(sorting
);
656 emit
sortingChanged(sorting
);
659 const Qt::SortOrder sortOrder
= props
.sortOrder();
660 if (sortOrder
!= m_proxyModel
->sortOrder()) {
661 m_proxyModel
->setSortOrder(sortOrder
);
662 emit
sortOrderChanged(sortOrder
);
665 KFileItemDelegate::AdditionalInformation info
= props
.additionalInfo();
666 if (info
!= m_fileItemDelegate
->additionalInformation()) {
667 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
668 m_fileItemDelegate
->setAdditionalInformation(info
);
669 emit
additionalInfoChanged(info
);
672 const bool showPreview
= props
.showPreview();
673 if (showPreview
!= m_controller
->showPreview()) {
674 m_controller
->setShowPreview(showPreview
);
675 emit
showPreviewChanged();
679 void DolphinView::changeSelection(const KFileItemList
& selection
)
682 if (selection
.isEmpty()) {
685 const KUrl
& baseUrl
= url();
687 QItemSelection new_selection
;
688 foreach(KFileItem
* item
, selection
) {
689 url
= item
->url().upUrl();
690 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
691 QModelIndex index
= m_proxyModel
->mapFromSource(m_dirModel
->indexForItem(*item
));
692 new_selection
.select(index
, index
);
695 itemView()->selectionModel()->select(new_selection
,
696 QItemSelectionModel::ClearAndSelect
697 | QItemSelectionModel::Current
);
700 void DolphinView::openContextMenu(const QPoint
& pos
)
704 const QModelIndex index
= itemView()->indexAt(pos
);
705 if (isValidNameIndex(index
)) {
706 item
= fileItem(index
);
709 emit
requestContextMenu(item
, url());
712 void DolphinView::dropUrls(const KUrl::List
& urls
,
713 const QModelIndex
& index
,
716 KFileItem
* directory
= 0;
717 if (isValidNameIndex(index
)) {
718 KFileItem
* item
= fileItem(index
);
721 // the URLs are dropped above a directory
726 if ((directory
== 0) && (source
== itemView())) {
727 // The dropping is done into the same viewport where
728 // the dragging has been started. Just ignore this...
732 const KUrl
& destination
= (directory
== 0) ?
733 url() : directory
->url();
734 dropUrls(urls
, destination
);
737 void DolphinView::dropUrls(const KUrl::List
& urls
,
738 const KUrl
& destination
)
740 emit
urlsDropped(urls
, destination
);
743 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
745 ViewProperties
props(url());
746 props
.setSorting(sorting
);
748 m_proxyModel
->setSorting(sorting
);
750 emit
sortingChanged(sorting
);
753 void DolphinView::updateSortOrder(Qt::SortOrder order
)
755 ViewProperties
props(url());
756 props
.setSortOrder(order
);
758 m_proxyModel
->setSortOrder(order
);
760 emit
sortOrderChanged(order
);
763 void DolphinView::emitContentsMoved()
765 // only emit the contents moved signal if:
766 // - no directory loading is ongoing (this would reset the contents position
768 // - if the Column View is active: the column view does an automatic
769 // positioning during the loading operation, which must be remembered
770 if (!m_loadingDirectory
|| isColumnViewActive()) {
771 const QPoint
pos(contentsPosition());
772 emit
contentsMoved(pos
.x(), pos
.y());
776 void DolphinView::updateCutItems()
778 // restore the icons of all previously selected items to the
780 QList
<CutItem
>::const_iterator it
= m_cutItemsCache
.begin();
781 QList
<CutItem
>::const_iterator end
= m_cutItemsCache
.end();
783 const QModelIndex index
= m_dirModel
->indexForUrl((*it
).url
);
784 if (index
.isValid()) {
785 m_dirModel
->setData(index
, QIcon((*it
).pixmap
), Qt::DecorationRole
);
789 m_cutItemsCache
.clear();
791 // ... and apply an item effect to all currently cut items
792 applyCutItemEffect();
795 void DolphinView::showHoverInformation(const QModelIndex
& index
)
797 if (hasSelection()) {
801 const KFileItem
* item
= fileItem(index
);
803 emit
requestItemInfo(item
->url());
807 void DolphinView::clearHoverInformation()
809 emit
requestItemInfo(KUrl());
813 void DolphinView::createView()
815 // delete current view
816 QAbstractItemView
* view
= itemView();
818 m_topLayout
->removeWidget(view
);
820 if (view
== m_iconsView
) {
821 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
822 m_iconsView
->setItemCategorizer(0);
830 m_fileItemDelegate
= 0;
833 Q_ASSERT(m_iconsView
== 0);
834 Q_ASSERT(m_detailsView
== 0);
835 Q_ASSERT(m_columnView
== 0);
837 // ... and recreate it representing the current mode
840 m_iconsView
= new DolphinIconsView(this, m_controller
);
845 m_detailsView
= new DolphinDetailsView(this, m_controller
);
846 view
= m_detailsView
;
850 m_columnView
= new DolphinColumnView(this, m_controller
);
857 m_fileItemDelegate
= new KFileItemDelegate(view
);
858 view
->setItemDelegate(m_fileItemDelegate
);
860 view
->setModel(m_proxyModel
);
861 view
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
863 new KMimeTypeResolver(view
, m_dirModel
);
864 m_topLayout
->insertWidget(1, view
);
866 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
867 this, SLOT(emitSelectionChangedSignal()));
868 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
869 this, SLOT(emitContentsMoved()));
870 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
871 this, SLOT(emitContentsMoved()));
874 void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags
)
876 QItemSelectionModel
* selectionModel
= itemView()->selectionModel();
877 const QAbstractItemModel
* itemModel
= selectionModel
->model();
879 const QModelIndex topLeft
= itemModel
->index(0, 0);
880 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
881 itemModel
->columnCount() - 1);
883 QItemSelection
selection(topLeft
, bottomRight
);
884 selectionModel
->select(selection
, flags
);
887 QAbstractItemView
* DolphinView::itemView() const
889 if (m_detailsView
!= 0) {
890 return m_detailsView
;
891 } else if (m_columnView
!= 0) {
898 bool DolphinView::isValidNameIndex(const QModelIndex
& index
) const
900 return index
.isValid() && (index
.column() == KDirModel::Name
);
903 bool DolphinView::isCutItem(const KFileItem
& item
) const
905 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
906 const KUrl::List cutUrls
= KUrl::List::fromMimeData(mimeData
);
908 const KUrl
& itemUrl
= item
.url();
909 KUrl::List::const_iterator it
= cutUrls
.begin();
910 const KUrl::List::const_iterator end
= cutUrls
.end();
912 if (*it
== itemUrl
) {
921 void DolphinView::applyCutItemEffect()
923 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
924 if (!KonqMimeData::decodeIsCutSelection(mimeData
)) {
928 KFileItemList
items(m_dirLister
->items());
929 KFileItemList::const_iterator it
= items
.begin();
930 const KFileItemList::const_iterator end
= items
.end();
932 KFileItem
* item
= *it
;
933 if (isCutItem(*item
)) {
934 const QModelIndex index
= m_dirModel
->indexForItem(*item
);
935 const KFileItem
* item
= m_dirModel
->itemForIndex(index
);
936 const QVariant value
= m_dirModel
->data(index
, Qt::DecorationRole
);
937 if ((value
.type() == QVariant::Icon
) && (item
!= 0)) {
938 const QIcon
icon(qvariant_cast
<QIcon
>(value
));
939 QPixmap pixmap
= icon
.pixmap(128, 128);
941 // remember current pixmap for the item to be able
942 // to restore it when other items get cut
944 cutItem
.url
= item
->url();
945 cutItem
.pixmap
= pixmap
;
946 m_cutItemsCache
.append(cutItem
);
948 // apply icon effect to the cut item
949 KIconEffect iconEffect
;
950 pixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
951 m_dirModel
->setData(index
, QIcon(pixmap
), Qt::DecorationRole
);
958 #include "dolphinview.moc"