From d81e21dd8c66f89a14087278ae6c3e321a6a8c4e Mon Sep 17 00:00:00 2001 From: adv Date: Mon, 21 Dec 2009 10:52:35 +0000 Subject: [PATCH] Improve HELP system: allow customize help items for modules --- src/LightApp/LightApp_Application.cxx | 49 +++++++++++++++++++++------ 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ca407cac2..46d71f48f 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -82,6 +82,7 @@ #include #include #include +#include #include @@ -480,22 +481,48 @@ void LightApp_Application::createActions() if ( aModule.isEmpty() ) // module title (user name) continue; QString modName = moduleName( aModule ); // module name + IMap paramValue; if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir - if ( !modDir.isEmpty() ) { + + QString docSection; + if (resMgr->hasValue( modName, "documentation" ) ) + docSection = resMgr->stringValue(modName, "documentation"); + else if ( resMgr->hasSection( modName + "_documentation" ) ) + docSection = modName + "_documentation"; + if ( !docSection.isEmpty() ) { + QStringList listOfParam = resMgr->parameters( docSection ); + foreach( QString paramName, listOfParam ){ + QString valueStr = resMgr->stringValue( docSection, paramName ); + if ( !valueStr.isEmpty() ) { + QFileInfo fi( valueStr ); + if ( fi.isRelative() && !modDir.isEmpty() ) + valueStr = Qtx::addSlash( modDir ) + valueStr; + if ( QFile::exists( valueStr ) ) + paramValue.insert( paramName, valueStr ); + } + } + } + + if ( paramValue.isEmpty() && !modDir.isEmpty() ) { QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html"; QString indexFile = idxLst.join( QDir::separator() ); // index file - if ( QFile::exists( indexFile ) ) { - QAction* a = createAction( id, tr( "%1 Help" ).arg( aModule ), - resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ), - tr( "%1 Help" ).arg( aModule ), - tr( "%1 Help" ).arg( aModule ), - 0, desk, false, this, SLOT( onHelpContentsModule() ) ); - a->setData( indexFile ); - createMenu( a, helpModuleMenu, -1 ); - id++; - } + if ( QFile::exists( indexFile ) ) + paramValue.insert( tr( "%1 Help" ).arg( aModule ), indexFile ); + } + + IMapConstIterator fileIt; + for ( fileIt = paramValue.begin(); fileIt != paramValue.end(); fileIt++ ) { + QString helpFileName = fileIt.key(); + QString helpFilePath = fileIt.value(); + QAction* a = createAction( id, helpFileName, + resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ), + helpFileName, helpFileName, + 0, desk, false, this, SLOT( onHelpContentsModule() ) ); + a->setData( helpFilePath ); + createMenu( a, helpModuleMenu, -1 ); + id++; } } -- 2.39.2