@@ -40,7 +40,6 @@ SOFTWARE.*/
4040#include < FEBioLink/FEBioClass.h>
4141
4242#define MANUAL_PATH " https://febiosoftware.github.io/febio-feature-manual/features/"
43- #define UNSELECTED_HELP " unselected_help"
4443
4544class Ui ::CHelpDialog
4645{
@@ -74,7 +73,7 @@ class Ui::CHelpDialog
7473};
7574
7675
77- CHelpDialog::CHelpDialog (QWidget* parent) : QDialog(parent), ui(new Ui::CHelpDialog), m_url(UNSELECTED_HELP)
76+ CHelpDialog::CHelpDialog (QWidget* parent) : QDialog(parent), ui(new Ui::CHelpDialog)
7877{
7978 ui->setupUi (this );
8079
@@ -83,17 +82,22 @@ CHelpDialog::CHelpDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CHelpDia
8382
8483CHelpDialog::~CHelpDialog () { delete ui; }
8584
85+ void ShowHelp (const QString& url)
86+ {
87+ QDesktopServices::openUrl (QUrl (QString (MANUAL_PATH) + url));
88+ }
89+
8690void CHelpDialog::on_help_clicked ()
8791{
8892 UpdateHelpURL ();
8993
90- if (m_url == UNSELECTED_HELP )
94+ if (m_url. isEmpty () )
9195 {
9296 QMessageBox::information (this , " Help" , " Please select an item before clicking Help." );
9397 }
9498 else
9599 {
96- QDesktopServices::openUrl ( QUrl ( QString (MANUAL_PATH) + m_url) );
100+ ShowHelp ( m_url);
97101 }
98102}
99103
@@ -102,19 +106,23 @@ void CHelpDialog::SetLeftSideLayout(QLayout* layout)
102106 ui->helpLayout ->insertLayout (0 , layout);
103107}
104108
105- void CHelpDialog::SetURL (int classID)
109+ QString ClassIDToURL (int classID)
106110{
107- if (classID == -1 )
108- {
109- m_url = UNSELECTED_HELP;
110- return ;
111- }
111+ QString url;
112+ if (classID != -1 )
113+ {
114+ FEBio::FEBioClassInfo classInfo = FEBio::GetClassInfo (classID);
112115
113- FEBio::FEBioClassInfo classInfo = FEBio::GetClassInfo (classID);
116+ QString superClass = classInfo.superClassName ;
117+ superClass.remove (0 , 2 ).remove (" _ID" );
114118
115- QString superClass = classInfo.superClassName ;
116- superClass.remove (0 ,2 ).remove (" _ID" );
119+ QString tmp = QString (classInfo.szmod ) + " _" + superClass + " _" + QString (classInfo.sztype );
120+ url = tmp.replace (" " , " _" ).toLower ();
121+ }
122+ return url;
123+ }
117124
118- QString url = QString (classInfo.szmod ) + " _" + superClass + " _" + QString (classInfo.sztype );
119- m_url = url.replace (" " , " _" ).toLower ();
120- }
125+ void CHelpDialog::SetURL (const QString& url)
126+ {
127+ m_url = url;
128+ }
0 commit comments