Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "SMESHGUI_Operation.h"
00026
00027 #include "SMESHGUI.h"
00028 #include "SMESHGUI_Dialog.h"
00029
00030
00031 #include <SalomeApp_Study.h>
00032 #include <LightApp_Application.h>
00033
00034 #include <SUIT_Session.h>
00035 #include <SUIT_MessageBox.h>
00036 #include <SUIT_Desktop.h>
00037 #include <SUIT_ResourceMgr.h>
00038
00039
00040 #include <QStringList>
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 SMESHGUI_Operation::SMESHGUI_Operation()
00052 : LightApp_Operation(),
00053 myIsApplyAndClose( false )
00054 {
00055 myHelpFileName = "";
00056 }
00057
00058
00059
00060
00061
00062 SMESHGUI_Operation::~SMESHGUI_Operation()
00063 {
00064 }
00065
00066
00067
00068
00069
00070 SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
00071 {
00072 return dynamic_cast<SMESHGUI*>( module() );
00073 }
00074
00075
00076
00077
00078
00079 void SMESHGUI_Operation::startOperation()
00080 {
00081 if( dlg() )
00082 {
00083 disconnect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
00084 disconnect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
00085 disconnect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
00086 disconnect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
00087 disconnect( dlg(), SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
00088
00089 if( dlg()->testButtonFlags( QtxDialog::OK ) )
00090 connect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
00091
00092 if( dlg()->testButtonFlags( QtxDialog::Apply ) )
00093 connect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
00094
00095 if( dlg()->testButtonFlags( QtxDialog::Cancel ) )
00096 connect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
00097
00098 if( dlg()->testButtonFlags( QtxDialog::Help ) )
00099 connect( dlg(), SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
00100
00101
00102
00103 connect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
00104
00105 initDialog();
00106 }
00107
00108 LightApp_Operation::startOperation();
00109 }
00110
00111
00112
00113
00114
00115 bool SMESHGUI_Operation::isReadyToStart() const
00116 {
00117 if ( !LightApp_Operation::isReadyToStart() )
00118 return false;
00119 else if ( getSMESHGUI() == 0 )
00120 {
00121 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
00122 tr( "NO_MODULE" ) );
00123 return false;
00124 }
00125 else if ( isStudyLocked() )
00126 return false;
00127
00128 return true;
00129 }
00130
00131
00132
00133
00134
00135 void SMESHGUI_Operation::setDialogActive( const bool active )
00136 {
00137 LightApp_Operation::setDialogActive( active );
00138
00139 SMESHGUI_Dialog* d = dynamic_cast<SMESHGUI_Dialog*>( dlg() );
00140 if( d )
00141 d->setContentActive( active );
00142
00143 }
00144
00145
00146
00147
00148
00149 _PTR(Study) SMESHGUI_Operation::studyDS() const
00150 {
00151 SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study() );
00152 return s->studyDS();
00153 }
00154
00155
00156
00157
00158
00159 void SMESHGUI_Operation::onOk()
00160 {
00161 setIsApplyAndClose( true );
00162 if( onApply() )
00163 commit();
00164 setIsApplyAndClose( false );
00165
00166
00167 }
00168
00169
00170
00171
00172
00173 bool SMESHGUI_Operation::onApply()
00174 {
00175 return false;
00176 }
00177
00178
00179
00180
00181
00182 void SMESHGUI_Operation::onCancel()
00183 {
00184 abort();
00185 }
00186
00187
00188
00189
00190
00191 void SMESHGUI_Operation::onHelp()
00192 {
00193 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00194 if (app)
00195 app->onHelpContextModule(getSMESHGUI() ? app->moduleName(getSMESHGUI()->moduleName()) : QString(""), myHelpFileName);
00196 else {
00197 QString platform;
00198 #ifdef WIN32
00199 platform = "winapplication";
00200 #else
00201 platform = "application";
00202 #endif
00203 SUIT_MessageBox::warning( desktop(), tr("WRN_WARNING"),
00204 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00205 arg(app->resourceMgr()->stringValue("ExternalBrowser",
00206 platform)).
00207 arg(myHelpFileName) );
00208 }
00209 }
00210
00211
00212
00213
00214
00215 void SMESHGUI_Operation::initDialog()
00216 {
00217 }
00218
00219
00220
00221
00222
00223
00224 void SMESHGUI_Operation::setIsApplyAndClose( const bool theFlag )
00225 {
00226 myIsApplyAndClose = theFlag;
00227 }
00228
00229
00230
00231
00232
00233
00234 bool SMESHGUI_Operation::isApplyAndClose() const
00235 {
00236 return myIsApplyAndClose;
00237 }
00238
00247 bool SMESHGUI_Operation::isStudyLocked( const bool theMess ) const
00248 {
00249 if ( studyDS() )
00250 {
00251 if ( studyDS()->GetProperties()->IsLocked() )
00252 {
00253 if ( theMess )
00254 SUIT_MessageBox::warning( SMESHGUI::desktop(), tr( "WRN_WARNING" ),
00255 tr( "WRN_STUDY_LOCKED" ) );
00256 return true;
00257 }
00258 }
00259
00260 return false;
00261 }
00262
00273 bool SMESHGUI_Operation::isValid( SUIT_Operation* theOtherOp ) const
00274 {
00275 static QStringList anOps;
00276 if ( anOps.count() == 0 )
00277 {
00278 anOps.append( "SMESHGUI_DeleteOp" );
00279
00280 }
00281
00282 return ( theOtherOp &&
00283 ( ( theOtherOp->inherits("SMESHGUI_Operation") && ( !anOps.contains(theOtherOp->metaObject()->className() ) || anOps.contains(metaObject()->className()) ) ) ||
00284 ( theOtherOp->inherits("LightApp_ShowHideOp") ) ) );
00285
00286 return true;
00287 }