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/renamedlg.h>
35 #include <kmimetyperesolver.h>
38 #include "urlnavigator.h"
39 #include "dolphinstatusbar.h"
40 #include "dolphinmainwindow.h"
41 #include "dolphindirlister.h"
42 #include "viewproperties.h"
43 #include "dolphindetailsview.h"
44 #include "dolphiniconsview.h"
45 #include "dolphincontextmenu.h"
46 #include "undomanager.h"
47 #include "renamedialog.h"
48 #include "progressindicator.h"
49 #include "filterbar.h"
51 DolphinView::DolphinView(DolphinMainWindow
*mainWindow
,
55 bool showHiddenFiles
) :
58 m_showProgress(false),
60 m_mainWindow(mainWindow
),
68 setFocusPolicy(Qt::StrongFocus
);
69 m_topLayout
= new QVBoxLayout(this);
70 m_topLayout
->setSpacing(0);
71 m_topLayout
->setMargin(0);
73 m_urlNavigator
= new UrlNavigator(url
, this);
74 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
75 this, SLOT(loadDirectory(const KUrl
&)));
77 m_statusBar
= new DolphinStatusBar(this);
79 m_dirLister
= new DolphinDirLister();
80 m_dirLister
->setAutoUpdate(true);
81 m_dirLister
->setMainWindow(this);
82 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
83 connect(m_dirLister
, SIGNAL(clear()),
84 this, SLOT(slotClear()));
85 connect(m_dirLister
, SIGNAL(percent(int)),
86 this, SLOT(slotPercent(int)));
87 connect(m_dirLister
, SIGNAL(deleteItem(KFileItem
*)),
88 this, SLOT(slotDeleteItem(KFileItem
*)));
89 connect(m_dirLister
, SIGNAL(completed()),
90 this, SLOT(slotCompleted()));
91 connect(m_dirLister
, SIGNAL(infoMessage(const QString
&)),
92 this, SLOT(slotInfoMessage(const QString
&)));
93 connect(m_dirLister
, SIGNAL(errorMessage(const QString
&)),
94 this, SLOT(slotErrorMessage(const QString
&)));
96 m_iconsView
= new DolphinIconsView(this);
99 KDirModel
* model
= new KDirModel();
100 model
->setDirLister(m_dirLister
);
101 m_iconsView
->setModel(model
);
103 KFileItemDelegate
* delegate
= new KFileItemDelegate(this);
104 m_iconsView
->setItemDelegate(delegate
);
106 m_dirLister
->setDelayedMimeTypes(true);
107 new KMimeTypeResolver(m_iconsView
, model
);
109 m_iconSize
= K3Icon::SizeMedium
;
111 m_filterBar
= new FilterBar(this);
113 connect(m_filterBar
, SIGNAL(filterChanged(const QString
&)),
114 this, SLOT(slotChangeNameFilter(const QString
&)));
115 connect(m_filterBar
, SIGNAL(closed()),
116 this, SLOT(closeFilterBar()));
118 m_topLayout
->addWidget(m_urlNavigator
);
119 m_topLayout
->addWidget(m_iconsView
);
120 m_topLayout
->addWidget(m_filterBar
);
121 m_topLayout
->addWidget(m_statusBar
);
123 connect(m_iconsView
, SIGNAL(clicked(const QModelIndex
&)),
124 this, SLOT(triggerItem(const QModelIndex
&)));
125 connect(m_iconsView
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
126 this, SLOT(emitSelectionChangedSignal()));
128 startDirLister(m_urlNavigator
->url());
131 DolphinView::~DolphinView()
137 void DolphinView::setUrl(const KUrl
& url
)
139 m_urlNavigator
->setUrl(url
);
142 const KUrl
& DolphinView::url() const
144 return m_urlNavigator
->url();
147 void DolphinView::requestActivation()
149 mainWindow()->setActiveView(this);
152 bool DolphinView::isActive() const
154 return (mainWindow()->activeView() == this);
157 void DolphinView::setMode(Mode mode
)
159 if (mode
== m_mode
) {
160 return; // the wished mode is already set
165 ViewProperties
props(m_urlNavigator
->url());
166 props
.setViewMode(m_mode
);
169 startDirLister(m_urlNavigator
->url());
174 DolphinView::Mode
DolphinView::mode() const
179 void DolphinView::setShowHiddenFiles(bool show
)
181 if (m_dirLister
->showingDotFiles() == show
) {
185 ViewProperties
props(m_urlNavigator
->url());
186 props
.setShowHiddenFiles(show
);
189 m_dirLister
->setShowingDotFiles(show
);
191 emit
showHiddenFilesChanged();
196 bool DolphinView::showHiddenFiles() const
198 return m_dirLister
->showingDotFiles();
201 void DolphinView::setViewProperties(const ViewProperties
& props
)
203 setMode(props
.viewMode());
204 setSorting(props
.sorting());
205 setSortOrder(props
.sortOrder());
206 setShowHiddenFiles(props
.showHiddenFiles());
209 void DolphinView::renameSelectedItems()
211 const KUrl::List urls
= selectedUrls();
212 if (urls
.count() > 1) {
213 // More than one item has been selected for renaming. Open
214 // a rename dialog and rename all items afterwards.
215 RenameDialog
dialog(urls
);
216 if (dialog
.exec() == QDialog::Rejected
) {
220 DolphinView
* view
= mainWindow()->activeView();
221 const QString
& newName
= dialog
.newName();
222 if (newName
.isEmpty()) {
223 view
->statusBar()->setMessage(i18n("The new item name is invalid."),
224 DolphinStatusBar::Error
);
227 UndoManager
& undoMan
= UndoManager::instance();
228 undoMan
.beginMacro();
230 assert(newName
.contains('#'));
232 const int urlsCount
= urls
.count();
233 ProgressIndicator
* progressIndicator
=
234 new ProgressIndicator(mainWindow(),
235 i18n("Renaming items..."),
236 i18n("Renaming finished."),
239 // iterate through all selected items and rename them...
240 const int replaceIndex
= newName
.indexOf('#');
241 assert(replaceIndex
>= 0);
242 for (int i
= 0; i
< urlsCount
; ++i
) {
243 const KUrl
& source
= urls
[i
];
244 QString
name(newName
);
245 name
.replace(replaceIndex
, 1, renameIndexPresentation(i
+ 1, urlsCount
));
247 if (source
.fileName() != name
) {
248 KUrl
dest(source
.upUrl());
251 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
253 delete progressIndicator
;
254 progressIndicator
= 0;
255 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
256 DolphinStatusBar::Error
);
259 else if (KIO::NetAccess::file_move(source
, dest
)) {
260 // TODO: From the users point of view he executed one 'rename n files' operation,
261 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
262 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
263 undoMan
.addCommand(command
);
267 progressIndicator
->execOperation();
269 delete progressIndicator
;
270 progressIndicator
= 0;
276 // Only one item has been selected for renaming. Use the custom
277 // renaming mechanism from the views.
278 assert(urls
.count() == 1);
280 /*if (m_mode == DetailsView) {
281 Q3ListViewItem* item = m_iconsView->firstChild();
283 if (item->isSelected()) {
284 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
287 item = item->nextSibling();
291 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
293 if (item->isSelected()) {
297 item = static_cast<KFileIconViewItem*>(item->nextItem());
303 void DolphinView::selectAll()
305 //fileView()->selectAll();
308 void DolphinView::invertSelection()
310 //fileView()->invertSelection();
313 DolphinStatusBar
* DolphinView::statusBar() const
318 int DolphinView::contentsX() const
321 return 0; //scrollView()->contentsX();
324 int DolphinView::contentsY() const
326 return 0; //scrollView()->contentsY();
329 void DolphinView::refreshSettings()
331 startDirLister(m_urlNavigator
->url());
334 void DolphinView::updateStatusBar()
336 // As the item count information is less important
337 // in comparison with other messages, it should only
339 // - the status bar is empty or
340 // - shows already the item count information or
341 // - shows only a not very important information
342 // - if any progress is given don't show the item count info at all
343 const QString
msg(m_statusBar
->message());
344 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
345 (msg
== m_statusBar
->defaultText()) ||
346 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
347 (m_statusBar
->progress() == 100);
349 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
350 m_statusBar
->setDefaultText(text
);
352 if (updateStatusBarMsg
) {
353 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
357 void DolphinView::emitRequestItemInfo(const KUrl
& url
)
359 emit
requestItemInfo(url
);
362 bool DolphinView::isFilterBarVisible() const
364 return m_filterBar
->isVisible();
367 bool DolphinView::isUrlEditable() const
369 return m_urlNavigator
->isUrlEditable();
372 void DolphinView::zoomIn()
374 //itemEffectsManager()->zoomIn();
377 void DolphinView::zoomOut()
379 //itemEffectsManager()->zoomOut();
382 bool DolphinView::isZoomInPossible() const
384 return false; //itemEffectsManager()->isZoomInPossible();
387 bool DolphinView::isZoomOutPossible() const
389 return false; //itemEffectsManager()->isZoomOutPossible();
392 void DolphinView::setSorting(Sorting sorting
)
394 if (sorting
!= this->sorting()) {
395 /*KFileView* view = fileView();
396 int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
399 case SortByName: spec = spec | QDir::Name; break;
400 case SortBySize: spec = spec | QDir::Size; break;
401 case SortByDate: spec = spec | QDir::Time; break;
405 ViewProperties props(url());
406 props.setSorting(sorting);
408 view->setSorting(static_cast<QDir::SortFlags>(spec));
410 emit signalSortingChanged(sorting);*/
414 DolphinView::Sorting
DolphinView::sorting() const
416 /*const QDir::SortFlags spec = fileView()->sorting();
418 if (spec & QDir::Time) {
422 if (spec & QDir::Size) {
429 void DolphinView::setSortOrder(Qt::SortOrder order
)
431 if (sortOrder() != order
) {
432 /*KFileView* view = fileView();
433 int sorting = view->sorting();
434 sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
435 (sorting | QDir::Reversed);
437 ViewProperties props(url());
438 props.setSortOrder(order);
440 view->setSorting(static_cast<QDir::SortFlags>(sorting));
442 emit signalSortOrderChanged(order);*/
446 Qt::SortOrder
DolphinView::sortOrder() const
448 //return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
449 return Qt::Descending
;
452 void DolphinView::goBack()
454 m_urlNavigator
->goBack();
457 void DolphinView::goForward()
459 m_urlNavigator
->goForward();
462 void DolphinView::goUp()
464 m_urlNavigator
->goUp();
467 void DolphinView::goHome()
469 m_urlNavigator
->goHome();
472 void DolphinView::setUrlEditable(bool editable
)
474 m_urlNavigator
->editUrl(editable
);
477 const Q3ValueList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
479 return m_urlNavigator
->history(index
);
482 bool DolphinView::hasSelection() const
484 return m_iconsView
->selectionModel()->hasSelection();
487 KFileItemList
DolphinView::selectedItems() const
489 QItemSelectionModel
* selModel
= m_iconsView
->selectionModel();
490 assert(selModel
!= 0);
492 KFileItemList itemList
;
493 if (selModel
->hasSelection()) {
494 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
495 const QModelIndexList indexList
= selModel
->selectedIndexes();
497 QModelIndexList::const_iterator end
= indexList
.end();
498 for (QModelIndexList::const_iterator it
= indexList
.begin(); it
!= end
; ++it
) {
499 KFileItem
* item
= dirModel
->itemForIndex(*it
);
501 itemList
.append(item
);
508 KUrl::List
DolphinView::selectedUrls() const
512 const KFileItemList list
= selectedItems();
513 KFileItemList::const_iterator it
= list
.begin();
514 const KFileItemList::const_iterator end
= list
.end();
516 KFileItem
* item
= *it
;
517 urls
.append(item
->url());
524 const KFileItem
* DolphinView::currentFileItem() const
526 return 0; // fileView()->currentFileItem();
529 void DolphinView::openContextMenu(KFileItem
* fileInfo
, const QPoint
& pos
)
531 DolphinContextMenu
contextMenu(this, fileInfo
, pos
);
535 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
539 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
543 KUrl
dest(source
.upUrl());
544 dest
.addPath(newName
);
546 const bool destExists
= KIO::NetAccess::exists(dest
,
548 mainWindow()->activeView());
550 // the destination already exists, hence ask the user
552 KIO::RenameDlg
renameDialog(this,
553 i18n("File Already Exists"),
557 switch (renameDialog
.exec()) {
558 case KIO::R_OVERWRITE
:
559 // the destination should be overwritten
560 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
563 case KIO::R_RENAME
: {
564 // a new name for the destination has been used
565 KUrl
newDest(renameDialog
.newDestUrl());
566 ok
= KIO::NetAccess::file_move(source
, newDest
);
571 // the renaming operation has been canceled
577 // no destination exists, hence just move the file to
579 ok
= KIO::NetAccess::file_move(source
, dest
);
583 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), dest
.fileName()),
584 DolphinStatusBar::OperationCompleted
);
586 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
587 UndoManager::instance().addCommand(command
);
590 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), dest
.fileName()),
591 DolphinStatusBar::Error
);
596 void DolphinView::reload()
598 startDirLister(m_urlNavigator
->url(), true);
601 void DolphinView::slotUrlListDropped(QDropEvent
* /* event */,
602 const KUrl::List
& urls
,
605 KUrl
destination(url
);
606 if (destination
.isEmpty()) {
607 destination
= m_urlNavigator
->url();
610 // Check whether the destination Url is a directory. If this is not the
611 // case, use the navigator Url as destination (otherwise the destination,
612 // which represents a file, would be replaced by a copy- or move-operation).
613 KFileItem
fileItem(KFileItem::Unknown
, KFileItem::Unknown
, destination
);
614 if (!fileItem
.isDir()) {
615 destination
= m_urlNavigator
->url();
619 mainWindow()->dropUrls(urls
, destination
);
622 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
624 QWidget::mouseReleaseEvent(event
);
625 mainWindow()->setActiveView(this);
628 DolphinMainWindow
* DolphinView::mainWindow() const
633 void DolphinView::loadDirectory(const KUrl
& url
)
635 const ViewProperties
props(url
);
636 setMode(props
.viewMode());
638 const bool showHiddenFiles
= props
.showHiddenFiles();
639 setShowHiddenFiles(showHiddenFiles
);
640 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
642 setSorting(props
.sorting());
643 setSortOrder(props
.sortOrder());
646 emit
urlChanged(url
);
649 void DolphinView::triggerIconsViewItem(Q3IconViewItem
* item
)
652 const Qt::ButtonState keyboardState = KApplication::keyboardMouseState();
653 const bool isSelectionActive = ((keyboardState & Qt::ShiftModifier) > 0) ||
654 ((keyboardState & Qt::ControlModifier) > 0);*/
655 const bool isSelectionActive
= false;
656 if ((item
!= 0) && !isSelectionActive
) {
657 // Updating the Url must be done outside the scope of this slot,
658 // as iconview items will get deleted.
659 QTimer::singleShot(0, this, SLOT(updateUrl()));
660 mainWindow()->setActiveView(this);
664 void DolphinView::triggerItem(const QModelIndex
& index
)
666 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
667 KFileItem
* item
= dirModel
->itemForIndex(index
);
673 // Prefer the local path over the Url. This assures that the
674 // volume space information is correct. Assuming that the Url is media:/sda1,
675 // and the local path is /windows/C: For the Url the space info is related
676 // to the root partition (and hence wrong) and for the local path the space
677 // info is related to the windows partition (-> correct).
678 //m_dirLister->stop();
679 //m_dirLister->openUrl(item->url());
682 const QString
localPath(item
->localPath());
683 if (localPath
.isEmpty()) {
687 setUrl(KUrl(localPath
));
695 void DolphinView::updateUrl()
697 //KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
698 // static_cast<KFileView*>(m_iconsView);
700 KFileItem
* fileItem
= 0; // TODO: fileView->currentFileItem();
705 if (fileItem
->isDir()) {
706 // Prefer the local path over the Url. This assures that the
707 // volume space information is correct. Assuming that the Url is media:/sda1,
708 // and the local path is /windows/C: For the Url the space info is related
709 // to the root partition (and hence wrong) and for the local path the space
710 // info is related to the windows partition (-> correct).
711 const QString
localPath(fileItem
->localPath());
712 if (localPath
.isEmpty()) {
713 setUrl(fileItem
->url());
716 setUrl(KUrl(localPath
));
724 void DolphinView::slotPercent(int percent
)
726 if (m_showProgress
) {
727 m_statusBar
->setProgress(percent
);
731 void DolphinView::slotClear()
733 //fileView()->clearView();
737 void DolphinView::slotDeleteItem(KFileItem
* item
)
739 //fileView()->removeItem(item);
743 void DolphinView::slotCompleted()
747 //KFileView* view = fileView();
750 // TODO: in Qt4 the code should get a lot
751 // simpler and nicer due to Interview...
752 /*if (m_iconsView != 0) {
753 m_iconsView->beginItemUpdates();
755 if (m_iconsView != 0) {
756 m_iconsView->beginItemUpdates();
759 if (m_showProgress
) {
760 m_statusBar
->setProgressText(QString::null
);
761 m_statusBar
->setProgress(100);
762 m_showProgress
= false;
765 KFileItemList
items(m_dirLister
->items());
766 KFileItemList::const_iterator it
= items
.begin();
767 const KFileItemList::const_iterator end
= items
.end();
773 KFileItem
* item
= *it
;
774 //view->insertItem(item);
786 /*if (m_iconsView != 0) {
787 // Prevent a flickering of the icon view widget by giving a small
788 // timeslot to swallow asynchronous update events.
789 m_iconsView->setUpdatesEnabled(false);
790 QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
793 if (m_iconsView != 0) {
794 m_iconsView->endItemUpdates();
795 m_refreshing = false;
799 void DolphinView::slotInfoMessage(const QString
& msg
)
801 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
804 void DolphinView::slotErrorMessage(const QString
& msg
)
806 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
809 void DolphinView::slotGrabActivation()
811 mainWindow()->setActiveView(this);
814 void DolphinView::emitSelectionChangedSignal()
816 emit
selectionChanged();
819 void DolphinView::closeFilterBar()
822 emit
showFilterBarChanged(false);
825 void DolphinView::slotContentsMoving(int x
, int y
)
828 // Only emit a 'contents moved' signal if the user
829 // moved the content by adjusting the sliders. Adjustments
830 // resulted by refreshing a directory should not be respected.
831 emit
contentsMoved(x
, y
);
835 /*KFileView* DolphinView::fileView() const
837 return (m_mode == DetailsView) ? static_cast<KFileView*>(m_iconsView) :
838 static_cast<KFileView*>(m_iconsView);
841 Q3ScrollView
* DolphinView::scrollView() const
843 return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
844 // static_cast<Q3ScrollView*>(m_iconsView);
847 ItemEffectsManager
* DolphinView::itemEffectsManager() const
852 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
854 if (!url
.isValid()) {
855 const QString
location(url
.pathOrUrl());
856 if (location
.isEmpty()) {
857 m_statusBar
->setMessage(i18n("The location is empty."), DolphinStatusBar::Error
);
860 m_statusBar
->setMessage(i18n("The location '%1' is invalid.",location
),
861 DolphinStatusBar::Error
);
866 // Only show the directory loading progress if the status bar does
867 // not contain another progress information. This means that
868 // the directory loading progress information has the lowest priority.
869 const QString
progressText(m_statusBar
->progressText());
870 m_showProgress
= progressText
.isEmpty() ||
871 (progressText
== i18n("Loading directory..."));
872 if (m_showProgress
) {
873 m_statusBar
->setProgressText(i18n("Loading directory..."));
874 m_statusBar
->setProgress(0);
879 m_dirLister
->openUrl(url
, false, reload
);
882 QString
DolphinView::defaultStatusBarText() const
884 // TODO: the following code is not suitable for languages where multiple forms
885 // of plurals are given (e. g. in Poland three forms of plurals exist).
886 const int itemCount
= m_folderCount
+ m_fileCount
;
889 if (itemCount
== 1) {
890 text
= i18n("1 Item");
893 text
= i18n("%1 Items",itemCount
);
898 if (m_folderCount
== 1) {
899 text
+= i18n("1 Folder");
902 text
+= i18n("%1 Folders",m_folderCount
);
907 if (m_fileCount
== 1) {
908 text
+= i18n("1 File");
911 text
+= i18n("%1 Files",m_fileCount
);
919 QString
DolphinView::selectionStatusBarText() const
921 // TODO: the following code is not suitable for languages where multiple forms
922 // of plurals are given (e. g. in Poland three forms of plurals exist).
924 const KFileItemList list
= selectedItems();
925 if (list
.isEmpty()) {
926 // TODO: assert(!list.isEmpty()) should be used, as this method is only invoked if
927 // DolphinView::hasSelection() is true. Inconsistent behavior?
933 KIO::filesize_t byteSize
= 0;
934 KFileItemList::const_iterator it
= list
.begin();
935 const KFileItemList::const_iterator end
= list
.end();
937 KFileItem
* item
= *it
;
943 byteSize
+= item
->size();
948 if (folderCount
== 1) {
949 text
= i18n("1 Folder selected");
951 else if (folderCount
> 1) {
952 text
= i18n("%1 Folders selected",folderCount
);
955 if ((fileCount
> 0) && (folderCount
> 0)) {
959 const QString
sizeText(KIO::convertSize(byteSize
));
960 if (fileCount
== 1) {
961 text
+= i18n("1 File selected (%1)",sizeText
);
963 else if (fileCount
> 1) {
964 text
+= i18n("%1 Files selected (%1)",fileCount
,sizeText
);
970 QString
DolphinView::renameIndexPresentation(int index
, int itemCount
) const
972 // assure that the string reprentation for all indicess have the same
973 // number of characters based on the given number of items
974 QString
str(QString::number(index
));
976 while (itemCount
>= 10) {
980 str
.reserve(chrCount
);
982 const int insertCount
= chrCount
- str
.length();
983 for (int i
= 0; i
< insertCount
; ++i
) {
989 void DolphinView::slotShowFilterBar(bool show
)
991 assert(m_filterBar
!= 0);
1000 void DolphinView::declareViewActive()
1002 mainWindow()->setActiveView( this );
1005 void DolphinView::slotChangeNameFilter(const QString
& nameFilter
)
1007 // The name filter of KDirLister does a 'hard' filtering, which
1008 // means that only the items are shown where the names match
1009 // exactly the filter. This is non-transparent for the user, which
1010 // just wants to have a 'soft' filtering: does the name contain
1011 // the filter string?
1012 QString
adjustedFilter(nameFilter
);
1013 adjustedFilter
.insert(0, '*');
1014 adjustedFilter
.append('*');
1016 m_dirLister
->setNameFilter(adjustedFilter
);
1017 m_dirLister
->emitChanges();
1019 // TODO: this is a workaround for QIconView: the item position
1020 // stay as they are by filtering, only an inserting of an item
1021 // results to an automatic adjusting of the item position. In Qt4/KDE4
1022 // this workaround should get obsolete due to Interview.
1023 /*KFileView* view = fileView();
1024 if (view == m_iconsView) {
1025 KFileItem* first = view->firstFileItem();
1027 view->removeItem(first);
1028 view->insertItem(first);
1033 void DolphinView::applyModeToView()
1035 //m_iconsView->setAlternatingRowColors(true);
1036 m_iconsView
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
1038 // TODO: the following code just tries to test some QListView capabilities
1041 m_iconsView
->setViewMode(QListView::IconMode
);
1042 m_iconsView
->setGridSize(QSize(128, 64));
1046 m_iconsView
->setViewMode(QListView::ListMode
);
1047 m_iconsView
->setGridSize(QSize(256, 24));
1050 //case PreviewsView:
1051 // m_iconsView->setViewMode(QListView::IconMode);
1052 // m_iconsView->setGridSize(QSize(128, 128));
1057 #include "dolphinview.moc"