if ( m ) {
m->updateTree( obj );
openLevels();
+
+ if (myAutoSizeFirstColumn)
+ adjustFirstColumnWidth();
+ if (myAutoSizeColumns)
+ adjustColumnsWidth();
}
}
createPopupMenu( menu );
}
+/*!
+ \brief Set 'auto-size first column' flag value.
+
+ If this flag is set to \c true (by default), the first column width is resized
+ to its contents.
+
+ \param on 'auto-size first column' flag value
+ \sa setAutoSizeColumns()
+*/
+void SUIT_DataBrowser::setAutoSizeFirstColumn( const bool on )
+{
+ myAutoSizeFirstColumn = on;
+}
+
+/*!
+ \brief Set 'auto-size columns' flag value.
+
+ If this flag is set to \c true (by default is false), columns width except
+ the first column is resized to its contents.
+
+ \param on 'auto-size columns' flag value
+ \sa setAutoSizeFirstColumn()
+*/
+void SUIT_DataBrowser::setAutoSizeColumns( const bool on )
+{
+ myAutoSizeColumns = on;
+}
+
/*!
\brief Process context menu request event.
\param e context menu event
contextMenuRequest( e );
}
+/*!
+ \brief Set 'resize on expand item' flag value.
+
+ If this flag is set to \c true (by default is false), after
+ expanding an item columns will be resized to its contents.
+
+ \param on 'resize on expand item' flag value
+*/
+void SUIT_DataBrowser::setResizeOnExpandItem( const bool on )
+{
+ myResizeOnExpandItem = on;
+}
+
/*!
\brief Initialize object browser.
\param root root data object
*/
void SUIT_DataBrowser::init( SUIT_DataObject* root )
{
- setModel( new SUIT_ProxyModel( root, this ) );
+ SUIT_ProxyModel* m = new SUIT_ProxyModel( root, this );
+ connect( m, SIGNAL( modelUpdated() ), this, SLOT( onModelUpdated() ) );
+
+ setModel( m );
setItemDelegate( qobject_cast<SUIT_ProxyModel*>( model() )->delegate() );
- connect( treeView(), SIGNAL( sortingEnabled(bool ) ),
- model(), SLOT( setSortingEnabled( bool ) ) );
+ connect( treeView(), SIGNAL( sortingEnabled( bool ) ),
+ model(), SLOT( setSortingEnabled( bool ) ) );
+ connect( treeView(), SIGNAL( doubleClicked( const QModelIndex& ) ),
+ this, SLOT( onDblClicked( const QModelIndex& ) ) );
+ connect( treeView(), SIGNAL( expanded( const QModelIndex& ) ),
+ this, SLOT( onExpanded( const QModelIndex& ) ) );
myShortcut = new QShortcut( Qt::Key_F5, this, SIGNAL( requestUpdate() ), SIGNAL( requestUpdate() ) );
+
+ myAutoSizeFirstColumn = true;
+ myAutoSizeColumns = false;
+ myResizeOnExpandItem = false;
}
/*!
\sa updateKey(), setUpdateKey()
*/
+
+/*!
+ \fn void SUIT_DataBrowser::doubleClicked( SUIT_DataObject* o );
+ \brief This signal is emitted when a mouse button is double-clicked.
+
+ The data object the mouse was double-clicked on is specified by \a o.
+ The signal is only emitted when the object is valid.
+
+ \param o data object which is double-clicked
+*/
+
+/*!
+ \brief Update internal modification time just after data model update
+*/
+void SUIT_DataBrowser::onModelUpdated()
+{
+ setModified();
+}
+
+/*!
+ \brief Called when item is double-clicked in the tree view
+ \internal
+
+ Emits signal doubleClicked( SUIT_DataObject* );
+*/
+void SUIT_DataBrowser::onDblClicked( const QModelIndex& index )
+{
+ SUIT_ProxyModel* m = qobject_cast<SUIT_ProxyModel*>( model() );
+
+ if ( m ) {
+ SUIT_DataObject* obj = m->object( index );
+ if ( obj ) emit( doubleClicked( obj ) );
+ }
+}
+
+/*!
+ \brief Called when item specified by index is expanded.
+ \internal
+*/
+void SUIT_DataBrowser::onExpanded( const QModelIndex& index )
+{
+ if (myResizeOnExpandItem) {
+ adjustFirstColumnWidth();
+ adjustColumnsWidth();
+ }
+}
+
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// 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
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
QtxPreferenceItem* item = parent->findItem( title, true );
- if ( item )
+ if ( item && item->depth() < 4 )
return item->id();
if ( pId == -1 )
*/
int SUIT_TreeModel::TreeItem::position() const
{
- return myParent->myChildren.indexOf( (TreeItem*)this );
+ return myParent ? myParent->myChildren.indexOf( (TreeItem*)this ) : -1;
}
/*!
//initialize();
reset();
+ emit modelUpdated();
}
/*!
synchronize<ObjPtr,ItemPtr,SUIT_TreeModel::TreeSync>( obj,
treeItem( obj ),
SUIT_TreeModel::TreeSync( this ) );
+ emit modelUpdated();
}
/*!
: QSortFilterProxyModel( parent ),
mySortingEnabled( true )
{
- setSourceModel( new SUIT_TreeModel( this ) );
+ SUIT_TreeModel* model = new SUIT_TreeModel( this );
+ connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
+ setSourceModel( model );
}
/*!
: QSortFilterProxyModel( parent ),
mySortingEnabled( true )
{
- setSourceModel( new SUIT_TreeModel( root, this ) );
+ SUIT_TreeModel* model = new SUIT_TreeModel( root, this );
+ connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
+ setSourceModel( model );
}
/*!
: QSortFilterProxyModel( parent ),
mySortingEnabled( true )
{
+ connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
setSourceModel( model );
}