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 <kcolorscheme.h>
32 #include <kdirmodel.h>
33 #include <kdirlister.h>
34 #include <kfileitemdelegate.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 QList
<KFileItem
>&)),
88 this, SLOT(generatePreviews(const QList
<KFileItem
>&)));
90 m_controller
= new DolphinController(this);
91 m_controller
->setUrl(url
);
92 connect(m_controller
, SIGNAL(urlChanged(const KUrl
&)),
93 this, SIGNAL(urlChanged(const KUrl
&)));
94 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&)),
95 this, SLOT(openContextMenu(const QPoint
&)));
96 connect(m_controller
, SIGNAL(urlsDropped(const KUrl::List
&, const QModelIndex
&, QWidget
*)),
97 this, SLOT(dropUrls(const KUrl::List
&, const QModelIndex
&, QWidget
*)));
98 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
99 this, SLOT(updateSorting(DolphinView::Sorting
)));
100 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
101 this, SLOT(updateSortOrder(Qt::SortOrder
)));
102 connect(m_controller
, SIGNAL(itemTriggered(const QModelIndex
&)),
103 this, SLOT(triggerItem(const QModelIndex
&)));
104 connect(m_controller
, SIGNAL(activated()),
105 this, SLOT(activate()));
106 connect(m_controller
, SIGNAL(itemEntered(const QModelIndex
&)),
107 this, SLOT(showHoverInformation(const QModelIndex
&)));
108 connect(m_controller
, SIGNAL(viewportEntered()),
109 this, SLOT(clearHoverInformation()));
111 applyViewProperties(url
);
112 m_topLayout
->addWidget(itemView());
115 DolphinView::~DolphinView()
119 const KUrl
& DolphinView::url() const
121 return m_controller
->url();
124 KUrl
DolphinView::rootUrl() const
126 return isColumnViewActive() ? m_dirLister
->url() : url();
129 void DolphinView::setActive(bool active
)
131 if (active
== m_active
) {
137 updateViewportColor();
145 bool DolphinView::isActive() const
150 void DolphinView::setMode(Mode mode
)
152 if (mode
== m_mode
) {
153 return; // the wished mode is already set
158 if (isColumnViewActive()) {
159 // When changing the mode in the column view, it makes sense
160 // to go back to the root URL of the column view automatically.
161 // Otherwise there it would not be possible to turn off the column view
162 // without focusing the first column.
163 setUrl(m_dirLister
->url());
164 m_controller
->setUrl(m_dirLister
->url());
167 const KUrl viewPropsUrl
= viewPropertiesUrl();
168 ViewProperties
props(viewPropsUrl
);
169 props
.setViewMode(m_mode
);
172 startDirLister(viewPropsUrl
);
177 DolphinView::Mode
DolphinView::mode() const
182 void DolphinView::setShowPreview(bool show
)
184 const KUrl viewPropsUrl
= viewPropertiesUrl();
185 ViewProperties
props(viewPropsUrl
);
186 props
.setShowPreview(show
);
188 m_controller
->setShowPreview(show
);
189 emit
showPreviewChanged();
191 startDirLister(viewPropsUrl
, true);
194 bool DolphinView::showPreview() const
196 return m_controller
->showPreview();
199 void DolphinView::setShowHiddenFiles(bool show
)
201 if (m_dirLister
->showingDotFiles() == show
) {
205 const KUrl viewPropsUrl
= viewPropertiesUrl();
206 ViewProperties
props(viewPropsUrl
);
207 props
.setShowHiddenFiles(show
);
209 m_dirLister
->setShowingDotFiles(show
);
210 emit
showHiddenFilesChanged();
212 startDirLister(viewPropsUrl
, true);
215 bool DolphinView::showHiddenFiles() const
217 return m_dirLister
->showingDotFiles();
220 void DolphinView::setCategorizedSorting(bool categorized
)
222 if (!supportsCategorizedSorting() || (categorized
== categorizedSorting())) {
226 Q_ASSERT(m_iconsView
!= 0);
228 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
229 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
231 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
232 m_iconsView
->setItemCategorizer(0);
236 ViewProperties
props(viewPropertiesUrl());
237 props
.setCategorizedSorting(categorized
);
240 emit
categorizedSortingChanged();
243 bool DolphinView::categorizedSorting() const
245 if (!supportsCategorizedSorting()) {
249 Q_ASSERT(m_iconsView
!= 0);
250 return m_iconsView
->itemCategorizer() != 0;
253 bool DolphinView::supportsCategorizedSorting() const
255 return m_iconsView
!= 0;
258 void DolphinView::selectAll()
260 itemView()->selectAll();
263 void DolphinView::invertSelection()
265 QItemSelectionModel
* selectionModel
= itemView()->selectionModel();
266 const QAbstractItemModel
* itemModel
= selectionModel
->model();
268 const QModelIndex topLeft
= itemModel
->index(0, 0);
269 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
270 itemModel
->columnCount() - 1);
272 QItemSelection
selection(topLeft
, bottomRight
);
273 selectionModel
->select(selection
, QItemSelectionModel::Toggle
);
276 bool DolphinView::hasSelection() const
278 return itemView()->selectionModel()->hasSelection();
281 void DolphinView::clearSelection()
283 itemView()->selectionModel()->clear();
286 QList
<KFileItem
> 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 QList
<KFileItem
> itemList
;
297 const QModelIndexList indexList
= selection
.indexes();
298 foreach (QModelIndex index
, indexList
) {
299 KFileItem item
= m_dirModel
->itemForIndex(index
);
300 if (!item
.isNull()) {
301 itemList
.append(item
);
308 KUrl::List
DolphinView::selectedUrls() const
311 const QList
<KFileItem
> list
= selectedItems();
312 for ( QList
<KFileItem
>::const_iterator it
= list
.begin(), end
= list
.end();
314 urls
.append((*it
).url());
319 KFileItem
DolphinView::fileItem(const QModelIndex
& index
) const
321 const QModelIndex dirModelIndex
= m_proxyModel
->mapToSource(index
);
322 return m_dirModel
->itemForIndex(dirModelIndex
);
325 void DolphinView::setContentsPosition(int x
, int y
)
327 QAbstractItemView
* view
= itemView();
329 // the ColumnView takes care itself for the horizontal scrolling
330 if (!isColumnViewActive()) {
331 view
->horizontalScrollBar()->setValue(x
);
333 view
->verticalScrollBar()->setValue(y
);
335 m_loadingDirectory
= false;
338 QPoint
DolphinView::contentsPosition() const
340 const int x
= itemView()->horizontalScrollBar()->value();
341 const int y
= itemView()->verticalScrollBar()->value();
345 void DolphinView::zoomIn()
347 m_controller
->triggerZoomIn();
350 void DolphinView::zoomOut()
352 m_controller
->triggerZoomOut();
355 bool DolphinView::isZoomInPossible() const
357 return m_controller
->isZoomInPossible();
360 bool DolphinView::isZoomOutPossible() const
362 return m_controller
->isZoomOutPossible();
365 void DolphinView::setSorting(Sorting sorting
)
367 if (sorting
!= this->sorting()) {
368 updateSorting(sorting
);
372 DolphinView::Sorting
DolphinView::sorting() const
374 return m_proxyModel
->sorting();
377 void DolphinView::setSortOrder(Qt::SortOrder order
)
379 if (sortOrder() != order
) {
380 updateSortOrder(order
);
384 Qt::SortOrder
DolphinView::sortOrder() const
386 return m_proxyModel
->sortOrder();
389 void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation info
)
391 const KUrl viewPropsUrl
= viewPropertiesUrl();
392 ViewProperties
props(viewPropsUrl
);
393 props
.setAdditionalInfo(info
);
395 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
396 m_fileItemDelegate
->setAdditionalInformation(info
);
398 emit
additionalInfoChanged(info
);
399 startDirLister(viewPropsUrl
, true);
402 KFileItemDelegate::AdditionalInformation
DolphinView::additionalInfo() const
404 return m_fileItemDelegate
->additionalInformation();
407 void DolphinView::reload()
410 startDirLister(url(), true);
413 void DolphinView::refresh()
416 applyViewProperties(m_controller
->url());
418 updateViewportColor();
421 void DolphinView::setUrl(const KUrl
& url
)
423 if (m_controller
->url() == url
) {
427 m_controller
->setUrl(url
); // emits urlChanged, which we forward
429 applyViewProperties(url
);
432 itemView()->setFocus();
435 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
437 QWidget::mouseReleaseEvent(event
);
440 void DolphinView::activate()
445 void DolphinView::triggerItem(const QModelIndex
& index
)
447 Q_ASSERT(index
.isValid());
449 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
450 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
451 // items are selected by the user, hence don't trigger the
452 // item specified by 'index'
456 const KFileItem item
= m_dirModel
->itemForIndex(m_proxyModel
->mapToSource(index
));
461 emit
itemTriggered(item
); // caught by DolphinViewContainer or DolphinPart
464 void DolphinView::generatePreviews(const QList
<KFileItem
>& items
)
466 if (m_controller
->showPreview()) {
467 KIO::PreviewJob
* job
= KIO::filePreview(items
, 128);
468 connect(job
, SIGNAL(gotPreview(const KFileItem
&, const QPixmap
&)),
469 this, SLOT(showPreview(const KFileItem
&, const QPixmap
&)));
473 void DolphinView::showPreview(const KFileItem
& item
, const QPixmap
& pixmap
)
475 Q_ASSERT(!item
.isNull());
476 if (item
.url().directory() != m_dirLister
->url().path()) {
477 // the preview job is still working on items of an older URL, hence
478 // the item is not part of the directory model anymore
482 const QModelIndex idx
= m_dirModel
->indexForItem(item
);
483 if (idx
.isValid() && (idx
.column() == 0)) {
484 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
485 if (KonqMimeData::decodeIsCutSelection(mimeData
) && isCutItem(item
)) {
486 KIconEffect iconEffect
;
487 const QPixmap cutPixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
488 m_dirModel
->setData(idx
, QIcon(cutPixmap
), Qt::DecorationRole
);
490 m_dirModel
->setData(idx
, QIcon(pixmap
), Qt::DecorationRole
);
495 void DolphinView::emitSelectionChangedSignal()
497 emit
selectionChanged(DolphinView::selectedItems());
500 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
502 if (!url
.isValid()) {
503 const QString
location(url
.pathOrUrl());
504 if (location
.isEmpty()) {
505 emit
errorMessage(i18nc("@info:status", "The location is empty."));
507 emit
errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location
));
512 m_cutItemsCache
.clear();
513 m_loadingDirectory
= true;
518 bool keepOldDirs
= isColumnViewActive() && !m_initializeColumnView
;
519 m_initializeColumnView
= false;
525 const KUrl
& dirListerUrl
= m_dirLister
->url();
526 if (dirListerUrl
.isValid()) {
527 const KUrl::List dirs
= m_dirLister
->directories();
530 m_dirLister
->updateDirectory(url
);
534 } else if (m_dirLister
->directories().contains(url
)) {
535 // The dir lister contains the directory already, so
536 // KDirLister::openUrl() may not been invoked twice.
537 m_dirLister
->updateDirectory(url
);
540 const KUrl
& dirListerUrl
= m_dirLister
->url();
541 if ((dirListerUrl
== url
) || !m_dirLister
->url().isParentOf(url
)) {
542 // The current URL is not a child of the dir lister
543 // URL. This may happen when e. g. a place has been selected
544 // and hence the view must be reset.
551 m_dirLister
->openUrl(url
, keepOldDirs
, reload
);
555 KUrl
DolphinView::viewPropertiesUrl() const
557 if (isColumnViewActive()) {
558 return m_dirLister
->url();
564 void DolphinView::applyViewProperties(const KUrl
& url
)
566 if (isColumnViewActive() && m_dirLister
->url().isParentOf(url
)) {
567 // The column view is active, hence don't apply the view properties
568 // of sub directories (represented by columns) to the view. The
569 // view always represents the properties of the first column.
573 const ViewProperties
props(url
);
575 const Mode mode
= props
.viewMode();
576 if (m_mode
!= mode
) {
581 if (m_mode
== ColumnView
) {
582 // The mode has been changed to the Column View. When starting the dir
583 // lister with DolphinView::startDirLister() it is important to give a
584 // hint that the dir lister may not keep the current directory
585 // although this is the default for showing a hierarchy.
586 m_initializeColumnView
= true;
589 if (itemView() == 0) {
592 Q_ASSERT(itemView() != 0);
593 Q_ASSERT(m_fileItemDelegate
!= 0);
595 const bool showHiddenFiles
= props
.showHiddenFiles();
596 if (showHiddenFiles
!= m_dirLister
->showingDotFiles()) {
597 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
598 emit
showHiddenFilesChanged();
601 const bool categorized
= props
.categorizedSorting();
602 if (categorized
!= categorizedSorting()) {
603 if (supportsCategorizedSorting()) {
604 Q_ASSERT(m_iconsView
!= 0);
606 Q_ASSERT(m_iconsView
->itemCategorizer() == 0);
607 m_iconsView
->setItemCategorizer(new DolphinItemCategorizer());
609 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
610 m_iconsView
->setItemCategorizer(0);
614 emit
categorizedSortingChanged();
617 const DolphinView::Sorting sorting
= props
.sorting();
618 if (sorting
!= m_proxyModel
->sorting()) {
619 m_proxyModel
->setSorting(sorting
);
620 emit
sortingChanged(sorting
);
623 const Qt::SortOrder sortOrder
= props
.sortOrder();
624 if (sortOrder
!= m_proxyModel
->sortOrder()) {
625 m_proxyModel
->setSortOrder(sortOrder
);
626 emit
sortOrderChanged(sortOrder
);
629 KFileItemDelegate::AdditionalInformation info
= props
.additionalInfo();
630 if (info
!= m_fileItemDelegate
->additionalInformation()) {
631 m_controller
->setShowAdditionalInfo(info
!= KFileItemDelegate::NoInformation
);
632 m_fileItemDelegate
->setAdditionalInformation(info
);
633 emit
additionalInfoChanged(info
);
636 const bool showPreview
= props
.showPreview();
637 if (showPreview
!= m_controller
->showPreview()) {
638 m_controller
->setShowPreview(showPreview
);
639 emit
showPreviewChanged();
643 void DolphinView::changeSelection(const QList
<KFileItem
>& selection
)
646 if (selection
.isEmpty()) {
649 const KUrl
& baseUrl
= url();
651 QItemSelection new_selection
;
652 foreach(const KFileItem
& item
, selection
) {
653 url
= item
.url().upUrl();
654 if (baseUrl
.equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
655 QModelIndex index
= m_proxyModel
->mapFromSource(m_dirModel
->indexForItem(item
));
656 new_selection
.select(index
, index
);
659 itemView()->selectionModel()->select(new_selection
,
660 QItemSelectionModel::ClearAndSelect
661 | QItemSelectionModel::Current
);
664 void DolphinView::openContextMenu(const QPoint
& pos
)
668 const QModelIndex index
= itemView()->indexAt(pos
);
669 if (isValidNameIndex(index
)) {
670 item
= fileItem(index
);
673 emit
requestContextMenu(item
, url());
676 void DolphinView::dropUrls(const KUrl::List
& urls
,
677 const QModelIndex
& index
,
681 if (isValidNameIndex(index
)) {
682 KFileItem item
= fileItem(index
);
683 Q_ASSERT(!item
.isNull());
685 // the URLs are dropped above a directory
690 if ((directory
.isNull()) && (source
== itemView())) {
691 // The dropping is done into the same viewport where
692 // the dragging has been started. Just ignore this...
696 const KUrl
& destination
= (directory
.isNull()) ?
697 url() : directory
.url();
698 dropUrls(urls
, destination
);
701 void DolphinView::dropUrls(const KUrl::List
& urls
,
702 const KUrl
& destination
)
704 emit
urlsDropped(urls
, destination
);
707 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
709 ViewProperties
props(viewPropertiesUrl());
710 props
.setSorting(sorting
);
712 m_proxyModel
->setSorting(sorting
);
714 emit
sortingChanged(sorting
);
717 void DolphinView::updateSortOrder(Qt::SortOrder order
)
719 ViewProperties
props(viewPropertiesUrl());
720 props
.setSortOrder(order
);
722 m_proxyModel
->setSortOrder(order
);
724 emit
sortOrderChanged(order
);
727 void DolphinView::emitContentsMoved()
729 // only emit the contents moved signal if:
730 // - no directory loading is ongoing (this would reset the contents position
732 // - if the Column View is active: the column view does an automatic
733 // positioning during the loading operation, which must be remembered
734 if (!m_loadingDirectory
|| isColumnViewActive()) {
735 const QPoint
pos(contentsPosition());
736 emit
contentsMoved(pos
.x(), pos
.y());
740 void DolphinView::updateCutItems()
742 // restore the icons of all previously selected items to the
744 QList
<CutItem
>::const_iterator it
= m_cutItemsCache
.begin();
745 QList
<CutItem
>::const_iterator end
= m_cutItemsCache
.end();
747 const QModelIndex index
= m_dirModel
->indexForUrl((*it
).url
);
748 if (index
.isValid()) {
749 m_dirModel
->setData(index
, QIcon((*it
).pixmap
), Qt::DecorationRole
);
753 m_cutItemsCache
.clear();
755 // ... and apply an item effect to all currently cut items
756 applyCutItemEffect();
759 void DolphinView::showHoverInformation(const QModelIndex
& index
)
761 if (hasSelection()) {
765 const KFileItem item
= fileItem(index
);
766 if (!item
.isNull()) {
767 emit
requestItemInfo(item
);
771 void DolphinView::clearHoverInformation()
773 emit
requestItemInfo(KFileItem());
777 void DolphinView::createView()
779 // delete current view
780 QAbstractItemView
* view
= itemView();
782 m_topLayout
->removeWidget(view
);
784 if (view
== m_iconsView
) {
785 KItemCategorizer
* categorizer
= m_iconsView
->itemCategorizer();
786 m_iconsView
->setItemCategorizer(0);
794 m_fileItemDelegate
= 0;
797 Q_ASSERT(m_iconsView
== 0);
798 Q_ASSERT(m_detailsView
== 0);
799 Q_ASSERT(m_columnView
== 0);
801 // ... and recreate it representing the current mode
804 m_iconsView
= new DolphinIconsView(this, m_controller
);
809 m_detailsView
= new DolphinDetailsView(this, m_controller
);
810 view
= m_detailsView
;
814 m_columnView
= new DolphinColumnView(this, m_controller
);
821 m_fileItemDelegate
= new KFileItemDelegate(view
);
822 view
->setItemDelegate(m_fileItemDelegate
);
824 view
->setModel(m_proxyModel
);
825 view
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
827 new KMimeTypeResolver(view
, m_dirModel
);
828 m_topLayout
->insertWidget(1, view
);
830 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
831 this, SLOT(emitSelectionChangedSignal()));
832 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
833 this, SLOT(emitContentsMoved()));
834 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
835 this, SLOT(emitContentsMoved()));
839 QAbstractItemView
* DolphinView::itemView() const
841 if (m_detailsView
!= 0) {
842 return m_detailsView
;
843 } else if (m_columnView
!= 0) {
850 bool DolphinView::isValidNameIndex(const QModelIndex
& index
) const
852 return index
.isValid() && (index
.column() == KDirModel::Name
);
855 bool DolphinView::isCutItem(const KFileItem
& item
) const
857 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
858 const KUrl::List cutUrls
= KUrl::List::fromMimeData(mimeData
);
860 const KUrl
& itemUrl
= item
.url();
861 KUrl::List::const_iterator it
= cutUrls
.begin();
862 const KUrl::List::const_iterator end
= cutUrls
.end();
864 if (*it
== itemUrl
) {
873 void DolphinView::applyCutItemEffect()
875 const QMimeData
* mimeData
= QApplication::clipboard()->mimeData();
876 if (!KonqMimeData::decodeIsCutSelection(mimeData
)) {
880 KFileItemList
items(m_dirLister
->items());
881 KFileItemList::const_iterator it
= items
.begin();
882 const KFileItemList::const_iterator end
= items
.end();
884 KFileItem
* item
= *it
;
885 if (isCutItem(*item
)) {
886 const QModelIndex index
= m_dirModel
->indexForItem(*item
);
887 // Huh? the item is already known
888 //const KFileItem item = m_dirModel->itemForIndex(index);
889 const QVariant value
= m_dirModel
->data(index
, Qt::DecorationRole
);
890 if (value
.type() == QVariant::Icon
) {
891 const QIcon
icon(qvariant_cast
<QIcon
>(value
));
892 QPixmap pixmap
= icon
.pixmap(128, 128);
894 // remember current pixmap for the item to be able
895 // to restore it when other items get cut
897 cutItem
.url
= item
->url();
898 cutItem
.pixmap
= pixmap
;
899 m_cutItemsCache
.append(cutItem
);
901 // apply icon effect to the cut item
902 KIconEffect iconEffect
;
903 pixmap
= iconEffect
.apply(pixmap
, K3Icon::Desktop
, K3Icon::DisabledState
);
904 m_dirModel
->setData(index
, QIcon(pixmap
), Qt::DecorationRole
);
911 void DolphinView::updateViewportColor()
913 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
915 emit
urlChanged(url()); // Hmm, this is a hack; the url hasn't really changed.
916 emit
selectionChanged(selectedItems());
921 QWidget
* viewport
= itemView()->viewport();
923 palette
.setColor(viewport
->backgroundRole(), color
);
924 viewport
->setPalette(palette
);
927 #include "dolphinview.moc"