diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index cbfdfbb9..460876f2 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -1276,15 +1276,13 @@ QString Daily::getSleepTime(Day * day) QVariant MyTextBrowser::loadResource(int type, const QUrl &url) { - if (type == QTextDocument::ImageResource - && url.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) - { - static QRegularExpression re("^image/[^;]+;base64,.+={0,2}$"); - QRegularExpressionMatch match = re.match(url.path()); - if (match.hasMatch()) - return QVariant(); - } - return QTextBrowser::loadResource(type, url); + if (type == QTextDocument::ImageResource && url.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) { + static QRegularExpression re("^image/[^;]+;base64,.+={0,2}$"); + QRegularExpressionMatch match = re.match(url.path()); + if (match.hasMatch()) + return QVariant(); + } + return QTextBrowser::loadResource(type, url); } diff --git a/sleepyhead/help.cpp b/sleepyhead/help.cpp index 2a9a7844..dfc76eae 100644 --- a/sleepyhead/help.cpp +++ b/sleepyhead/help.cpp @@ -41,7 +41,13 @@ Help::Help(QWidget *parent) : tabWidget->addTab(helpEngine->contentWidget(), tr("Contents")); tabWidget->addTab(helpEngine->indexWidget(), tr("Index")); - tabWidget->addTab(helpEngine->searchEngine()->resultWidget(), tr("Search")); + + resultWidget = new MyTextBrowser(this); + resultWidget->setOpenLinks(false); + tabWidget->addTab(resultWidget, tr("Search")); + resultWidget->setStyleSheet("a:link, a:visited { color: inherit; text-decoration: none; font-weight: normal;}" + "a:hover { background-color: inherit; color: #ff8888; text-decoration:underline; font-weight: normal; }"); + helpBrowser = new HelpBrowser(helpEngine); @@ -60,13 +66,15 @@ Help::Help(QWidget *parent) : QTimer::singleShot(50,this, SLOT(startup())); - connect(helpEngine->contentWidget(), SIGNAL(linkActivated(QUrl)), helpBrowser, SLOT(setSource(QUrl))); - connect(helpEngine->indexWidget(), SIGNAL(linkActivated(QUrl, QString)), helpBrowser, SLOT(setSource(QUrl))); connect(helpBrowser, SIGNAL(forwardAvailable(bool)), this, SLOT(forwardAvailable(bool))); connect(helpBrowser, SIGNAL(backwardAvailable(bool)), this, SLOT(backwardAvailable(bool))); + connect(helpEngine->contentWidget(), SIGNAL(linkActivated(QUrl)), helpBrowser, SLOT(setSource(QUrl))); + connect(helpEngine->indexWidget(), SIGNAL(linkActivated(QUrl, QString)), helpBrowser, SLOT(setSource(QUrl))); + connect(helpEngine->searchEngine(), SIGNAL(searchingFinished(int)), this, SLOT(on_searchComplete(int))); connect(helpEngine->searchEngine(), SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); - connect(helpEngine->searchEngine()->resultWidget(), SIGNAL(requestShowLink(QUrl)), this, SLOT(requestShowLink(QUrl))); + + connect(resultWidget, SIGNAL(anchorClicked(QUrl)), this, SLOT(requestShowLink(QUrl))); ui->forwardButton->setEnabled(false); ui->backButton->setEnabled(false); @@ -80,7 +88,7 @@ Help::Help(QWidget *parent) : Help::~Help() { - disconnect(helpEngine->searchEngine()->resultWidget(), SIGNAL(requestShowLink(QUrl)), this, SLOT(requestShowLink(QUrl))); + disconnect(resultWidget, SIGNAL(anchorClicked(QUrl)), this, SLOT(requestShowLink(QUrl))); disconnect(helpEngine->searchEngine(), SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); disconnect(helpEngine->searchEngine(), SIGNAL(searchingFinished(int)), this, SLOT(on_searchComplete(int))); @@ -111,8 +119,7 @@ QVariant HelpBrowser::loadResource(int type, const QUrl &name) QByteArray bytes = helpEngine->fileData(urlstr); if (bytes.size()>0) return QVariant(bytes); - if (type == QTextDocument::ImageResource - && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) { + if (type == QTextDocument::ImageResource && name.scheme().compare(QLatin1String(""), Qt::CaseInsensitive) == 0) { static QRegularExpression re("^image/[^;]+;base64,.+={0,2}$"); QRegularExpressionMatch match = re.match(name.path()); if (match.hasMatch()) @@ -136,7 +143,7 @@ void Help::on_homeButton_clicked() QByteArray index = helpEngine->fileData(QUrl("qthelp://jedimark.net.sleepyhead.1.1/doc/help_en/index.html")); helpBrowser->setHtml(index); } -void Help::on_searchComplete(int) +void Help::on_searchComplete(int count) { if (!searchReady) { QString html = "

Please wait a bit.. Indexing still in progress

"; @@ -144,23 +151,39 @@ void Help::on_searchComplete(int) return; } - tabWidget->setCurrentWidget(helpEngine->searchEngine()->resultWidget()); - return; - /* QHelpSearchEngine * search = helpEngine->searchEngine(); QVector results = search->searchResults(0, count); - QString html = "

Search results: "; +// ui->searchBar->blockSignals(true); + ui->searchBar->setText(QString()); +// ui->searchBar->blockSignals(false); - if (results.size() == 0) html += "none"; - html+="


"; + QString html = ""; + + QString queryString; +#if QT_VERSION < QT_VERSION_CHECK(5,9,0) + QList results = search->query(); + if (results.size()>0) { + queryString=results[0].wordList.at(0); + } +#else + queryString = search->searchInput(); +#endif + QString a = (results.size() == 0) ? tr("No") : QString("%1").arg(results.size()); + html+=""+ tr("%1 result(s) for \"%2\"").arg(a).arg(queryString)+""; + if (results.size()>0) html += " ["+tr("clear")+"]"; for (QHelpSearchResult & result : results) { - html += QString("

Title: %2
%3
").arg(result.url().toString()).arg(result.title()).arg(result.snippet()); + QString title = result.url().toString().section("/",-1); + html += QString("

%2: %3

").arg(result.url().toString()).arg(title).arg(result.snippet()); } - helpBrowser->setText(html); - ui->searchBar->setText(QString()); */ + html += ""; + resultWidget->setText(html); + tabWidget->setCurrentWidget(resultWidget); } void Help::on_searchBar_returnPressed() @@ -169,7 +192,7 @@ void Help::on_searchBar_returnPressed() QString str=ui->searchBar->text(); - #if QT_VERSION < QT_VERSION_CHECK(5,10,0) + #if QT_VERSION < QT_VERSION_CHECK(5,9,0) QList query; query.push_back(QHelpSearchQuery(QHelpSearchQuery::FUZZY, QStringList(str))); search->search(query); @@ -194,5 +217,9 @@ void Help::backwardAvailable(bool b) void Help::requestShowLink(const QUrl & link) { - helpBrowser->setSource(link); + if (link.toString() == "clear") { + resultWidget->clear(); + } else { + helpBrowser->setSource(link); + } } diff --git a/sleepyhead/help.h b/sleepyhead/help.h index 30e26099..32c1cf7c 100644 --- a/sleepyhead/help.h +++ b/sleepyhead/help.h @@ -14,6 +14,7 @@ #include #include #include +#include "mytextbrowser.h" namespace Ui { class Help; @@ -59,6 +60,7 @@ private: QHelpEngine *helpEngine; QTabWidget * tabWidget; HelpBrowser * helpBrowser; + MyTextBrowser * resultWidget; bool searchReady; }; diff --git a/sleepyhead/help/help_en.qhp b/sleepyhead/help/help_en.qhp index f26f9c06..58835774 100644 --- a/sleepyhead/help/help_en.qhp +++ b/sleepyhead/help/help_en.qhp @@ -73,7 +73,17 @@ default.css - help_en/*.html + help_en/daily.html + help_en/faq.html + help_en/gettingstarted.html + help_en/glossary.html + help_en/import.html + help_en/index.html + help_en/overview.html + help_en/oximetry.html + help_en/statistics.html + help_en/supported.html + help_en/tipsntricks.html images/*.png diff --git a/sleepyhead/help/help_en/doc.html b/sleepyhead/help/help_en/doc.html deleted file mode 100644 index 96a614f5..00000000 --- a/sleepyhead/help/help_en/doc.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -

Introduction to SleepyHead

-SleepyHead is software designed for exploring data produced by your CPAP/APAP/BiLevel/etc Ventilator. -
-

Importing CPAP data

-Click import. Cross your fingers. -
-

Exploring Daily View

-The mouse does stuff - - diff --git a/sleepyhead/sleepyhead.pro b/sleepyhead/sleepyhead.pro index 531a9bb8..8185f05d 100644 --- a/sleepyhead/sleepyhead.pro +++ b/sleepyhead/sleepyhead.pro @@ -339,7 +339,6 @@ DISTFILES += \ help/default.css \ help/help_en.qhp \ help/help_en/daily.html \ - help/help_en/doc.html \ help/help_en/glossary.html \ help/help_en/import.html \ help/help_en/index.html \