1 #include "CAF_Application.h"
5 #include "SUIT_Desktop.h"
6 #include "SUIT_Session.h"
7 #include "SUIT_ViewModel.h"
8 #include "SUIT_Operation.h"
9 #include "SUIT_MessageBox.h"
10 #include "SUIT_ResourceMgr.h"
12 #include "QtxListAction.h"
16 #include <qpopupmenu.h>
17 #include <qstatusbar.h>
18 #include <qfiledialog.h>
19 #include <qapplication.h>
21 extern "C" CAF_EXPORT SUIT_Application* createApplication()
23 return new CAF_Application();
26 CAF_Application::CAF_Application()
31 CAF_Application::~CAF_Application()
35 QString CAF_Application::applicationName() const
37 return QString( "CAFApplication" );
40 void CAF_Application::createActions()
42 STD_Application::createActions();
44 SUIT_Desktop* desk = desktop();
45 SUIT_ResourceMgr* resMgr = resourceMgr();
47 QtxListAction* editUndo =
48 new QtxListAction( tr( "TOT_APP_EDIT_UNDO" ), resMgr->loadPixmap( "CAF", tr( "ICON_APP_EDIT_UNDO" ) ),
49 tr( "MEN_APP_EDIT_UNDO" ), CTRL+Key_Z, desk );
50 registerAction( EditUndoId, editUndo );
52 QtxListAction* editRedo =
53 new QtxListAction( tr( "TOT_APP_EDIT_REDO" ), resMgr->loadPixmap( "CAF", tr( "ICON_APP_EDIT_REDO" ) ),
54 tr( "MEN_APP_EDIT_REDO" ), CTRL+Key_Y, desk );
55 registerAction( EditRedoId, editRedo );
57 editUndo->setComment( tr( "INF_APP_UNDOACTIONS" ) );
58 editRedo->setComment( tr( "INF_APP_REDOACTIONS" ) );
60 connect( editUndo, SIGNAL( activated( int ) ), this, SLOT( onUndo( int ) ) );
61 connect( editRedo, SIGNAL( activated( int ) ), this, SLOT( onRedo( int ) ) );
64 int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 10 );
66 createMenu( EditUndoId, editMenu, 0 );
67 createMenu( EditRedoId, editMenu, 0 );
68 createMenu( separator(), editMenu, -1, 0 );
70 int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ) );
72 createTool( separator(), stdTBar );
73 createTool( EditUndoId, stdTBar );
74 createTool( EditRedoId, stdTBar );
75 createTool( separator(), stdTBar );
79 Undo operation on the given document. [ virtual protected ]
81 bool CAF_Application::undo( CAF_Study* doc )
86 if ( success = doc->undo() )
93 Redo operation on the given document. [ virtual protected ]
95 bool CAF_Application::redo(CAF_Study* doc)
100 if ( success = doc->redo() )
107 Undo operation on the active document. [ virtual protected slot ]
109 bool CAF_Application::onUndo( int numActions )
112 while ( numActions > 0 )
114 CAF_Study* cafStudy = dynamic_cast<CAF_Study*>( activeStudy() );
117 if ( !undo( cafStudy ) )
125 updateCommandsStatus(); /* enable/disable undo/redo */
130 Redo operation on the active document. [ virtual protected slot ]
132 bool CAF_Application::onRedo( int numActions )
135 while ( numActions > 0 )
137 CAF_Study* cafStudy = dynamic_cast<CAF_Study*>( activeStudy() );
140 if ( !redo( cafStudy ) )
148 updateCommandsStatus(); /* enable/disable undo/redo */
153 Enables / disables the actions according to the application state. [ virtual protected ]
155 void CAF_Application::updateCommandsStatus()
157 STD_Application::updateCommandsStatus();
159 CAF_Study* cafStudy = 0;
160 if ( activeStudy() && activeStudy()->inherits( "CAF_Study" ) )
161 cafStudy = (CAF_Study*)activeStudy();
163 QAction* undo = action( EditUndoId );
164 if ( cafStudy && undo->inherits( "QtxListAction" ) )
165 ((QtxListAction*)undo)->addNames( cafStudy->undoNames() );
167 QAction* redo = action( EditRedoId );
168 if ( cafStudy && redo->inherits( "QtxListAction" ) )
169 ((QtxListAction*)redo)->addNames( cafStudy->redoNames() );
171 undo->setEnabled( cafStudy && cafStudy->canUndo() );
172 redo->setEnabled( cafStudy && cafStudy->canRedo() );