void HelpBrowser::jumpToHelpSection(const QString& jumpToSection, const QString& jumpToFile, bool dontChangeIfAlreadyLoaded) { QString toLoad; bool noDocs=false; if (jumpToFile.isEmpty()) { toLoad = finalBaseDir + "/"; //clean this later to handle 5 char locales if (jumpToSection.isEmpty()) { QModelIndex index=menuModel->index(0,1); if (index.isValid()) { helpNav->listView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); toLoad += menuModel->data(index, Qt::DisplayRole).toString(); } else noDocs=true; } else if (jumpToSection=="scripter") { toLoad+="scripter1.html"; } } else { toLoad=finalBaseDir + "/" + jumpToFile; } if (!noDocs) loadHelp(toLoad); else if (!dontChangeIfAlreadyLoaded) displayNoHelp(); }
HelpBrowser::HelpBrowser( QWidget* parent, const QString& /*caption*/, const QString& guiLanguage, const QString& jumpToSection, const QString& jumpToFile) : QMainWindow( parent ) { firstRun=true; setupUi(this); helpNav = new HelpNavigation(this); #if defined(Q_OS_MAC) && defined(HELP_NAV_AS_DRAWER) // TODO #else QDockWidget * dckw = new QDockWidget(tr("Navigation"),this); dckw->setWidget(helpNav); addDockWidget(Qt::LeftDockWidgetArea, dckw); #endif progressBar = new QProgressBar(this); progressBar->setRange(0,100); statusBar()->addPermanentWidget(progressBar); setupLocalUI(); language = guiLanguage.isEmpty() ? QString("en") : guiLanguage.left(2); finalBaseDir = ScPaths::instance().docDir() + "en/"; //Sane default for help location textBrowser->setSearchPaths(QStringList(finalBaseDir)); menuModel=NULL; loadMenu(); if (menuModel!=NULL) { readBookmarks(); readHistory(); jumpToHelpSection(jumpToSection, jumpToFile ); languageChange(); } else { displayNoHelp(); } }
void HelpBrowser::loadHelp(const QString& filename) { struct histd2 his; bool Avail = true; QString toLoad; QFileInfo fi; fi = QFileInfo(filename); if (fi.fileName().length()>0) { if (fi.exists()) toLoad=filename; else { toLoad = QDir::toNativeSeparators(ScPaths::instance().docDir() + "en/index.html"); // language="en"; fi = QFileInfo(toLoad); if (!fi.exists()) { displayNoHelp(); Avail = false; } } } else Avail=false; if (Avail) { textBrowser->setSource( QUrl::fromLocalFile(toLoad) ); his.title = textBrowser->documentTitle(); if (his.title.isEmpty()) his.title = toLoad; his.url = toLoad; mHistory[histMenu->addAction(his.title)] = his; } if (mHistory.count() > 15) { QAction* first=histMenu->actions().first(); mHistory.remove(first); histMenu->removeAction(first); } }
void HelpBrowser::loadHelp(const QString& filename) { struct histd2 his; bool Avail = false; QString toLoad; QFileInfo fi; fi = QFileInfo(filename); if (fi.fileName().length()>0) { if (fi.exists()) toLoad = filename; else { toLoad = finalBaseDir + "/index.html"; fi = QFileInfo(toLoad); } Avail = fi.exists(); } if (Avail) { textBrowser->setSource(QUrl::fromLocalFile(toLoad)); // his.title = textBrowser->title(); if (his.title.isEmpty()) his.title = toLoad; his.url = toLoad; mHistory[histMenu->addAction(his.title)] = his; } else { displayNoHelp(); } if (mHistory.count() > 15) { QAction* first=histMenu->actions().first(); mHistory.remove(first); histMenu->removeAction(first); } }
HelpBrowser::HelpBrowser( QWidget* parent, const QString& /*caption*/, const QString& guiLanguage, const QString& jumpToSection, const QString& jumpToFile) : QMainWindow( parent ) { firstRun=true; setupUi(this); setupLocalUI(); language = guiLanguage.isEmpty() ? QString("en") : guiLanguage.left(2); finalBaseDir = ScPaths::instance().docDir() + "en/"; //Sane default for help location menuModel=NULL; loadMenu(); if (menuModel!=NULL) { readBookmarks(); readHistory(); jumpToHelpSection(jumpToSection, jumpToFile ); languageChange(); } else { displayNoHelp(); } }