]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
Fix the other bug reported by BCoppens: the tab title was the full path, until switch...
[dolphin.git] / src / dolphinview.cpp
index 085c791fdad4d124fdda4c75592163439ca3627b..fabda169e252f7b8a283426102d5dbcb93ba7c7c 100644 (file)
@@ -61,6 +61,7 @@ DolphinView::DolphinView(QWidget* parent,
                          DolphinSortFilterProxyModel* proxyModel) :
     QWidget(parent),
     m_active(true),
+    m_showPreview(false),
     m_loadingDirectory(false),
     m_storedCategorizedSorting(false),
     m_mode(DolphinView::IconsView),
@@ -102,8 +103,8 @@ DolphinView::DolphinView(QWidget* parent,
 
     connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
             this, SLOT(openContextMenu(const QPoint&)));
-    connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)),
-            this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)));
+    connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&)),
+            this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&)));
     connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
             this, SLOT(updateSorting(DolphinView::Sorting)));
     connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
@@ -193,6 +194,11 @@ void DolphinView::setMode(Mode mode)
         m_controller->setUrl(root);
     }
 
+    deleteView();
+
+    // It is important to read the view properties _after_ deleting the view,
+    // as e. g. the detail view might adjust the additional information properties
+    // after getting closed:
     const KUrl viewPropsUrl = viewPropertiesUrl();
     ViewProperties props(viewPropsUrl);
     props.setViewMode(m_mode);
@@ -227,11 +233,16 @@ DolphinView::Mode DolphinView::mode() const
 
 void DolphinView::setShowPreview(bool show)
 {
+    if (m_showPreview == show) {
+        return;
+    }
+
     const KUrl viewPropsUrl = viewPropertiesUrl();
     ViewProperties props(viewPropsUrl);
     props.setShowPreview(show);
 
-    m_controller->setShowPreview(show);
+    m_showPreview = show;
+
     emit showPreviewChanged();
 
     loadDirectory(viewPropsUrl, true);
@@ -239,7 +250,7 @@ void DolphinView::setShowPreview(bool show)
 
 bool DolphinView::showPreview() const
 {
-    return m_controller->showPreview();
+    return m_showPreview;
 }
 
 void DolphinView::setShowHiddenFiles(bool show)
@@ -253,7 +264,6 @@ void DolphinView::setShowHiddenFiles(bool show)
     props.setShowHiddenFiles(show);
 
     m_dirLister->setShowingDotFiles(show);
-    m_controller->setShowHiddenFiles(show);
     emit showHiddenFilesChanged();
 
     loadDirectory(viewPropsUrl, true);
@@ -557,7 +567,7 @@ void DolphinView::triggerItem(const KFileItem& item)
 
 void DolphinView::generatePreviews(const KFileItemList& items)
 {
-    if (m_controller->showPreview()) {
+    if (m_controller->dolphinView()->showPreview()) {
         KIO::PreviewJob* job = KIO::filePreview(items, 128);
         connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
                 this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
@@ -655,7 +665,6 @@ void DolphinView::applyViewProperties(const KUrl& url)
     const bool showHiddenFiles = props.showHiddenFiles();
     if (showHiddenFiles != m_dirLister->showingDotFiles()) {
         m_dirLister->setShowingDotFiles(showHiddenFiles);
-        m_controller->setShowHiddenFiles(showHiddenFiles);
         emit showHiddenFilesChanged();
     }
 
@@ -685,8 +694,8 @@ void DolphinView::applyViewProperties(const KUrl& url)
     }
 
     const bool showPreview = props.showPreview();
-    if (showPreview != m_controller->showPreview()) {
-        m_controller->setShowPreview(showPreview);
+    if (showPreview != m_showPreview) {
+        m_showPreview = showPreview;
         emit showPreviewChanged();
     }
 }
@@ -726,24 +735,14 @@ void DolphinView::openContextMenu(const QPoint& pos)
 
 void DolphinView::dropUrls(const KUrl::List& urls,
                            const KUrl& destPath,
-                           const KFileItem& destItem,
-                           QWidget* source)
-{
-    bool dropAboveDir = false;
-    if (!destItem.isNull()) {
-        dropAboveDir = destItem.isDir();
-        if (!dropAboveDir) {
-            // the dropping is done above a file
-            return;
-        }
-    } else if (source == itemView()) {
-        // the dropping is done into the same viewport where the dragging
-        // has been started
-        return;
+                           const KFileItem& destItem)
+{
+    const KUrl& destination = !destItem.isNull() && destItem.isDir() ?
+                              destItem.url() : destPath;
+    const KUrl sourceDir = KUrl(urls.first().directory());
+    if (sourceDir != destination) {
+        dropUrls(urls, destination);
     }
-
-    const KUrl& destination = dropAboveDir ? destItem.url() : destPath;
-    dropUrls(urls, destination);
 }
 
 void DolphinView::dropUrls(const KUrl::List& urls,
@@ -776,6 +775,7 @@ void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList&
 {
     ViewProperties props(viewPropertiesUrl());
     props.setAdditionalInfo(info);
+    props.save();
 
     m_fileItemDelegate->setShowInformation(info);
 
@@ -832,24 +832,12 @@ void DolphinView::clearHoverInformation()
 
 void DolphinView::createView()
 {
-    // delete current view
-    QAbstractItemView* view = itemView();
-    if (view != 0) {
-        m_topLayout->removeWidget(view);
-        view->close();
-        view->deleteLater();
-        view = 0;
-        m_iconsView = 0;
-        m_detailsView = 0;
-        m_columnView = 0;
-        m_fileItemDelegate = 0;
-    }
-
+    deleteView();
     Q_ASSERT(m_iconsView == 0);
     Q_ASSERT(m_detailsView == 0);
     Q_ASSERT(m_columnView == 0);
 
-    // ... and recreate it representing the current mode
+    QAbstractItemView* view = 0;
     switch (m_mode) {
     case IconsView: {
         m_iconsView = new DolphinIconsView(this, m_controller);
@@ -887,6 +875,21 @@ void DolphinView::createView()
             this, SLOT(emitContentsMoved()));
 }
 
+void DolphinView::deleteView()
+{
+    QAbstractItemView* view = itemView();
+    if (view != 0) {
+        m_topLayout->removeWidget(view);
+        view->close();
+        view->deleteLater();
+        view = 0;
+        m_iconsView = 0;
+        m_detailsView = 0;
+        m_columnView = 0;
+        m_fileItemDelegate = 0;
+    }
+}
+
 QAbstractItemView* DolphinView::itemView() const
 {
     if (m_detailsView != 0) {