]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Use the actions "new_tab" and "new_window" for the viewport-contextmenu instead of...
[dolphin.git] / src / views / dolphinview.cpp
index 00751bf771168e0cd8332d761649b41838b5c3b5..6cda685d9dcee3a65bfbe0e12af09cd46aa1044a 100644 (file)
@@ -45,7 +45,6 @@
 #include <konq_fileitemcapabilities.h>
 #include <konq_operations.h>
 #include <konqmimedata.h>
-#include <kstringhandler.h>
 #include <ktoggleaction.h>
 #include <kurl.h>
 
 #include "zoomlevelinfo.h"
 #include "dolphindetailsviewexpander.h"
 
-/**
- * Helper function for sorting items with qSort() in
- * DolphinView::renameSelectedItems().
- */
-bool lessThan(const KFileItem& item1, const KFileItem& item2)
-{
-    return KStringHandler::naturalCompare(item1.name(), item2.name()) < 0;
-}
-
 DolphinView::DolphinView(QWidget* parent,
                          const KUrl& url,
                          DolphinSortFilterProxyModel* proxyModel) :
@@ -86,7 +76,6 @@ DolphinView::DolphinView(QWidget* parent,
     m_storedCategorizedSorting(false),
     m_tabsForFiles(false),
     m_isContextMenuOpen(false),
-    m_ignoreViewProperties(false),
     m_assureVisibleCurrentIndex(false),
     m_mode(DolphinView::IconsView),
     m_topLayout(0),
@@ -438,10 +427,13 @@ void DolphinView::reload()
     restoreState(restoreStream);
 }
 
-void DolphinView::refresh()
+void DolphinView::stopLoading()
 {
-    m_ignoreViewProperties = false;
+    m_viewAccessor.dirLister()->stop();
+}
 
+void DolphinView::refresh()
+{
     const bool oldActivationState = m_active;
     const int oldZoomLevel = m_viewModeController->zoomLevel();
     m_active = true;
@@ -599,82 +591,17 @@ void DolphinView::renameSelectedItems()
         return;
     }
 
-    if (itemCount > 1) {
-        // More than one item has been selected for renaming. Open
-        // a rename dialog and rename all items afterwards.
-        QPointer<RenameDialog> dialog = new RenameDialog(this, items);
-        if (dialog->exec() == QDialog::Rejected) {
-            delete dialog;
-            return;
-        }
-
-        const QString newName = dialog->newName();
-        if (newName.isEmpty()) {
-            emit errorMessage(dialog->errorString());
-            delete dialog;
-            return;
-        }
-        delete dialog;
-
-        // the selection would be invalid after renaming the items, so just clear
-        // it before
-        clearSelection();
-
-        // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
-        // as one operation instead of n rename operations like it is done now...
-        Q_ASSERT(newName.contains('#'));
-
-        // currently the items are sorted by the selection order, resort
-        // them by the file name
-        qSort(items.begin(), items.end(), lessThan);
-
-        // iterate through all selected items and rename them...
-        int index = 1;
-        foreach (const KFileItem& item, items) {
-            const KUrl& oldUrl = item.url();
-            QString number;
-            number.setNum(index++);
-
-            QString name = newName;
-            name.replace('#', number);
-
-            if (oldUrl.fileName() != name) {
-                KUrl newUrl = oldUrl;
-                newUrl.setFileName(name);
-                KonqOperations::rename(this, oldUrl, newUrl);
-            }
-        }
-    } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
-        Q_ASSERT(itemCount == 1);
+    if ((itemCount == 1) && DolphinSettings::instance().generalSettings()->renameInline()) {
         const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForItem(items.first());
         const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
         m_viewAccessor.itemView()->edit(proxyIndex);
     } else {
-        Q_ASSERT(itemCount == 1);
-
-        QPointer<RenameDialog> dialog = new RenameDialog(this, items);
-        if (dialog->exec() == QDialog::Rejected) {
-            delete dialog;
-            return;
-        }
-
-        const QString newName = dialog->newName();
-        if (newName.isEmpty()) {
-            emit errorMessage(dialog->errorString());
-            delete dialog;
-            return;
-        }
-        delete dialog;
-
-        const KUrl& oldUrl = items.first().url();
-        KUrl newUrl = oldUrl;
-        newUrl.setFileName(newName);
-        KonqOperations::rename(this, oldUrl, newUrl);
+        RenameDialog* dialog = new RenameDialog(this, items);
+        dialog->setAttribute(Qt::WA_DeleteOnClose);
+        dialog->show();
+        dialog->raise();
+        dialog->activateWindow();
     }
-
-    // assure that the current index remains visible when KDirLister
-    // will notify the view about changed items
-    m_assureVisibleCurrentIndex = true;
 }
 
 void DolphinView::trashSelectedItems()
@@ -1164,6 +1091,8 @@ void DolphinView::slotLoadingCompleted()
     // Restore the contents position. This has to be done using a Qt::QueuedConnection
     // because the view might not be in its final state yet.
     QMetaObject::invokeMethod(this, "restoreContentsPosition", Qt::QueuedConnection);
+
+    emit finishedPathLoading(url());
 }
 
 void DolphinView::slotRefreshItems()
@@ -1192,10 +1121,6 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
 
 void DolphinView::applyViewProperties()
 {
-    if (m_ignoreViewProperties) {
-        return;
-    }
-
     const ViewProperties props(rootUrl());
 
     const Mode mode = props.viewMode();
@@ -1262,13 +1187,6 @@ void DolphinView::applyViewProperties()
         // the used zoom level of the controller must be adjusted manually:
         updateZoomLevel(oldZoomLevel);
     }
-
-    if (DolphinSettings::instance().generalSettings()->globalViewProps()) {
-        // During the lifetime of a DolphinView instance the global view properties
-        // should not be changed. This allows e. g. to split a view and use different
-        // view properties for each view.
-        m_ignoreViewProperties = true;
-    }
 }
 
 void DolphinView::createView()