23 #if defined (HAVE_CONFIG_H) 31 #include <QApplication> 36 #include <QHelpContentWidget> 37 #include <QHelpIndexWidget> 38 #include <QHelpSearchEngine> 39 #include <QHelpSearchQueryWidget> 40 #include <QHelpSearchResultWidget> 43 #include <QMessageBox> 46 #include <QToolButton> 47 #include <QVBoxLayout> 60 QString collection = getenv (
"OCTAVE_QTHELP_COLLECTION");
61 if (collection.isEmpty ())
64 +
"octave_interpreter.qhc");
70 QString tmpdir = QDir::tempPath();
79 tr (
"Could not copy help collection to temporary\n" 80 "file. Search capabilities may be affected.\n" 89 tr (
"Could not setup the data required for the\n" 90 "documentation viewer. Only help texts in\n" 91 "the Console Widget will be available."));
101 connect (
m_doc_browser, SIGNAL (cursorPositionChanged (
void)),
105 QLabel *find_label =
new QLabel (tr (
"Find:"), find_footer);
112 forward_button->setText (tr (
"Search forward"));
113 forward_button->setToolTip (tr (
"Search forward"));
115 connect (forward_button, SIGNAL (pressed (
void)),
118 backward_button->setText (tr (
"Search backward"));
119 backward_button->setToolTip (tr (
"Search backward"));
121 connect (backward_button, SIGNAL (pressed (
void)),
123 QHBoxLayout *h_box_find_footer =
new QHBoxLayout (find_footer);
124 h_box_find_footer->addWidget (find_label);
126 h_box_find_footer->addWidget (forward_button);
127 h_box_find_footer->addWidget (backward_button);
128 h_box_find_footer->setMargin (2);
129 find_footer->setLayout (h_box_find_footer);
131 QVBoxLayout *v_box_browser_find =
new QVBoxLayout (browser_find);
133 v_box_browser_find->addWidget (find_footer);
134 browser_find->setLayout (v_box_browser_find);
136 QShortcut *show_shortcut =
new QShortcut (QKeySequence (QKeySequence::Find),
p);
137 show_shortcut->setContext (Qt::WidgetWithChildrenShortcut);
138 connect (show_shortcut, SIGNAL (activated (
void)),
140 connect (show_shortcut, SIGNAL (activated (
void)),
142 connect (show_shortcut, SIGNAL (activated (
void)),
144 QShortcut *hide_shortcut =
new QShortcut (Qt::Key_Escape,
p);
145 hide_shortcut->setContext (Qt::WidgetWithChildrenShortcut);
146 connect (hide_shortcut, SIGNAL (activated (
void)),
148 connect (hide_shortcut, SIGNAL (activated (
void)),
150 QShortcut *findnext_shortcut =
new QShortcut (QKeySequence (QKeySequence::FindNext),
p);
151 findnext_shortcut->setContext (Qt::WidgetWithChildrenShortcut);
152 connect (findnext_shortcut, SIGNAL (activated (
void)),
154 QShortcut *findprev_shortcut =
new QShortcut (QKeySequence (QKeySequence::FindPrevious),
p);
155 findprev_shortcut->setContext (Qt::WidgetWithChildrenShortcut);
156 connect (findprev_shortcut, SIGNAL (activated (
void)),
158 find_footer->hide ();
163 navi->setTabsClosable (
false);
164 navi->setMovable (
true);
167 QHelpContentWidget *content =
m_help_engine->contentWidget ();
168 navi->addTab (content, tr (
"Contents"));
171 SIGNAL (linkActivated (
const QUrl&)),
178 m_filter->setToolTip (tr (
"Enter text to search the indices"));
180 m_filter->setInsertPolicy (QComboBox::NoInsert);
184 QComboBox::AdjustToMinimumContentsLengthWithIcon);
185 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
187 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
188 QLabel *filter_label =
new QLabel (tr (
"Search"));
191 QHBoxLayout *h_box_index =
new QHBoxLayout (filter_all);
192 h_box_index->addWidget (filter_label);
194 h_box_index->setMargin (2);
195 filter_all->setLayout (h_box_index);
198 QVBoxLayout *v_box_index =
new QVBoxLayout (index_all);
199 v_box_index->addWidget (filter_all);
200 v_box_index->addWidget (index);
201 index_all->setLayout (v_box_index);
203 navi->addTab (index_all, tr (
"Index"));
206 SIGNAL (linkActivated (
const QUrl&,
const QString&)),
210 connect (
m_filter, SIGNAL (editTextChanged (
const QString&)),
213 connect (
m_filter->lineEdit (), SIGNAL (editingFinished (
void)),
217 QHelpSearchEngine *search_engine =
m_help_engine->searchEngine ();
218 QHelpSearchQueryWidget *
search = search_engine->queryWidget ();
219 QHelpSearchResultWidget *
result = search_engine->resultWidget ();
221 QVBoxLayout *v_box_search =
new QVBoxLayout (search_all);
222 v_box_search->addWidget (
search);
223 v_box_search->addWidget (
result);
224 search_all->setLayout (v_box_search);
225 navi->addTab (search_all, tr (
"Search"));
230 connect (search_engine, SIGNAL (searchingStarted (
void)),
232 connect (search_engine, SIGNAL (searchingFinished (
int)),
235 connect (search_engine->resultWidget (),
236 SIGNAL (requestShowLink (
const QUrl&)),
238 SLOT(handle_index_clicked (
const QUrl&)));
241 insertWidget (0, navi);
242 insertWidget (1, browser_find);
243 setStretchFactor (1, 1);
247 "qthelp://org.octave.interpreter-1.0/doc/octave.html/index.html"));
259 QFileInfo finfo (
file);
260 QString bname = finfo.fileName ();
261 QDir dir = finfo.absoluteDir ();
262 dir.setFilter (QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden);
263 QStringList namefilter;
264 namefilter.append (
"*" + bname +
"*");
265 foreach (QFileInfo
fi, dir.entryInfoList (namefilter))
267 std::string file_name =
fi.absoluteFilePath ().toStdString ();
277 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT) 279 =
m_help_engine->searchEngine ()->queryWidget ()->searchInput ();
290 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
295 qApp->restoreOverrideCursor();
312 if (found_links.count() > 0)
323 if (expression.contains (QLatin1Char(
'*')))
324 wildcard = expression;
326 m_help_engine->indexWidget ()->filterIndices(expression, wildcard);
392 bool do_setup =
true;
393 if (
m_help_engine->registeredDocumentations ().contains (ns))
406 tr (
"Unable to register help file %1.").
449 if (
url.scheme () ==
"qthelp")
452 return QTextBrowser::loadResource(
type,
url);
QHelpEngine * m_help_engine
QHelpEngine * m_help_engine
std::string oct_doc_dir(void)
For example cd octave end example noindent changes the current working directory to file
void filter_update_history(void)
void find_forward_from_anchor(const QString &text)
void handle_index_clicked(const QUrl &url, const QString &keyword=QString())
std::string tempnam(const std::string &dir, const std::string &pfx)
int m_search_anchor_position
QString fromStdString(const std::string &s)
void notice_settings(const QSettings *settings)
void registerDoc(const QString &name)
std::string dir_sep_str(void)
int recursive_rmdir(const std::string &name)
void filter_update(const QString &expression)
~documentation_browser(void)
void unregisterDoc(const QString &name)
virtual QVariant loadResource(int type, const QUrl &url)
void record_anchor_position(void)
void pasteClipboard(void)
void handle_cursor_position_change(void)
void load_ref(const QString &name)
void notice_settings(const QSettings *settings)
static std::list< std::string > search(const std::string &path, const std::string &original_name, bool all)
documentation_browser * m_doc_browser
With real return the complex result
void warning(const char *fmt,...)
documentation(QWidget *parent=nullptr)
static QIcon icon(const QString &icon_name, bool fallback=true)
documentation_browser(QHelpEngine *help_engine, QWidget *parent=nullptr)
QLineEdit * m_find_line_edit
void global_search_started(void)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
void global_search_finished(int hits)