From 282485c2dedc5419ce7f51b63982659f42c480a4 Mon Sep 17 00:00:00 2001 From: ars_goldendict Date: Sun, 3 May 2009 18:46:19 +0000 Subject: [PATCH] small fix of drag&group in group (deletion of the dictionaries after drop to the same window) --- src/groups_widgets.cc | 46 ++++++++++++++++++++++++++++--------------- src/groups_widgets.hh | 2 +- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/groups_widgets.cc b/src/groups_widgets.cc index 885ca9c0..58c68743 100644 --- a/src/groups_widgets.cc +++ b/src/groups_widgets.cc @@ -134,19 +134,19 @@ QVariant DictListModel::data( QModelIndex const & index, int role ) const // return true; //} -bool DictListModel::removeRows( int row, int count, - const QModelIndex & parent ) -{ - if ( isSource ) - return false; - - beginRemoveRows( parent, row, row + count - 1 ); - dictionaries.erase( dictionaries.begin() + row, - dictionaries.begin() + row + count ); - endRemoveRows(); - - return true; -} +//bool DictListModel::removeRows( int row, int count, +// const QModelIndex & parent ) +//{ +// if ( isSource ) +// return false; +// +// beginRemoveRows( parent, row, row + count - 1 ); +// dictionaries.erase( dictionaries.begin() + row, +// dictionaries.begin() + row + count ); +// endRemoveRows(); +// +// return true; +//} bool DictListModel::setData( QModelIndex const & index, const QVariant & value, int role ) @@ -301,13 +301,27 @@ void DictListWidget::dropEvent ( QDropEvent * event ) { DictListWidget * sourceList = dynamic_cast< DictListWidget* > ( event->source() ); - if ( sourceList && sourceList->model.sourceModel() ) + if ( sourceList == this ) { - model.addSelectedUniqueFromModel( sourceList->selectionModel() ); + event->accept(); return; } - QListView::dropEvent( event ); + if ( sourceList && sourceList->model.sourceModel() ) + { + model.addSelectedUniqueFromModel( sourceList->selectionModel() ); + event->ignore(); + return; + } + + if ( sourceList && model.sourceModel() ) + { + sourceList->model.removeSelectedRows( sourceList->selectionModel() ); + event->ignore(); + return; + } + + //QListView::dropEvent( event ); } // DictGroupsWidget diff --git a/src/groups_widgets.hh b/src/groups_widgets.hh index 6dbabb1d..23d40af7 100644 --- a/src/groups_widgets.hh +++ b/src/groups_widgets.hh @@ -41,7 +41,7 @@ public: int rowCount( QModelIndex const & parent ) const; QVariant data( QModelIndex const & index, int role ) const; //bool insertRows( int row, int count, const QModelIndex & parent ); - bool removeRows( int row, int count, const QModelIndex & parent ); + //bool removeRows( int row, int count, const QModelIndex & parent ); bool setData( QModelIndex const & index, const QVariant & value, int role ); Qt::DropActions supportedDropActions() const;