summaryrefslogtreecommitdiff
path: root/src/frontend/cmdiarea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/cmdiarea.cpp')
-rw-r--r--src/frontend/cmdiarea.cpp86
1 files changed, 70 insertions, 16 deletions
diff --git a/src/frontend/cmdiarea.cpp b/src/frontend/cmdiarea.cpp
index fb116af..d879dfa 100644
--- a/src/frontend/cmdiarea.cpp
+++ b/src/frontend/cmdiarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#include "bibletime.h"
#include "frontend/cmdiarea.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
-
+#include "frontend/display/cdisplay.h"
#include <QEvent>
#include <QMdiSubWindow>
#include <QMenu>
@@ -18,9 +18,26 @@
#include <QTabBar>
#include <QTimer>
#include <QToolBar>
+#include <QWebView>
#include <QWindowStateChangeEvent>
-#define MOVESIZE 30
+
+namespace {
+
+inline CDisplayWindow * getDisplayWindow(const QMdiSubWindow * const mdiWindow) {
+ return qobject_cast<CDisplayWindow *>(mdiWindow->widget());
+}
+
+inline QWebView * getWebViewFromDisplayWindow(const CDisplayWindow * const displayWindow) {
+ if (!displayWindow)
+ return NULL;
+ CDisplay * const display = displayWindow->displayWidget();
+ if (!display)
+ return NULL;
+ return qobject_cast<QWebView *>(display->view());
+}
+
+} // anonymous namespace
CMDIArea::CMDIArea(BibleTime *parent)
@@ -61,8 +78,10 @@ void CMDIArea::fixSystemMenu(QMdiSubWindow* subWindow) {
}
}
-QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
- QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
+QMdiSubWindow * CMDIArea::addSubWindow(QWidget * widget,
+ Qt::WindowFlags windowFlags)
+{
+ QMdiSubWindow * const subWindow = QMdiArea::addSubWindow(widget, windowFlags);
subWindow->installEventFilter(this);
fixSystemMenu(subWindow);
@@ -73,28 +92,24 @@ QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFl
// If we already have an active window, make the new one simular to it
if (activeSubWindow()) {
if (activeSubWindow()->isMaximized()) {
- // Maximize the new window
- subWindow->showMaximized();
- }
- else {
+ subWindow->showMaximized(); // Maximize the new window
+ } else {
// Make new window the same size as the active window and move it slightly.
subWindow->resize(activeSubWindow()->size());
QRect subWinGeom = activeSubWindow()->geometry();
+ static const int MOVESIZE = 30;
subWinGeom.translate(MOVESIZE, MOVESIZE);
// If it goes off screen, move it almost to the top left
- if ( ! frameRect().contains(subWinGeom)) {
+ if (!frameRect().contains(subWinGeom))
subWinGeom.moveTo(MOVESIZE, MOVESIZE);
- }
subWindow->setGeometry(subWinGeom);
}
- }
- else {
+ } else {
//set the window to be big enough
subWindow->resize(400, 400);
}
subWindow->raise();
- }
- else {
+ } else {
// Automatic arrangement modes
enableWindowMinMaxFlags(false);
triggerWindowUpdate();
@@ -285,6 +300,14 @@ QList<QMdiSubWindow*> CMDIArea::usableWindowList() const {
return ret;
}
+QWebView* CMDIArea::getActiveWebView()
+{
+ QMdiSubWindow* activeMdiWindow = activeSubWindow();
+ CDisplayWindow* const activeWindow = getDisplayWindow(activeMdiWindow);
+ QWebView* webView = getWebViewFromDisplayWindow(activeWindow);
+ return webView;
+}
+
void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
if (subWindowList().isEmpty())
m_bibleTime->clearMdiToolBars();
@@ -295,13 +318,44 @@ void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
emit sigSetToplevelCaption( client->windowTitle().trimmed() );
// Notify child window it is active
- CDisplayWindow * const activeWindow = qobject_cast<CDisplayWindow*>(client->widget());
+ CDisplayWindow* const activeWindow = getDisplayWindow(client);
if (activeWindow != 0 && activeWindow != m_activeWindow) {
m_activeWindow = activeWindow;
activeWindow->windowActivated();
}
}
+void CMDIArea::findNextTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText(text, options);
+}
+
+void CMDIArea::findPreviousTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText(text, options);
+}
+
+void CMDIArea::highlightTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText("", options); // clear old highlight
+ activeWebView->findText(text, options);
+}
+
void CMDIArea::resizeEvent(QResizeEvent* e) {
/*
Do not call QMdiArea::resizeEvent(e) if we are in manual arrangement