Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit c53d4a45 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

UI state loaded from the additional XML file stored with each project.

parent 688e60fb
......@@ -339,8 +339,15 @@ void UIMainWindow::loadPlugins()
DisplayableFactoryInterface *dispFactory = qobject_cast<DisplayableFactoryInterface*>( plugin );
if( dispFactory )
{
m_DisplayablePlugins.push_back( dispFactory );
QVector<QString> acceptedTypes;
dispFactory->acceptedDataTypes( acceptedTypes );
for( auto &type : acceptedTypes )
m_DisplayableFactoryByTypes[ type ] = dispFactory;
}
ExportInterface *exporter = qobject_cast<ExportInterface*>( plugin );
if( exporter )
ui->tableCurrentProjContent->populateExports( exporter );
......@@ -984,6 +991,157 @@ bool UIMainWindow::saveProjectOptions( const QString &filePath, UIProject *proje
}
bool UIMainWindow::loadProjectOptions( const QString &filePath, UIProject *project )
{
// Open the source file.
QFile file( filePath );
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
return false;
// Create a stream for the XML parsing of the file.
QXmlStreamReader xml( &file );
// Start parsing.
enum ParsingState
{
PARSING_STARTS ,
IS_AT_ROOT_LEVEL ,
IS_READING_DISPLAY_OPTIONS ,
IS_READING_TOOL_OPTIONS ,
IS_READING_DATA_STATE ,
};
ParsingState currentState = PARSING_STARTS;
QString source;
bool mustReadNext = true;
while( !xml.atEnd() )
{
if( mustReadNext && xml.readNext() != QXmlStreamReader::StartElement )
continue;
mustReadNext = true;
QXmlStreamAttributes attr = xml.attributes();
switch( currentState )
{
case PARSING_STARTS:
{
if( xml.name() != "PROJECTOPTIONS" )
return false;
currentState = IS_AT_ROOT_LEVEL;
break;
}
case IS_AT_ROOT_LEVEL:
{
if( xml.name() == "DISPLAYOPTIONS" )
{
if( attr.hasAttribute("Source") )
{
source = attr.value("Source").toString();
currentState = IS_READING_DISPLAY_OPTIONS;
break;
}
}
else if( xml.name() == "TOOLOPTIONS" )
{
if( attr.hasAttribute("Name") )
{
source = attr.value("Name").toString();
currentState = IS_READING_TOOL_OPTIONS;
break;
}
}
else if( xml.name() == "DATASTATE" )
{
currentState = IS_READING_DATA_STATE;
break;
}
return false;
}
case IS_READING_DISPLAY_OPTIONS:
{
if( xml.name() != "PARAM" )
{
mustReadNext = false;
currentState = IS_AT_ROOT_LEVEL;
break;
}
else if( !attr.hasAttribute("Id") || !attr.hasAttribute("Value") )
return false;
QString id = attr.value("Id").toString();
QString value = attr.value("Value").toString();
GenericUIData *d = project->GetByFilename( source );
if( d )
{
if( !d->GetDisplayOptions() )
m_DisplayableFactoryByTypes[ d->GetTypeString() ]->allocateDisplayOptions( d );
d->GetDisplayOptions()->Get( id )->SetValueString( value );
}
break;
}
case IS_READING_TOOL_OPTIONS:
{
if( xml.name() != "PARAM" )
{
mustReadNext = false;
currentState = IS_AT_ROOT_LEVEL;
break;
}
else if( !attr.hasAttribute("Id") || !attr.hasAttribute("Value") )
return false;
QString id = attr.value("Id").toString();
QString value = attr.value("Value").toString();
auto tool = ui->toolSelector->getToolByName( source );
if( tool )
tool->param->Get( id )->SetValueString( value );
break;
}
case IS_READING_DATA_STATE:
{
if( xml.name() == "DISPLAYED" )
{
if( !attr.hasAttribute("Source") )
return false;
//GenericUIData *d = project->GetByFilename( attr.value("Source").toString() );
//if( d )
// m_CurrentViewer->addDisplayable( d );
}
else if( xml.name() == "SELECTED" )
{
if( !attr.hasAttribute("Source") )
return false;
//ui->tableCurrentProjContent->setItemSelected( )
}
else
{
mustReadNext = false;
currentState = IS_AT_ROOT_LEVEL;
}
break;
}
}
}
return !xml.hasError();
}
void UIMainWindow::saveCurrentProject()
{
UIProject *project = getCurrentProject();
......@@ -1772,7 +1930,10 @@ bool UIMainWindow::loadProject( const QString& filename )
ui->comboProject->addItem( p->Name(), QVariant::fromValue<void*>(pHndl) );
ui->comboProject->setCurrentIndex( ui->comboProject->count()-1 );
updateTypeFilters();
if( QFile( p->GetSaveDir()+".project.opt" ).exists() )
loadProjectOptions( p->GetSaveDir()+".project.opt", p );
updateTypeFilters();
updateCurrentProjectContent();
updateRecentListEntry( filename );
......
......@@ -64,6 +64,7 @@ class GUIMAIN_API UIMainWindow : public QMainWindow
QList<QPluginLoader*> m_pluginLoaders;
QList<DisplayableFactoryInterface*> m_DisplayablePlugins;
QMap<QString,DisplayableFactoryInterface*> m_DisplayableFactoryByTypes;
QList<ImportHandle> m_ImportPlugins;
QMap<QString,ImportHandle> m_ImportSortedByExtensions;
......@@ -138,6 +139,7 @@ private:
bool loadUISettings();
bool saveProjectOptions( const QString &filePath, UIProject *project );
bool loadProjectOptions( const QString &filePath, UIProject *project );
void updateRecentListEntry( const QString& path );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment