]>
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
&)));
112 KDirModel
* model
= new KDirModel();
113 model
->setDirLister(m_dirLister
);
114 m_iconsView
->setModel(model
);
116 m_iconSize
= K3Icon::SizeMedium
;
118 m_filterBar
= new FilterBar(this);
120 connect(m_filterBar
, SIGNAL(signalFilterChanged(const QString
&)),
121 this, SLOT(slotChangeNameFilter(const QString
&)));
123 m_topLayout
->addWidget(m_urlNavigator
);
124 m_topLayout
->addWidget(m_iconsView
);
125 m_topLayout
->addWidget(m_filterBar
);
126 m_topLayout
->addWidget(m_statusBar
);
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 Dolphin::mainWin().setActiveView(this);
152 bool DolphinView::isActive() const
154 return (Dolphin::mainWin().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());
171 emit
signalModeChanged();
174 DolphinView::Mode
DolphinView::mode() const
179 void DolphinView::setShowHiddenFilesEnabled(bool show
)
181 if (m_dirLister
->showingDotFiles() == show
) {
185 ViewProperties
props(m_urlNavigator
->url());
186 props
.setShowHiddenFilesEnabled(show
);
189 m_dirLister
->setShowingDotFiles(show
);
191 emit
signalShowHiddenFilesChanged();
196 bool DolphinView::isShowHiddenFilesEnabled() 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 setShowHiddenFilesEnabled(props
.isShowHiddenFilesEnabled());
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
= Dolphin::mainWin().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(i18n("Renaming items..."),
235 i18n("Renaming finished."),
238 // iterate through all selected items and rename them...
239 const int replaceIndex
= newName
.find('#');
240 assert(replaceIndex
>= 0);
241 for (int i
= 0; i
< urlsCount
; ++i
) {
242 const KUrl
& source
= urls
[i
];
243 QString
name(newName
);
244 name
.replace(replaceIndex
, 1, renameIndexPresentation(i
+ 1, urlsCount
));
246 if (source
.fileName() != name
) {
247 KUrl
dest(source
.upUrl());
250 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
252 delete progressIndicator
;
253 progressIndicator
= 0;
254 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
255 DolphinStatusBar::Error
);
258 else if (KIO::NetAccess::file_move(source
, dest
)) {
259 // TODO: From the users point of view he executed one 'rename n files' operation,
260 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
261 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
262 undoMan
.addCommand(command
);
266 progressIndicator
->execOperation();
268 delete progressIndicator
;
269 progressIndicator
= 0;
275 // Only one item has been selected for renaming. Use the custom
276 // renaming mechanism from the views.
277 assert(urls
.count() == 1);
279 /*if (m_mode == DetailsView) {
280 Q3ListViewItem* item = m_iconsView->firstChild();
282 if (item->isSelected()) {
283 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
286 item = item->nextSibling();
290 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
292 if (item->isSelected()) {
296 item = static_cast<KFileIconViewItem*>(item->nextItem());
302 void DolphinView::selectAll()
304 //fileView()->selectAll();
307 void DolphinView::invertSelection()
309 //fileView()->invertSelection();
312 DolphinStatusBar
* DolphinView::statusBar() const
317 int DolphinView::contentsX() const
320 return 0; //scrollView()->contentsX();
323 int DolphinView::contentsY() const
325 return 0; //scrollView()->contentsY();
328 void DolphinView::refreshSettings()
330 startDirLister(m_urlNavigator
->url());
333 void DolphinView::updateStatusBar()
335 // As the item count information is less important
336 // in comparison with other messages, it should only
338 // - the status bar is empty or
339 // - shows already the item count information or
340 // - shows only a not very important information
341 // - if any progress is given don't show the item count info at all
342 const QString
msg(m_statusBar
->message());
343 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
344 (msg
== m_statusBar
->defaultText()) ||
345 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
346 (m_statusBar
->progress() == 100);
348 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
349 m_statusBar
->setDefaultText(text
);
351 if (updateStatusBarMsg
) {
352 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
356 void DolphinView::requestItemInfo(const KUrl
& url
)
358 emit
signalRequestItemInfo(url
);
361 bool DolphinView::isUrlEditable() const
363 return m_urlNavigator
->isUrlEditable();
366 void DolphinView::zoomIn()
368 //itemEffectsManager()->zoomIn();
371 void DolphinView::zoomOut()
373 //itemEffectsManager()->zoomOut();
376 bool DolphinView::isZoomInPossible() const
378 return false; //itemEffectsManager()->isZoomInPossible();
381 bool DolphinView::isZoomOutPossible() const
383 return false; //itemEffectsManager()->isZoomOutPossible();
386 void DolphinView::setSorting(Sorting sorting
)
388 if (sorting
!= this->sorting()) {
389 /*KFileView* view = fileView();
390 int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
393 case SortByName: spec = spec | QDir::Name; break;
394 case SortBySize: spec = spec | QDir::Size; break;
395 case SortByDate: spec = spec | QDir::Time; break;
399 ViewProperties props(url());
400 props.setSorting(sorting);
402 view->setSorting(static_cast<QDir::SortFlags>(spec));
404 emit signalSortingChanged(sorting);*/
408 DolphinView::Sorting
DolphinView::sorting() const
410 /*const QDir::SortFlags spec = fileView()->sorting();
412 if (spec & QDir::Time) {
416 if (spec & QDir::Size) {
423 void DolphinView::setSortOrder(Qt::SortOrder order
)
425 if (sortOrder() != order
) {
426 /*KFileView* view = fileView();
427 int sorting = view->sorting();
428 sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
429 (sorting | QDir::Reversed);
431 ViewProperties props(url());
432 props.setSortOrder(order);
434 view->setSorting(static_cast<QDir::SortFlags>(sorting));
436 emit signalSortOrderChanged(order);*/
440 Qt::SortOrder
DolphinView::sortOrder() const
442 //return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
443 return Qt::Descending
;
446 void DolphinView::goBack()
448 m_urlNavigator
->goBack();
451 void DolphinView::goForward()
453 m_urlNavigator
->goForward();
456 void DolphinView::goUp()
458 m_urlNavigator
->goUp();
461 void DolphinView::goHome()
463 m_urlNavigator
->goHome();
466 void DolphinView::setUrlEditable(bool editable
)
468 m_urlNavigator
->editUrl(editable
);
471 const Q3ValueList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
473 return m_urlNavigator
->history(index
);
476 bool DolphinView::hasSelection() const
478 const KFileItemList
* list
= selectedItems();
479 return (list
!= 0) && !list
->isEmpty();
482 const KFileItemList
* DolphinView::selectedItems() const
484 return 0; //fileView()->selectedItems();
487 KUrl::List
DolphinView::selectedUrls() const
491 /*const KFileItemList* list = fileView()->selectedItems();
493 KFileItemList::const_iterator it = list->begin();
494 const KFileItemList::const_iterator end = list->end();
496 KFileItem* item = *it;
497 urls.append(item->url());
505 const KFileItem
* DolphinView::currentFileItem() const
507 return 0; // fileView()->currentFileItem();
510 void DolphinView::openContextMenu(KFileItem
* fileInfo
, const QPoint
& pos
)
512 DolphinContextMenu
contextMenu(this, fileInfo
, pos
);
516 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
520 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
524 KUrl
dest(source
.upUrl());
525 dest
.addPath(newName
);
527 const bool destExists
= KIO::NetAccess::exists(dest
,
529 Dolphin::mainWin().activeView());
531 // the destination already exists, hence ask the user
533 KIO::RenameDlg
renameDialog(this,
534 i18n("File Already Exists"),
538 switch (renameDialog
.exec()) {
539 case KIO::R_OVERWRITE
:
540 // the destination should be overwritten
541 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
544 case KIO::R_RENAME
: {
545 // a new name for the destination has been used
546 KUrl
newDest(renameDialog
.newDestUrl());
547 ok
= KIO::NetAccess::file_move(source
, newDest
);
552 // the renaming operation has been canceled
558 // no destination exists, hence just move the file to
560 ok
= KIO::NetAccess::file_move(source
, dest
);
564 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), dest
.fileName()),
565 DolphinStatusBar::OperationCompleted
);
567 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
568 UndoManager::instance().addCommand(command
);
571 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), dest
.fileName()),
572 DolphinStatusBar::Error
);
577 void DolphinView::reload()
579 startDirLister(m_urlNavigator
->url(), true);
582 void DolphinView::slotUrlListDropped(QDropEvent
* /* event */,
583 const KUrl::List
& urls
,
586 KUrl
destination(url
);
587 if (destination
.isEmpty()) {
588 destination
= m_urlNavigator
->url();
591 // Check whether the destination Url is a directory. If this is not the
592 // case, use the navigator Url as destination (otherwise the destination,
593 // which represents a file, would be replaced by a copy- or move-operation).
594 KFileItem
fileItem(KFileItem::Unknown
, KFileItem::Unknown
, destination
);
595 if (!fileItem
.isDir()) {
596 destination
= m_urlNavigator
->url();
600 Dolphin::mainWin().dropUrls(urls
, destination
);
603 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
605 QWidget::mouseReleaseEvent(event
);
606 Dolphin::mainWin().setActiveView(this);
609 void DolphinView::slotUrlChanged(const KUrl
& url
)
611 const ViewProperties
props(url
);
612 setMode(props
.viewMode());
614 const bool showHiddenFiles
= props
.isShowHiddenFilesEnabled();
615 setShowHiddenFilesEnabled(showHiddenFiles
);
616 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
618 setSorting(props
.sorting());
619 setSortOrder(props
.sortOrder());
623 // The selectionChanged signal is not emitted when a new view object is
624 // created. The application does not care whether a view is represented by a
625 // different instance, hence inform the application that the selection might have
626 // changed so that it can update it's actions.
627 Dolphin::mainWin().slotSelectionChanged();
629 emit
signalUrlChanged(url
);
632 void DolphinView::triggerIconsViewItem(Q3IconViewItem
* item
)
635 const Qt::ButtonState keyboardState = KApplication::keyboardMouseState();
636 const bool isSelectionActive = ((keyboardState & Qt::ShiftModifier) > 0) ||
637 ((keyboardState & Qt::ControlModifier) > 0);*/
638 const bool isSelectionActive
= false;
639 if ((item
!= 0) && !isSelectionActive
) {
640 // Updating the Url must be done outside the scope of this slot,
641 // as iconview items will get deleted.
642 QTimer::singleShot(0, this, SLOT(updateUrl()));
643 Dolphin::mainWin().setActiveView(this);
647 void DolphinView::triggerItem(const QModelIndex
& index
)
649 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
650 KFileItem
* item
= dirModel
->itemForIndex(index
);
656 // Prefer the local path over the Url. This assures that the
657 // volume space information is correct. Assuming that the Url is media:/sda1,
658 // and the local path is /windows/C: For the Url the space info is related
659 // to the root partition (and hence wrong) and for the local path the space
660 // info is related to the windows partition (-> correct).
661 //m_dirLister->stop();
662 //m_dirLister->openUrl(item->url());
665 const QString
localPath(item
->localPath());
666 if (localPath
.isEmpty()) {
670 setUrl(KUrl(localPath
));
678 void DolphinView::updateUrl()
680 //KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
681 // static_cast<KFileView*>(m_iconsView);
683 KFileItem
* fileItem
= 0; // TODO: fileView->currentFileItem();
688 if (fileItem
->isDir()) {
689 // Prefer the local path over the Url. This assures that the
690 // volume space information is correct. Assuming that the Url is media:/sda1,
691 // and the local path is /windows/C: For the Url the space info is related
692 // to the root partition (and hence wrong) and for the local path the space
693 // info is related to the windows partition (-> correct).
694 const QString
localPath(fileItem
->localPath());
695 if (localPath
.isEmpty()) {
696 setUrl(fileItem
->url());
699 setUrl(KUrl(localPath
));
707 void DolphinView::slotPercent(int percent
)
709 if (m_showProgress
) {
710 m_statusBar
->setProgress(percent
);
714 void DolphinView::slotClear()
716 //fileView()->clearView();
720 void DolphinView::slotDeleteItem(KFileItem
* item
)
722 //fileView()->removeItem(item);
726 void DolphinView::slotCompleted()
730 //KFileView* view = fileView();
733 // TODO: in Qt4 the code should get a lot
734 // simpler and nicer due to Interview...
735 /*if (m_iconsView != 0) {
736 m_iconsView->beginItemUpdates();
738 if (m_iconsView != 0) {
739 m_iconsView->beginItemUpdates();
742 if (m_showProgress
) {
743 m_statusBar
->setProgressText(QString::null
);
744 m_statusBar
->setProgress(100);
745 m_showProgress
= false;
748 KFileItemList
items(m_dirLister
->items());
749 KFileItemList::const_iterator it
= items
.begin();
750 const KFileItemList::const_iterator end
= items
.end();
756 KFileItem
* item
= *it
;
757 //view->insertItem(item);
769 /*if (m_iconsView != 0) {
770 // Prevent a flickering of the icon view widget by giving a small
771 // timeslot to swallow asynchronous update events.
772 m_iconsView->setUpdatesEnabled(false);
773 QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
776 if (m_iconsView != 0) {
777 m_iconsView->endItemUpdates();
778 m_refreshing = false;
782 void DolphinView::slotInfoMessage(const QString
& msg
)
784 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
787 void DolphinView::slotErrorMessage(const QString
& msg
)
789 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
792 void DolphinView::slotGrabActivation()
794 Dolphin::mainWin().setActiveView(this);
797 void DolphinView::slotContentsMoving(int x
, int y
)
800 // Only emit a 'contents moved' signal if the user
801 // moved the content by adjusting the sliders. Adjustments
802 // resulted by refreshing a directory should not be respected.
803 emit
contentsMoved(x
, y
);
807 /*KFileView* DolphinView::fileView() const
809 return (m_mode == DetailsView) ? static_cast<KFileView*>(m_iconsView) :
810 static_cast<KFileView*>(m_iconsView);
813 Q3ScrollView
* DolphinView::scrollView() const
815 return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
816 // static_cast<Q3ScrollView*>(m_iconsView);
819 ItemEffectsManager
* DolphinView::itemEffectsManager() const
824 void DolphinView::startDirLister(const KUrl
& url
, bool reload
)
826 if (!url
.isValid()) {
827 const QString
location(url
.pathOrUrl());
828 if (location
.isEmpty()) {
829 m_statusBar
->setMessage(i18n("The location is empty."), DolphinStatusBar::Error
);
832 m_statusBar
->setMessage(i18n("The location '%1' is invalid.",location
),
833 DolphinStatusBar::Error
);
838 // Only show the directory loading progress if the status bar does
839 // not contain another progress information. This means that
840 // the directory loading progress information has the lowest priority.
841 const QString
progressText(m_statusBar
->progressText());
842 m_showProgress
= progressText
.isEmpty() ||
843 (progressText
== i18n("Loading directory..."));
844 if (m_showProgress
) {
845 m_statusBar
->setProgressText(i18n("Loading directory..."));
846 m_statusBar
->setProgress(0);
851 m_dirLister
->openUrl(url
, false, reload
);
854 QString
DolphinView::defaultStatusBarText() const
856 // TODO: the following code is not suitable for languages where multiple forms
857 // of plurals are given (e. g. in Poland three forms of plurals exist).
858 const int itemCount
= m_folderCount
+ m_fileCount
;
861 if (itemCount
== 1) {
862 text
= i18n("1 Item");
865 text
= i18n("%1 Items",itemCount
);
870 if (m_folderCount
== 1) {
871 text
+= i18n("1 Folder");
874 text
+= i18n("%1 Folders",m_folderCount
);
879 if (m_fileCount
== 1) {
880 text
+= i18n("1 File");
883 text
+= i18n("%1 Files",m_fileCount
);
891 QString
DolphinView::selectionStatusBarText() const
893 // TODO: the following code is not suitable for languages where multiple forms
894 // of plurals are given (e. g. in Poland three forms of plurals exist).
896 const KFileItemList
* list
= selectedItems();
897 assert((list
!= 0) && !list
->isEmpty());
901 KIO::filesize_t byteSize
= 0;
902 KFileItemList::const_iterator it
= list
->begin();
903 const KFileItemList::const_iterator end
= list
->end();
905 KFileItem
* item
= *it
;
911 byteSize
+= item
->size();
916 if (folderCount
== 1) {
917 text
= i18n("1 Folder selected");
919 else if (folderCount
> 1) {
920 text
= i18n("%1 Folders selected",folderCount
);
923 if ((fileCount
> 0) && (folderCount
> 0)) {
927 const QString
sizeText(KIO::convertSize(byteSize
));
928 if (fileCount
== 1) {
929 text
+= i18n("1 File selected (%1)",sizeText
);
931 else if (fileCount
> 1) {
932 text
+= i18n("%1 Files selected (%1)",fileCount
,sizeText
);
938 QString
DolphinView::renameIndexPresentation(int index
, int itemCount
) const
940 // assure that the string reprentation for all indicess have the same
941 // number of characters based on the given number of items
942 QString
str(QString::number(index
));
944 while (itemCount
>= 10) {
948 str
.reserve(chrCount
);
950 const int insertCount
= chrCount
- str
.length();
951 for (int i
= 0; i
< insertCount
; ++i
) {
957 void DolphinView::slotShowFilterBar(bool show
)
959 assert(m_filterBar
!= 0);
968 void DolphinView::slotChangeNameFilter(const QString
& nameFilter
)
970 // The name filter of KDirLister does a 'hard' filtering, which
971 // means that only the items are shown where the names match
972 // exactly the filter. This is non-transparent for the user, which
973 // just wants to have a 'soft' filtering: does the name contain
974 // the filter string?
975 QString
adjustedFilter(nameFilter
);
976 adjustedFilter
.insert(0, '*');
977 adjustedFilter
.append('*');
979 m_dirLister
->setNameFilter(adjustedFilter
);
980 m_dirLister
->emitChanges();
982 // TODO: this is a workaround for QIconView: the item position
983 // stay as they are by filtering, only an inserting of an item
984 // results to an automatic adjusting of the item position. In Qt4/KDE4
985 // this workaround should get obsolete due to Interview.
986 /*KFileView* view = fileView();
987 if (view == m_iconsView) {
988 KFileItem* first = view->firstFileItem();
990 view->removeItem(first);
991 view->insertItem(first);
996 bool DolphinView::isFilterBarVisible()
998 return m_filterBar
->isVisible();
1001 void DolphinView::applyModeToView()
1003 // TODO: the following code just tries to test some QListView capabilities
1006 m_iconsView
->setViewMode(QListView::IconMode
);
1007 m_iconsView
->setGridSize(QSize(128, 64));
1011 m_iconsView
->setViewMode(QListView::ListMode
);
1012 m_iconsView
->setGridSize(QSize(256, 24));
1016 m_iconsView
->setViewMode(QListView::IconMode
);
1017 m_iconsView
->setGridSize(QSize(128, 128));
1022 #include "dolphinview.moc"