]>
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>
36 #include <kmimetyperesolver.h>
39 #include "urlnavigator.h"
40 #include "dolphinstatusbar.h"
42 #include "dolphindirlister.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"
51 #include "filterbar.h"
53 DolphinView::DolphinView(QWidget
*parent
,
56 bool showHiddenFiles
) :
59 m_showProgress(false),
67 setFocusPolicy(Qt::StrongFocus
);
68 m_topLayout
= new Q3VBoxLayout(this);
70 Dolphin
& dolphin
= Dolphin::mainWin();
72 connect(this, SIGNAL(signalModeChanged()),
73 &dolphin
, SLOT(slotViewModeChanged()));
74 connect(this, SIGNAL(signalShowHiddenFilesChanged()),
75 &dolphin
, SLOT(slotShowHiddenFilesChanged()));
76 connect(this, SIGNAL(signalSortingChanged(DolphinView::Sorting
)),
77 &dolphin
, SLOT(slotSortingChanged(DolphinView::Sorting
)));
78 connect(this, SIGNAL(signalSortOrderChanged(Qt::SortOrder
)),
79 &dolphin
, SLOT(slotSortOrderChanged(Qt::SortOrder
)));
81 m_urlNavigator
= new UrlNavigator(url
, this);
82 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
83 this, SLOT(slotUrlChanged(const KUrl
&)));
84 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
85 &dolphin
, SLOT(slotUrlChanged(const KUrl
&)));
86 connect(m_urlNavigator
, SIGNAL(historyChanged()),
87 &dolphin
, SLOT(slotHistoryChanged()));
89 m_statusBar
= new DolphinStatusBar(this);
91 m_dirLister
= new DolphinDirLister();
92 m_dirLister
->setAutoUpdate(true);
93 m_dirLister
->setMainWindow(this);
94 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
95 connect(m_dirLister
, SIGNAL(clear()),
96 this, SLOT(slotClear()));
97 connect(m_dirLister
, SIGNAL(percent(int)),
98 this, SLOT(slotPercent(int)));
99 connect(m_dirLister
, SIGNAL(deleteItem(KFileItem
*)),
100 this, SLOT(slotDeleteItem(KFileItem
*)));
101 connect(m_dirLister
, SIGNAL(completed()),
102 this, SLOT(slotCompleted()));
103 connect(m_dirLister
, SIGNAL(infoMessage(const QString
&)),
104 this, SLOT(slotInfoMessage(const QString
&)));
105 connect(m_dirLister
, SIGNAL(errorMessage(const QString
&)),
106 this, SLOT(slotErrorMessage(const QString
&)));
108 m_iconsView
= new DolphinIconsView(this);
109 connect(m_iconsView
, SIGNAL(clicked(const QModelIndex
&)),
110 this, SLOT(triggerItem(const QModelIndex
&)));
113 KDirModel
* model
= new KDirModel();
114 model
->setDirLister(m_dirLister
);
115 m_iconsView
->setModel(model
);
117 m_dirLister
->setDelayedMimeTypes(true);
118 new KMimeTypeResolver( m_iconsView
, model
);
120 m_iconSize
= K3Icon::SizeMedium
;
122 m_filterBar
= new FilterBar(this);
124 connect(m_filterBar
, SIGNAL(signalFilterChanged(const QString
&)),
125 this, SLOT(slotChangeNameFilter(const QString
&)));
127 m_topLayout
->addWidget(m_urlNavigator
);
128 m_topLayout
->addWidget(m_iconsView
);
129 m_topLayout
->addWidget(m_filterBar
);
130 m_topLayout
->addWidget(m_statusBar
);
132 startDirLister(m_urlNavigator
->url());
135 DolphinView::~DolphinView()
141 void DolphinView::setUrl(const KUrl
& url
)
143 m_urlNavigator
->setUrl(url
);
146 const KUrl
& DolphinView::url() const
148 return m_urlNavigator
->url();
151 void DolphinView::requestActivation()
153 Dolphin::mainWin().setActiveView(this);
156 bool DolphinView::isActive() const
158 return (Dolphin::mainWin().activeView() == this);
161 void DolphinView::setMode(Mode mode
)
163 if (mode
== m_mode
) {
164 return; // the wished mode is already set
169 ViewProperties
props(m_urlNavigator
->url());
170 props
.setViewMode(m_mode
);
173 startDirLister(m_urlNavigator
->url());
175 emit
signalModeChanged();
178 DolphinView::Mode
DolphinView::mode() const
183 void DolphinView::setShowHiddenFilesEnabled(bool show
)
185 if (m_dirLister
->showingDotFiles() == show
) {
189 ViewProperties
props(m_urlNavigator
->url());
190 props
.setShowHiddenFilesEnabled(show
);
193 m_dirLister
->setShowingDotFiles(show
);
195 emit
signalShowHiddenFilesChanged();
200 bool DolphinView::isShowHiddenFilesEnabled() const
202 return m_dirLister
->showingDotFiles();
205 void DolphinView::setViewProperties(const ViewProperties
& props
)
207 setMode(props
.viewMode());
208 setSorting(props
.sorting());
209 setSortOrder(props
.sortOrder());
210 setShowHiddenFilesEnabled(props
.isShowHiddenFilesEnabled());
213 void DolphinView::renameSelectedItems()
215 const KUrl::List urls
= selectedUrls();
216 if (urls
.count() > 1) {
217 // More than one item has been selected for renaming. Open
218 // a rename dialog and rename all items afterwards.
219 RenameDialog
dialog(urls
);
220 if (dialog
.exec() == QDialog::Rejected
) {
224 DolphinView
* view
= Dolphin::mainWin().activeView();
225 const QString
& newName
= dialog
.newName();
226 if (newName
.isEmpty()) {
227 view
->statusBar()->setMessage(i18n("The new item name is invalid."),
228 DolphinStatusBar::Error
);
231 UndoManager
& undoMan
= UndoManager::instance();
232 undoMan
.beginMacro();
234 assert(newName
.contains('#'));
236 const int urlsCount
= urls
.count();
237 ProgressIndicator
* progressIndicator
=
238 new ProgressIndicator(i18n("Renaming items..."),
239 i18n("Renaming finished."),
242 // iterate through all selected items and rename them...
243 const int replaceIndex
= newName
.find('#');
244 assert(replaceIndex
>= 0);
245 for (int i
= 0; i
< urlsCount
; ++i
) {
246 const KUrl
& source
= urls
[i
];
247 QString
name(newName
);
248 name
.replace(replaceIndex
, 1, renameIndexPresentation(i
+ 1, urlsCount
));
250 if (source
.fileName() != name
) {
251 KUrl
dest(source
.upUrl());
254 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
256 delete progressIndicator
;
257 progressIndicator
= 0;
258 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
259 DolphinStatusBar::Error
);
262 else if (KIO::NetAccess::file_move(source
, dest
)) {
263 // TODO: From the users point of view he executed one 'rename n files' operation,
264 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
265 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
266 undoMan
.addCommand(command
);
270 progressIndicator
->execOperation();
272 delete progressIndicator
;
273 progressIndicator
= 0;
279 // Only one item has been selected for renaming. Use the custom
280 // renaming mechanism from the views.
281 assert(urls
.count() == 1);
283 /*if (m_mode == DetailsView) {
284 Q3ListViewItem* item = m_iconsView->firstChild();
286 if (item->isSelected()) {
287 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
290 item = item->nextSibling();
294 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
296 if (item->isSelected()) {
300 item = static_cast<KFileIconViewItem*>(item->nextItem());
306 void DolphinView::selectAll()
308 //fileView()->selectAll();
311 void DolphinView::invertSelection()
313 //fileView()->invertSelection();
316 DolphinStatusBar
* DolphinView::statusBar() const
321 int DolphinView::contentsX() const
324 return 0; //scrollView()->contentsX();
327 int DolphinView::contentsY() const
329 return 0; //scrollView()->contentsY();
332 void DolphinView::refreshSettings()
334 startDirLister(m_urlNavigator
->url());
337 void DolphinView::updateStatusBar()
339 // As the item count information is less important
340 // in comparison with other messages, it should only
342 // - the status bar is empty or
343 // - shows already the item count information or
344 // - shows only a not very important information
345 // - if any progress is given don't show the item count info at all
346 const QString
msg(m_statusBar
->message());
347 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
348 (msg
== m_statusBar
->defaultText()) ||
349 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
350 (m_statusBar
->progress() == 100);
352 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
353 m_statusBar
->setDefaultText(text
);
355 if (updateStatusBarMsg
) {
356 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
360 void DolphinView::requestItemInfo(const KUrl
& url
)
362 emit
signalRequestItemInfo(url
);
365 bool DolphinView::isUrlEditable() const
367 return m_urlNavigator
->isUrlEditable();
370 void DolphinView::zoomIn()
372 //itemEffectsManager()->zoomIn();
375 void DolphinView::zoomOut()
377 //itemEffectsManager()->zoomOut();
380 bool DolphinView::isZoomInPossible() const
382 return false; //itemEffectsManager()->isZoomInPossible();
385 bool DolphinView::isZoomOutPossible() const
387 return false; //itemEffectsManager()->isZoomOutPossible();
390 void DolphinView::setSorting(Sorting sorting
)
392 if (sorting
!= this->sorting()) {
393 /*KFileView* view = fileView();
394 int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
397 case SortByName: spec = spec | QDir::Name; break;
398 case SortBySize: spec = spec | QDir::Size; break;
399 case SortByDate: spec = spec | QDir::Time; break;
403 ViewProperties props(url());
404 props.setSorting(sorting);
406 view->setSorting(static_cast<QDir::SortFlags>(spec));
408 emit signalSortingChanged(sorting);*/
412 DolphinView::Sorting
DolphinView::sorting() const
414 /*const QDir::SortFlags spec = fileView()->sorting();
416 if (spec & QDir::Time) {
420 if (spec & QDir::Size) {
427 void DolphinView::setSortOrder(Qt::SortOrder order
)
429 if (sortOrder() != order
) {
430 /*KFileView* view = fileView();
431 int sorting = view->sorting();
432 sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
433 (sorting | QDir::Reversed);
435 ViewProperties props(url());
436 props.setSortOrder(order);
438 view->setSorting(static_cast<QDir::SortFlags>(sorting));
440 emit signalSortOrderChanged(order);*/
444 Qt::SortOrder
DolphinView::sortOrder() const
446 //return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
447 return Qt::Descending
;
450 void DolphinView::goBack()
452 m_urlNavigator
->goBack();
455 void DolphinView::goForward()
457 m_urlNavigator
->goForward();
460 void DolphinView::goUp()
462 m_urlNavigator
->goUp();
465 void DolphinView::goHome()
467 m_urlNavigator
->goHome();
470 void DolphinView::setUrlEditable(bool editable
)
472 m_urlNavigator
->editUrl(editable
);
475 const Q3ValueList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
477 return m_urlNavigator
->history(index
);
480 bool DolphinView::hasSelection() const
482 const KFileItemList
* list
= selectedItems();
483 return (list
!= 0) && !list
->isEmpty();
486 const KFileItemList
* DolphinView::selectedItems() const
488 return 0; //fileView()->selectedItems();
491 KUrl::List
DolphinView::selectedUrls() const
495 /*const KFileItemList* list = fileView()->selectedItems();
497 KFileItemList::const_iterator it = list->begin();
498 const KFileItemList::const_iterator end = list->end();
500 KFileItem* item = *it;
501 urls.append(item->url());
509 const KFileItem
* DolphinView::currentFileItem() const
511 return 0; // fileView()->currentFileItem();
514 void DolphinView::openContextMenu(KFileItem
* fileInfo
, const QPoint
& pos
)
516 DolphinContextMenu
contextMenu(this, fileInfo
, pos
);
520 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
524 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
528 KUrl
dest(source
.upUrl());
529 dest
.addPath(newName
);
531 const bool destExists
= KIO::NetAccess::exists(dest
,
533 Dolphin::mainWin().activeView());
535 // the destination already exists, hence ask the user
537 KIO::RenameDlg
renameDialog(this,
538 i18n("File Already Exists"),
542 switch (renameDialog
.exec()) {
543 case KIO::R_OVERWRITE
:
544 // the destination should be overwritten
545 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
548 case KIO::R_RENAME
: {
549 // a new name for the destination has been used
550 KUrl
newDest(renameDialog
.newDestUrl());
551 ok
= KIO::NetAccess::file_move(source
, newDest
);
556 // the renaming operation has been canceled
562 // no destination exists, hence just move the file to
564 ok
= KIO::NetAccess::file_move(source
, dest
);
568 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), dest
.fileName()),
569 DolphinStatusBar::OperationCompleted
);
571 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
572 UndoManager::instance().addCommand(command
);
575 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), dest
.fileName()),
576 DolphinStatusBar::Error
);
581 void DolphinView::reload()
583 startDirLister(m_urlNavigator
->url(), true);
586 void DolphinView::slotUrlListDropped(QDropEvent
* /* event */,
587 const KUrl::List
& urls
,
590 KUrl
destination(url
);
591 if (destination
.isEmpty()) {
592 destination
= m_urlNavigator
->url();
595 // Check whether the destination Url is a directory. If this is not the
596 // case, use the navigator Url as destination (otherwise the destination,
597 // which represents a file, would be replaced by a copy- or move-operation).
598 KFileItem
fileItem(KFileItem::Unknown
, KFileItem::Unknown
, destination
);
599 if (!fileItem
.isDir()) {
600 destination
= m_urlNavigator
->url();
604 Dolphin::mainWin().dropUrls(urls
, destination
);
607 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
609 QWidget::mouseReleaseEvent(event
);
610 Dolphin::mainWin().setActiveView(this);
613 void DolphinView::slotUrlChanged(const KUrl
& url
)
615 const ViewProperties
props(url
);
616 setMode(props
.viewMode());
618 const bool showHiddenFiles
= props
.isShowHiddenFilesEnabled();
619 setShowHiddenFilesEnabled(showHiddenFiles
);
620 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
622 setSorting(props
.sorting());
623 setSortOrder(props
.sortOrder());
627 // The selectionChanged signal is not emitted when a new view object is
628 // created. The application does not care whether a view is represented by a
629 // different instance, hence inform the application that the selection might have
630 // changed so that it can update it's actions.
631 Dolphin::mainWin().slotSelectionChanged();
633 emit
signalUrlChanged(url
);
636 void DolphinView::triggerIconsViewItem(Q3IconViewItem
* item
)
639 const Qt::ButtonState keyboardState = KApplication::keyboardMouseState();
640 const bool isSelectionActive = ((keyboardState & Qt::ShiftModifier) > 0) ||
641 ((keyboardState & Qt::ControlModifier) > 0);*/
642 const bool isSelectionActive
= false;
643 if ((item
!= 0) && !isSelectionActive
) {
644 // Updating the Url must be done outside the scope of this slot,
645 // as iconview items will get deleted.
646 QTimer::singleShot(0, this, SLOT(updateUrl()));
647 Dolphin::mainWin().setActiveView(this);
651 void DolphinView::triggerItem(const QModelIndex
& index
)
653 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
654 KFileItem
* item
= dirModel
->itemForIndex(index
);
660 // Prefer the local path over the Url. This assures that the
661 // volume space information is correct. Assuming that the Url is media:/sda1,
662 // and the local path is /windows/C: For the Url the space info is related
663 // to the root partition (and hence wrong) and for the local path the space
664 // info is related to the windows partition (-> correct).
665 //m_dirLister->stop();
666 //m_dirLister->openUrl(item->url());
669 const QString
localPath(item
->localPath());
670 if (localPath
.isEmpty()) {
674 setUrl(KUrl(localPath
));
682 void DolphinView::updateUrl()
684 //KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
685 // static_cast<KFileView*>(m_iconsView);
687 KFileItem
* fileItem
= 0; // TODO: fileView->currentFileItem();
692 if (fileItem
->isDir()) {
693 // Prefer the local path over the Url. This assures that the
694 // volume space information is correct. Assuming that the Url is media:/sda1,
695 // and the local path is /windows/C: For the Url the space info is related
696 // to the root partition (and hence wrong) and for the local path the space
697 // info is related to the windows partition (-> correct).
698 const QString
localPath(fileItem
->localPath());
699 if (localPath
.isEmpty()) {
700 setUrl(fileItem
->url());
703 setUrl(KUrl(localPath
));
711 void DolphinView::slotPercent(int percent
)
713 if (m_showProgress
) {
714 m_statusBar
->setProgress(percent
);
718 void DolphinView::slotClear()
720 //fileView()->clearView();
724 void DolphinView::slotDeleteItem(KFileItem
* item
)
726 //fileView()->removeItem(item);
730 void DolphinView::slotCompleted()
734 //KFileView* view = fileView();
737 // TODO: in Qt4 the code should get a lot
738 // simpler and nicer due to Interview...
739 /*if (m_iconsView != 0) {
740 m_iconsView->beginItemUpdates();
742 if (m_iconsView != 0) {
743 m_iconsView->beginItemUpdates();
746 if (m_showProgress
) {
747 m_statusBar
->setProgressText(QString::null
);
748 m_statusBar
->setProgress(100);
749 m_showProgress
= false;
752 KFileItemList
items(m_dirLister
->items());
753 KFileItemList::const_iterator it
= items
.begin();
754 const KFileItemList::const_iterator end
= items
.end();
760 KFileItem
* item
= *it
;
761 //view->insertItem(item);
773 /*if (m_iconsView != 0) {
774 // Prevent a flickering of the icon view widget by giving a small
775 // timeslot to swallow asynchronous update events.
776 m_iconsView->setUpdatesEnabled(false);
777 QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
780 if (m_iconsView != 0) {
781 m_iconsView->endItemUpdates();
782 m_refreshing = false;
786 void DolphinView::slotInfoMessage(const QString
& msg
)
788 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
791 void DolphinView::slotErrorMessage(const QString
& msg
)
793 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
796 void DolphinView::slotGrabActivation()
798 Dolphin::mainWin().setActiveView(this);
801 void DolphinView::slotContentsMoving(int x
, int y
)
804 // Only emit a 'contents moved' signal if the user
805 // moved the content by adjusting the sliders. Adjustments
806 // resulted by refreshing a directory should not be respected.
807 emit
contentsMoved(x
, y
);
811 /*KFileView* DolphinView::fileView() const
813 return (m_mode == DetailsView) ? static_cast<KFileView*>(m_iconsView) :
814 static_cast<KFileView*>(m_iconsView);
817 Q3ScrollView
* DolphinView::scrollView() const
819 return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
820 // static_cast<Q3ScrollView*>(m_iconsView);
823 ItemEffectsManager
* DolphinView::itemEffectsManager() const
828 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
830 if (!url
.isValid()) {
831 const QString
location(url
.pathOrUrl());
832 if (location
.isEmpty()) {
833 m_statusBar
->setMessage(i18n("The location is empty."), DolphinStatusBar::Error
);
836 m_statusBar
->setMessage(i18n("The location '%1' is invalid.",location
),
837 DolphinStatusBar::Error
);
842 // Only show the directory loading progress if the status bar does
843 // not contain another progress information. This means that
844 // the directory loading progress information has the lowest priority.
845 const QString
progressText(m_statusBar
->progressText());
846 m_showProgress
= progressText
.isEmpty() ||
847 (progressText
== i18n("Loading directory..."));
848 if (m_showProgress
) {
849 m_statusBar
->setProgressText(i18n("Loading directory..."));
850 m_statusBar
->setProgress(0);
855 m_dirLister
->openUrl(url
, false, reload
);
858 QString
DolphinView::defaultStatusBarText() const
860 // TODO: the following code is not suitable for languages where multiple forms
861 // of plurals are given (e. g. in Poland three forms of plurals exist).
862 const int itemCount
= m_folderCount
+ m_fileCount
;
865 if (itemCount
== 1) {
866 text
= i18n("1 Item");
869 text
= i18n("%1 Items",itemCount
);
874 if (m_folderCount
== 1) {
875 text
+= i18n("1 Folder");
878 text
+= i18n("%1 Folders",m_folderCount
);
883 if (m_fileCount
== 1) {
884 text
+= i18n("1 File");
887 text
+= i18n("%1 Files",m_fileCount
);
895 QString
DolphinView::selectionStatusBarText() const
897 // TODO: the following code is not suitable for languages where multiple forms
898 // of plurals are given (e. g. in Poland three forms of plurals exist).
900 const KFileItemList
* list
= selectedItems();
901 assert((list
!= 0) && !list
->isEmpty());
905 KIO::filesize_t byteSize
= 0;
906 KFileItemList::const_iterator it
= list
->begin();
907 const KFileItemList::const_iterator end
= list
->end();
909 KFileItem
* item
= *it
;
915 byteSize
+= item
->size();
920 if (folderCount
== 1) {
921 text
= i18n("1 Folder selected");
923 else if (folderCount
> 1) {
924 text
= i18n("%1 Folders selected",folderCount
);
927 if ((fileCount
> 0) && (folderCount
> 0)) {
931 const QString
sizeText(KIO::convertSize(byteSize
));
932 if (fileCount
== 1) {
933 text
+= i18n("1 File selected (%1)",sizeText
);
935 else if (fileCount
> 1) {
936 text
+= i18n("%1 Files selected (%1)",fileCount
,sizeText
);
942 QString
DolphinView::renameIndexPresentation(int index
, int itemCount
) const
944 // assure that the string reprentation for all indicess have the same
945 // number of characters based on the given number of items
946 QString
str(QString::number(index
));
948 while (itemCount
>= 10) {
952 str
.reserve(chrCount
);
954 const int insertCount
= chrCount
- str
.length();
955 for (int i
= 0; i
< insertCount
; ++i
) {
961 void DolphinView::slotShowFilterBar(bool show
)
963 assert(m_filterBar
!= 0);
972 void DolphinView::slotChangeNameFilter(const QString
& nameFilter
)
974 // The name filter of KDirLister does a 'hard' filtering, which
975 // means that only the items are shown where the names match
976 // exactly the filter. This is non-transparent for the user, which
977 // just wants to have a 'soft' filtering: does the name contain
978 // the filter string?
979 QString
adjustedFilter(nameFilter
);
980 adjustedFilter
.insert(0, '*');
981 adjustedFilter
.append('*');
983 m_dirLister
->setNameFilter(adjustedFilter
);
984 m_dirLister
->emitChanges();
986 // TODO: this is a workaround for QIconView: the item position
987 // stay as they are by filtering, only an inserting of an item
988 // results to an automatic adjusting of the item position. In Qt4/KDE4
989 // this workaround should get obsolete due to Interview.
990 /*KFileView* view = fileView();
991 if (view == m_iconsView) {
992 KFileItem* first = view->firstFileItem();
994 view->removeItem(first);
995 view->insertItem(first);
1000 bool DolphinView::isFilterBarVisible()
1002 return m_filterBar
->isVisible();
1005 void DolphinView::applyModeToView()
1007 // TODO: the following code just tries to test some QListView capabilities
1010 m_iconsView
->setViewMode(QListView::IconMode
);
1011 m_iconsView
->setGridSize(QSize(128, 64));
1015 m_iconsView
->setViewMode(QListView::ListMode
);
1016 m_iconsView
->setGridSize(QSize(256, 24));
1020 m_iconsView
->setViewMode(QListView::IconMode
);
1021 m_iconsView
->setGridSize(QSize(128, 128));
1026 #include "dolphinview.moc"