Skip to content

Commit

Permalink
Fix drag drop behaviour of composer legend items
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13492 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 15, 2010
1 parent cc6eccc commit 62bbe6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 12 additions & 10 deletions src/core/composer/qgslegendmodel.cpp
Expand Up @@ -694,18 +694,25 @@ Qt::DropActions QgsLegendModel::supportedDropActions() const

Qt::ItemFlags QgsLegendModel::flags( const QModelIndex &index ) const
{
Qt::ItemFlags flags = QStandardItemModel::flags( index );
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
if ( !index.isValid() )
{
flags |= Qt::ItemIsDropEnabled;
return flags;
}

QStandardItem* item = itemFromIndex( index );
if ( item )
QgsComposerLegendItem* cItem = dynamic_cast<QgsComposerLegendItem*>( item );

if ( cItem )
{
ItemType type = itemType( *item );
if ( type == QgsLegendModel::GroupItem )
QgsComposerLegendItem::ItemType type = cItem->itemType();
if ( type == QgsComposerLegendItem::GroupItem )
{
flags |= Qt::ItemIsDragEnabled;
flags |= Qt::ItemIsDropEnabled;
}
else if ( type == QgsLegendModel::LayerItem )
else if ( type == QgsComposerLegendItem::LayerItem )
{
flags |= Qt::ItemIsDragEnabled;
}
Expand Down Expand Up @@ -741,11 +748,6 @@ bool QgsLegendModel::removeRows( int row, int count, const QModelIndex & parent
return true;
}

QgsLegendModel::ItemType QgsLegendModel::itemType( const QStandardItem& item ) const
{
return ( QgsLegendModel::ItemType )item.data( Qt::UserRole + 1 ).toInt();
}

QMimeData* QgsLegendModel::mimeData( const QModelIndexList &indexes ) const
{
QMimeData* mimeData = new QMimeData();
Expand Down
2 changes: 0 additions & 2 deletions src/core/composer/qgslegendmodel.h
Expand Up @@ -77,8 +77,6 @@ class CORE_EXPORT QgsLegendModel: public QStandardItemModel
/**Implemented to support drag operations*/
virtual bool removeRows( int row, int count, const QModelIndex & parent = QModelIndex() );

QgsLegendModel::ItemType itemType( const QStandardItem& item ) const;

/**For the drag operation*/
QMimeData* mimeData( const QModelIndexList &indexes ) const;
QStringList mimeTypes() const;
Expand Down

0 comments on commit 62bbe6b

Please sign in to comment.