]>
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"
41 #include "dolphinmainwindow.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(DolphinMainWindow
*mainWindow
,
57 bool showHiddenFiles
) :
59 m_mainWindow(mainWindow
),
61 m_showProgress(false),
69 setFocusPolicy(Qt::StrongFocus
);
70 m_topLayout
= new Q3VBoxLayout(this);
72 connect(this, SIGNAL(signalModeChanged()),
73 mainWindow
, SLOT(slotViewModeChanged()));
74 connect(this, SIGNAL(signalShowHiddenFilesChanged()),
75 mainWindow
, SLOT(slotShowHiddenFilesChanged()));
76 connect(this, SIGNAL(signalSortingChanged(DolphinView::Sorting
)),
77 mainWindow
, SLOT(slotSortingChanged(DolphinView::Sorting
)));
78 connect(this, SIGNAL(signalSortOrderChanged(Qt::SortOrder
)),
79 mainWindow
, 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 mainWindow
, SLOT(slotUrlChanged(const KUrl
&)));
86 connect(m_urlNavigator
, SIGNAL(historyChanged()),
87 mainWindow
, 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(mainWindow
, 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 mainWindow()->setActiveView(this);
156 bool DolphinView::isActive() const
158 return (mainWindow()->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
= mainWindow()->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(mainWindow(),
239 i18n("Renaming items..."),
240 i18n("Renaming finished."),
243 // iterate through all selected items and rename them...
244 const int replaceIndex
= newName
.find('#');
245 assert(replaceIndex
>= 0);
246 for (int i
= 0; i
< urlsCount
; ++i
) {
247 const KUrl
& source
= urls
[i
];
248 QString
name(newName
);
249 name
.replace(replaceIndex
, 1, renameIndexPresentation(i
+ 1, urlsCount
));
251 if (source
.fileName() != name
) {
252 KUrl
dest(source
.upUrl());
255 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
257 delete progressIndicator
;
258 progressIndicator
= 0;
259 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
260 DolphinStatusBar::Error
);
263 else if (KIO::NetAccess::file_move(source
, dest
)) {
264 // TODO: From the users point of view he executed one 'rename n files' operation,
265 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
266 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
, mainWindow());
267 undoMan
.addCommand(command
);
271 progressIndicator
->execOperation();
273 delete progressIndicator
;
274 progressIndicator
= 0;
280 // Only one item has been selected for renaming. Use the custom
281 // renaming mechanism from the views.
282 assert(urls
.count() == 1);
284 /*if (m_mode == DetailsView) {
285 Q3ListViewItem* item = m_iconsView->firstChild();
287 if (item->isSelected()) {
288 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
291 item = item->nextSibling();
295 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
297 if (item->isSelected()) {
301 item = static_cast<KFileIconViewItem*>(item->nextItem());
307 void DolphinView::selectAll()
309 //fileView()->selectAll();
312 void DolphinView::invertSelection()
314 //fileView()->invertSelection();
317 DolphinStatusBar
* DolphinView::statusBar() const
322 int DolphinView::contentsX() const
325 return 0; //scrollView()->contentsX();
328 int DolphinView::contentsY() const
330 return 0; //scrollView()->contentsY();
333 void DolphinView::refreshSettings()
335 startDirLister(m_urlNavigator
->url());
338 void DolphinView::updateStatusBar()
340 // As the item count information is less important
341 // in comparison with other messages, it should only
343 // - the status bar is empty or
344 // - shows already the item count information or
345 // - shows only a not very important information
346 // - if any progress is given don't show the item count info at all
347 const QString
msg(m_statusBar
->message());
348 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
349 (msg
== m_statusBar
->defaultText()) ||
350 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
351 (m_statusBar
->progress() == 100);
353 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
354 m_statusBar
->setDefaultText(text
);
356 if (updateStatusBarMsg
) {
357 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
361 void DolphinView::requestItemInfo(const KUrl
& url
)
363 emit
signalRequestItemInfo(url
);
366 bool DolphinView::isUrlEditable() const
368 return m_urlNavigator
->isUrlEditable();
371 void DolphinView::zoomIn()
373 //itemEffectsManager()->zoomIn();
376 void DolphinView::zoomOut()
378 //itemEffectsManager()->zoomOut();
381 bool DolphinView::isZoomInPossible() const
383 return false; //itemEffectsManager()->isZoomInPossible();
386 bool DolphinView::isZoomOutPossible() const
388 return false; //itemEffectsManager()->isZoomOutPossible();
391 void DolphinView::setSorting(Sorting sorting
)
393 if (sorting
!= this->sorting()) {
394 /*KFileView* view = fileView();
395 int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
398 case SortByName: spec = spec | QDir::Name; break;
399 case SortBySize: spec = spec | QDir::Size; break;
400 case SortByDate: spec = spec | QDir::Time; break;
404 ViewProperties props(url());
405 props.setSorting(sorting);
407 view->setSorting(static_cast<QDir::SortFlags>(spec));
409 emit signalSortingChanged(sorting);*/
413 DolphinView::Sorting
DolphinView::sorting() const
415 /*const QDir::SortFlags spec = fileView()->sorting();
417 if (spec & QDir::Time) {
421 if (spec & QDir::Size) {
428 void DolphinView::setSortOrder(Qt::SortOrder order
)
430 if (sortOrder() != order
) {
431 /*KFileView* view = fileView();
432 int sorting = view->sorting();
433 sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
434 (sorting | QDir::Reversed);
436 ViewProperties props(url());
437 props.setSortOrder(order);
439 view->setSorting(static_cast<QDir::SortFlags>(sorting));
441 emit signalSortOrderChanged(order);*/
445 Qt::SortOrder
DolphinView::sortOrder() const
447 //return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
448 return Qt::Descending
;
451 void DolphinView::goBack()
453 m_urlNavigator
->goBack();
456 void DolphinView::goForward()
458 m_urlNavigator
->goForward();
461 void DolphinView::goUp()
463 m_urlNavigator
->goUp();
466 void DolphinView::goHome()
468 m_urlNavigator
->goHome();
471 void DolphinView::setUrlEditable(bool editable
)
473 m_urlNavigator
->editUrl(editable
);
476 const Q3ValueList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
478 return m_urlNavigator
->history(index
);
481 bool DolphinView::hasSelection() const
483 const KFileItemList
* list
= selectedItems();
484 return (list
!= 0) && !list
->isEmpty();
487 const KFileItemList
* DolphinView::selectedItems() const
489 return 0; //fileView()->selectedItems();
492 KUrl::List
DolphinView::selectedUrls() const
496 /*const KFileItemList* list = fileView()->selectedItems();
498 KFileItemList::const_iterator it = list->begin();
499 const KFileItemList::const_iterator end = list->end();
501 KFileItem* item = *it;
502 urls.append(item->url());
510 const KFileItem
* DolphinView::currentFileItem() const
512 return 0; // fileView()->currentFileItem();
515 void DolphinView::openContextMenu(KFileItem
* fileInfo
, const QPoint
& pos
)
517 DolphinContextMenu
contextMenu(this, fileInfo
, pos
);
521 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
525 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
529 KUrl
dest(source
.upUrl());
530 dest
.addPath(newName
);
532 const bool destExists
= KIO::NetAccess::exists(dest
,
534 mainWindow()->activeView());
536 // the destination already exists, hence ask the user
538 KIO::RenameDlg
renameDialog(this,
539 i18n("File Already Exists"),
543 switch (renameDialog
.exec()) {
544 case KIO::R_OVERWRITE
:
545 // the destination should be overwritten
546 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
549 case KIO::R_RENAME
: {
550 // a new name for the destination has been used
551 KUrl
newDest(renameDialog
.newDestUrl());
552 ok
= KIO::NetAccess::file_move(source
, newDest
);
557 // the renaming operation has been canceled
563 // no destination exists, hence just move the file to
565 ok
= KIO::NetAccess::file_move(source
, dest
);
569 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), dest
.fileName()),
570 DolphinStatusBar::OperationCompleted
);
572 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
, mainWindow());
573 UndoManager::instance().addCommand(command
);
576 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), dest
.fileName()),
577 DolphinStatusBar::Error
);
582 void DolphinView::reload()
584 startDirLister(m_urlNavigator
->url(), true);
587 void DolphinView::slotUrlListDropped(QDropEvent
* /* event */,
588 const KUrl::List
& urls
,
591 KUrl
destination(url
);
592 if (destination
.isEmpty()) {
593 destination
= m_urlNavigator
->url();
596 // Check whether the destination Url is a directory. If this is not the
597 // case, use the navigator Url as destination (otherwise the destination,
598 // which represents a file, would be replaced by a copy- or move-operation).
599 KFileItem
fileItem(KFileItem::Unknown
, KFileItem::Unknown
, destination
);
600 if (!fileItem
.isDir()) {
601 destination
= m_urlNavigator
->url();
605 mainWindow()->dropUrls(urls
, destination
);
608 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
610 QWidget::mouseReleaseEvent(event
);
611 mainWindow()->setActiveView(this);
614 DolphinMainWindow
* DolphinView::mainWindow() const
619 void DolphinView::slotUrlChanged(const KUrl
& url
)
621 const ViewProperties
props(url
);
622 setMode(props
.viewMode());
624 const bool showHiddenFiles
= props
.isShowHiddenFilesEnabled();
625 setShowHiddenFilesEnabled(showHiddenFiles
);
626 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
628 setSorting(props
.sorting());
629 setSortOrder(props
.sortOrder());
633 // The selectionChanged signal is not emitted when a new view object is
634 // created. The application does not care whether a view is represented by a
635 // different instance, hence inform the application that the selection might have
636 // changed so that it can update it's actions.
637 mainWindow()->slotSelectionChanged();
639 emit
signalUrlChanged(url
);
642 void DolphinView::triggerIconsViewItem(Q3IconViewItem
* item
)
645 const Qt::ButtonState keyboardState = KApplication::keyboardMouseState();
646 const bool isSelectionActive = ((keyboardState & Qt::ShiftModifier) > 0) ||
647 ((keyboardState & Qt::ControlModifier) > 0);*/
648 const bool isSelectionActive
= false;
649 if ((item
!= 0) && !isSelectionActive
) {
650 // Updating the Url must be done outside the scope of this slot,
651 // as iconview items will get deleted.
652 QTimer::singleShot(0, this, SLOT(updateUrl()));
653 mainWindow()->setActiveView(this);
657 void DolphinView::triggerItem(const QModelIndex
& index
)
659 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
660 KFileItem
* item
= dirModel
->itemForIndex(index
);
666 // Prefer the local path over the Url. This assures that the
667 // volume space information is correct. Assuming that the Url is media:/sda1,
668 // and the local path is /windows/C: For the Url the space info is related
669 // to the root partition (and hence wrong) and for the local path the space
670 // info is related to the windows partition (-> correct).
671 //m_dirLister->stop();
672 //m_dirLister->openUrl(item->url());
675 const QString
localPath(item
->localPath());
676 if (localPath
.isEmpty()) {
680 setUrl(KUrl(localPath
));
688 void DolphinView::updateUrl()
690 //KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
691 // static_cast<KFileView*>(m_iconsView);
693 KFileItem
* fileItem
= 0; // TODO: fileView->currentFileItem();
698 if (fileItem
->isDir()) {
699 // Prefer the local path over the Url. This assures that the
700 // volume space information is correct. Assuming that the Url is media:/sda1,
701 // and the local path is /windows/C: For the Url the space info is related
702 // to the root partition (and hence wrong) and for the local path the space
703 // info is related to the windows partition (-> correct).
704 const QString
localPath(fileItem
->localPath());
705 if (localPath
.isEmpty()) {
706 setUrl(fileItem
->url());
709 setUrl(KUrl(localPath
));
717 void DolphinView::slotPercent(int percent
)
719 if (m_showProgress
) {
720 m_statusBar
->setProgress(percent
);
724 void DolphinView::slotClear()
726 //fileView()->clearView();
730 void DolphinView::slotDeleteItem(KFileItem
* item
)
732 //fileView()->removeItem(item);
736 void DolphinView::slotCompleted()
740 //KFileView* view = fileView();
743 // TODO: in Qt4 the code should get a lot
744 // simpler and nicer due to Interview...
745 /*if (m_iconsView != 0) {
746 m_iconsView->beginItemUpdates();
748 if (m_iconsView != 0) {
749 m_iconsView->beginItemUpdates();
752 if (m_showProgress
) {
753 m_statusBar
->setProgressText(QString::null
);
754 m_statusBar
->setProgress(100);
755 m_showProgress
= false;
758 KFileItemList
items(m_dirLister
->items());
759 KFileItemList::const_iterator it
= items
.begin();
760 const KFileItemList::const_iterator end
= items
.end();
766 KFileItem
* item
= *it
;
767 //view->insertItem(item);
779 /*if (m_iconsView != 0) {
780 // Prevent a flickering of the icon view widget by giving a small
781 // timeslot to swallow asynchronous update events.
782 m_iconsView->setUpdatesEnabled(false);
783 QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
786 if (m_iconsView != 0) {
787 m_iconsView->endItemUpdates();
788 m_refreshing = false;
792 void DolphinView::slotInfoMessage(const QString
& msg
)
794 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
797 void DolphinView::slotErrorMessage(const QString
& msg
)
799 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
802 void DolphinView::slotGrabActivation()
804 mainWindow()->setActiveView(this);
807 void DolphinView::slotContentsMoving(int x
, int y
)
810 // Only emit a 'contents moved' signal if the user
811 // moved the content by adjusting the sliders. Adjustments
812 // resulted by refreshing a directory should not be respected.
813 emit
contentsMoved(x
, y
);
817 /*KFileView* DolphinView::fileView() const
819 return (m_mode == DetailsView) ? static_cast<KFileView*>(m_iconsView) :
820 static_cast<KFileView*>(m_iconsView);
823 Q3ScrollView
* DolphinView::scrollView() const
825 return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
826 // static_cast<Q3ScrollView*>(m_iconsView);
829 ItemEffectsManager
* DolphinView::itemEffectsManager() const
834 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
836 if (!url
.isValid()) {
837 const QString
location(url
.pathOrUrl());
838 if (location
.isEmpty()) {
839 m_statusBar
->setMessage(i18n("The location is empty."), DolphinStatusBar::Error
);
842 m_statusBar
->setMessage(i18n("The location '%1' is invalid.",location
),
843 DolphinStatusBar::Error
);
848 // Only show the directory loading progress if the status bar does
849 // not contain another progress information. This means that
850 // the directory loading progress information has the lowest priority.
851 const QString
progressText(m_statusBar
->progressText());
852 m_showProgress
= progressText
.isEmpty() ||
853 (progressText
== i18n("Loading directory..."));
854 if (m_showProgress
) {
855 m_statusBar
->setProgressText(i18n("Loading directory..."));
856 m_statusBar
->setProgress(0);
861 m_dirLister
->openUrl(url
, false, reload
);
864 QString
DolphinView::defaultStatusBarText() const
866 // TODO: the following code is not suitable for languages where multiple forms
867 // of plurals are given (e. g. in Poland three forms of plurals exist).
868 const int itemCount
= m_folderCount
+ m_fileCount
;
871 if (itemCount
== 1) {
872 text
= i18n("1 Item");
875 text
= i18n("%1 Items",itemCount
);
880 if (m_folderCount
== 1) {
881 text
+= i18n("1 Folder");
884 text
+= i18n("%1 Folders",m_folderCount
);
889 if (m_fileCount
== 1) {
890 text
+= i18n("1 File");
893 text
+= i18n("%1 Files",m_fileCount
);
901 QString
DolphinView::selectionStatusBarText() const
903 // TODO: the following code is not suitable for languages where multiple forms
904 // of plurals are given (e. g. in Poland three forms of plurals exist).
906 const KFileItemList
* list
= selectedItems();
907 assert((list
!= 0) && !list
->isEmpty());
911 KIO::filesize_t byteSize
= 0;
912 KFileItemList::const_iterator it
= list
->begin();
913 const KFileItemList::const_iterator end
= list
->end();
915 KFileItem
* item
= *it
;
921 byteSize
+= item
->size();
926 if (folderCount
== 1) {
927 text
= i18n("1 Folder selected");
929 else if (folderCount
> 1) {
930 text
= i18n("%1 Folders selected",folderCount
);
933 if ((fileCount
> 0) && (folderCount
> 0)) {
937 const QString
sizeText(KIO::convertSize(byteSize
));
938 if (fileCount
== 1) {
939 text
+= i18n("1 File selected (%1)",sizeText
);
941 else if (fileCount
> 1) {
942 text
+= i18n("%1 Files selected (%1)",fileCount
,sizeText
);
948 QString
DolphinView::renameIndexPresentation(int index
, int itemCount
) const
950 // assure that the string reprentation for all indicess have the same
951 // number of characters based on the given number of items
952 QString
str(QString::number(index
));
954 while (itemCount
>= 10) {
958 str
.reserve(chrCount
);
960 const int insertCount
= chrCount
- str
.length();
961 for (int i
= 0; i
< insertCount
; ++i
) {
967 void DolphinView::slotShowFilterBar(bool show
)
969 assert(m_filterBar
!= 0);
978 void DolphinView::declareViewActive()
980 mainWindow()->setActiveView( this );
983 void DolphinView::slotChangeNameFilter(const QString
& nameFilter
)
985 // The name filter of KDirLister does a 'hard' filtering, which
986 // means that only the items are shown where the names match
987 // exactly the filter. This is non-transparent for the user, which
988 // just wants to have a 'soft' filtering: does the name contain
989 // the filter string?
990 QString
adjustedFilter(nameFilter
);
991 adjustedFilter
.insert(0, '*');
992 adjustedFilter
.append('*');
994 m_dirLister
->setNameFilter(adjustedFilter
);
995 m_dirLister
->emitChanges();
997 // TODO: this is a workaround for QIconView: the item position
998 // stay as they are by filtering, only an inserting of an item
999 // results to an automatic adjusting of the item position. In Qt4/KDE4
1000 // this workaround should get obsolete due to Interview.
1001 /*KFileView* view = fileView();
1002 if (view == m_iconsView) {
1003 KFileItem* first = view->firstFileItem();
1005 view->removeItem(first);
1006 view->insertItem(first);
1011 bool DolphinView::isFilterBarVisible()
1013 return m_filterBar
->isVisible();
1016 void DolphinView::applyModeToView()
1018 // TODO: the following code just tries to test some QListView capabilities
1021 m_iconsView
->setViewMode(QListView::IconMode
);
1022 m_iconsView
->setGridSize(QSize(128, 64));
1026 m_iconsView
->setViewMode(QListView::ListMode
);
1027 m_iconsView
->setGridSize(QSize(256, 24));
1031 m_iconsView
->setViewMode(QListView::IconMode
);
1032 m_iconsView
->setGridSize(QSize(128, 128));
1037 #include "dolphinview.moc"