/*!
\brief Save module data. Called when user saves study.
\param files output list of files where module stores data
+ \param url study URL
\sa PyModuleHelper::save()
*/
-void SALOME_PYQT_ModuleLight::save( QStringList& files )
+void SALOME_PYQT_ModuleLight::save( QStringList& files, const QString& url )
{
// call helper
- myHelper->save( files );
+ myHelper->save( files, url );
}
/*
- \brief Load module data. Called when user opens study
- and activates module.
- \param files list of files where module data is stored
- \sa PyModuleHelper::load()
+ \brief Load module data. Called when user opens study
+ and activates module.
+ \param files list of files where module data is stored
+ \param url study URL
+ \return \c true if loading has been finished successfully or \c false otherwise
+ \sa PyModuleHelper::load()
*/
-bool SALOME_PYQT_ModuleLight::load( const QStringList& files )
+bool SALOME_PYQT_ModuleLight::load( const QStringList& files, const QString& url )
{
// call helper
- return myHelper->load( files );
+ return myHelper->load( files, url );
}
/*!
/*!
\brief Save module data. Called when user saves study.
\param files output list of files where module stores data
+ \param url study URL
*/
-void PyModuleHelper::save( QStringList& files )
+void PyModuleHelper::save( QStringList& files, const QString& url )
{
FuncMsg fmsg( "PyModuleHelper::save()" );
public:
SaveReq( PyInterp_Interp* _py_interp,
PyModuleHelper* _helper,
- QStringList& _files )
+ QStringList& _files,
+ const QString& _url )
: PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
myHelper( _helper ) ,
- myFiles( _files )
+ myFiles( _files ),
+ myUrl( _url )
{}
protected:
virtual void execute()
{
- myHelper->internalSave( myFiles );
+ myHelper->internalSave( myFiles, myUrl );
}
private:
PyModuleHelper* myHelper;
QStringList& myFiles;
+ QString myUrl;
};
// Posting the request only if dispatcher is not busy!
// Executing the request synchronously
if ( !PyInterp_Dispatcher::Get()->IsBusy() )
- PyInterp_Dispatcher::Get()->Exec( new SaveReq( myInterp, this, files ) );
+ PyInterp_Dispatcher::Get()->Exec( new SaveReq( myInterp, this, files, url ) );
}
/*
- \brief Load module data. Called when user opens study
- and activates module.
- \param files list of files where module data is stored
+ \brief Load module data. Called when user opens study
+ and activates module.
+ \param files list of files where module data is stored
+ \param url study URL
+ \return \c true if loading has been finished successfully or \c false otherwise
*/
-bool PyModuleHelper::load( const QStringList& files )
+bool PyModuleHelper::load( const QStringList& files, const QString& url )
{
FuncMsg fmsg( "PyModuleHelper::load()" );
LoadReq( PyInterp_Interp* _py_interp,
PyModuleHelper* _helper,
QStringList _files,
+ const QString& _url,
bool& _loaded )
: PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
myHelper( _helper ) ,
myFiles( _files ),
+ myUrl( _url ),
myLoaded( _loaded )
{}
protected:
virtual void execute()
{
- myHelper->internalLoad( myFiles, myLoaded );
+ myHelper->internalLoad( myFiles, myUrl, myLoaded );
}
private:
PyModuleHelper* myHelper;
QStringList myFiles;
+ QString myUrl;
bool& myLoaded;
};
// Posting the request only if dispatcher is not busy!
// Executing the request synchronously
if ( !PyInterp_Dispatcher::Get()->IsBusy() )
- PyInterp_Dispatcher::Get()->Exec( new LoadReq( myInterp, this, files, loaded ) );
+ PyInterp_Dispatcher::Get()->Exec( new LoadReq( myInterp, this, files, url, loaded ) );
return loaded;
}
\brief Module data saving callback function.
\internal
\param files output list of files where module stores data
+ \param url study URL
*/
-void PyModuleHelper::internalSave( QStringList& files )
+void PyModuleHelper::internalSave( QStringList& files, const QString& url )
{
FuncMsg fmsg( "--- PyModuleHelper::internalSave()" );
if ( PyObject_HasAttrString(myPyModule, (char*)"saveFiles") ) {
+ // try with two parameters (new syntax)
PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"saveFiles",
- (char*)"s", files.first().toLatin1().constData() ) );
-
+ (char*)"ss",
+ files.first().toLatin1().constData(),
+ url.toLatin1().constData() ) );
+ if ( !res )
+ // try with single parameter (old syntax)
+ res = PyObject_CallMethod( myPyModule, (char*)"saveFiles",
+ (char*)"s", files.first().toLatin1().constData() );
+
if ( !res ) {
PyErr_Print();
}
\brief Module data loading callback function.
\internal
\param files list of files where module data is stored
+ \param url study URL
\param opened output success flag
*/
-void PyModuleHelper::internalLoad( const QStringList& files, bool& opened )
+void PyModuleHelper::internalLoad( const QStringList& files, const QString& url, bool& opened )
{
FuncMsg fmsg( "--- PyModuleHelper::internalLoad()" );
PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL ) );
#endif
if ( PyObject_HasAttrString(myPyModule , (char*)"openFiles") ) {
+
+ // try with two parameters (new syntax)
PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"openFiles",
- (char*)"O", sipList.get()));
- if( !res || !PyBool_Check( res )) {
+ (char*)"Os", sipList.get(),
+ url.toLatin1().constData() ) );
+
+ if ( !res )
+ // try with single parameter (old syntax)
+ res = PyObject_CallMethod( myPyModule, (char*)"openFiles",
+ (char*)"O", sipList.get() );
+
+ if ( !res || !PyBool_Check( res ) ) {
PyErr_Print();
opened = false;
}
- else{
+ else {
opened = PyObject_IsTrue( res );
}
}
void tryCloseView( SUIT_ViewWindow* );
void closeView( SUIT_ViewWindow* );
void cloneView( SUIT_ViewWindow* );
- void save( QStringList& );
- bool load( const QStringList& );
+ void save( QStringList&, const QString& );
+ bool load( const QStringList&, const QString& );
void dumpPython( QStringList& files );
bool isDraggable( const SUIT_DataObject* ) const;
bool isDropAccepted( const SUIT_DataObject* ) const;
void internalTryCloseView( SUIT_ViewWindow* );
void internalCloseView( SUIT_ViewWindow* );
void internalCloneView( SUIT_ViewWindow* );
- void internalSave( QStringList& );
- void internalLoad( const QStringList&, bool& );
+ void internalSave( QStringList&, const QString& );
+ void internalLoad( const QStringList&, const QString&, bool& );
void internalDumpPython( QStringList& );
bool internalIsDraggable( LightApp_DataObject* );
bool internalIsDropAccepted( LightApp_DataObject* );