1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphinview.h"
23 #include <QItemSelectionModel>
24 #include <Q3ValueList>
26 #include <QMouseEvent>
27 #include <QVBoxLayout>
29 #include <kdirmodel.h>
30 #include <kfileitemdelegate.h>
33 #include <kio/netaccess.h>
34 #include <kio/renamedlg.h>
35 #include <kmimetyperesolver.h>
38 #include "urlnavigator.h"
39 #include "dolphinstatusbar.h"
40 #include "dolphinmainwindow.h"
41 #include "dolphindirlister.h"
42 #include "viewproperties.h"
43 #include "dolphindetailsview.h"
44 #include "dolphiniconsview.h"
45 #include "dolphincontextmenu.h"
46 #include "undomanager.h"
47 #include "renamedialog.h"
48 #include "progressindicator.h"
49 #include "filterbar.h"
51 DolphinView::DolphinView(DolphinMainWindow
*mainWindow
,
55 bool showHiddenFiles
) :
58 m_showProgress(false),
60 m_mainWindow(mainWindow
),
68 setFocusPolicy(Qt::StrongFocus
);
69 m_topLayout
= new QVBoxLayout(this);
70 m_topLayout
->setSpacing(0);
71 m_topLayout
->setMargin(0);
73 m_urlNavigator
= new UrlNavigator(url
, this);
74 connect(m_urlNavigator
, SIGNAL(urlChanged(const KUrl
&)),
75 this, SLOT(loadDirectory(const KUrl
&)));
77 m_statusBar
= new DolphinStatusBar(this);
79 m_dirLister
= new DolphinDirLister();
80 m_dirLister
->setAutoUpdate(true);
81 m_dirLister
->setMainWindow(this);
82 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
83 connect(m_dirLister
, SIGNAL(clear()),
84 this, SLOT(slotClear()));
85 connect(m_dirLister
, SIGNAL(percent(int)),
86 this, SLOT(slotPercent(int)));
87 connect(m_dirLister
, SIGNAL(deleteItem(KFileItem
*)),
88 this, SLOT(slotDeleteItem(KFileItem
*)));
89 connect(m_dirLister
, SIGNAL(completed()),
90 this, SLOT(slotCompleted()));
91 connect(m_dirLister
, SIGNAL(infoMessage(const QString
&)),
92 this, SLOT(slotInfoMessage(const QString
&)));
93 connect(m_dirLister
, SIGNAL(errorMessage(const QString
&)),
94 this, SLOT(slotErrorMessage(const QString
&)));
96 m_iconsView
= new DolphinIconsView(this);
99 KDirModel
* model
= new KDirModel();
100 model
->setDirLister(m_dirLister
);
101 m_iconsView
->setModel(model
);
103 KFileItemDelegate
* delegate
= new KFileItemDelegate(this);
104 m_iconsView
->setItemDelegate(delegate
);
106 m_dirLister
->setDelayedMimeTypes(true);
107 new KMimeTypeResolver(m_iconsView
, model
);
109 m_iconSize
= K3Icon::SizeMedium
;
111 m_filterBar
= new FilterBar(this);
113 connect(m_filterBar
, SIGNAL(filterChanged(const QString
&)),
114 this, SLOT(slotChangeNameFilter(const QString
&)));
115 connect(m_filterBar
, SIGNAL(closed()),
116 this, SLOT(closeFilterBar()));
118 m_topLayout
->addWidget(m_urlNavigator
);
119 m_topLayout
->addWidget(m_iconsView
);
120 m_topLayout
->addWidget(m_filterBar
);
121 m_topLayout
->addWidget(m_statusBar
);
123 connect(m_iconsView
, SIGNAL(clicked(const QModelIndex
&)),
124 this, SLOT(triggerItem(const QModelIndex
&)));
125 connect(m_iconsView
->selectionModel(), SIGNAL(selectionChanged(const QItemSelection
&, const QItemSelection
&)),
126 this, SLOT(emitSelectionChangedSignal()));
128 startDirLister(m_urlNavigator
->url());
131 DolphinView::~DolphinView()
137 void DolphinView::setUrl(const KUrl
& url
)
139 m_urlNavigator
->setUrl(url
);
142 const KUrl
& DolphinView::url() const
144 return m_urlNavigator
->url();
147 void DolphinView::requestActivation()
149 mainWindow()->setActiveView(this);
152 bool DolphinView::isActive() const
154 return (mainWindow()->activeView() == this);
157 void DolphinView::setMode(Mode mode
)
159 if (mode
== m_mode
) {
160 return; // the wished mode is already set
165 ViewProperties
props(m_urlNavigator
->url());
166 props
.setViewMode(m_mode
);
169 startDirLister(m_urlNavigator
->url());
174 DolphinView::Mode
DolphinView::mode() const
179 void DolphinView::setShowHiddenFiles(bool show
)
181 if (m_dirLister
->showingDotFiles() == show
) {
185 ViewProperties
props(m_urlNavigator
->url());
186 props
.setShowHiddenFiles(show
);
189 m_dirLister
->setShowingDotFiles(show
);
191 emit
showHiddenFilesChanged();
196 bool DolphinView::showHiddenFiles() const
198 return m_dirLister
->showingDotFiles();
201 void DolphinView::setViewProperties(const ViewProperties
& props
)
203 setMode(props
.viewMode());
204 setSorting(props
.sorting());
205 setSortOrder(props
.sortOrder());
206 setShowHiddenFiles(props
.showHiddenFiles());
209 void DolphinView::renameSelectedItems()
211 const KUrl::List urls
= selectedUrls();
212 if (urls
.count() > 1) {
213 // More than one item has been selected for renaming. Open
214 // a rename dialog and rename all items afterwards.
215 RenameDialog
dialog(urls
);
216 if (dialog
.exec() == QDialog::Rejected
) {
220 DolphinView
* view
= mainWindow()->activeView();
221 const QString
& newName
= dialog
.newName();
222 if (newName
.isEmpty()) {
223 view
->statusBar()->setMessage(i18n("The new item name is invalid."),
224 DolphinStatusBar::Error
);
227 UndoManager
& undoMan
= UndoManager::instance();
228 undoMan
.beginMacro();
230 assert(newName
.contains('#'));
232 const int urlsCount
= urls
.count();
233 ProgressIndicator
* progressIndicator
=
234 new ProgressIndicator(mainWindow(),
235 i18n("Renaming items..."),
236 i18n("Renaming finished."),
239 // iterate through all selected items and rename them...
240 const int replaceIndex
= newName
.indexOf('#');
241 assert(replaceIndex
>= 0);
242 for (int i
= 0; i
< urlsCount
; ++i
) {
243 const KUrl
& source
= urls
[i
];
244 QString
name(newName
);
245 name
.replace(replaceIndex
, 1, renameIndexPresentation(i
+ 1, urlsCount
));
247 if (source
.fileName() != name
) {
248 KUrl
dest(source
.upUrl());
251 const bool destExists
= KIO::NetAccess::exists(dest
, false, view
);
253 delete progressIndicator
;
254 progressIndicator
= 0;
255 view
->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name
),
256 DolphinStatusBar::Error
);
259 else if (KIO::NetAccess::file_move(source
, dest
)) {
260 // TODO: From the users point of view he executed one 'rename n files' operation,
261 // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
262 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
263 undoMan
.addCommand(command
);
267 progressIndicator
->execOperation();
269 delete progressIndicator
;
270 progressIndicator
= 0;
276 // Only one item has been selected for renaming. Use the custom
277 // renaming mechanism from the views.
278 assert(urls
.count() == 1);
280 /*if (m_mode == DetailsView) {
281 Q3ListViewItem* item = m_iconsView->firstChild();
283 if (item->isSelected()) {
284 m_iconsView->rename(item, DolphinDetailsView::NameColumn);
287 item = item->nextSibling();
291 KFileIconViewItem* item = static_cast<KFileIconViewItem*>(m_iconsView->firstItem());
293 if (item->isSelected()) {
297 item = static_cast<KFileIconViewItem*>(item->nextItem());
303 void DolphinView::selectAll()
305 //fileView()->selectAll();
308 void DolphinView::invertSelection()
310 //fileView()->invertSelection();
313 DolphinStatusBar
* DolphinView::statusBar() const
318 int DolphinView::contentsX() const
321 return 0; //scrollView()->contentsX();
324 int DolphinView::contentsY() const
326 return 0; //scrollView()->contentsY();
329 void DolphinView::refreshSettings()
331 startDirLister(m_urlNavigator
->url());
334 void DolphinView::updateStatusBar()
336 // As the item count information is less important
337 // in comparison with other messages, it should only
339 // - the status bar is empty or
340 // - shows already the item count information or
341 // - shows only a not very important information
342 // - if any progress is given don't show the item count info at all
343 const QString
msg(m_statusBar
->message());
344 const bool updateStatusBarMsg
= (msg
.isEmpty() ||
345 (msg
== m_statusBar
->defaultText()) ||
346 (m_statusBar
->type() == DolphinStatusBar::Information
)) &&
347 (m_statusBar
->progress() == 100);
349 const QString
text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
350 m_statusBar
->setDefaultText(text
);
352 if (updateStatusBarMsg
) {
353 m_statusBar
->setMessage(text
, DolphinStatusBar::Default
);
357 void DolphinView::emitRequestItemInfo(const KUrl
& url
)
359 emit
requestItemInfo(url
);
362 bool DolphinView::isFilterBarVisible() const
364 return m_filterBar
->isVisible();
367 bool DolphinView::isUrlEditable() const
369 return m_urlNavigator
->isUrlEditable();
372 void DolphinView::zoomIn()
374 //itemEffectsManager()->zoomIn();
377 void DolphinView::zoomOut()
379 //itemEffectsManager()->zoomOut();
382 bool DolphinView::isZoomInPossible() const
384 return false; //itemEffectsManager()->isZoomInPossible();
387 bool DolphinView::isZoomOutPossible() const
389 return false; //itemEffectsManager()->isZoomOutPossible();
392 void DolphinView::setSorting(Sorting sorting
)
394 if (sorting
!= this->sorting()) {
395 ViewProperties
props(url());
396 props
.setSorting(sorting
);
398 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
399 dirModel
->sort(columnIndex(sorting
), props
.sortOrder());
401 emit
sortingChanged(sorting
);
405 DolphinView::Sorting
DolphinView::sorting() const
407 // TODO: instead of getting the sorting from the properties just fetch
408 // them from KDirModel, if such an interface will be offered (David?)
409 ViewProperties
props(url());
410 return props
.sorting();
413 void DolphinView::setSortOrder(Qt::SortOrder order
)
415 if (sortOrder() != order
) {
416 ViewProperties
props(url());
417 props
.setSortOrder(order
);
419 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
420 dirModel
->sort(columnIndex(props
.sorting()), order
);
422 emit
sortOrderChanged(order
);
426 Qt::SortOrder
DolphinView::sortOrder() const
428 // TODO: instead of getting the order from the properties just fetch
429 // them from KDirModel, if such an interface will be offered (David?)
430 ViewProperties
props(url());
431 return props
.sortOrder();
434 void DolphinView::goBack()
436 m_urlNavigator
->goBack();
439 void DolphinView::goForward()
441 m_urlNavigator
->goForward();
444 void DolphinView::goUp()
446 m_urlNavigator
->goUp();
449 void DolphinView::goHome()
451 m_urlNavigator
->goHome();
454 void DolphinView::setUrlEditable(bool editable
)
456 m_urlNavigator
->editUrl(editable
);
459 const Q3ValueList
<UrlNavigator::HistoryElem
> DolphinView::urlHistory(int& index
) const
461 return m_urlNavigator
->history(index
);
464 bool DolphinView::hasSelection() const
466 return m_iconsView
->selectionModel()->hasSelection();
469 KFileItemList
DolphinView::selectedItems() const
471 QItemSelectionModel
* selModel
= m_iconsView
->selectionModel();
472 assert(selModel
!= 0);
474 KFileItemList itemList
;
475 if (selModel
->hasSelection()) {
476 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
477 const QModelIndexList indexList
= selModel
->selectedIndexes();
479 QModelIndexList::const_iterator end
= indexList
.end();
480 for (QModelIndexList::const_iterator it
= indexList
.begin(); it
!= end
; ++it
) {
481 KFileItem
* item
= dirModel
->itemForIndex(*it
);
483 itemList
.append(item
);
490 KUrl::List
DolphinView::selectedUrls() const
494 const KFileItemList list
= selectedItems();
495 KFileItemList::const_iterator it
= list
.begin();
496 const KFileItemList::const_iterator end
= list
.end();
498 KFileItem
* item
= *it
;
499 urls
.append(item
->url());
506 const KFileItem
* DolphinView::currentFileItem() const
508 return 0; // fileView()->currentFileItem();
511 void DolphinView::openContextMenu(KFileItem
* fileInfo
, const QPoint
& pos
)
513 DolphinContextMenu
contextMenu(this, fileInfo
, pos
);
517 void DolphinView::rename(const KUrl
& source
, const QString
& newName
)
521 if (newName
.isEmpty() || (source
.fileName() == newName
)) {
525 KUrl
dest(source
.upUrl());
526 dest
.addPath(newName
);
528 const bool destExists
= KIO::NetAccess::exists(dest
,
530 mainWindow()->activeView());
532 // the destination already exists, hence ask the user
534 KIO::RenameDlg
renameDialog(this,
535 i18n("File Already Exists"),
539 switch (renameDialog
.exec()) {
540 case KIO::R_OVERWRITE
:
541 // the destination should be overwritten
542 ok
= KIO::NetAccess::file_move(source
, dest
, -1, true);
545 case KIO::R_RENAME
: {
546 // a new name for the destination has been used
547 KUrl
newDest(renameDialog
.newDestUrl());
548 ok
= KIO::NetAccess::file_move(source
, newDest
);
553 // the renaming operation has been canceled
559 // no destination exists, hence just move the file to
561 ok
= KIO::NetAccess::file_move(source
, dest
);
565 m_statusBar
->setMessage(i18n("Renamed file '%1' to '%2'.",source
.fileName(), dest
.fileName()),
566 DolphinStatusBar::OperationCompleted
);
568 DolphinCommand
command(DolphinCommand::Rename
, source
, dest
);
569 UndoManager::instance().addCommand(command
);
572 m_statusBar
->setMessage(i18n("Renaming of file '%1' to '%2' failed.",source
.fileName(), dest
.fileName()),
573 DolphinStatusBar::Error
);
578 void DolphinView::reload()
580 startDirLister(m_urlNavigator
->url(), true);
583 void DolphinView::slotUrlListDropped(QDropEvent
* /* event */,
584 const KUrl::List
& urls
,
587 KUrl
destination(url
);
588 if (destination
.isEmpty()) {
589 destination
= m_urlNavigator
->url();
592 // Check whether the destination Url is a directory. If this is not the
593 // case, use the navigator Url as destination (otherwise the destination,
594 // which represents a file, would be replaced by a copy- or move-operation).
595 KFileItem
fileItem(KFileItem::Unknown
, KFileItem::Unknown
, destination
);
596 if (!fileItem
.isDir()) {
597 destination
= m_urlNavigator
->url();
601 mainWindow()->dropUrls(urls
, destination
);
604 void DolphinView::mouseReleaseEvent(QMouseEvent
* event
)
606 QWidget::mouseReleaseEvent(event
);
607 mainWindow()->setActiveView(this);
610 DolphinMainWindow
* DolphinView::mainWindow() const
615 void DolphinView::loadDirectory(const KUrl
& url
)
617 const ViewProperties
props(url
);
618 setMode(props
.viewMode());
620 const bool showHiddenFiles
= props
.showHiddenFiles();
621 setShowHiddenFiles(showHiddenFiles
);
622 m_dirLister
->setShowingDotFiles(showHiddenFiles
);
624 setSorting(props
.sorting());
625 setSortOrder(props
.sortOrder());
628 emit
urlChanged(url
);
631 void DolphinView::triggerIconsViewItem(Q3IconViewItem
* item
)
634 const Qt::ButtonState keyboardState = KApplication::keyboardMouseState();
635 const bool isSelectionActive = ((keyboardState & Qt::ShiftModifier) > 0) ||
636 ((keyboardState & Qt::ControlModifier) > 0);*/
637 const bool isSelectionActive
= false;
638 if ((item
!= 0) && !isSelectionActive
) {
639 // Updating the Url must be done outside the scope of this slot,
640 // as iconview items will get deleted.
641 QTimer::singleShot(0, this, SLOT(updateUrl()));
642 mainWindow()->setActiveView(this);
646 void DolphinView::triggerItem(const QModelIndex
& index
)
648 KDirModel
* dirModel
= static_cast<KDirModel
*>(m_iconsView
->model());
649 KFileItem
* item
= dirModel
->itemForIndex(index
);
655 // Prefer the local path over the Url. This assures that the
656 // volume space information is correct. Assuming that the Url is media:/sda1,
657 // and the local path is /windows/C: For the Url the space info is related
658 // to the root partition (and hence wrong) and for the local path the space
659 // info is related to the windows partition (-> correct).
660 //m_dirLister->stop();
661 //m_dirLister->openUrl(item->url());
664 const QString
localPath(item
->localPath());
665 if (localPath
.isEmpty()) {
669 setUrl(KUrl(localPath
));
677 void DolphinView::updateUrl()
679 //KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
680 // static_cast<KFileView*>(m_iconsView);
682 KFileItem
* fileItem
= 0; // TODO: fileView->currentFileItem();
687 if (fileItem
->isDir()) {
688 // Prefer the local path over the Url. This assures that the
689 // volume space information is correct. Assuming that the Url is media:/sda1,
690 // and the local path is /windows/C: For the Url the space info is related
691 // to the root partition (and hence wrong) and for the local path the space
692 // info is related to the windows partition (-> correct).
693 const QString
localPath(fileItem
->localPath());
694 if (localPath
.isEmpty()) {
695 setUrl(fileItem
->url());
698 setUrl(KUrl(localPath
));
706 void DolphinView::slotPercent(int percent
)
708 if (m_showProgress
) {
709 m_statusBar
->setProgress(percent
);
713 void DolphinView::slotClear()
715 //fileView()->clearView();
719 void DolphinView::slotDeleteItem(KFileItem
* item
)
721 //fileView()->removeItem(item);
725 void DolphinView::slotCompleted()
729 //KFileView* view = fileView();
732 // TODO: in Qt4 the code should get a lot
733 // simpler and nicer due to Interview...
734 /*if (m_iconsView != 0) {
735 m_iconsView->beginItemUpdates();
737 if (m_iconsView != 0) {
738 m_iconsView->beginItemUpdates();
741 if (m_showProgress
) {
742 m_statusBar
->setProgressText(QString::null
);
743 m_statusBar
->setProgress(100);
744 m_showProgress
= false;
747 KFileItemList
items(m_dirLister
->items());
748 KFileItemList::const_iterator it
= items
.begin();
749 const KFileItemList::const_iterator end
= items
.end();
755 KFileItem
* item
= *it
;
756 //view->insertItem(item);
768 /*if (m_iconsView != 0) {
769 // Prevent a flickering of the icon view widget by giving a small
770 // timeslot to swallow asynchronous update events.
771 m_iconsView->setUpdatesEnabled(false);
772 QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
775 if (m_iconsView != 0) {
776 m_iconsView->endItemUpdates();
777 m_refreshing = false;
781 void DolphinView::slotInfoMessage(const QString
& msg
)
783 m_statusBar
->setMessage(msg
, DolphinStatusBar::Information
);
786 void DolphinView::slotErrorMessage(const QString
& msg
)
788 m_statusBar
->setMessage(msg
, DolphinStatusBar::Error
);
791 void DolphinView::slotGrabActivation()
793 mainWindow()->setActiveView(this);
796 void DolphinView::emitSelectionChangedSignal()
798 emit
selectionChanged();
801 void DolphinView::closeFilterBar()
804 emit
showFilterBarChanged(false);
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 if (list
.isEmpty()) {
908 // TODO: assert(!list.isEmpty()) should be used, as this method is only invoked if
909 // DolphinView::hasSelection() is true. Inconsistent behavior?
915 KIO::filesize_t byteSize
= 0;
916 KFileItemList::const_iterator it
= list
.begin();
917 const KFileItemList::const_iterator end
= list
.end();
919 KFileItem
* item
= *it
;
925 byteSize
+= item
->size();
930 if (folderCount
== 1) {
931 text
= i18n("1 Folder selected");
933 else if (folderCount
> 1) {
934 text
= i18n("%1 Folders selected",folderCount
);
937 if ((fileCount
> 0) && (folderCount
> 0)) {
941 const QString
sizeText(KIO::convertSize(byteSize
));
942 if (fileCount
== 1) {
943 text
+= i18n("1 File selected (%1)",sizeText
);
945 else if (fileCount
> 1) {
946 text
+= i18n("%1 Files selected (%1)",fileCount
,sizeText
);
952 QString
DolphinView::renameIndexPresentation(int index
, int itemCount
) const
954 // assure that the string reprentation for all indicess have the same
955 // number of characters based on the given number of items
956 QString
str(QString::number(index
));
958 while (itemCount
>= 10) {
962 str
.reserve(chrCount
);
964 const int insertCount
= chrCount
- str
.length();
965 for (int i
= 0; i
< insertCount
; ++i
) {
971 void DolphinView::slotShowFilterBar(bool show
)
973 assert(m_filterBar
!= 0);
982 void DolphinView::declareViewActive()
984 mainWindow()->setActiveView( this );
987 void DolphinView::slotChangeNameFilter(const QString
& nameFilter
)
989 // The name filter of KDirLister does a 'hard' filtering, which
990 // means that only the items are shown where the names match
991 // exactly the filter. This is non-transparent for the user, which
992 // just wants to have a 'soft' filtering: does the name contain
993 // the filter string?
994 QString
adjustedFilter(nameFilter
);
995 adjustedFilter
.insert(0, '*');
996 adjustedFilter
.append('*');
998 m_dirLister
->setNameFilter(adjustedFilter
);
999 m_dirLister
->emitChanges();
1001 // TODO: this is a workaround for QIconView: the item position
1002 // stay as they are by filtering, only an inserting of an item
1003 // results to an automatic adjusting of the item position. In Qt4/KDE4
1004 // this workaround should get obsolete due to Interview.
1005 /*KFileView* view = fileView();
1006 if (view == m_iconsView) {
1007 KFileItem* first = view->firstFileItem();
1009 view->removeItem(first);
1010 view->insertItem(first);
1015 void DolphinView::applyModeToView()
1017 //m_iconsView->setAlternatingRowColors(true);
1018 m_iconsView
->setSelectionMode(QAbstractItemView::ExtendedSelection
);
1020 // TODO: the following code just tries to test some QListView capabilities
1023 m_iconsView
->setViewMode(QListView::IconMode
);
1024 m_iconsView
->setGridSize(QSize(128, 64));
1028 m_iconsView
->setViewMode(QListView::ListMode
);
1029 m_iconsView
->setGridSize(QSize(256, 24));
1032 //case PreviewsView:
1033 // m_iconsView->setViewMode(QListView::IconMode);
1034 // m_iconsView->setGridSize(QSize(128, 128));
1039 int DolphinView::columnIndex(Sorting sorting
) const
1043 case SortByName
: index
= KDirModel::Name
; break;
1044 case SortBySize
: index
= KDirModel::Size
; break;
1045 case SortByDate
: index
= KDirModel::ModifiedTime
; break;
1046 default: assert(false);
1051 #include "dolphinview.moc"