From 518546b5255cd10fc7dc7a8ac15cd392d49d45a7 Mon Sep 17 00:00:00 2001
From: Leo Franchi <lfranchi@kde.org>
Date: Fri, 11 Nov 2011 13:22:54 -0500
Subject: [PATCH] Don't select a temp item when deleting it

---
 src/libtomahawk/database/databaseimpl.cpp | 1 +
 src/sourcetree/sourcedelegate.cpp         | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/libtomahawk/database/databaseimpl.cpp b/src/libtomahawk/database/databaseimpl.cpp
index 3a240ec53..5634f81c4 100644
--- a/src/libtomahawk/database/databaseimpl.cpp
+++ b/src/libtomahawk/database/databaseimpl.cpp
@@ -1,6 +1,7 @@
 /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  *
  *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
+ *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  *
  *   Tomahawk is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
diff --git a/src/sourcetree/sourcedelegate.cpp b/src/sourcetree/sourcedelegate.cpp
index 86a874d09..3b8fc4152 100644
--- a/src/sourcetree/sourcedelegate.cpp
+++ b/src/sourcetree/sourcedelegate.cpp
@@ -414,7 +414,7 @@ bool
 SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
 {
 
-    if ( event->type() == QEvent::MouseButtonRelease )
+    if ( event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::MouseButtonPress )
     {
         SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
         if ( type == SourcesModel::TemporaryPage )
@@ -429,7 +429,12 @@ SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QS
             QRect r ( o.rect.right() - padding - m_iconHeight, padding + o.rect.y(), m_iconHeight, m_iconHeight );
 
             if ( r.contains( ev->pos() ) )
-                gpi->removeFromList();
+            {
+                if ( event->type() == QEvent::MouseButtonRelease )
+                    gpi->removeFromList();
+
+                return true;
+            }
         }
         else if ( type == SourcesModel::Collection )
         {