small fix of drag&group in group (deletion of the dictionaries after drop to the same window)

This commit is contained in:
ars_goldendict 2009-05-03 18:46:19 +00:00
parent c694aec9d3
commit 282485c2de
2 changed files with 31 additions and 17 deletions

View file

@ -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

View file

@ -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;