1 #include "SalomeApp_WidgetContainer.h"
3 #include <qobjectlist.h>
4 #include <qwidgetstack.h>
9 SalomeApp_WidgetContainer::SalomeApp_WidgetContainer( const int type, QWidget* parent )
10 : QDockWindow( QDockWindow::InDock, parent ),
13 setWidget( myStack = new QWidgetStack( this ) );
20 SalomeApp_WidgetContainer::~SalomeApp_WidgetContainer()
25 Checks: is widget container is empty?
27 bool SalomeApp_WidgetContainer::isEmpty() const
29 const QObjectList* lst = myStack->children();
34 for ( QObjectListIt it( *lst ); it.current() && res; ++it )
36 if ( it.current()->isWidgetType() && myStack->id( (QWidget*)it.current() ) != -1 )
43 Gets type of widget container.
45 int SalomeApp_WidgetContainer::type() const
51 Checks: is container contains widget with id \a id.
53 bool SalomeApp_WidgetContainer::contains( const int id ) const
55 return myStack->widget( id ) != 0;
59 * Insert widget(\a wid with id \a id) to container.And return id of widget in stack.
60 *\warning remove widget with id = \a id , if it was in container.
62 int SalomeApp_WidgetContainer::insert( const int id, QWidget* wid )
64 if ( id == -1 || !wid )
70 int stackId = myStack->addWidget( wid, id );
71 if ( !myStack->visibleWidget() )
72 myStack->raiseWidget( wid );
74 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
80 Remove widget from stack by widget \a id.
82 void SalomeApp_WidgetContainer::remove( const int id )
84 remove( myStack->widget( id ) );
86 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
90 Remove widget(\a wid) from stack.
92 void SalomeApp_WidgetContainer::remove( QWidget* wid )
94 myStack->removeWidget( wid );
96 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
100 Raise widget with id = \a id.
102 void SalomeApp_WidgetContainer::activate( const int id )
104 myStack->raiseWidget( id );
106 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
110 Raise widget (\a wid).
112 void SalomeApp_WidgetContainer::activate( QWidget* wid )
114 myStack->raiseWidget( wid );
116 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
120 Gets widget from container list(stack) by id = \a id.
122 QWidget* SalomeApp_WidgetContainer::widget( const int id ) const
124 return myStack->widget( id );
130 QWidget* SalomeApp_WidgetContainer::active() const
132 return myStack->visibleWidget();