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 <QItemSelectionModel>
24 #include <Q3ValueList>
26 #include <QMouseEvent>
27 #include <QVBoxLayout>
29 #include <kdirmodel.h>
30 #include <kfileitemdelegate.h>
33 #include <kio/netaccess.h>
34 #include <kio/renamedialog.h>
35 #include <kmimetyperesolver.h>
38 #include "urlnavigator.h"
39 #include "dolphinstatusbar.h"
40 #include "dolphinmainwindow.h"
41 #include "dolphindirlister.h"
42 #include "dolphinsortfilterproxymodel.h"
43 #include "viewproperties.h"
44 #include "dolphindetailsview.h"
45 #include "dolphiniconsview.h"
46 #include "dolphincontextmenu.h"
47 #include "undomanager.h"
48 #include "renamedialog.h"
49 #include "progressindicator.h"
50 #include "filterbar.h"
52 DolphinView::DolphinView(DolphinMainWindow
*mainWindow
,
56 bool showHiddenFiles
) :
59 m_showProgress(false),
64 m_mainWindow(mainWindow
),
75 setFocusPolicy(Qt::StrongFocus
);
76 m_topLayout
= new QVBoxLayout(this);
77 m_topLayout
->setSpacing(0);
78 m_topLayout
->setMargin(0);
80 m_urlNavigator
= new UrlNavigator(url
, this);
81 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
82 this, SLOT(loadDirectory(const KUrl
&)));
84 m_statusBar
= new DolphinStatusBar(this);
86 m_dirLister
= new DolphinDirLister();
87 m_dirLister
->setAutoUpdate(true);
88 m_dirLister
->setMainWindow(this);
89 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
90 connect(m_dirLister
, SIGNAL(clear()),
91 this, SLOT(slotClear()));
92 connect(m_dirLister
, SIGNAL(percent(int)),
93 this, SLOT(slotPercent(int)));
94 connect(m_dirLister
, SIGNAL(deleteItem(KFileItem
*)),
95 this, SLOT(slotDeleteItem(KFileItem
*)));
96 connect(m_dirLister
, SIGNAL(completed()),
97 this, SLOT(slotCompleted()));
98 connect(m_dirLister
, SIGNAL(infoMessage(const QString
&)),
99 this, SLOT(slotInfoMessage(const QString
&)));
100 connect(m_dirLister
, SIGNAL(errorMessage(const QString
&)),
101 this, SLOT(slotErrorMessage(const QString
&)));
103 m_iconsView
= new DolphinIconsView(this);
106 m_dirModel
= new KDirModel();
107 m_dirModel
->setDirLister(m_dirLister
);
109 m_proxyModel
= new DolphinSortFilterProxyModel(this);
110 m_proxyModel
->setSourceModel(m_dirModel
);
112 m_iconsView
->setModel(m_proxyModel
);
114 KFileItemDelegate
* delegate
= new KFileItemDelegate(this);
115 delegate
->setAdditionalInformation(KFileItemDelegate::FriendlyMimeType
);
116 m_iconsView
->setItemDelegate(delegate
);
118 m_dirLister
->setDelayedMimeTypes(true);
119 new KMimeTypeResolver(m_iconsView
, m_dirModel
);
121 m_iconSize
= K3Icon::SizeMedium
;
123 m_filterBar
= new FilterBar(this);
125 connect(m_filterBar
, SIGNAL(filterChanged(const QString
&)),
126 this, SLOT(slotChangeNameFilter(const QString
&)));
127 connect(m_filterBar
, SIGNAL(closed()),
128 this, SLOT(closeFilterBar()));
130 m_topLayout
->addWidget(m_urlNavigator
);
131 m_topLayout
->addWidget(m_iconsView
);
132 m_topLayout
->addWidget(m_filterBar
);
133 m_topLayout
->addWidget(m_statusBar
);
135 connect(m_iconsView
, SIGNAL(clicked(const QModelIndex
&)),
136 this, SLOT(triggerItem(const QModelIndex
&)));
137 connect(m_iconsView
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
138 this, SLOT(emitSelectionChangedSignal()));
140 startDirLister(m_urlNavigator
->url());
143 DolphinView::~DolphinView()
149 void DolphinView::setUrl(const KUrl
& url
)
151 m_urlNavigator
->setUrl(url
);
154 const KUrl
& DolphinView::url() const
156 return m_urlNavigator
->url();
159 void DolphinView::requestActivation()
161 mainWindow()->setActiveView(this);
164 bool DolphinView::isActive() const
166 return (mainWindow()->activeView() == this);
169 void DolphinView::setMode(Mode mode
)
171 if (mode
== m_mode
) {
172 return; // the wished mode is already set
177 ViewProperties
props(m_urlNavigator
->url());
178 props
.setViewMode(m_mode
);
181 startDirLister(m_urlNavigator
->url());
186 DolphinView::Mode
DolphinView::mode() const
191 void DolphinView::setShowPreview(bool show
)
193 ViewProperties
props(m_urlNavigator
->url());
194 props
.setShowPreview(show
);
196 // TODO: wait until previews are possible with KFileItemDelegate
198 emit
showPreviewChanged();
201 bool DolphinView::showPreview() const
203 // TODO: wait until previews are possible with KFileItemDelegate
207 void DolphinView::setShowHiddenFiles(bool show
)
209 if (m_dirLister
->showingDotFiles() == show
) {
213 ViewProperties
props(m_urlNavigator
->url());
214 props
.setShowHiddenFiles(show
);
217 m_dirLister
->setShowingDotFiles(show
);
219 emit
showHiddenFilesChanged();
224 bool DolphinView::showHiddenFiles() const
226 return m_dirLister
->showingDotFiles();
229 void DolphinView::renameSelectedItems()
231 const KUrl::List urls
= selectedUrls();
232 if (urls
.count() > 1) {
233 // More than one item has been selected for renaming. Open
234 // a rename dialog and rename all items afterwards.
235 RenameDialog
dialog(urls
);
236 if (dialog
.exec() == QDialog::Rejected
) {
240 DolphinView
* view
= mainWindow()->activeView();
241 const QString
& newName
= dialog
.newName();
242 if (newName
.isEmpty()) {
243 view
->statusBar()->setMessage(i18n("The new item name is invalid."),
244 DolphinStatusBar::Error
);
247 UndoManager
& undoMan
= UndoManager::instance();
248 undoMan
.beginMacro();
250 assert(newName
.contains('#'));
252 const int urlsCount
= urls
.count();
253 ProgressIndicator
* progressIndicator
=
254 new ProgressIndicator(mainWindow(),
255 i18n("Renaming items..."),
256 i18n("Renaming finished."),
259 // iterate through all selected items and rename them...
260 const int replaceIndex
= newName
.indexOf('#');
261 assert(replaceIndex
>= 0);
262 for (int i
= 0; i
< urlsCount
; ++i
) {
263 const KUrl
& source
= urls
[i
];
264 QString
name(newName
);
265 name
.replace(replaceIndex
, 1, renameIndexPresentation(i
+ 1, urlsCount
));
267 if (source
.fileName() != name
) {
268 KUrl
dest(source
.upUrl());
271 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
273 delete progressIndicator
;
274 progressIndicator
= 0;
275 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
276 DolphinStatusBar::Error
);
279 else if (KIO::NetAccess::file_move(source
, dest
)) {
280 // TODO: From the users point of view he executed one 'rename n files' operation,
281 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
282 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
283 undoMan
.addCommand(command
);
287 progressIndicator
->execOperation();
289 delete progressIndicator
;
290 progressIndicator
= 0;
296 // Only one item has been selected for renaming. Use the custom
297 // renaming mechanism from the views.
298 assert(urls
.count() == 1);
300 /*if (m_mode == DetailsView) {
301 Q3ListViewItem* item = m_iconsView->firstChild();
303 if (item->isSelected()) {
304 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
307 item = item->nextSibling();
311 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
313 if (item->isSelected()) {
317 item = static_cast<KFileIconViewItem*>(item->nextItem());
323 void DolphinView::selectAll()
325 selectAll(QItemSelectionModel::Select
);
328 void DolphinView::invertSelection()
330 selectAll(QItemSelectionModel::Toggle
);
333 DolphinStatusBar
* DolphinView::statusBar() const
338 int DolphinView::contentsX() const
341 return 0; //scrollView()->contentsX();
344 int DolphinView::contentsY() const
346 return 0; //scrollView()->contentsY();
349 void DolphinView::refreshSettings()
351 startDirLister(m_urlNavigator
->url());
354 void DolphinView::updateStatusBar()
356 // As the item count information is less important
357 // in comparison with other messages, it should only
359 // - the status bar is empty or
360 // - shows already the item count information or
361 // - shows only a not very important information
362 // - if any progress is given don't show the item count info at all
363 const QString
msg(m_statusBar
->message());
364 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
365 (msg
== m_statusBar
->defaultText()) ||
366 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
367 (m_statusBar
->progress() == 100);
369 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
370 m_statusBar
->setDefaultText(text
);
372 if (updateStatusBarMsg
) {
373 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
377 void DolphinView::emitRequestItemInfo(const KUrl
& url
)
379 emit
requestItemInfo(url
);
382 bool DolphinView::isFilterBarVisible() const
384 return m_filterBar
->isVisible();
387 bool DolphinView::isUrlEditable() const
389 return m_urlNavigator
->isUrlEditable();
392 void DolphinView::zoomIn()
394 //itemEffectsManager()->zoomIn();
397 void DolphinView::zoomOut()
399 //itemEffectsManager()->zoomOut();
402 bool DolphinView::isZoomInPossible() const
404 return false; //itemEffectsManager()->isZoomInPossible();
407 bool DolphinView::isZoomOutPossible() const
409 return false; //itemEffectsManager()->isZoomOutPossible();
412 void DolphinView::setSorting(Sorting sorting
)
414 if (sorting
!= this->sorting()) {
415 ViewProperties
props(url());
416 props
.setSorting(sorting
);
418 m_proxyModel
->setSorting(sorting
);
420 emit
sortingChanged(sorting
);
424 DolphinView::Sorting
DolphinView::sorting() const
426 return m_proxyModel
->sorting();
429 void DolphinView::setSortOrder(Qt::SortOrder order
)
431 if (sortOrder() != order
) {
432 ViewProperties
props(url());
433 props
.setSortOrder(order
);
435 m_proxyModel
->setSortOrder(order
);
437 emit
sortOrderChanged(order
);
441 Qt::SortOrder
DolphinView::sortOrder() const
443 return m_proxyModel
->sortOrder();
446 void DolphinView::goBack()
448 m_urlNavigator
->goBack();
451 void DolphinView::goForward()
453 m_urlNavigator
->goForward();
456 void DolphinView::goUp()
458 m_urlNavigator
->goUp();
461 void DolphinView::goHome()
463 m_urlNavigator
->goHome();
466 void DolphinView::setUrlEditable(bool editable
)
468 m_urlNavigator
->editUrl(editable
);
471 const Q3ValueList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
473 return m_urlNavigator
->history(index
);
476 bool DolphinView::hasSelection() const
478 return m_iconsView
->selectionModel()->hasSelection();
482 * Our view has a selection, we will map them back to the DirModel
483 * and then fill the KFileItemList
485 KFileItemList
DolphinView::selectedItems() const
487 assert( m_iconsView
&& m_iconsView
->selectionModel() );
489 const QItemSelection selection
= m_proxyModel
->mapSelectionToSource( m_iconsView
->selectionModel()->selection() );
490 KFileItemList itemList
;
492 const QModelIndexList indexList
= selection
.indexes();
493 QModelIndexList::const_iterator end
= indexList
.end();
494 for (QModelIndexList::const_iterator it
= indexList
.begin(); it
!= end
; ++it
) {
495 assert( (*it
).isValid() );
497 KFileItem
* item
= m_dirModel
->itemForIndex(*it
);
499 itemList
.append(item
);
506 KUrl::List
DolphinView::selectedUrls() const
510 const KFileItemList list
= selectedItems();
511 KFileItemList::const_iterator it
= list
.begin();
512 const KFileItemList::const_iterator end
= list
.end();
514 KFileItem
* item
= *it
;
515 urls
.append(item
->url());
522 const KFileItem
* DolphinView::currentFileItem() const
524 return 0; // fileView()->currentFileItem();
527 void DolphinView::openContextMenu(KFileItem
* fileInfo
, const QPoint
& pos
)
529 DolphinContextMenu
contextMenu(this, fileInfo
, pos
);
533 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
537 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
541 KUrl
dest(source
.upUrl());
542 dest
.addPath(newName
);
544 const bool destExists
= KIO::NetAccess::exists(dest
,
546 mainWindow()->activeView());
548 // the destination already exists, hence ask the user
550 KIO::RenameDialog
renameDialog(this,
551 i18n("File Already Exists"),
555 switch (renameDialog
.exec()) {
556 case KIO::R_OVERWRITE
:
557 // the destination should be overwritten
558 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
561 case KIO::R_RENAME
: {
562 // a new name for the destination has been used
563 KUrl
newDest(renameDialog
.newDestUrl());
564 ok
= KIO::NetAccess::file_move(source
, newDest
);
569 // the renaming operation has been canceled
575 // no destination exists, hence just move the file to
577 ok
= KIO::NetAccess::file_move(source
, dest
);
581 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), dest
.fileName()),
582 DolphinStatusBar::OperationCompleted
);
584 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
585 UndoManager::instance().addCommand(command
);
588 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), dest
.fileName()),
589 DolphinStatusBar::Error
);
594 void DolphinView::reload()
596 startDirLister(m_urlNavigator
->url(), true);
599 void DolphinView::slotUrlListDropped(QDropEvent
* /* event */,
600 const KUrl::List
& urls
,
603 KUrl
destination(url
);
604 if (destination
.isEmpty()) {
605 destination
= m_urlNavigator
->url();
608 // Check whether the destination Url is a directory. If this is not the
609 // case, use the navigator Url as destination (otherwise the destination,
610 // which represents a file, would be replaced by a copy- or move-operation).
611 KFileItem
fileItem(KFileItem::Unknown
, KFileItem::Unknown
, destination
);
612 if (!fileItem
.isDir()) {
613 destination
= m_urlNavigator
->url();
617 mainWindow()->dropUrls(urls
, destination
);
620 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
622 QWidget::mouseReleaseEvent(event
);
623 mainWindow()->setActiveView(this);
626 DolphinMainWindow
* DolphinView::mainWindow() const
631 void DolphinView::loadDirectory(const KUrl
& url
)
633 const ViewProperties
props(url
);
635 const Mode mode
= props
.viewMode();
636 if (m_mode
!= mode
) {
642 const bool showHiddenFiles
= props
.showHiddenFiles();
643 if (showHiddenFiles
!= m_dirLister
->showingDotFiles()) {
644 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
645 emit
showHiddenFilesChanged();
648 const DolphinView::Sorting sorting
= props
.sorting();
649 if (sorting
!= m_proxyModel
->sorting()) {
650 m_proxyModel
->setSorting(sorting
);
651 emit
sortingChanged(sorting
);
654 const Qt::SortOrder sortOrder
= props
.sortOrder();
655 if (sortOrder
!= m_proxyModel
->sortOrder()) {
656 m_proxyModel
->setSortOrder(sortOrder
);
657 emit
sortOrderChanged(sortOrder
);
660 // TODO: handle previews (props.showPreview())
663 emit
urlChanged(url
);
666 void DolphinView::triggerItem(const QModelIndex
& index
)
668 KFileItem
* item
= m_dirModel
->itemForIndex(m_proxyModel
->mapToSource(index
));
674 // Prefer the local path over the Url. This assures that the
675 // volume space information is correct. Assuming that the Url is media:/sda1,
676 // and the local path is /windows/C: For the Url the space info is related
677 // to the root partition (and hence wrong) and for the local path the space
678 // info is related to the windows partition (-> correct).
679 //m_dirLister->stop();
680 //m_dirLister->openUrl(item->url());
683 const QString
localPath(item
->localPath());
684 if (localPath
.isEmpty()) {
688 setUrl(KUrl(localPath
));
696 void DolphinView::slotPercent(int percent
)
698 if (m_showProgress
) {
699 m_statusBar
->setProgress(percent
);
703 void DolphinView::slotClear()
705 //fileView()->clearView();
709 void DolphinView::slotDeleteItem(KFileItem
* item
)
711 //fileView()->removeItem(item);
715 void DolphinView::slotCompleted()
719 //KFileView* view = fileView();
722 // TODO: in Qt4 the code should get a lot
723 // simpler and nicer due to Interview...
724 /*if (m_iconsView != 0) {
725 m_iconsView->beginItemUpdates();
727 if (m_iconsView != 0) {
728 m_iconsView->beginItemUpdates();
731 if (m_showProgress
) {
732 m_statusBar
->setProgressText(QString::null
);
733 m_statusBar
->setProgress(100);
734 m_showProgress
= false;
737 KFileItemList
items(m_dirLister
->items());
738 KFileItemList::const_iterator it
= items
.begin();
739 const KFileItemList::const_iterator end
= items
.end();
745 KFileItem
* item
= *it
;
746 //view->insertItem(item);
758 /*if (m_iconsView != 0) {
759 // Prevent a flickering of the icon view widget by giving a small
760 // timeslot to swallow asynchronous update events.
761 m_iconsView->setUpdatesEnabled(false);
762 QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
765 if (m_iconsView != 0) {
766 m_iconsView->endItemUpdates();
767 m_refreshing = false;
771 void DolphinView::slotInfoMessage(const QString
& msg
)
773 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
776 void DolphinView::slotErrorMessage(const QString
& msg
)
778 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
781 void DolphinView::slotGrabActivation()
783 mainWindow()->setActiveView(this);
786 void DolphinView::emitSelectionChangedSignal()
788 emit
selectionChanged();
791 void DolphinView::closeFilterBar()
794 emit
showFilterBarChanged(false);
797 void DolphinView::slotContentsMoving(int x
, int y
)
800 // Only emit a 'contents moved' signal if the user
801 // moved the content by adjusting the sliders. Adjustments
802 // resulted by refreshing a directory should not be respected.
803 emit
contentsMoved(x
, y
);
807 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
809 if (!url
.isValid()) {
810 const QString
location(url
.pathOrUrl());
811 if (location
.isEmpty()) {
812 m_statusBar
->setMessage(i18n("The location is empty."), DolphinStatusBar::Error
);
815 m_statusBar
->setMessage(i18n("The location '%1' is invalid.",location
),
816 DolphinStatusBar::Error
);
821 // Only show the directory loading progress if the status bar does
822 // not contain another progress information. This means that
823 // the directory loading progress information has the lowest priority.
824 const QString
progressText(m_statusBar
->progressText());
825 m_showProgress
= progressText
.isEmpty() ||
826 (progressText
== i18n("Loading directory..."));
827 if (m_showProgress
) {
828 m_statusBar
->setProgressText(i18n("Loading directory..."));
829 m_statusBar
->setProgress(0);
834 m_dirLister
->openUrl(url
, false, reload
);
837 QString
DolphinView::defaultStatusBarText() const
839 // TODO: the following code is not suitable for languages where multiple forms
840 // of plurals are given (e. g. in Poland three forms of plurals exist).
841 const int itemCount
= m_folderCount
+ m_fileCount
;
844 if (itemCount
== 1) {
845 text
= i18n("1 Item");
848 text
= i18n("%1 Items",itemCount
);
853 if (m_folderCount
== 1) {
854 text
+= i18n("1 Folder");
857 text
+= i18n("%1 Folders",m_folderCount
);
862 if (m_fileCount
== 1) {
863 text
+= i18n("1 File");
866 text
+= i18n("%1 Files",m_fileCount
);
874 QString
DolphinView::selectionStatusBarText() const
876 // TODO: the following code is not suitable for languages where multiple forms
877 // of plurals are given (e. g. in Poland three forms of plurals exist).
879 const KFileItemList list
= selectedItems();
880 if (list
.isEmpty()) {
881 // TODO: assert(!list.isEmpty()) should be used, as this method is only invoked if
882 // DolphinView::hasSelection() is true. Inconsistent behavior?
888 KIO::filesize_t byteSize
= 0;
889 KFileItemList::const_iterator it
= list
.begin();
890 const KFileItemList::const_iterator end
= list
.end();
892 KFileItem
* item
= *it
;
898 byteSize
+= item
->size();
903 if (folderCount
== 1) {
904 text
= i18n("1 Folder selected");
906 else if (folderCount
> 1) {
907 text
= i18n("%1 Folders selected",folderCount
);
910 if ((fileCount
> 0) && (folderCount
> 0)) {
914 const QString
sizeText(KIO::convertSize(byteSize
));
915 if (fileCount
== 1) {
916 text
+= i18n("1 File selected (%1)",sizeText
);
918 else if (fileCount
> 1) {
919 text
+= i18n("%1 Files selected (%1)",fileCount
,sizeText
);
925 QString
DolphinView::renameIndexPresentation(int index
, int itemCount
) const
927 // assure that the string reprentation for all indicess have the same
928 // number of characters based on the given number of items
929 QString
str(QString::number(index
));
931 while (itemCount
>= 10) {
935 str
.reserve(chrCount
);
937 const int insertCount
= chrCount
- str
.length();
938 for (int i
= 0; i
< insertCount
; ++i
) {
944 void DolphinView::slotShowFilterBar(bool show
)
946 assert(m_filterBar
!= 0);
955 void DolphinView::declareViewActive()
957 mainWindow()->setActiveView( this );
960 void DolphinView::slotChangeNameFilter(const QString
& nameFilter
)
962 // The name filter of KDirLister does a 'hard' filtering, which
963 // means that only the items are shown where the names match
964 // exactly the filter. This is non-transparent for the user, which
965 // just wants to have a 'soft' filtering: does the name contain
966 // the filter string?
967 QString
adjustedFilter(nameFilter
);
968 adjustedFilter
.insert(0, '*');
969 adjustedFilter
.append('*');
972 * Use the ProxyModel to filter:
973 * This code is #ifdefed as setNameFilter behaves
974 * slightly different than the QSortFilterProxyModel
975 * as it will not remove directories. I will ask
976 * our beloved usability experts for input
980 m_dirLister
->setNameFilter(adjustedFilter
);
981 m_dirLister
->emitChanges();
983 m_proxyModel
->setFilterRegExp( nameFilter
);
987 void DolphinView::applyModeToView()
989 m_iconsView
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
991 // TODO: the following code just tries to test some QListView capabilities
994 m_iconsView
->setViewMode(QListView::IconMode
);
995 m_iconsView
->setSpacing(32);
996 // m_iconsView->setAlternatingRowColors(false);
997 // m_iconsView->setGridSize(QSize(128, 64));
1001 m_iconsView
->setViewMode(QListView::ListMode
);
1002 m_iconsView
->setSpacing(0);
1003 // m_iconsView->setAlternatingRowColors(true);
1004 // m_iconsView->setGridSize(QSize(256, 24));
1009 int DolphinView::columnIndex(Sorting sorting
) const
1013 case SortByName
: index
= KDirModel::Name
; break;
1014 case SortBySize
: index
= KDirModel::Size
; break;
1015 case SortByDate
: index
= KDirModel::ModifiedTime
; break;
1016 default: assert(false);
1021 void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags
)
1023 QItemSelectionModel
* selectionModel
= m_iconsView
->selectionModel();
1024 const QAbstractItemModel
* itemModel
= selectionModel
->model();
1026 const QModelIndex topLeft
= itemModel
->index(0, 0);
1027 const QModelIndex bottomRight
= itemModel
->index(itemModel
->rowCount() - 1,
1028 itemModel
->columnCount() - 1);
1030 QItemSelection
selection(topLeft
, bottomRight
);
1031 selectionModel
->select(selection
, flags
);
1034 #include "dolphinview.moc"