]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Reset the location to the home URL, if a place has been removed (e. g. a DVD has...
authorPeter Penz <peter.penz19@gmail.com>
Thu, 13 May 2010 18:23:04 +0000 (18:23 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 13 May 2010 18:23:04 +0000 (18:23 +0000)
Thanks to Christian Mühlhäuser for the patch!

BUG: 231518

svn path=/trunk/KDE/kdebase/apps/; revision=1126336

src/panels/places/placespanel.cpp
src/panels/places/placespanel.h

index e1e63ba9b5c6ed34ed9f53e53fc65594ce76477b..0da932154bd0437a3af2376f5d07e3c3cbd25f60 100644 (file)
@@ -1,5 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2010 by Christian Muehlhaeuser <muesli@gmail.com>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  ***************************************************************************/
 
 #include "placespanel.h"
+
+#include "dolphin_generalsettings.h"
 #include "draganddrophelper.h"
 #include <kfileitem.h>
 #include <konq_operations.h>
+#include "settings/dolphinsettings.h"
 
 PlacesPanel::PlacesPanel(QWidget* parent) :
     KFilePlacesView(parent),
@@ -43,6 +47,22 @@ void PlacesPanel::mousePressEvent(QMouseEvent* event)
     KFilePlacesView::mousePressEvent(event);
 }
 
+void PlacesPanel::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
+{
+    Q_UNUSED(parent);
+
+    const QModelIndexList indexes = selectedIndexes();
+    if (!indexes.isEmpty()) {
+        const int selectedRow = indexes.first().row();
+        if ((start >= selectedRow) && (end <= selectedRow)) {
+            // The currently selected item is about to be removed, reset view to home URL
+            const KUrl homeUrl = DolphinSettings::instance().generalSettings()->homeUrl();
+            setUrl(homeUrl);
+            emit urlChanged(homeUrl, Qt::NoButton);
+        }
+    }
+}
+
 void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
 {
     DragAndDropHelper::instance().dropUrls(KFileItem(), dest, event, parent);
index 1b6681af84762147328db73a7315b144625768db..f39bdec47ef21ebfc0aca8b8c14d816e34fa53a2 100644 (file)
@@ -1,5 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2010 by Christian Muehlhaeuser <muesli@gmail.com>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -38,6 +39,7 @@ signals:
 
 protected:
     virtual void mousePressEvent(QMouseEvent* event);
+    virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
 
 private slots:
     void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);