Commit 8db9a8fe authored by Jan Möbius's avatar Jan Möbius
Browse files

Search for all Help files in the helpdir (no collection required anymore), indentations

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9305 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3ee679f3
...@@ -55,184 +55,192 @@ ...@@ -55,184 +55,192 @@
#include <iostream> #include <iostream>
#include <QTextStream> #include <QTextStream>
#include <QDir>
HelpWidget::HelpWidget(QWidget* parent, const QString& _homeSite) HelpWidget::HelpWidget(QWidget* parent, const QString& _homeSite)
: QMainWindow(parent), : QMainWindow(parent),
searchWidget_(0), searchWidget_(0),
tabWidget_(0), tabWidget_(0),
textWindow_(0), textWindow_(0),
helpEngine_(0), helpEngine_(0),
searchEngine_(0) { searchEngine_(0) {
setupUi(this); setupUi(this);
homeSite_ = _homeSite; homeSite_ = _homeSite;
QString filename = QString(OpenFlipper::Options::helpDirStr()); QString filename = QString( OpenFlipper::Options::configDirStr() );
filename += OpenFlipper::Options::dirSeparator(); filename += OpenFlipper::Options::dirSeparator();
filename += "Help.qhc"; filename += "Help.qhc";
QDir helpDir = QDir(OpenFlipper::Options::helpDirStr());
QStringList helpFiles = helpDir.entryList(QStringList("*.qch"),QDir::Files);
QString iconPath = QString(OpenFlipper::Options::iconDirStr()); QString iconPath = QString(OpenFlipper::Options::iconDirStr());
#ifdef WIN32 #ifdef WIN32
iconPath += "\\"; iconPath += "\\";
#else #else
iconPath += "/"; iconPath += "/";
#endif #endif
// Set Buttons // Set Buttons
backButton_->setIcon(QIcon(iconPath+"arrow-left.png")); backButton_->setIcon(QIcon(iconPath+"arrow-left.png"));
forwardButton_->setIcon(QIcon(iconPath+"arrow-right.png")); forwardButton_->setIcon(QIcon(iconPath+"arrow-right.png"));
homeButton_->setIcon(QIcon(iconPath+"go-home.png")); homeButton_->setIcon(QIcon(iconPath+"go-home.png"));
searchButton_->setIcon(QIcon(iconPath+"edit-find.png")); searchButton_->setIcon(QIcon(iconPath+"edit-find.png"));
tabWidget_ = new QTabWidget(this); tabWidget_ = new QTabWidget(this);
helpEngine_ = new QHelpEngine(filename, this); helpEngine_ = new QHelpEngine(filename, this);
helpEngine_->setupData();
for ( int i = 0 ; i < helpFiles.size() ; ++i )
if ( !helpEngine_->registerDocumentation( helpDir.path()+ QDir::separator() + helpFiles[i]) )
std::cerr << helpEngine_->error().toStdString() << std::endl;
helpEngine_->setupData(); searchEngine_ = new QHelpSearchEngine(helpEngine_, this);
searchEngine_ = new QHelpSearchEngine(helpEngine_, this); textWindow_ = new HelpBrowser(helpEngine_, this);
textWindow_ = new HelpBrowser(helpEngine_, this); homeIndex_ = tabWidget_->addTab(textWindow_, tr("Home"));
homeIndex_ = tabWidget_->addTab(textWindow_, tr("Home")); gridLayout_->addWidget(helpEngine_->contentWidget(), 1, 0);
gridLayout_->addWidget(tabWidget_, 1, 1);
gridLayout_->addWidget(helpEngine_->contentWidget(), 1, 0); gridLayout_->setColumnStretch(0, 1);
gridLayout_->addWidget(tabWidget_, 1, 1); gridLayout_->setColumnStretch(1, 3);
gridLayout_->setColumnStretch(0, 1); // Search popup at bottom of window
gridLayout_->setColumnStretch(1, 3); searchWidget_ = new QDockWidget(tr("Search results"), this);
searchWidget_->setFeatures( QDockWidget::DockWidgetClosable );
// Search popup at bottom of window searchWidget_->resize(this->size().width(), floor( double(this->size().height() / 3)) );
searchWidget_ = new QDockWidget(tr("Search results"), this);
searchWidget_->setFeatures( QDockWidget::DockWidgetClosable );
searchWidget_->resize(this->size().width(), floor( double(this->size().height() / 3)) ); searchWidget_->setWidget(searchEngine_->queryWidget());
//searchWidget_->setWidget(results_);
searchWidget_->setWidget(searchEngine_->queryWidget()); searchWidget_->hide();
//searchWidget_->setWidget(results_); addDockWidget(Qt::BottomDockWidgetArea, searchWidget_);
searchWidget_->hide();
addDockWidget(Qt::BottomDockWidgetArea, searchWidget_);
// Entry in tree view has been clicked
connect(helpEngine_->contentWidget(), SIGNAL(linkActivated(const QUrl&)),
this, SLOT(linkActivated(const QUrl&)));
// Entry in tree view has been clicked
connect(helpEngine_->contentWidget(), SIGNAL(linkActivated(const QUrl&)),
this, SLOT(linkActivated(const QUrl&)));
// Search button
connect(searchButton_, SIGNAL(clicked()), this, SLOT(showSearchWidget()));
// Search button // Search button
connect(searchButton_, SIGNAL(clicked()), this, SLOT(showSearchWidget())); connect(searchEngine_->queryWidget(), SIGNAL(search()), this, SLOT(startSearch()));
// Search button // Show results if search is finished
connect(searchEngine_->queryWidget(), SIGNAL(search()), this, SLOT(startSearch())); connect(searchEngine_, SIGNAL(searchingFinished(int)), this, SLOT(showResults(int)));
// Show results if search is finished // Show results if search is finished
connect(searchEngine_, SIGNAL(searchingFinished(int)), this, SLOT(showResults(int))); connect(searchEngine_->resultWidget(), SIGNAL(requestShowLink(const QUrl&)),
this, SLOT(showFoundSite(const QUrl&)));
// Show results if search is finished // Back button
connect(searchEngine_->resultWidget(), SIGNAL(requestShowLink(const QUrl&)), connect(backButton_, SIGNAL(clicked()), this, SLOT(goBack()));
this, SLOT(showFoundSite(const QUrl&)));
// Back button // Forward button
connect(backButton_, SIGNAL(clicked()), this, SLOT(goBack())); connect(forwardButton_, SIGNAL(clicked()), this, SLOT(goForward()));
// Forward button // Forward button
connect(forwardButton_, SIGNAL(clicked()), this, SLOT(goForward())); connect(homeButton_, SIGNAL(clicked()), this, SLOT(goHome()));
// Forward button // Source has been reloaded
connect(homeButton_, SIGNAL(clicked()), this, SLOT(goHome())); connect(textWindow_, SIGNAL(urlChanged(const QUrl&)), this, SLOT(update(const QUrl&)));
// Source has been reloaded // Register documentation
connect(textWindow_, SIGNAL(urlChanged(const QUrl&)), this, SLOT(update(const QUrl&))); helpEngine_->registerDocumentation(filename);
// Register documentation // Load main page
helpEngine_->registerDocumentation(filename); textWindow_->open(QUrl(homeSite_));
// Load main page
textWindow_->open(QUrl(homeSite_));
} }
void HelpWidget::linkActivated(const QUrl& _url) { void HelpWidget::linkActivated(const QUrl& _url) {
textWindow_->open(_url); textWindow_->open(_url);
tabWidget_->setCurrentIndex(homeIndex_); tabWidget_->setCurrentIndex(homeIndex_);
} }
void HelpWidget::startSearch() { void HelpWidget::startSearch() {
searchEngine_->search(searchEngine_->queryWidget()->query()); searchEngine_->search(searchEngine_->queryWidget()->query());
} }
void HelpWidget::setHomeSite(const QString& _homeSite) { void HelpWidget::setHomeSite(const QString& _homeSite) {
homeSite_ = _homeSite; homeSite_ = _homeSite;
} }
void HelpWidget::showFoundSite(const QUrl& _url) { void HelpWidget::showFoundSite(const QUrl& _url) {
textWindow_->open(_url); textWindow_->open(_url);
tabWidget_->setCurrentIndex(homeIndex_); tabWidget_->setCurrentIndex(homeIndex_);
} }
void HelpWidget::update(const QUrl& /* url */) { void HelpWidget::update(const QUrl& /* url */) {
updateButtons(); updateButtons();
} }
void HelpWidget::goForward() { void HelpWidget::goForward() {
textWindow_->forward(); textWindow_->forward();
tabWidget_->setCurrentIndex(homeIndex_); tabWidget_->setCurrentIndex(homeIndex_);
updateButtons(); updateButtons();
} }
void HelpWidget::goBack() { void HelpWidget::goBack() {
textWindow_->backward(); textWindow_->backward();
tabWidget_->setCurrentIndex(homeIndex_); tabWidget_->setCurrentIndex(homeIndex_);
updateButtons(); updateButtons();
} }
void HelpWidget::goHome() { void HelpWidget::goHome() {
textWindow_->open(homeSite_); textWindow_->open(homeSite_);
tabWidget_->setCurrentIndex(homeIndex_); tabWidget_->setCurrentIndex(homeIndex_);
updateButtons(); updateButtons();
} }
void HelpWidget::updateButtons() { void HelpWidget::updateButtons() {
if(!textWindow_->isBackwardAvailable()) { if(!textWindow_->isBackwardAvailable()) {
backButton_->setEnabled(false); backButton_->setEnabled(false);
} else { } else {
backButton_->setEnabled(true); backButton_->setEnabled(true);
} }
if(!textWindow_->isForwardAvailable()) { if(!textWindow_->isForwardAvailable()) {
forwardButton_->setEnabled(false); forwardButton_->setEnabled(false);
} else { } else {
forwardButton_->setEnabled(true); forwardButton_->setEnabled(true);
} }
} }
void HelpWidget::showSearchWidget() { void HelpWidget::showSearchWidget() {
searchWidget_->show(); searchWidget_->show();
} }
void HelpWidget::showResults(int /*_hits*/) { void HelpWidget::showResults(int /*_hits*/) {
searchWidget_->hide(); searchWidget_->hide();
int resultsTabIndex_ = tabWidget_->addTab(searchEngine_->resultWidget(), tr("Results") ); int resultsTabIndex_ = tabWidget_->addTab(searchEngine_->resultWidget(), tr("Results") );
tabWidget_->setCurrentIndex(resultsTabIndex_); tabWidget_->setCurrentIndex(resultsTabIndex_);
} }
void HelpWidget::openFoundSite(QListWidgetItem* /*_item*/) { void HelpWidget::openFoundSite(QListWidgetItem* /*_item*/) {
...@@ -241,6 +249,6 @@ void HelpWidget::openFoundSite(QListWidgetItem* /*_item*/) { ...@@ -241,6 +249,6 @@ void HelpWidget::openFoundSite(QListWidgetItem* /*_item*/) {
HelpWidget::~HelpWidget() { HelpWidget::~HelpWidget() {
delete searchWidget_; delete searchWidget_;
delete textWindow_; delete textWindow_;
} }
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