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

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 @@
#include <iostream>
#include <QTextStream>
#include <QDir>
HelpWidget::HelpWidget(QWidget* parent, const QString& _homeSite)
: QMainWindow(parent),
searchWidget_(0),
tabWidget_(0),
textWindow_(0),
helpEngine_(0),
searchEngine_(0) {
: QMainWindow(parent),
searchWidget_(0),
tabWidget_(0),
textWindow_(0),
helpEngine_(0),
searchEngine_(0) {
setupUi(this);
setupUi(this);
homeSite_ = _homeSite;
homeSite_ = _homeSite;
QString filename = QString(OpenFlipper::Options::helpDirStr());
filename += OpenFlipper::Options::dirSeparator();
filename += "Help.qhc";
QString filename = QString( OpenFlipper::Options::configDirStr() );
filename += OpenFlipper::Options::dirSeparator();
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
iconPath += "\\";
iconPath += "\\";
#else
iconPath += "/";
iconPath += "/";
#endif
// Set Buttons
backButton_->setIcon(QIcon(iconPath+"arrow-left.png"));
forwardButton_->setIcon(QIcon(iconPath+"arrow-right.png"));
homeButton_->setIcon(QIcon(iconPath+"go-home.png"));
searchButton_->setIcon(QIcon(iconPath+"edit-find.png"));
// Set Buttons
backButton_->setIcon(QIcon(iconPath+"arrow-left.png"));
forwardButton_->setIcon(QIcon(iconPath+"arrow-right.png"));
homeButton_->setIcon(QIcon(iconPath+"go-home.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_->addWidget(tabWidget_, 1, 1);
gridLayout_->setColumnStretch(0, 1);
gridLayout_->setColumnStretch(1, 3);
gridLayout_->setColumnStretch(0, 1);
gridLayout_->setColumnStretch(1, 3);
// Search popup at bottom of window
searchWidget_ = new QDockWidget(tr("Search results"), this);
searchWidget_->setFeatures( QDockWidget::DockWidgetClosable );
// Search popup at bottom of window
searchWidget_ = new QDockWidget(tr("Search results"), this);
searchWidget_->setFeatures( QDockWidget::DockWidgetClosable );
searchWidget_->resize(this->size().width(), floor( double(this->size().height() / 3)) );
searchWidget_->resize(this->size().width(), floor( double(this->size().height() / 3)) );
searchWidget_->setWidget(searchEngine_->queryWidget());
//searchWidget_->setWidget(results_);
searchWidget_->setWidget(searchEngine_->queryWidget());
//searchWidget_->setWidget(results_);
searchWidget_->hide();
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
connect(searchButton_, SIGNAL(clicked()), this, SLOT(showSearchWidget()));
// Search button
connect(searchEngine_->queryWidget(), SIGNAL(search()), this, SLOT(startSearch()));
// Search button
connect(searchEngine_->queryWidget(), SIGNAL(search()), this, SLOT(startSearch()));
// Show results if search is finished
connect(searchEngine_, SIGNAL(searchingFinished(int)), this, SLOT(showResults(int)));
// Show results if search is finished
connect(searchEngine_, SIGNAL(searchingFinished(int)), this, SLOT(showResults(int)));
// Show results if search is finished
connect(searchEngine_->resultWidget(), SIGNAL(requestShowLink(const QUrl&)),
this, SLOT(showFoundSite(const QUrl&)));
// Show results if search is finished
connect(searchEngine_->resultWidget(), SIGNAL(requestShowLink(const QUrl&)),
this, SLOT(showFoundSite(const QUrl&)));
// Back button
connect(backButton_, SIGNAL(clicked()), this, SLOT(goBack()));
// Back button
connect(backButton_, SIGNAL(clicked()), this, SLOT(goBack()));
// Forward button
connect(forwardButton_, SIGNAL(clicked()), this, SLOT(goForward()));
// Forward button
connect(forwardButton_, SIGNAL(clicked()), this, SLOT(goForward()));
// Forward button
connect(homeButton_, SIGNAL(clicked()), this, SLOT(goHome()));
// Forward button
connect(homeButton_, SIGNAL(clicked()), this, SLOT(goHome()));
// Source has been reloaded
connect(textWindow_, SIGNAL(urlChanged(const QUrl&)), this, SLOT(update(const QUrl&)));
// Source has been reloaded
connect(textWindow_, SIGNAL(urlChanged(const QUrl&)), this, SLOT(update(const QUrl&)));
// Register documentation
helpEngine_->registerDocumentation(filename);
// Register documentation
helpEngine_->registerDocumentation(filename);
// Load main page
textWindow_->open(QUrl(homeSite_));
// Load main page
textWindow_->open(QUrl(homeSite_));
}
void HelpWidget::linkActivated(const QUrl& _url) {
textWindow_->open(_url);
tabWidget_->setCurrentIndex(homeIndex_);
textWindow_->open(_url);
tabWidget_->setCurrentIndex(homeIndex_);
}
void HelpWidget::startSearch() {
searchEngine_->search(searchEngine_->queryWidget()->query());
searchEngine_->search(searchEngine_->queryWidget()->query());
}
void HelpWidget::setHomeSite(const QString& _homeSite) {
homeSite_ = _homeSite;
homeSite_ = _homeSite;
}
void HelpWidget::showFoundSite(const QUrl& _url) {
textWindow_->open(_url);
tabWidget_->setCurrentIndex(homeIndex_);
textWindow_->open(_url);
tabWidget_->setCurrentIndex(homeIndex_);
}
void HelpWidget::update(const QUrl& /* url */) {
updateButtons();
updateButtons();
}
void HelpWidget::goForward() {
textWindow_->forward();
textWindow_->forward();
tabWidget_->setCurrentIndex(homeIndex_);
tabWidget_->setCurrentIndex(homeIndex_);
updateButtons();
updateButtons();
}
void HelpWidget::goBack() {
textWindow_->backward();
textWindow_->backward();
tabWidget_->setCurrentIndex(homeIndex_);
tabWidget_->setCurrentIndex(homeIndex_);
updateButtons();
updateButtons();
}
void HelpWidget::goHome() {
textWindow_->open(homeSite_);
textWindow_->open(homeSite_);
tabWidget_->setCurrentIndex(homeIndex_);
tabWidget_->setCurrentIndex(homeIndex_);
updateButtons();
updateButtons();
}
void HelpWidget::updateButtons() {
if(!textWindow_->isBackwardAvailable()) {
backButton_->setEnabled(false);
} else {
backButton_->setEnabled(true);
}
if(!textWindow_->isForwardAvailable()) {
forwardButton_->setEnabled(false);
} else {
forwardButton_->setEnabled(true);
}
if(!textWindow_->isBackwardAvailable()) {
backButton_->setEnabled(false);
} else {
backButton_->setEnabled(true);
}
if(!textWindow_->isForwardAvailable()) {
forwardButton_->setEnabled(false);
} else {
forwardButton_->setEnabled(true);
}
}
void HelpWidget::showSearchWidget() {
searchWidget_->show();
searchWidget_->show();
}
void HelpWidget::showResults(int /*_hits*/) {
searchWidget_->hide();
searchWidget_->hide();
int resultsTabIndex_ = tabWidget_->addTab(searchEngine_->resultWidget(), tr("Results") );
tabWidget_->setCurrentIndex(resultsTabIndex_);
int resultsTabIndex_ = tabWidget_->addTab(searchEngine_->resultWidget(), tr("Results") );
tabWidget_->setCurrentIndex(resultsTabIndex_);
}
void HelpWidget::openFoundSite(QListWidgetItem* /*_item*/) {
......@@ -241,6 +249,6 @@ void HelpWidget::openFoundSite(QListWidgetItem* /*_item*/) {
HelpWidget::~HelpWidget() {
delete searchWidget_;
delete textWindow_;
delete searchWidget_;
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