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"
25 #include <QApplication>
27 #include <QItemSelectionModel>
28 #include <QMouseEvent>
29 #include <QVBoxLayout>
31 #include <kdirmodel.h>
32 #include <kfileitemdelegate.h>
34 #include <kio/netaccess.h>
35 #include <kio/renamedialog.h>
36 #include <kmimetyperesolver.h>
37 #include <konq_operations.h>
40 #include "dolphincontroller.h"
41 #include "dolphinstatusbar.h"
42 #include "dolphinmainwindow.h"
43 #include "dolphindirlister.h"
44 #include "dolphinsortfilterproxymodel.h"
45 #include "dolphindetailsview.h"
46 #include "dolphiniconsview.h"
47 #include "dolphincontextmenu.h"
48 #include "filterbar.h"
49 #include "renamedialog.h"
50 #include "urlnavigator.h"
51 #include "viewproperties.h"
53 DolphinView::DolphinView(DolphinMainWindow
* mainWindow
,
57 bool showHiddenFiles
) :
59 m_showProgress(false),
64 m_mainWindow(mainWindow
),
77 setFocusPolicy(Qt::StrongFocus
);
78 m_topLayout
= new QVBoxLayout(this);
79 m_topLayout
->setSpacing(0);
80 m_topLayout
->setMargin(0);
82 connect(m_mainWindow
, SIGNAL(activeViewChanged()),
83 this, SLOT(updateActivationState()));
85 m_urlNavigator
= new UrlNavigator(url
, this);
86 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
87 this, SLOT(loadDirectory(const KUrl
&)));
88 connect(m_urlNavigator
, SIGNAL(urlsDropped(const KUrl::List
&, const KUrl
&)),
89 this, SLOT(dropUrls(const KUrl::List
&, const KUrl
&)));
90 connect(m_urlNavigator
, SIGNAL(activated()),
91 this, SLOT(requestActivation()));
92 connect(this, SIGNAL(contentsMoved(int, int)),
93 m_urlNavigator
, SLOT(storeContentsPosition(int, int)));
95 m_statusBar
= new DolphinStatusBar(this);
97 m_dirLister
= new DolphinDirLister();
98 m_dirLister
->setAutoUpdate(true);
99 m_dirLister
->setMainWindow(this);
100 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
101 m_dirLister
->setDelayedMimeTypes(true);
103 connect(m_dirLister
, SIGNAL(clear()),
104 this, SLOT(updateStatusBar()));
105 connect(m_dirLister
, SIGNAL(percent(int)),
106 this, SLOT(updateProgress(int)));
107 connect(m_dirLister
, SIGNAL(deleteItem(KFileItem
*)),
108 this, SLOT(updateStatusBar()));
109 connect(m_dirLister
, SIGNAL(completed()),
110 this, SLOT(updateItemCount()));
111 connect(m_dirLister
, SIGNAL(infoMessage(const QString
&)),
112 this, SLOT(showInfoMessage(const QString
&)));
113 connect(m_dirLister
, SIGNAL(errorMessage(const QString
&)),
114 this, SLOT(showErrorMessage(const QString
&)));
116 m_dirModel
= new KDirModel();
117 m_dirModel
->setDirLister(m_dirLister
);
118 m_dirModel
->setDropsAllowed(KDirModel::DropOnDirectory
);
120 m_proxyModel
= new DolphinSortFilterProxyModel(this);
121 m_proxyModel
->setSourceModel(m_dirModel
);
123 m_controller
= new DolphinController(this);
124 connect(m_controller
, SIGNAL(requestContextMenu(const QPoint
&)),
125 this, SLOT(openContextMenu(const QPoint
&)));
126 connect(m_controller
, SIGNAL(urlsDropped(const KUrl::List
&, const QPoint
&)),
127 this, SLOT(dropUrls(const KUrl::List
&, const QPoint
&)));
128 connect(m_controller
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
129 this, SLOT(updateSorting(DolphinView::Sorting
)));
130 connect(m_controller
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
131 this, SLOT(updateSortOrder(Qt::SortOrder
)));
132 connect(m_controller
, SIGNAL(itemTriggered(const QModelIndex
&)),
133 this, SLOT(triggerItem(const QModelIndex
&)));
134 connect(m_controller
, SIGNAL(selectionChanged()),
135 this, SLOT(emitSelectionChangedSignal()));
136 connect(m_controller
, SIGNAL(activated()),
137 this, SLOT(requestActivation()));
141 m_iconSize
= K3Icon::SizeMedium
;
143 m_filterBar
= new FilterBar(this);
145 connect(m_filterBar
, SIGNAL(filterChanged(const QString
&)),
146 this, SLOT(changeNameFilter(const QString
&)));
147 connect(m_filterBar
, SIGNAL(closeRequest()),
148 this, SLOT(closeFilterBar()));
150 m_topLayout
->addWidget(m_urlNavigator
);
151 m_topLayout
->addWidget(itemView());
152 m_topLayout
->addWidget(m_filterBar
);
153 m_topLayout
->addWidget(m_statusBar
);
155 loadDirectory(m_urlNavigator
->url());
158 DolphinView::~DolphinView()
164 void DolphinView::setUrl(const KUrl
& url
)
166 m_urlNavigator
->setUrl(url
);
167 m_controller
->setUrl(url
);
170 const KUrl
& DolphinView::url() const
172 return m_urlNavigator
->url();
175 bool DolphinView::isActive() const
177 return m_mainWindow
->activeView() == this;
180 void DolphinView::setMode(Mode mode
)
182 if (mode
== m_mode
) {
183 return; // the wished mode is already set
188 ViewProperties
props(m_urlNavigator
->url());
189 props
.setViewMode(m_mode
);
192 startDirLister(m_urlNavigator
->url());
197 DolphinView::Mode
DolphinView::mode() const
202 void DolphinView::setShowPreview(bool show
)
204 ViewProperties
props(m_urlNavigator
->url());
205 props
.setShowPreview(show
);
207 // TODO: wait until previews are possible with KFileItemDelegate
209 emit
showPreviewChanged();
212 bool DolphinView::showPreview() const
214 // TODO: wait until previews are possible with KFileItemDelegate
218 void DolphinView::setShowHiddenFiles(bool show
)
220 if (m_dirLister
->showingDotFiles() == show
) {
224 ViewProperties
props(m_urlNavigator
->url());
225 props
.setShowHiddenFiles(show
);
228 m_dirLister
->setShowingDotFiles(show
);
230 emit
showHiddenFilesChanged();
235 bool DolphinView::showHiddenFiles() const
237 return m_dirLister
->showingDotFiles();
240 void DolphinView::renameSelectedItems()
242 const KUrl::List urls
= selectedUrls();
243 if (urls
.count() > 1) {
244 // More than one item has been selected for renaming. Open
245 // a rename dialog and rename all items afterwards.
246 RenameDialog
dialog(urls
);
247 if (dialog
.exec() == QDialog::Rejected
) {
251 DolphinView
* view
= mainWindow()->activeView();
252 const QString
& newName
= dialog
.newName();
253 if (newName
.isEmpty()) {
254 view
->statusBar()->setMessage(i18n("The new item name is invalid."),
255 DolphinStatusBar::Error
);
258 // TODO: check how this can be integrated into KonqUndoManager/KonqOperations
260 //UndoManager& undoMan = UndoManager::instance();
261 //undoMan.beginMacro();
263 assert(newName
.contains('#'));
265 const int urlsCount
= urls
.count();
267 // iterate through all selected items and rename them...
268 const int replaceIndex
= newName
.indexOf('#');
269 assert(replaceIndex
>= 0);
270 for (int i
= 0; i
< urlsCount
; ++i
) {
271 const KUrl
& source
= urls
[i
];
273 number
.setNum(i
+ 1);
275 QString
name(newName
);
276 name
.replace(replaceIndex
, 1, number
);
278 if (source
.fileName() != name
) {
279 KUrl
dest(source
.upUrl());
282 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
284 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
285 DolphinStatusBar::Error
);
288 else if (KIO::NetAccess::file_move(source
, dest
)) {
289 // TODO: From the users point of view he executed one 'rename n files' operation,
290 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
291 //DolphinCommand command(DolphinCommand::Rename, source, dest);
292 //undoMan.addCommand(command);
297 //undoMan.endMacro();
301 // Only one item has been selected for renaming. Use the custom
302 // renaming mechanism from the views.
303 assert(urls
.count() == 1);
305 /*if (m_mode == DetailsView) {
306 Q3ListViewItem* item = m_iconsView->firstChild();
308 if (item->isSelected()) {
309 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
312 item = item->nextSibling();
316 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
318 if (item->isSelected()) {
322 item = static_cast<KFileIconViewItem*>(item->nextItem());
328 void DolphinView::selectAll()
330 selectAll(QItemSelectionModel::Select
);
333 void DolphinView::invertSelection()
335 selectAll(QItemSelectionModel::Toggle
);
338 DolphinStatusBar
* DolphinView::statusBar() const
343 int DolphinView::contentsX() const
346 return itemView()->horizontalScrollBar()->value();
349 int DolphinView::contentsY() const
351 return itemView()->verticalScrollBar()->value();
354 void DolphinView::refreshSettings()
356 startDirLister(m_urlNavigator
->url());
359 void DolphinView::emitRequestItemInfo(const KUrl
& url
)
361 emit
requestItemInfo(url
);
364 bool DolphinView::isFilterBarVisible() const
366 return m_filterBar
->isVisible();
369 bool DolphinView::isUrlEditable() const
371 return m_urlNavigator
->isUrlEditable();
374 void DolphinView::zoomIn()
376 //itemEffectsManager()->zoomIn();
379 void DolphinView::zoomOut()
381 //itemEffectsManager()->zoomOut();
384 bool DolphinView::isZoomInPossible() const
386 return false; //itemEffectsManager()->isZoomInPossible();
389 bool DolphinView::isZoomOutPossible() const
391 return false; //itemEffectsManager()->isZoomOutPossible();
394 void DolphinView::setSorting(Sorting sorting
)
396 if (sorting
!= this->sorting()) {
397 updateSorting(sorting
);
401 DolphinView::Sorting
DolphinView::sorting() const
403 return m_proxyModel
->sorting();
406 void DolphinView::setSortOrder(Qt::SortOrder order
)
408 if (sortOrder() != order
) {
409 updateSortOrder(order
);
413 Qt::SortOrder
DolphinView::sortOrder() const
415 return m_proxyModel
->sortOrder();
418 void DolphinView::goBack()
420 m_urlNavigator
->goBack();
423 void DolphinView::goForward()
425 m_urlNavigator
->goForward();
428 void DolphinView::goUp()
430 m_urlNavigator
->goUp();
433 void DolphinView::goHome()
435 m_urlNavigator
->goHome();
438 void DolphinView::setUrlEditable(bool editable
)
440 m_urlNavigator
->editUrl(editable
);
443 const QLinkedList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
445 return m_urlNavigator
->history(index
);
448 bool DolphinView::hasSelection() const
450 return itemView()->selectionModel()->hasSelection();
453 KFileItemList
DolphinView::selectedItems() const
455 const QAbstractItemView
* view
= itemView();
457 // Our view has a selection, we will map them back to the DirModel
458 // and then fill the KFileItemList.
459 assert((view
!= 0) && (view
->selectionModel() != 0));
461 const QItemSelection selection
= m_proxyModel
->mapSelectionToSource(view
->selectionModel()->selection());
462 KFileItemList itemList
;
464 const QModelIndexList indexList
= selection
.indexes();
465 QModelIndexList::const_iterator end
= indexList
.end();
466 for (QModelIndexList::const_iterator it
= indexList
.begin(); it
!= end
; ++it
) {
467 assert((*it
).isValid());
469 KFileItem
* item
= m_dirModel
->itemForIndex(*it
);
471 itemList
.append(item
);
478 KUrl::List
DolphinView::selectedUrls() const
482 const KFileItemList list
= selectedItems();
483 KFileItemList::const_iterator it
= list
.begin();
484 const KFileItemList::const_iterator end
= list
.end();
486 KFileItem
* item
= *it
;
487 urls
.append(item
->url());
494 KFileItem
* DolphinView::fileItem(const QModelIndex index
) const
496 const QModelIndex dirModelIndex
= m_proxyModel
->mapToSource(index
);
497 return m_dirModel
->itemForIndex(dirModelIndex
);
500 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
504 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
508 KUrl
dest(source
.upUrl());
509 dest
.addPath(newName
);
511 const bool destExists
= KIO::NetAccess::exists(dest
,
513 mainWindow()->activeView());
515 // the destination already exists, hence ask the user
517 KIO::RenameDialog
renameDialog(this,
518 i18n("File Already Exists"),
522 switch (renameDialog
.exec()) {
523 case KIO::R_OVERWRITE
:
524 // the destination should be overwritten
525 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
528 case KIO::R_RENAME
: {
529 // a new name for the destination has been used
530 KUrl
newDest(renameDialog
.newDestUrl());
531 ok
= KIO::NetAccess::file_move(source
, newDest
);
536 // the renaming operation has been canceled
542 // no destination exists, hence just move the file to
544 ok
= KIO::NetAccess::file_move(source
, dest
);
547 const QString destFileName
= dest
.fileName();
549 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), destFileName
),
550 DolphinStatusBar::OperationCompleted
);
552 KonqOperations::rename(this, source
, destFileName
);
555 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), destFileName
),
556 DolphinStatusBar::Error
);
561 void DolphinView::reload()
563 startDirLister(m_urlNavigator
->url(), true);
566 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
568 QWidget::mouseReleaseEvent(event
);
569 mainWindow()->setActiveView(this);
572 DolphinMainWindow
* DolphinView::mainWindow() const
577 void DolphinView::loadDirectory(const KUrl
& url
)
579 const ViewProperties
props(url
);
581 const Mode mode
= props
.viewMode();
582 if (m_mode
!= mode
) {
588 const bool showHiddenFiles
= props
.showHiddenFiles();
589 if (showHiddenFiles
!= m_dirLister
->showingDotFiles()) {
590 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
591 emit
showHiddenFilesChanged();
594 const DolphinView::Sorting sorting
= props
.sorting();
595 if (sorting
!= m_proxyModel
->sorting()) {
596 m_proxyModel
->setSorting(sorting
);
597 emit
sortingChanged(sorting
);
600 const Qt::SortOrder sortOrder
= props
.sortOrder();
601 if (sortOrder
!= m_proxyModel
->sortOrder()) {
602 m_proxyModel
->setSortOrder(sortOrder
);
603 emit
sortOrderChanged(sortOrder
);
606 // TODO: handle previews (props.showPreview())
609 emit
urlChanged(url
);
611 m_statusBar
->clear();
614 void DolphinView::triggerItem(const QModelIndex
& index
)
616 const Qt::KeyboardModifiers modifier
= QApplication::keyboardModifiers();
617 if ((modifier
& Qt::ShiftModifier
) || (modifier
& Qt::ControlModifier
)) {
618 // items are selected by the user, hence don't trigger the
619 // item specified by 'index'
623 KFileItem
* item
= m_dirModel
->itemForIndex(m_proxyModel
->mapToSource(index
));
629 // Prefer the local path over the URL. This assures that the
630 // volume space information is correct. Assuming that the URL is media:/sda1,
631 // and the local path is /windows/C: For the URL the space info is related
632 // to the root partition (and hence wrong) and for the local path the space
633 // info is related to the windows partition (-> correct).
634 const QString
localPath(item
->localPath());
635 if (localPath
.isEmpty()) {
639 setUrl(KUrl(localPath
));
647 void DolphinView::updateProgress(int percent
)
649 if (m_showProgress
) {
650 m_statusBar
->setProgress(percent
);
654 void DolphinView::updateItemCount()
656 if (m_showProgress
) {
657 m_statusBar
->setProgressText(QString());
658 m_statusBar
->setProgress(100);
659 m_showProgress
= false;
662 KFileItemList
items(m_dirLister
->items());
663 KFileItemList::const_iterator it
= items
.begin();
664 const KFileItemList::const_iterator end
= items
.end();
670 KFileItem
* item
= *it
;
682 QTimer::singleShot(0, this, SLOT(restoreContentsPos()));
685 void DolphinView::restoreContentsPos()
688 const QLinkedList
<UrlNavigator::HistoryElem
> history
= urlHistory(index
);
689 if (!history
.isEmpty()) {
690 QAbstractItemView
* view
= itemView();
691 // TODO: view->setCurrentItem(history[index].currentFileName());
693 QLinkedList
<UrlNavigator::HistoryElem
>::const_iterator it
= history
.begin();
695 view
->horizontalScrollBar()->setValue((*it
).contentsX());
696 view
->verticalScrollBar()->setValue((*it
).contentsY());
700 void DolphinView::showInfoMessage(const QString
& msg
)
702 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
705 void DolphinView::showErrorMessage(const QString
& msg
)
707 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
710 void DolphinView::emitSelectionChangedSignal()
712 emit
selectionChanged();
715 void DolphinView::closeFilterBar()
718 emit
showFilterBarChanged(false);
721 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
723 if (!url
.isValid()) {
724 const QString
location(url
.pathOrUrl());
725 if (location
.isEmpty()) {
726 m_statusBar
->setMessage(i18n("The location is empty."), DolphinStatusBar::Error
);
729 m_statusBar
->setMessage(i18n("The location '%1' is invalid.",location
),
730 DolphinStatusBar::Error
);
735 // Only show the directory loading progress if the status bar does
736 // not contain another progress information. This means that
737 // the directory loading progress information has the lowest priority.
738 const QString
progressText(m_statusBar
->progressText());
739 m_showProgress
= progressText
.isEmpty() ||
740 (progressText
== i18n("Loading directory..."));
741 if (m_showProgress
) {
742 m_statusBar
->setProgressText(i18n("Loading directory..."));
743 m_statusBar
->setProgress(0);
747 m_dirLister
->openUrl(url
, false, reload
);
750 QString
DolphinView::defaultStatusBarText() const
752 return KIO::itemsSummaryString(m_fileCount
+ m_folderCount
,
758 QString
DolphinView::selectionStatusBarText() const
761 const KFileItemList list
= selectedItems();
762 if (list
.isEmpty()) {
763 // when an item is triggered, it is temporary selected but selectedItems()
764 // will return an empty list
770 KIO::filesize_t byteSize
= 0;
771 KFileItemList::const_iterator it
= list
.begin();
772 const KFileItemList::const_iterator end
= list
.end();
774 KFileItem
* item
= *it
;
780 byteSize
+= item
->size();
785 if (folderCount
> 0) {
786 text
= i18np("1 Folder selected", "%1 Folders selected", folderCount
);
793 const QString
sizeText(KIO::convertSize(byteSize
));
794 text
+= i18np("1 File selected (%2)", "%1 Files selected (%2)", fileCount
, sizeText
);
800 void DolphinView::showFilterBar(bool show
)
802 assert(m_filterBar
!= 0);
811 void DolphinView::updateStatusBar()
813 // As the item count information is less important
814 // in comparison with other messages, it should only
816 // - the status bar is empty or
817 // - shows already the item count information or
818 // - shows only a not very important information
819 // - if any progress is given don't show the item count info at all
820 const QString
msg(m_statusBar
->message());
821 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
822 (msg
== m_statusBar
->defaultText()) ||
823 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
824 (m_statusBar
->progress() == 100);
826 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
827 m_statusBar
->setDefaultText(text
);
829 if (updateStatusBarMsg
) {
830 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
834 void DolphinView::requestActivation()
836 m_mainWindow
->setActiveView(this);
839 void DolphinView::changeNameFilter(const QString
& nameFilter
)
841 // The name filter of KDirLister does a 'hard' filtering, which
842 // means that only the items are shown where the names match
843 // exactly the filter. This is non-transparent for the user, which
844 // just wants to have a 'soft' filtering: does the name contain
845 // the filter string?
846 QString
adjustedFilter(nameFilter
);
847 adjustedFilter
.insert(0, '*');
848 adjustedFilter
.append('*');
850 // Use the ProxyModel to filter:
851 // This code is #ifdefed as setNameFilter behaves
852 // slightly different than the QSortFilterProxyModel
853 // as it will not remove directories. I will ask
854 // our beloved usability experts for input
857 m_dirLister
->setNameFilter(adjustedFilter
);
858 m_dirLister
->emitChanges();
860 m_proxyModel
->setFilterRegExp( nameFilter
);
864 void DolphinView::openContextMenu(const QPoint
& pos
)
868 const QModelIndex index
= itemView()->indexAt(pos
);
869 if (index
.isValid()) {
870 item
= fileItem(index
);
873 DolphinContextMenu
contextMenu(this, item
);
877 void DolphinView::dropUrls(const KUrl::List
& urls
,
880 KFileItem
* directory
= 0;
881 const QModelIndex index
= itemView()->indexAt(pos
);
882 if (index
.isValid()) {
883 KFileItem
* item
= fileItem(index
);
886 // the URLs are dropped above a directory
891 const KUrl
& destination
= (directory
== 0) ? url() :
893 dropUrls(urls
, destination
);
896 void DolphinView::dropUrls(const KUrl::List
& urls
,
897 const KUrl
& destination
)
899 m_mainWindow
->dropUrls(urls
, destination
);
903 void DolphinView::updateSorting(DolphinView::Sorting sorting
)
905 ViewProperties
props(url());
906 props
.setSorting(sorting
);
908 m_proxyModel
->setSorting(sorting
);
910 emit
sortingChanged(sorting
);
913 void DolphinView::updateSortOrder(Qt::SortOrder order
)
915 ViewProperties
props(url());
916 props
.setSortOrder(order
);
918 m_proxyModel
->setSortOrder(order
);
920 emit
sortOrderChanged(order
);
923 void DolphinView::emitContentsMoved()
925 emit
contentsMoved(contentsX(), contentsY());
928 void DolphinView::updateActivationState()
930 m_urlNavigator
->setActive(isActive());
933 void DolphinView::createView()
935 // delete current view
936 QAbstractItemView
* view
= itemView();
938 m_topLayout
->removeWidget(view
);
945 assert(m_iconsView
== 0);
946 assert(m_detailsView
== 0);
948 // ... and recreate it representing the current mode
951 m_iconsView
= new DolphinIconsView(this, m_controller
);
956 m_detailsView
= new DolphinDetailsView(this, m_controller
);
957 view
= m_detailsView
;
961 view
->setModel(m_proxyModel
);
962 view
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
964 KFileItemDelegate
* delegate
= new KFileItemDelegate(this);
965 delegate
->setAdditionalInformation(KFileItemDelegate::FriendlyMimeType
);
966 view
->setItemDelegate(delegate
);
968 new KMimeTypeResolver(view
, m_dirModel
);
969 m_topLayout
->insertWidget(1, view
);
971 connect(view
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
972 m_controller
, SLOT(indicateSelectionChange()));
973 connect(view
->verticalScrollBar(), SIGNAL(valueChanged(int)),
974 this, SLOT(emitContentsMoved()));
975 connect(view
->horizontalScrollBar(), SIGNAL(valueChanged(int)),
976 this, SLOT(emitContentsMoved()));
979 void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags
)
981 QItemSelectionModel
* selectionModel
= itemView()->selectionModel();
982 const QAbstractItemModel
* itemModel
= selectionModel
->model();
984 const QModelIndex topLeft
= itemModel
->index(0, 0);
985 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
986 itemModel
->columnCount() - 1);
988 QItemSelection
selection(topLeft
, bottomRight
);
989 selectionModel
->select(selection
, flags
);
992 QAbstractItemView
* DolphinView::itemView() const
994 assert((m_iconsView
== 0) || (m_detailsView
== 0));
995 if (m_detailsView
!= 0) {
996 return m_detailsView
;
1001 #include "dolphinview.moc"