+ QString text;
+ int folderCount = 0;
+ int fileCount = 0;
+ KIO::filesize_t totalFileSize = 0;
+
+ if (hasSelection()) {
+ // give a summary of the status of the selected files
+ const KFileItemList list = selectedItems();
+ if (list.isEmpty()) {
+ // when an item is triggered, it is temporary selected but selectedItems()
+ // will return an empty list
+ return text;
+ }
+
+ KFileItemList::const_iterator it = list.begin();
+ const KFileItemList::const_iterator end = list.end();
+ while (it != end) {
+ const KFileItem& item = *it;
+ if (item.isDir()) {
+ ++folderCount;
+ } else {
+ ++fileCount;
+ totalFileSize += item.size();
+ }
+ ++it;
+ }
+
+ if (folderCount + fileCount == 1) {
+ // if only one item is selected, show the filename
+ const QString name = list.first().text();
+ text = (folderCount == 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name) :
+ i18nc("@info:status", "<filename>%1</filename> selected (%2)",
+ name, KIO::convertSize(totalFileSize));
+ } else {
+ // at least 2 items are selected
+ const QString foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
+ const QString filesText = i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount);
+ if ((folderCount > 0) && (fileCount > 0)) {
+ text = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
+ foldersText, filesText, KIO::convertSize(totalFileSize));
+ } else if (fileCount > 0) {
+ text = i18nc("@info:status files (size)", "%1 (%2)", filesText, KIO::convertSize(totalFileSize));
+ } else {
+ Q_ASSERT(folderCount > 0);
+ text = foldersText;
+ }
+ }
+ } else {
+ calculateItemCount(fileCount, folderCount, totalFileSize);
+ text = KIO::itemsSummaryString(fileCount + folderCount,
+ fileCount, folderCount,
+ totalFileSize, true);
+ }
+
+ return text;
+}
+
+QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
+{
+ return m_controller->versionControlActions(items);
+}
+
+void DolphinView::setUrl(const KUrl& url)
+{
+ if (m_controller->url() != url) {
+ m_newFileNames.clear();
+
+ m_controller->setUrl(url); // emits urlChanged, which we forward
+ m_viewAccessor.prepareUrlChange(url);
+ applyViewProperties();
+ loadDirectory(url);
+
+ // When changing the URL there is no need to keep the version
+ // data of the previous URL.
+ m_viewAccessor.dirModel()->clearVersionData();
+
+ emit startedPathLoading(url);
+ }
+
+ // the selection model might have changed in the case of a column view
+ QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
+ if (m_selectionModel != selectionModel) {
+ disconnect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+ this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+ m_selectionModel = selectionModel;
+ connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+ this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+ }
+}
+
+void DolphinView::selectAll()
+{
+ m_viewAccessor.itemView()->selectAll();
+}
+
+void DolphinView::invertSelection()
+{
+ QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
+ const QAbstractItemModel* itemModel = selectionModel->model();
+
+ const QModelIndex topLeft = itemModel->index(0, 0);
+ const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
+ itemModel->columnCount() - 1);
+
+ const QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
+}
+
+void DolphinView::clearSelection()
+{
+ m_viewAccessor.itemView()->clearSelection();