]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinview.cpp
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "dolphinview.h"
23 #include <kdirmodel.h>
28 #include <Q3ValueList>
30 #include <QMouseEvent>
31 #include <Q3VBoxLayout>
34 #include <kio/netaccess.h>
35 #include <kio/renamedlg.h>
38 #include "urlnavigator.h"
39 #include "dolphinstatusbar.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"
50 #include "filterbar.h"
52 DolphinView::DolphinView(QWidget
*parent
,
55 bool showHiddenFiles
) :
58 m_showProgress(false),
66 setFocusPolicy(Qt::StrongFocus
);
67 m_topLayout
= new Q3VBoxLayout(this);
69 Dolphin
& dolphin
= Dolphin::mainWin();
71 connect(this, SIGNAL(signalModeChanged()),
72 &dolphin
, SLOT(slotViewModeChanged()));
73 connect(this, SIGNAL(signalShowHiddenFilesChanged()),
74 &dolphin
, SLOT(slotShowHiddenFilesChanged()));
75 connect(this, SIGNAL(signalSortingChanged(DolphinView::Sorting
)),
76 &dolphin
, SLOT(slotSortingChanged(DolphinView::Sorting
)));
77 connect(this, SIGNAL(signalSortOrderChanged(Qt::SortOrder
)),
78 &dolphin
, SLOT(slotSortOrderChanged(Qt::SortOrder
)));
80 m_urlNavigator
= new UrlNavigator(url
, this);
81 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
82 this, SLOT(slotUrlChanged(const KUrl
&)));
83 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
84 &dolphin
, SLOT(slotUrlChanged(const KUrl
&)));
85 connect(m_urlNavigator
, SIGNAL(historyChanged()),
86 &dolphin
, SLOT(slotHistoryChanged()));
88 m_statusBar
= new DolphinStatusBar(this);
90 m_dirLister
= new DolphinDirLister();
91 m_dirLister
->setAutoUpdate(true);
92 m_dirLister
->setMainWindow(this);
93 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
94 connect(m_dirLister
, SIGNAL(clear()),
95 this, SLOT(slotClear()));
96 connect(m_dirLister
, SIGNAL(percent(int)),
97 this, SLOT(slotPercent(int)));
98 connect(m_dirLister
, SIGNAL(deleteItem(KFileItem
*)),
99 this, SLOT(slotDeleteItem(KFileItem
*)));
100 connect(m_dirLister
, SIGNAL(completed()),
101 this, SLOT(slotCompleted()));
102 connect(m_dirLister
, SIGNAL(infoMessage(const QString
&)),
103 this, SLOT(slotInfoMessage(const QString
&)));
104 connect(m_dirLister
, SIGNAL(errorMessage(const QString
&)),
105 this, SLOT(slotErrorMessage(const QString
&)));
107 m_iconsView
= new DolphinIconsView(this);
108 connect(m_iconsView
, SIGNAL(clicked(const QModelIndex
&)),
109 this, SLOT(triggerItem(const QModelIndex
&)));
111 KDirModel
* model
= new KDirModel();
112 model
->setDirLister(m_dirLister
);
113 m_iconsView
->setModel(model
);
115 m_iconSize
= K3Icon::SizeMedium
;
117 m_filterBar
= new FilterBar(this);
119 connect(m_filterBar
, SIGNAL(signalFilterChanged(const QString
&)),
120 this, SLOT(slotChangeNameFilter(const QString
&)));
122 m_topLayout
->addWidget(m_urlNavigator
);
123 m_topLayout
->addWidget(m_iconsView
);
124 m_topLayout
->addWidget(m_filterBar
);
125 m_topLayout
->addWidget(m_statusBar
);
127 startDirLister(m_urlNavigator
->url());
130 DolphinView::~DolphinView()
136 void DolphinView::setUrl(const KUrl
& url
)
138 m_urlNavigator
->setUrl(url
);
141 const KUrl
& DolphinView::url() const
143 return m_urlNavigator
->url();
146 void DolphinView::requestActivation()
148 Dolphin::mainWin().setActiveView(this);
151 bool DolphinView::isActive() const
153 return (Dolphin::mainWin().activeView() == this);
156 void DolphinView::setMode(Mode mode
)
158 if (mode
== m_mode
) {
159 return; // the wished mode is already set
164 ViewProperties
props(m_urlNavigator
->url());
165 props
.setViewMode(m_mode
);
167 startDirLister(m_urlNavigator
->url());
169 emit
signalModeChanged();
172 DolphinView::Mode
DolphinView::mode() const
177 void DolphinView::setShowHiddenFilesEnabled(bool show
)
179 if (m_dirLister
->showingDotFiles() == show
) {
183 ViewProperties
props(m_urlNavigator
->url());
184 props
.setShowHiddenFilesEnabled(show
);
187 m_dirLister
->setShowingDotFiles(show
);
189 emit
signalShowHiddenFilesChanged();
194 bool DolphinView::isShowHiddenFilesEnabled() const
196 return m_dirLister
->showingDotFiles();
199 void DolphinView::setViewProperties(const ViewProperties
& props
)
201 setMode(props
.viewMode());
202 setSorting(props
.sorting());
203 setSortOrder(props
.sortOrder());
204 setShowHiddenFilesEnabled(props
.isShowHiddenFilesEnabled());
207 void DolphinView::renameSelectedItems()
209 const KUrl::List urls
= selectedUrls();
210 if (urls
.count() > 1) {
211 // More than one item has been selected for renaming. Open
212 // a rename dialog and rename all items afterwards.
213 RenameDialog
dialog(urls
);
214 if (dialog
.exec() == QDialog::Rejected
) {
218 DolphinView
* view
= Dolphin::mainWin().activeView();
219 const QString
& newName
= dialog
.newName();
220 if (newName
.isEmpty()) {
221 view
->statusBar()->setMessage(i18n("The new item name is invalid."),
222 DolphinStatusBar::Error
);
225 UndoManager
& undoMan
= UndoManager::instance();
226 undoMan
.beginMacro();
228 assert(newName
.contains('#'));
230 const int urlsCount
= urls
.count();
231 ProgressIndicator
* progressIndicator
=
232 new ProgressIndicator(i18n("Renaming items..."),
233 i18n("Renaming finished."),
236 // iterate through all selected items and rename them...
237 const int replaceIndex
= newName
.find('#');
238 assert(replaceIndex
>= 0);
239 for (int i
= 0; i
< urlsCount
; ++i
) {
240 const KUrl
& source
= urls
[i
];
241 QString
name(newName
);
242 name
.replace(replaceIndex
, 1, renameIndexPresentation(i
+ 1, urlsCount
));
244 if (source
.fileName() != name
) {
245 KUrl
dest(source
.upUrl());
248 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
250 delete progressIndicator
;
251 progressIndicator
= 0;
252 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
253 DolphinStatusBar::Error
);
256 else if (KIO::NetAccess::file_move(source
, dest
)) {
257 // TODO: From the users point of view he executed one 'rename n files' operation,
258 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
259 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
260 undoMan
.addCommand(command
);
264 progressIndicator
->execOperation();
266 delete progressIndicator
;
267 progressIndicator
= 0;
273 // Only one item has been selected for renaming. Use the custom
274 // renaming mechanism from the views.
275 assert(urls
.count() == 1);
277 /*if (m_mode == DetailsView) {
278 Q3ListViewItem* item = m_iconsView->firstChild();
280 if (item->isSelected()) {
281 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
284 item = item->nextSibling();
288 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
290 if (item->isSelected()) {
294 item = static_cast<KFileIconViewItem*>(item->nextItem());
300 void DolphinView::selectAll()
302 //fileView()->selectAll();
305 void DolphinView::invertSelection()
307 //fileView()->invertSelection();
310 DolphinStatusBar
* DolphinView::statusBar() const
315 int DolphinView::contentsX() const
318 return 0; //scrollView()->contentsX();
321 int DolphinView::contentsY() const
323 return 0; //scrollView()->contentsY();
326 void DolphinView::refreshSettings()
328 startDirLister(m_urlNavigator
->url());
331 void DolphinView::updateStatusBar()
333 // As the item count information is less important
334 // in comparison with other messages, it should only
336 // - the status bar is empty or
337 // - shows already the item count information or
338 // - shows only a not very important information
339 // - if any progress is given don't show the item count info at all
340 const QString
msg(m_statusBar
->message());
341 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
342 (msg
== m_statusBar
->defaultText()) ||
343 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
344 (m_statusBar
->progress() == 100);
346 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
347 m_statusBar
->setDefaultText(text
);
349 if (updateStatusBarMsg
) {
350 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
354 void DolphinView::requestItemInfo(const KUrl
& url
)
356 emit
signalRequestItemInfo(url
);
359 bool DolphinView::isUrlEditable() const
361 return m_urlNavigator
->isUrlEditable();
364 void DolphinView::zoomIn()
366 //itemEffectsManager()->zoomIn();
369 void DolphinView::zoomOut()
371 //itemEffectsManager()->zoomOut();
374 bool DolphinView::isZoomInPossible() const
376 return false; //itemEffectsManager()->isZoomInPossible();
379 bool DolphinView::isZoomOutPossible() const
381 return false; //itemEffectsManager()->isZoomOutPossible();
384 void DolphinView::setSorting(Sorting sorting
)
386 if (sorting
!= this->sorting()) {
387 /*KFileView* view = fileView();
388 int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
391 case SortByName: spec = spec | QDir::Name; break;
392 case SortBySize: spec = spec | QDir::Size; break;
393 case SortByDate: spec = spec | QDir::Time; break;
397 ViewProperties props(url());
398 props.setSorting(sorting);
400 view->setSorting(static_cast<QDir::SortFlags>(spec));
402 emit signalSortingChanged(sorting);*/
406 DolphinView::Sorting
DolphinView::sorting() const
408 /*const QDir::SortFlags spec = fileView()->sorting();
410 if (spec & QDir::Time) {
414 if (spec & QDir::Size) {
421 void DolphinView::setSortOrder(Qt::SortOrder order
)
423 if (sortOrder() != order
) {
424 /*KFileView* view = fileView();
425 int sorting = view->sorting();
426 sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
427 (sorting | QDir::Reversed);
429 ViewProperties props(url());
430 props.setSortOrder(order);
432 view->setSorting(static_cast<QDir::SortFlags>(sorting));
434 emit signalSortOrderChanged(order);*/
438 Qt::SortOrder
DolphinView::sortOrder() const
440 //return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
441 return Qt::Descending
;
444 void DolphinView::goBack()
446 m_urlNavigator
->goBack();
449 void DolphinView::goForward()
451 m_urlNavigator
->goForward();
454 void DolphinView::goUp()
456 m_urlNavigator
->goUp();
459 void DolphinView::goHome()
461 m_urlNavigator
->goHome();
464 void DolphinView::setUrlEditable(bool editable
)
466 m_urlNavigator
->editUrl(editable
);
469 const Q3ValueList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
471 return m_urlNavigator
->history(index
);
474 bool DolphinView::hasSelection() const
476 const KFileItemList
* list
= selectedItems();
477 return (list
!= 0) && !list
->isEmpty();
480 const KFileItemList
* DolphinView::selectedItems() const
482 return 0; //fileView()->selectedItems();
485 KUrl::List
DolphinView::selectedUrls() const
489 /*const KFileItemList* list = fileView()->selectedItems();
491 KFileItemList::const_iterator it = list->begin();
492 const KFileItemList::const_iterator end = list->end();
494 KFileItem* item = *it;
495 urls.append(item->url());
503 const KFileItem
* DolphinView::currentFileItem() const
505 return 0; // fileView()->currentFileItem();
508 void DolphinView::openContextMenu(KFileItem
* fileInfo
, const QPoint
& pos
)
510 DolphinContextMenu
contextMenu(this, fileInfo
, pos
);
514 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
518 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
522 KUrl
dest(source
.upUrl());
523 dest
.addPath(newName
);
525 const bool destExists
= KIO::NetAccess::exists(dest
,
527 Dolphin::mainWin().activeView());
529 // the destination already exists, hence ask the user
531 KIO::RenameDlg
renameDialog(this,
532 i18n("File Already Exists"),
536 switch (renameDialog
.exec()) {
537 case KIO::R_OVERWRITE
:
538 // the destination should be overwritten
539 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
542 case KIO::R_RENAME
: {
543 // a new name for the destination has been used
544 KUrl
newDest(renameDialog
.newDestUrl());
545 ok
= KIO::NetAccess::file_move(source
, newDest
);
550 // the renaming operation has been canceled
556 // no destination exists, hence just move the file to
558 ok
= KIO::NetAccess::file_move(source
, dest
);
562 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), dest
.fileName()),
563 DolphinStatusBar::OperationCompleted
);
565 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
566 UndoManager::instance().addCommand(command
);
569 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), dest
.fileName()),
570 DolphinStatusBar::Error
);
575 void DolphinView::reload()
577 startDirLister(m_urlNavigator
->url(), true);
580 void DolphinView::slotUrlListDropped(QDropEvent
* /* event */,
581 const KUrl::List
& urls
,
584 KUrl
destination(url
);
585 if (destination
.isEmpty()) {
586 destination
= m_urlNavigator
->url();
589 // Check whether the destination Url is a directory. If this is not the
590 // case, use the navigator Url as destination (otherwise the destination,
591 // which represents a file, would be replaced by a copy- or move-operation).
592 KFileItem
fileItem(KFileItem::Unknown
, KFileItem::Unknown
, destination
);
593 if (!fileItem
.isDir()) {
594 destination
= m_urlNavigator
->url();
598 Dolphin::mainWin().dropUrls(urls
, destination
);
601 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
603 QWidget::mouseReleaseEvent(event
);
604 Dolphin::mainWin().setActiveView(this);
607 void DolphinView::slotUrlChanged(const KUrl
& url
)
609 const ViewProperties
props(url
);
610 setMode(props
.viewMode());
612 const bool showHiddenFiles
= props
.isShowHiddenFilesEnabled();
613 setShowHiddenFilesEnabled(showHiddenFiles
);
614 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
616 setSorting(props
.sorting());
617 setSortOrder(props
.sortOrder());
621 // The selectionChanged signal is not emitted when a new view object is
622 // created. The application does not care whether a view is represented by a
623 // different instance, hence inform the application that the selection might have
624 // changed so that it can update it's actions.
625 Dolphin::mainWin().slotSelectionChanged();
627 emit
signalUrlChanged(url
);
630 void DolphinView::triggerIconsViewItem(Q3IconViewItem
* item
)
633 const Qt::ButtonState keyboardState = KApplication::keyboardMouseState();
634 const bool isSelectionActive = ((keyboardState & Qt::ShiftModifier) > 0) ||
635 ((keyboardState & Qt::ControlModifier) > 0);*/
636 const bool isSelectionActive
= false;
637 if ((item
!= 0) && !isSelectionActive
) {
638 // Updating the Url must be done outside the scope of this slot,
639 // as iconview items will get deleted.
640 QTimer::singleShot(0, this, SLOT(updateUrl()));
641 Dolphin::mainWin().setActiveView(this);
645 void DolphinView::triggerItem(const QModelIndex
& index
)
647 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
648 KFileItem
* item
= dirModel
->itemForIndex(index
);
654 // Prefer the local path over the Url. This assures that the
655 // volume space information is correct. Assuming that the Url is media:/sda1,
656 // and the local path is /windows/C: For the Url the space info is related
657 // to the root partition (and hence wrong) and for the local path the space
658 // info is related to the windows partition (-> correct).
659 //m_dirLister->stop();
660 //m_dirLister->openUrl(item->url());
663 const QString
localPath(item
->localPath());
664 if (localPath
.isEmpty()) {
668 setUrl(KUrl(localPath
));
676 void DolphinView::updateUrl()
678 //KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
679 // static_cast<KFileView*>(m_iconsView);
681 KFileItem
* fileItem
= 0; // TODO: fileView->currentFileItem();
686 if (fileItem
->isDir()) {
687 // Prefer the local path over the Url. This assures that the
688 // volume space information is correct. Assuming that the Url is media:/sda1,
689 // and the local path is /windows/C: For the Url the space info is related
690 // to the root partition (and hence wrong) and for the local path the space
691 // info is related to the windows partition (-> correct).
692 const QString
localPath(fileItem
->localPath());
693 if (localPath
.isEmpty()) {
694 setUrl(fileItem
->url());
697 setUrl(KUrl(localPath
));
705 void DolphinView::slotPercent(int percent
)
707 if (m_showProgress
) {
708 m_statusBar
->setProgress(percent
);
712 void DolphinView::slotClear()
714 //fileView()->clearView();
718 void DolphinView::slotDeleteItem(KFileItem
* item
)
720 //fileView()->removeItem(item);
724 void DolphinView::slotCompleted()
728 //KFileView* view = fileView();
731 // TODO: in Qt4 the code should get a lot
732 // simpler and nicer due to Interview...
733 /*if (m_iconsView != 0) {
734 m_iconsView->beginItemUpdates();
736 if (m_iconsView != 0) {
737 m_iconsView->beginItemUpdates();
740 if (m_showProgress
) {
741 m_statusBar
->setProgressText(QString::null
);
742 m_statusBar
->setProgress(100);
743 m_showProgress
= false;
746 KFileItemList
items(m_dirLister
->items());
747 KFileItemList::const_iterator it
= items
.begin();
748 const KFileItemList::const_iterator end
= items
.end();
754 KFileItem
* item
= *it
;
755 //view->insertItem(item);
767 /*if (m_iconsView != 0) {
768 // Prevent a flickering of the icon view widget by giving a small
769 // timeslot to swallow asynchronous update events.
770 m_iconsView->setUpdatesEnabled(false);
771 QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
774 if (m_iconsView != 0) {
775 m_iconsView->endItemUpdates();
776 m_refreshing = false;
780 void DolphinView::slotInfoMessage(const QString
& msg
)
782 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
785 void DolphinView::slotErrorMessage(const QString
& msg
)
787 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
790 void DolphinView::slotGrabActivation()
792 Dolphin::mainWin().setActiveView(this);
795 void DolphinView::slotContentsMoving(int x
, int y
)
798 // Only emit a 'contents moved' signal if the user
799 // moved the content by adjusting the sliders. Adjustments
800 // resulted by refreshing a directory should not be respected.
801 emit
contentsMoved(x
, y
);
805 /*KFileView* DolphinView::fileView() const
807 return (m_mode == DetailsView) ? static_cast<KFileView*>(m_iconsView) :
808 static_cast<KFileView*>(m_iconsView);
811 Q3ScrollView
* DolphinView::scrollView() const
813 return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
814 // static_cast<Q3ScrollView*>(m_iconsView);
817 ItemEffectsManager
* DolphinView::itemEffectsManager() const
822 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
824 if (!url
.isValid()) {
825 const QString
location(url
.pathOrUrl());
826 if (location
.isEmpty()) {
827 m_statusBar
->setMessage(i18n("The location is empty."), DolphinStatusBar::Error
);
830 m_statusBar
->setMessage(i18n("The location '%1' is invalid.",location
),
831 DolphinStatusBar::Error
);
836 // Only show the directory loading progress if the status bar does
837 // not contain another progress information. This means that
838 // the directory loading progress information has the lowest priority.
839 const QString
progressText(m_statusBar
->progressText());
840 m_showProgress
= progressText
.isEmpty() ||
841 (progressText
== i18n("Loading directory..."));
842 if (m_showProgress
) {
843 m_statusBar
->setProgressText(i18n("Loading directory..."));
844 m_statusBar
->setProgress(0);
849 m_dirLister
->openUrl(url
, false, reload
);
852 QString
DolphinView::defaultStatusBarText() const
854 // TODO: the following code is not suitable for languages where multiple forms
855 // of plurals are given (e. g. in Poland three forms of plurals exist).
856 const int itemCount
= m_folderCount
+ m_fileCount
;
859 if (itemCount
== 1) {
860 text
= i18n("1 Item");
863 text
= i18n("%1 Items",itemCount
);
868 if (m_folderCount
== 1) {
869 text
+= i18n("1 Folder");
872 text
+= i18n("%1 Folders",m_folderCount
);
877 if (m_fileCount
== 1) {
878 text
+= i18n("1 File");
881 text
+= i18n("%1 Files",m_fileCount
);
889 QString
DolphinView::selectionStatusBarText() const
891 // TODO: the following code is not suitable for languages where multiple forms
892 // of plurals are given (e. g. in Poland three forms of plurals exist).
894 const KFileItemList
* list
= selectedItems();
895 assert((list
!= 0) && !list
->isEmpty());
899 KIO::filesize_t byteSize
= 0;
900 KFileItemList::const_iterator it
= list
->begin();
901 const KFileItemList::const_iterator end
= list
->end();
903 KFileItem
* item
= *it
;
909 byteSize
+= item
->size();
914 if (folderCount
== 1) {
915 text
= i18n("1 Folder selected");
917 else if (folderCount
> 1) {
918 text
= i18n("%1 Folders selected",folderCount
);
921 if ((fileCount
> 0) && (folderCount
> 0)) {
925 const QString
sizeText(KIO::convertSize(byteSize
));
926 if (fileCount
== 1) {
927 text
+= i18n("1 File selected (%1)",sizeText
);
929 else if (fileCount
> 1) {
930 text
+= i18n("%1 Files selected (%1)",fileCount
,sizeText
);
936 QString
DolphinView::renameIndexPresentation(int index
, int itemCount
) const
938 // assure that the string reprentation for all indicess have the same
939 // number of characters based on the given number of items
940 QString
str(QString::number(index
));
942 while (itemCount
>= 10) {
946 str
.reserve(chrCount
);
948 const int insertCount
= chrCount
- str
.length();
949 for (int i
= 0; i
< insertCount
; ++i
) {
955 void DolphinView::slotShowFilterBar(bool show
)
957 assert(m_filterBar
!= 0);
966 void DolphinView::slotChangeNameFilter(const QString
& nameFilter
)
968 // The name filter of KDirLister does a 'hard' filtering, which
969 // means that only the items are shown where the names match
970 // exactly the filter. This is non-transparent for the user, which
971 // just wants to have a 'soft' filtering: does the name contain
972 // the filter string?
973 QString
adjustedFilter(nameFilter
);
974 adjustedFilter
.insert(0, '*');
975 adjustedFilter
.append('*');
977 m_dirLister
->setNameFilter(adjustedFilter
);
978 m_dirLister
->emitChanges();
980 // TODO: this is a workaround for QIconView: the item position
981 // stay as they are by filtering, only an inserting of an item
982 // results to an automatic adjusting of the item position. In Qt4/KDE4
983 // this workaround should get obsolete due to Interview.
984 /*KFileView* view = fileView();
985 if (view == m_iconsView) {
986 KFileItem* first = view->firstFileItem();
988 view->removeItem(first);
989 view->insertItem(first);
994 bool DolphinView::isFilterBarVisible()
996 return m_filterBar
->isVisible();
999 #include "dolphinview.moc"