--- a/src/qtgui/snippets_w.cpp
+++ b/src/qtgui/snippets_w.cpp
@@ -23,12 +23,12 @@
#include <sstream>
using namespace std;
-#ifdef SNIPPETS_TEXTBROWSER
-#include <QTextBrowser>
-#else
+#if defined(USING_WEBKIT)
#include <QWebSettings>
#include <QWebFrame>
#include <QUrl>
+#else
+#include <QTextBrowser>
#endif
#include <QShortcut>
@@ -42,10 +42,10 @@
// Note: the internal search currently does not work with QTextBrowser. To be
// fixed by looking at the preview code if someone asks for it...
-#ifdef SNIPPETS_TEXTBROWSER
+#if defined(USING_WEBKIT)
+#define browser ((QWebView*)browserw)
+#else
#define browser ((QTextBrowser*)browserw)
-#else
-#define browser ((QWebView*)browserw)
#endif
class PlainToRichQtSnippets : public PlainToRich {
@@ -92,7 +92,23 @@
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
-#ifdef SNIPPETS_TEXTBROWSER
+#if defined(USING_WEBKIT)
+ browserw = new QWebView(this);
+ verticalLayout->insertWidget(0, browserw);
+ browser->setUrl(QUrl(QString::fromUtf8("about:blank")));
+ connect(browser, SIGNAL(linkClicked(const QUrl &)),
+ this, SLOT(linkWasClicked(const QUrl &)));
+ browser->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+ browser->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal,
+ Qt::ScrollBarAlwaysOff);
+ QWebSettings *ws = browser->page()->settings();
+ if (prefs.reslistfontfamily != "") {
+ ws->setFontFamily(QWebSettings::StandardFont, prefs.reslistfontfamily);
+ ws->setFontSize(QWebSettings::DefaultFontSize, prefs.reslistfontsize);
+ }
+ if (!prefs.snipCssFile.isEmpty())
+ ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
+#else
browserw = new QTextBrowser(this);
verticalLayout->insertWidget(0, browserw);
connect(browser, SIGNAL(anchorClicked(const QUrl &)),
@@ -107,22 +123,6 @@
} else {
browser->setFont(QFont());
}
-#else
- browserw = new QWebView(this);
- verticalLayout->insertWidget(0, browserw);
- browser->setUrl(QUrl(QString::fromUtf8("about:blank")));
- connect(browser, SIGNAL(linkClicked(const QUrl &)),
- this, SLOT(linkWasClicked(const QUrl &)));
- browser->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
- browser->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal,
- Qt::ScrollBarAlwaysOff);
- QWebSettings *ws = browser->page()->settings();
- if (prefs.reslistfontfamily != "") {
- ws->setFontFamily(QWebSettings::StandardFont, prefs.reslistfontfamily);
- ws->setFontSize(QWebSettings::DefaultFontSize, prefs.reslistfontsize);
- }
- if (!prefs.snipCssFile.isEmpty())
- ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
#endif
// Make title out of file name if none yet
@@ -193,10 +193,10 @@
"generator got lost in a maze...</p>"));
}
oss << "\n</body></html>";
-#ifdef SNIPPETS_TEXTBROWSER
+#if defined(USING_WEBKIT)
+ browser->setHtml(QString::fromUtf8(oss.str().c_str()));
+#else
browser->insertHtml(QString::fromUtf8(oss.str().c_str()));
-#else
- browser->setHtml(QString::fromUtf8(oss.str().c_str()));
#endif
}
@@ -212,10 +212,10 @@
if (!searchFM->isVisible())
slotEditFind();
-#ifdef SNIPPETS_TEXTBROWSER
+#if defined(USING_WEBKIT)
+ browser->findText(searchLE->text());
+#else
browser->find(searchLE->text(), 0);
-#else
- browser->findText(searchLE->text());
#endif
}
@@ -224,18 +224,19 @@
if (!searchFM->isVisible())
slotEditFind();
-#ifdef SNIPPETS_TEXTBROWSER
+#if defined(USING_WEBKIT)
+ browser->findText(searchLE->text(), QWebPage::FindBackward);
+#else
browser->find(searchLE->text(), QTextDocument::FindBackward);
-#else
- browser->findText(searchLE->text(), QWebPage::FindBackward);
-#endif
-}
+#endif
+}
+
void SnippetsW::slotSearchTextChanged(const QString& txt)
{
-#ifdef SNIPPETS_TEXTBROWSER
+#if defined(USING_WEBKIT)
+ browser->findText(txt);
+#else
browser->find(txt, 0);
-#else
- browser->findText(txt);
#endif
}