]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
remove the asynchronous update of the zooming again, it decreases the "feeled" perfor...
[dolphin.git] / src / dolphinview.cpp
index 64aa10fd4847f1f2e042338be872a95464e4cee1..25d0cc1995d60a60e164b0cb6764fa6a7293998c 100644 (file)
@@ -193,6 +193,7 @@ void DolphinView::setMode(Mode mode)
         return; // the wished mode is already set
     }
 
+    const int oldZoomLevel = m_controller->zoomLevel();
     m_mode = mode;
 
     deleteView();
@@ -219,6 +220,7 @@ void DolphinView::setMode(Mode mode)
     }
 
     emit modeChanged();
+    updateZoomLevel(oldZoomLevel);
 }
 
 DolphinView::Mode DolphinView::mode() const
@@ -481,9 +483,9 @@ void DolphinView::setNameFilter(const QString& nameFilter)
     }
 }
 
-void DolphinView::calculateItemCount(int& fileCount, int& folderCount)
+void DolphinView::calculateItemCount(int& fileCount, int& folderCount) const
 {
-    foreach (const KFileItem &item, m_dirLister->items()) {
+    foreach (const KFileItemitem, m_dirLister->items()) {
         if (item.isDir()) {
             ++folderCount;
         } else {
@@ -492,6 +494,58 @@ void DolphinView::calculateItemCount(int& fileCount, int& folderCount)
     }
 }
 
+QString DolphinView::statusBarText() const
+{    
+    if (hasSelection()) {
+        // give a summary of the status of the selected files
+        QString text;
+        const KFileItemList list = selectedItems();
+        if (list.isEmpty()) {
+            // when an item is triggered, it is temporary selected but selectedItems()
+            // will return an empty list
+            return QString();
+        }
+
+        int fileCount = 0;
+        int folderCount = 0;
+        KIO::filesize_t byteSize = 0;
+        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;
+                byteSize += item.size();
+            }
+            ++it;
+        }
+
+        if (folderCount > 0) {
+            text = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
+            if (fileCount > 0) {
+                text += ", ";
+            }
+        }
+
+        if (fileCount > 0) {
+            const QString sizeText(KIO::convertSize(byteSize));
+            text += i18ncp("@info:status", "1 File selected (%2)", "%1 Files selected (%2)", fileCount, sizeText);
+        }
+        return text;
+    } else {
+        // Give a summary of the status of the current folder.
+        int folderCount = 0;
+        int fileCount = 0;
+        calculateItemCount(fileCount, folderCount);
+        return KIO::itemsSummaryString(fileCount + folderCount,
+                                       fileCount,
+                                       folderCount,
+                                       0, false);
+    }
+}
+
 void DolphinView::setUrl(const KUrl& url)
 {
     // remember current item candidate (see restoreCurrentItem())
@@ -558,7 +612,6 @@ void DolphinView::renameSelectedItems()
                     KUrl newUrl = oldUrl;
                     newUrl.setFileName(name);
                     KonqOperations::rename(this, oldUrl, newUrl);
-                    emit doingOperation(KIO::FileUndoManager::Rename);
                 }
             }
         }
@@ -588,14 +641,12 @@ void DolphinView::renameSelectedItems()
             KUrl newUrl = oldUrl;
             newUrl.setFileName(newName);
             KonqOperations::rename(this, oldUrl, newUrl);
-            emit doingOperation(KIO::FileUndoManager::Rename);
         }
     }
 }
 
 void DolphinView::trashSelectedItems()
 {
-    emit doingOperation(KIO::FileUndoManager::Trash);
     const KUrl::List list = simplifiedSelectedUrls();
     KonqOperations::del(this, KonqOperations::TRASH, list);
 }
@@ -820,11 +871,7 @@ void DolphinView::dropUrls(const KFileItem& destItem,
                            const KUrl& destPath,
                            QDropEvent* event)
 {
-    DolphinDropController dropController(this);
-    // forward doingOperation signal up to the mainwindow
-    connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
-            this, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)));
-    dropController.dropUrls(destItem, destPath, event);
+    DolphinDropController::dropUrls(destItem, destPath, event, this);
 }
 
 void DolphinView::updateSorting(DolphinView::Sorting sorting)
@@ -1057,9 +1104,13 @@ void DolphinView::applyViewProperties(const KUrl& url)
 
     const Mode mode = props.viewMode();
     if (m_mode != mode) {
+        const int oldZoomLevel = m_controller->zoomLevel();
+        
         m_mode = mode;
         createView();
         emit modeChanged();
+        
+        updateZoomLevel(oldZoomLevel);
     }
     if (itemView() == 0) {
         createView();
@@ -1175,7 +1226,7 @@ void DolphinView::createView()
 
     view->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
-    m_previewGenerator = new KFilePreviewGenerator(view, m_proxyModel);
+    m_previewGenerator = new KFilePreviewGenerator(view);
     m_previewGenerator->setPreviewShown(m_showPreview);
 
     if (DolphinSettings::instance().generalSettings()->showToolTips()) {
@@ -1252,11 +1303,9 @@ void DolphinView::pasteToUrl(const KUrl& url)
     const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
     if (KonqMimeData::decodeIsCutSelection(mimeData)) {
         KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url);
-        emit doingOperation(KIO::FileUndoManager::Move);
         clipboard->clear();
     } else {
         KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url);
-        emit doingOperation(KIO::FileUndoManager::Copy);
     }
 }