1 #include "STD_TabDesktop.h"
3 #include <SUIT_Session.h>
4 #include <SUIT_ViewWindow.h>
5 #include <SUIT_ResourceMgr.h>
8 #include <QtxWorkstack.h>
9 #include <QtxActionMenuMgr.h>
10 #include <QtxWorkstackAction.h>
14 #include <qworkspace.h>
15 #include <qobjectlist.h>
19 /*!Constructor.Create new instances of QVBox and QtxWorkstack.*/
20 STD_TabDesktop::STD_TabDesktop()
23 myWorkstackAction( 0 )
25 QVBox* base = new QVBox( this );
26 base->setFrameStyle( QFrame::Panel | QFrame::Sunken );
28 setCentralWidget( base );
30 myWorkstack = new QtxWorkstack( base );
31 // setting Expanding size policy for central workstack. If there are several widgets
32 // in central area of Desktop, other widgets will be added below the workstack (CATHARE, TIRPOLI modules).
33 // But the workstack must occupy as much space as possible -- set Expanding for it.
34 myWorkstack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
36 myWorkstack->setAccel(QtxWorkstack::SplitVertical, SHIFT + Key_V);
37 myWorkstack->setAccel(QtxWorkstack::SplitHorizontal, SHIFT + Key_H);
38 myWorkstack->setAccel(QtxWorkstack::Close, SHIFT + Key_C);
40 connect( myWorkstack, SIGNAL( windowActivated( QWidget* ) ),
41 this, SLOT( onWindowActivated( QWidget* ) ) );
47 STD_TabDesktop::~STD_TabDesktop()
51 /*!\retval SUIT_ViewWindow - return const active window.*/
52 SUIT_ViewWindow* STD_TabDesktop::activeWindow() const
54 SUIT_ViewWindow* wnd = 0;
56 QWidget* wid = myWorkstack->activeWindow();
57 if ( wid && wid->inherits( "SUIT_ViewWindow" ) )
58 wnd = (SUIT_ViewWindow*)wid;
63 /*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
64 QPtrList<SUIT_ViewWindow> STD_TabDesktop::windows() const
66 QPtrList<SUIT_ViewWindow> winList;
68 QWidgetList children = myWorkstack->windowList();
69 for ( QWidgetListIt it( children ); it.current(); ++it )
71 if ( it.current()->inherits( "SUIT_ViewWindow" ) )
72 winList.append( (SUIT_ViewWindow*)it.current() );
78 /*!\retval QWidget pointer - QT work stack.*/
79 QWidget* STD_TabDesktop::parentArea() const
84 /*!Call method perform for operation \a type.*/
85 void STD_TabDesktop::windowOperation( const int type )
87 myWorkstackAction->perform( operationFlag( type ) );
90 /*!Sets window operations by \a first ... parameters.*/
91 void STD_TabDesktop::setWindowOperations( const int first, ... )
94 va_start( ints, first );
96 QValueList<int> typeList;
101 typeList.append( cur );
102 cur = va_arg( ints, int );
105 setWindowOperations( typeList );
108 /*!Sets window operations by variable \a opList - operation list.*/
109 void STD_TabDesktop::setWindowOperations( const QValueList<int>& opList )
113 for ( QValueList<int>::const_iterator it = opList.begin(); it != opList.end(); ++it )
114 flags = flags | operationFlag( *it );
116 myWorkstackAction->setItems( flags );
119 /*!\retval QtxWorkstack pointer - QT work stack.*/
120 QtxWorkstack* STD_TabDesktop::workstack() const
125 /*!Emit window activated.*/
126 void STD_TabDesktop::onWindowActivated( QWidget* w )
128 if ( w && w->inherits( "SUIT_ViewWindow" ) )
129 emit windowActivated( (SUIT_ViewWindow*)w );
132 /*!Create actions for window.*/
133 void STD_TabDesktop::createActions()
135 if ( myWorkstackAction )
138 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
142 myWorkstackAction = new QtxWorkstackAction( workstack(), this );
144 myWorkstackAction->setItems( QtxWorkstackAction::Split | QtxWorkstackAction::Windows );
147 myWorkstackAction->setIconSet( QtxWorkstackAction::HSplit,
148 resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_HSPLIT" ) ) );
149 myWorkstackAction->setMenuText( QtxWorkstackAction::HSplit, tr( "MEN_DESK_WINDOW_HSPLIT" ) );
150 myWorkstackAction->setStatusTip( QtxWorkstackAction::HSplit, tr( "PRP_DESK_WINDOW_HSPLIT" ) );
153 myWorkstackAction->setIconSet( QtxWorkstackAction::VSplit,
154 resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_VSPLIT" ) ) );
155 myWorkstackAction->setMenuText( QtxWorkstackAction::VSplit, tr( "MEN_DESK_WINDOW_VSPLIT" ) );
156 myWorkstackAction->setStatusTip( QtxWorkstackAction::VSplit, tr( "PRP_DESK_WINDOW_VSPLIT" ) );
158 QtxActionMenuMgr* mMgr = menuMgr();
162 int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 );
163 mMgr->insert( myWorkstackAction, winMenuId, -1 );
164 mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 );
167 /*!Convert STD_TabDesktop enumerations to QtxWorkstackAction*/
168 int STD_TabDesktop::operationFlag( const int type ) const
174 res = QtxWorkstackAction::VSplit;
177 res = QtxWorkstackAction::HSplit;