]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
* changed "Click to add comment..." to simply "Add comment..." for consistency with...
[dolphin.git] / src / dolphinview.cpp
index 4b221a0e34acb9d25af110350c0f4acc1cede5b4..4800b9e9ab620e18eabbc3a029df52aa3768a5c2 100644 (file)
@@ -31,7 +31,6 @@
 #include <kactioncollection.h>
 #include <kcolorscheme.h>
 #include <kdirlister.h>
-#include <kfileitemdelegate.h>
 #include <kiconeffect.h>
 #include <klocale.h>
 #include <kio/deletejob.h>
@@ -39,6 +38,7 @@
 #include <kio/previewjob.h>
 #include <kjob.h>
 #include <kmenu.h>
+#include <kmessagebox.h>
 #include <kmimetyperesolver.h>
 #include <konq_operations.h>
 #include <konqmimedata.h>
@@ -49,6 +49,7 @@
 #include "dolphinmodel.h"
 #include "dolphincolumnview.h"
 #include "dolphincontroller.h"
+#include "dolphinfileitemdelegate.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphindetailsview.h"
 #include "dolphiniconsview.h"
@@ -86,9 +87,6 @@ DolphinView::DolphinView(QWidget* parent,
     m_topLayout->setSpacing(0);
     m_topLayout->setMargin(0);
 
-    connect(m_dirLister, SIGNAL(completed()),
-            this, SLOT(updateCutItems()));
-
     m_controller = new DolphinController(this);
     m_controller->setUrl(url);
 
@@ -230,7 +228,7 @@ void DolphinView::setShowPreview(bool show)
     m_iconManager->setShowPreview(show);
     emit showPreviewChanged();
 
-    loadDirectory(viewPropsUrl, true);
+    loadDirectory(viewPropsUrl);
 }
 
 bool DolphinView::showPreview() const
@@ -251,7 +249,7 @@ void DolphinView::setShowHiddenFiles(bool show)
     m_dirLister->setShowingDotFiles(show);
     emit showHiddenFilesChanged();
 
-    loadDirectory(viewPropsUrl, true);
+    loadDirectory(viewPropsUrl);
 }
 
 bool DolphinView::showHiddenFiles() const
@@ -400,13 +398,13 @@ QPoint DolphinView::contentsPosition() const
 void DolphinView::zoomIn()
 {
     m_controller->triggerZoomIn();
-    reload();
+    m_iconManager->updatePreviews();
 }
 
 void DolphinView::zoomOut()
 {
     m_controller->triggerZoomOut();
-    reload();
+    m_iconManager->updatePreviews();
 }
 
 bool DolphinView::isZoomInPossible() const
@@ -455,7 +453,7 @@ void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info)
     if (itemView() != m_detailsView) {
         // the details view requires no reloading of the directory, as it maps
         // the file item delegate info to its columns internally
-        loadDirectory(viewPropsUrl, true);
+        loadDirectory(viewPropsUrl);
     }
 }
 
@@ -540,15 +538,24 @@ void DolphinView::mouseReleaseEvent(QMouseEvent* event)
 
 void DolphinView::wheelEvent(QWheelEvent* event)
 {
-    if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
-        int d = event->delta();
-        if (d > 0 && isZoomInPossible()) {
+    if (event->modifiers() & Qt::ControlModifier) {
+        const int delta = event->delta();
+        if ((delta > 0) && isZoomInPossible()) {
             zoomIn();
-        } else if (d < 0 && isZoomOutPossible()) {
+        } else if ((delta < 0) && isZoomOutPossible()) {
             zoomOut();
         }
-       event->accept();
+        event->accept();
+    }
+}
+
+bool DolphinView::eventFilter(QObject* watched, QEvent* event)
+{
+    if ((watched == itemView()) && (event->type() == QEvent::FocusIn)) {
+        m_controller->requestActivation();
     }
+
+    return QWidget::eventFilter(watched, event);
 }
 
 void DolphinView::activate()
@@ -859,11 +866,9 @@ void DolphinView::emitContentsMoved()
 
 void DolphinView::showHoverInformation(const KFileItem& item)
 {
-    if (hasSelection() || !m_active) {
-        return;
+    if (!hasSelection()) {
+        emit requestItemInfo(item);
     }
-
-    emit requestItemInfo(item);
 }
 
 void DolphinView::clearHoverInformation()
@@ -900,8 +905,11 @@ void DolphinView::createView()
     }
 
     Q_ASSERT(view != 0);
+    view->installEventFilter(this);
 
-    m_fileItemDelegate = new KFileItemDelegate(view);
+    m_controller->setItemView(view);
+
+    m_fileItemDelegate = new DolphinFileItemDelegate(view);
     view->setItemDelegate(m_fileItemDelegate);
 
     view->setModel(m_proxyModel);
@@ -1094,8 +1102,8 @@ void DolphinView::paste()
 
     const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
 
-    // per default the pasting is done into the current Url of the view
-    KUrl destUrl(url());
+    // per default the pasting is done into the current URL of the view
+    KUrl destUrl = url();
 
     // check whether the pasting should be done into a selected directory
     const KUrl::List selectedUrls = this->selectedUrls();
@@ -1108,6 +1116,17 @@ void DolphinView::paste()
             // only one item is selected which is a directory, hence paste
             // into this directory
             destUrl = selectedUrls.first();
+            if (sourceUrls.contains(destUrl)) {
+                const QString text = i18nc("@info", "The folder <filename>%1</filename> is pasted into itself. Is this intended?", fileItem.name());
+                int result = KMessageBox::questionYesNo(window(),
+                                                        text,
+                                                        i18nc("@title:window", "Paste into Folder"),
+                                                        KGuiItem(i18nc("@action:button", "Paste"), "dialog-ok"),
+                                                        KGuiItem(i18nc("@action:button", "Cancel"), "dialog-cancel"));
+                if (result == KMessageBox::No) {
+                    return;
+                }
+            }
         }
     }
 
@@ -1130,7 +1149,14 @@ QPair<bool, QString> DolphinView::pasteInfo() const
     KUrl::List urls = KUrl::List::fromMimeData(mimeData);
     if (!urls.isEmpty()) {
         ret.first = true;
-        ret.second = i18ncp("@action:inmenu", "Paste One File", "Paste %1 Files", urls.count());
+        if (urls.count() == 1) {
+            const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(), true);
+            ret.second = item.isDir() ? i18nc("@action:inmenu", "Paste One Folder") :
+                                        i18nc("@action:inmenu", "Paste One File");
+
+        } else {
+            ret.second = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count());
+        }
     } else {
         ret.first = false;
         ret.second = i18nc("@action:inmenu", "Paste");