Skip to content
Permalink
Browse files
Fix drag drop behaviour of composer legend items
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 62bbe6ba6e8c9260265bfa77e95b0d899aa74d5b
Showing with 12 additions and 12 deletions.
  1. +12 −10 src/core/composer/qgslegendmodel.cpp
  2. +0 −2 src/core/composer/qgslegendmodel.h
@@ -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;
}
@@ -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();
@@ -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;

0 comments on commit 62bbe6b

Please sign in to comment.