Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Cantor
Commits
86f7c1ac
Commit
86f7c1ac
authored
Jun 28, 2020
by
Shubham .
Browse files
Implement context sensitive search
parent
c056b452
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
86f7c1ac
...
...
@@ -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
()
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.h
View file @
86f7c1ac
...
...
@@ -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
;
...
...
src/worksheettextitem.cpp
View file @
86f7c1ac
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment