[Qgis-developer] Need help with LayerTreeModel (legend node)
wonder.sk at gmail.com
Sun Dec 21 05:49:53 PST 2014
On Fri, Dec 19, 2014 at 6:55 PM, Sandro Santilli <strk at keybit.net> wrote:
> Qt::ItemFlags flags = model->flags( QModelIndex() );
> Q_ASSERT( flags == Qt::ItemIsDropEnabled || flags == 0 );
> The test checks that the flag for an invalid index can only
> be 0 or Qt::ItemIsDropEnabled. Instead QgsLayerTreeModel includes
> ItemIsSelectable and ItemIsEnabled in the flags:
> if ( !index.isValid() )
> Qt::ItemFlags rootFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
> if ( testFlag( AllowNodeReorder ) )
> rootFlags |= Qt::ItemIsDropEnabled;
> return rootFlags;
> What's the rationale for adding those two flags ?
> I've tested that initializing ti to 0 and adding the dropEnabled
> based on AllowNodeReorder passes the test.
I don't think there was any particular reason for that - just an omission I
would say (adding those flags for invalid index obviously does not make any
harm besides not being 100% correct).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Qgis-developer