Commit 86f7c1ac authored by Shubham  .'s avatar Shubham .
Browse files

Implement context sensitive search

parent c056b452
......@@ -32,7 +32,6 @@
#include <QHelpIndexWidget>
#include <QIcon>
#include <QLineEdit>
#include <QListWidget>
#include <QPointer>
#include <QPushButton>
#include <QSplitter>
......@@ -59,10 +58,6 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(par
loadDocumentation();
m_tabWidget = new QTabWidget(this);
m_tabWidget->setMovable(true);
m_tabWidget->setElideMode(Qt::ElideRight);
// create a container for Search tab
QWidget* container = new QWidget(this);
QHBoxLayout* clayout = new QHBoxLayout(this);
......@@ -73,6 +68,10 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(par
clayout->addWidget(input);
clayout->addWidget(search);
m_tabWidget = new QTabWidget(this);
m_tabWidget->setMovable(true);
m_tabWidget->setElideMode(Qt::ElideRight);
// Add different tabs to the widget
m_tabWidget->addTab(m_engine->contentWidget(), i18n("Contents"));
m_tabWidget->addTab(m_engine->indexWidget(), i18n("Index"));
......@@ -106,11 +105,19 @@ void DocumentationPanelWidget::displayHelp(const QUrl& url)
void DocumentationPanelWidget::doSearch(const QString& str)
{
// perform searching of the string passed
Q_UNUSED(str)
}
void DocumentationPanelWidget::contextSensitiveHelp(const QString& keyword)
{
qDebug() << "INSIDE DOCUMENTATION PANEL WIDGET" << keyword;
qDebug() << "Context sensitive help for " << keyword;
// get the index widget
QHelpIndexWidget* const index = m_engine->indexWidget();
index->filterIndices(keyword); // filter exactly, no wildcards
index->activateCurrentItem(); // this internally emitts the QHelpContentWidget::linkActivated signal
loadDocumentation();
}
void DocumentationPanelWidget::loadDocumentation()
......
......@@ -47,12 +47,10 @@ class DocumentationPanelWidget : public QWidget
void loadDocumentation();
void unloadDocumentation();
public Q_SLOTS:
void contextSensitiveHelp(const QString&);
private Q_SLOTS:
void displayHelp(const QUrl&);
void doSearch(const QString&);
void contextSensitiveHelp(const QString&);
private:
QPointer<QHelpEngine> m_engine;
......
......@@ -471,7 +471,7 @@ void WorksheetTextItem::keyPressEvent(QKeyEvent *event)
case Qt::Key_Tab:
qDebug() << "Tab";
break;
case Qt::Key_H:
case Qt::Key_F2:
// logic to display help for keyword under selection
if(textCursor().hasSelection()) {
QString keyword = textCursor().selectedText();
......@@ -479,7 +479,6 @@ void WorksheetTextItem::keyPressEvent(QKeyEvent *event)
keyword = keyword.simplified();
keyword.replace(QStringLiteral(" "), QStringLiteral(""));
emit worksheet()->requestDocumentation(keyword);
qDebug()<<"Searching help for "<<keyword;
return;
} else { // when the keyword is not under selection and the user presses key
QTextCursor cursor;
......@@ -487,7 +486,6 @@ void WorksheetTextItem::keyPressEvent(QKeyEvent *event)
setTextCursor(cursor);
const QString keyword = textCursor().selectedText();
emit worksheet()->requestDocumentation(keyword);
qDebug()<<"Searching help for "<<keyword;
return;
}
break;
......
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