mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
small fix of drag&group in group (deletion of the dictionaries after drop to the same window)
This commit is contained in:
parent
c694aec9d3
commit
282485c2de
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue