X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUIT%2FSUIT_TreeModel.cxx;h=9dfd4bc96f9e79030e614724fc483d0e90731615;hb=e1ce73d5be167bde706ee8af330ceb3fc952a2e4;hp=3a8eacc1a5012a891b6f823d851730af1cc4bb6c;hpb=5796a26d6925386f93f18a3f5567e8ea85558d41;p=modules%2Fgui.git diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx old mode 100755 new mode 100644 index 3a8eacc1a..9dfd4bc96 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -500,6 +500,7 @@ SUIT_TreeModel::~SUIT_TreeModel() void SUIT_TreeModel::registerColumn( const int group_id, const QString& name, const int custom_id ) { bool found = false; + beginResetModel(); for ( int i=0, n=myColumns.size(); i anIds = myVisibilityMap.keys(); - myVisibilityMap.clear(); - QList::ConstIterator it = anIds.begin(); - while ( it != anIds.end() ) { - QModelIndexList lst; - if ( searcher() ) { - SUIT_DataObject* o = searcher()->findObject( *it ); - if ( o ) lst << index( o ); - } - else { - lst = match( index( 0, root()->customData( Qtx::IdType ).toInt() ), DisplayRole, (*it), 1, Qt::MatchExactly | Qt::MatchRecursive ); - } - if ( !lst.isEmpty() ) { - QModelIndex idx = index( lst.first().row(), SUIT_DataObject::VisibilityId ,lst.first().parent() ); - emit dataChanged( idx, idx ); - } - it++; - } - } + foreach( QString id, myVisibilityMap.keys() ) + setVisibilityState( id, state ); } /*! @@ -772,6 +748,7 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r ) { if ( root() == r ) return; + beginResetModel(); if ( autoDeleteTree() ) { SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), @@ -792,7 +769,7 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r ) myRoot = r; //initialize(); - reset(); + endResetModel(); emit modelUpdated(); } @@ -967,12 +944,15 @@ bool SUIT_TreeModel::setData( const QModelIndex& index, } break; case EditRole: { - QString val = value.toString(); + QString val = value.toString(); + bool mod = obj->name() != val; if ( !val.isEmpty() && obj->setName(val) ) { emit( dataChanged( index, index ) ); - return true; - } - return false; + if (mod) + emit ( renamed(obj) ); + return true; + } + return false; break; } default: @@ -1748,7 +1728,7 @@ QMimeData* SUIT_TreeModel::mimeData( const QModelIndexList& indexes ) const } bool SUIT_TreeModel::dropMimeData( const QMimeData* data, Qt::DropAction action, - int row, int column, const QModelIndex& parent ) + int row, int /*column*/, const QModelIndex& parent ) { if ( action == Qt::IgnoreAction ) // do nothing with data @@ -1813,6 +1793,7 @@ SUIT_ProxyModel::SUIT_ProxyModel( QObject* parent ) connect( model, SIGNAL( clicked( SUIT_DataObject*, int ) ), this, SIGNAL(clicked( SUIT_DataObject*, int ) ) ); connect( model, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), this, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); + connect( model, SIGNAL( renamed( SUIT_DataObject* ) ), this, SIGNAL( renamed( SUIT_DataObject* ) ) ); setSourceModel( model ); setDynamicSortFilter( true ); } @@ -1831,6 +1812,7 @@ SUIT_ProxyModel::SUIT_ProxyModel( SUIT_DataObject* root, QObject* parent ) connect( model, SIGNAL( clicked( SUIT_DataObject*, int ) ), this, SIGNAL( clicked( SUIT_DataObject*, int ) ) ); connect( model, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), this, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); + connect( model, SIGNAL( renamed( SUIT_DataObject* ) ), this, SIGNAL( renamed( SUIT_DataObject* ) ) ); setSourceModel( model ); setDynamicSortFilter( true ); } @@ -1848,6 +1830,7 @@ SUIT_ProxyModel::SUIT_ProxyModel( SUIT_AbstractModel* model, QObject* parent ) connect( *model, SIGNAL( clicked( SUIT_DataObject*, int ) ), this, SIGNAL( clicked( SUIT_DataObject*, int ) ) ); connect( *model, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), this, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); + connect( *model, SIGNAL( renamed( SUIT_DataObject* ) ), this, SIGNAL( renamed( SUIT_DataObject* ) ) ); setSourceModel( *model ); setDynamicSortFilter( true ); } @@ -2316,8 +2299,6 @@ void SUIT_ItemDelegate::paint( QPainter* painter, QSize SUIT_ItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const { QSize size = QItemDelegate::sizeHint ( option, index ); -#if QT_VERSION >= 0x040500 size.setHeight( size.height() + 1 ); -#endif return size; }