diff options
Diffstat (limited to 'src/frontend/display')
22 files changed, 235 insertions, 235 deletions
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp index 37bea2d..0d09259 100644 --- a/src/frontend/display/btcolorwidget.cpp +++ b/src/frontend/display/btcolorwidget.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h index 0d8e8ad..5cc0f56 100644 --- a/src/frontend/display/btcolorwidget.h +++ b/src/frontend/display/btcolorwidget.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -22,10 +22,11 @@ class BtColorWidget : public QFrame { BtColorWidget(QWidget* parent = 0); ~BtColorWidget(); QSize sizeHint() const; + + public slots: void setColor(const QColor& color); protected: -// void paintEvent( QPaintEvent* ); void mouseReleaseEvent(QMouseEvent* event); private: diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp index 116d0d7..b302fed 100644 --- a/src/frontend/display/btfontsizewidget.cpp +++ b/src/frontend/display/btfontsizewidget.cpp @@ -1,9 +1,9 @@ /********* * -* This file is part of BtFontSizeWidget's source code, http://www.bibletime.info/. +* This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BtFontSizeWidget developers. -* The BtFontSizeWidget source code is licensed under the GNU General Public License version 2.0. +* Copyright 1999-2011 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h index 3db867d..c2d7198 100644 --- a/src/frontend/display/btfontsizewidget.h +++ b/src/frontend/display/btfontsizewidget.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -19,9 +19,11 @@ class BtFontSizeWidget : public QComboBox { public: BtFontSizeWidget(QWidget* parent = 0); ~BtFontSizeWidget(); - void setFontSize(int size); int fontSize() const; + public slots: + void setFontSize(int size); + private slots: virtual void changed(const QString& text); diff --git a/src/frontend/display/bthtml.js b/src/frontend/display/bthtml.js index d64215d..689ba55 100644 --- a/src/frontend/display/bthtml.js +++ b/src/frontend/display/bthtml.js @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp index 70e8a5d..1b15b11 100644 --- a/src/frontend/display/bthtmlfindtext.cpp +++ b/src/frontend/display/bthtmlfindtext.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -49,10 +49,6 @@ void BtHtmlFindText::findNext() { } } -void BtHtmlFindText::doHide() { - hide(); -} - void BtHtmlFindText::findPrevious() { QWebView* webView = getActiveWindowWebView(); if (webView != 0) { diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h index 3c24489..1d941c1 100644 --- a/src/frontend/display/bthtmlfindtext.h +++ b/src/frontend/display/bthtmlfindtext.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -26,7 +26,6 @@ class BtHtmlFindText : public QDialog { public slots: void findNext(); void findPrevious(); - void doHide(); private: QWebView* getActiveWindowWebView(); Ui_findTextDialog ui; diff --git a/src/frontend/display/bthtmlfindtext.ui b/src/frontend/display/bthtmlfindtext.ui index 97c373e..c04de0c 100644 --- a/src/frontend/display/bthtmlfindtext.ui +++ b/src/frontend/display/bthtmlfindtext.ui @@ -48,7 +48,7 @@ <item> <widget class="QCheckBox" name="caseBox" > <property name="toolTip" > - <string>Seach with case sensitivity</string> + <string>Search with case sensitivity</string> </property> <property name="text" > <string>Case &sensitive</string> diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp index 195564e..119c2a8 100644 --- a/src/frontend/display/bthtmljsobject.cpp +++ b/src/frontend/display/bthtmljsobject.cpp @@ -2,14 +2,14 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ #include "frontend/display/bthtmljsobject.h" -#include <boost/scoped_ptr.hpp> +#include <QSharedPointer> #include <QObject> #include "backend/config/cbtconfig.h" #include "backend/keys/cswordkey.h" @@ -18,6 +18,7 @@ #include "frontend/cdragdrop.h" #include "frontend/cinfodisplay.h" #include "frontend/display/bthtmlreaddisplay.h" +#include "bibletime.h" using namespace InfoDisplay; @@ -28,7 +29,10 @@ using namespace InfoDisplay; // Access to DOM objects is implemented in Javascript and is communicated back to c++ through this class BtHtmlJsObject::BtHtmlJsObject(BtHtmlReadDisplay* display) - : m_display(display) { + : m_display(display) +{ + m_dndData.isDragging = false; + m_dndData.mousePressed = false; } void BtHtmlJsObject::moveToAnchor(const QString& anchor) { @@ -36,13 +40,6 @@ void BtHtmlJsObject::moveToAnchor(const QString& anchor) { emit gotoAnchor(anchor); } -void BtHtmlJsObject::setBodyEditable(bool editable) { - if (editable) - emit setDocumentEditable(); - else - emit setDocumentNotEditable(); -} - void BtHtmlJsObject::mouseDownLeft(const QString& url, const int& x, const int& y) { m_dndData.mousePressed = true; m_dndData.isDragging = false; @@ -75,7 +72,6 @@ void BtHtmlJsObject::mouseDownRight(const QString& url, const QString& lemma) { // The mouse move event starts in the javascript function "mouseMoveHandler" in bthtml.js. It calls this function void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, const int& y, const bool& shiftKey) { - /// \bug Valgrind reports uninitialized m_dndData or m_dndData member: if (!m_dndData.isDragging && m_dndData.mousePressed) { // If we have not started dragging, but the mouse button is down, create a the mime data QPoint current(x, y); @@ -92,9 +88,9 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con BTMimeData* mimedata = new BTMimeData(moduleName, keyName, QString::null); drag->setMimeData(mimedata); //add real Bible text from module/key - if (CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName)) { - boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) ); - key->key( keyName ); + if (CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName(moduleName)) { + QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) ); + key->setKey(keyName); mimedata->setText(key->strippedText()); // This works across applications! } } @@ -149,7 +145,7 @@ void BtHtmlJsObject::timeOutEvent(const QString& attributes) { } // Update the mag if valid attributes were found if (!(infoList.isEmpty())) { - CPointers::infoDisplay()->setInfo(infoList); + BibleTime::instance()->infoDisplay()->setInfo(infoList); } } diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h index c3536ff..c49dc83 100644 --- a/src/frontend/display/bthtmljsobject.h +++ b/src/frontend/display/bthtmljsobject.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -24,7 +24,6 @@ class BtHtmlJsObject: public QObject { BtHtmlJsObject(BtHtmlReadDisplay* display); ~BtHtmlJsObject() {} void moveToAnchor(const QString& anchor); - void setBodyEditable(bool editable); void clearPrevAttribute(); public slots: @@ -39,8 +38,6 @@ class BtHtmlJsObject: public QObject { void mouseMoveAttribute(const QString& attrName, const QString& attrValue); void gotoAnchor(const QString& anchor); void selectAll(); - void setDocumentEditable(); - void setDocumentNotEditable(); private: int m_int; @@ -56,7 +53,7 @@ class BtHtmlJsObject: public QObject { Link, Text } dragType; - } m_dndData; + } m_dndData; }; diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp index dd2132f..2d95c38 100644 --- a/src/frontend/display/bthtmlreaddisplay.cpp +++ b/src/frontend/display/bthtmlreaddisplay.cpp @@ -2,14 +2,14 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ #include "frontend/display/bthtmlreaddisplay.h" -#include <boost/scoped_ptr.hpp> +#include <QSharedPointer> #include <QMenu> #include <QString> #include "backend/config/cbtconfig.h" @@ -19,9 +19,9 @@ #include "frontend/cinfodisplay.h" #include "frontend/display/bthtmljsobject.h" #include "frontend/displaywindow/cdisplaywindow.h" +#include "frontend/displaywindow/cdisplaywindowfactory.h" #include "frontend/displaywindow/creadwindow.h" #include "util/directory.h" -#include "util/cpointers.h" using namespace InfoDisplay; @@ -35,7 +35,7 @@ BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWid { settings()->setAttribute(QWebSettings::JavascriptEnabled, true); - m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow); + m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow, readWindow); m_view->setAcceptDrops(true); m_view->setPage(this); setParent(m_view); @@ -87,7 +87,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD else { CDisplayWindow* window = parentWindow(); CSwordKey* const key = window->key(); - CSwordModuleInfo* module = key->module(); + const CSwordModuleInfo *module = key->module(); //This is never used for Bibles, so it is not implemented for //them. If it should be, see CReadDisplay::print() for example //code. @@ -98,7 +98,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD module->type() == CSwordModuleInfo::Commentary || module->type() == CSwordModuleInfo::GenericBook) { /// \todo This is a BAD HACK, we have to fnd a better solution to manage the settings now - CSwordBackend::FilterOptions filterOptions; + FilterOptions filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -106,7 +106,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD filterOptions.scriptureReferences = false; filterOptions.textualVariants = false; - CPointers::backend()->setFilterOptions(filterOptions); + CSwordBackend::instance()->setFilterOptions(filterOptions); return QString(key->strippedText()).append("\n(") .append(key->key()) @@ -122,7 +122,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD return QString::null; } else if (format == HTMLText) { - // \todo It does not appear this is ever called + // \todo It does not appear this is ever called } else { //plain text requested return selectedText(); @@ -144,9 +144,9 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD ReferenceManager::Type type; ReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type); - if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) { - boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) ); - key->key( keyName ); + if (CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName(moduleName)) { + QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) ); + key->setKey(keyName); return key->strippedText(); } @@ -159,12 +159,12 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD ReferenceManager::Type type; ReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type); - if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) { - boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) ); - key->key( keyName ); + if (CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName(moduleName)) { + QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) ); + key->setKey(keyName); /// \todo This is a BAD HACK, we have to fnd a better solution to manage the settings now - CSwordBackend::FilterOptions filterOptions; + FilterOptions filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -172,7 +172,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD filterOptions.scriptureReferences = false; filterOptions.textualVariants = false; - CPointers::backend()->setFilterOptions(filterOptions); + CSwordBackend::instance()->setFilterOptions(filterOptions); return QString(key->strippedText()).append("\n(") .append(key->key()) @@ -180,16 +180,16 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD .append(key->module()->name()) .append(")"); /* ("%1\n(%2, %3)") - .arg() - .arg(key->key()) - .arg(key->module()->name());*/ + .arg() + .arg(key->key()) + .arg(key->module()->name());*/ } return QString::null; } default: return QString::null; } - return QString(); + return QString::null; } // Puts html text and javascript into QWebView @@ -198,11 +198,11 @@ void BtHtmlReadDisplay::setText( const QString& newText ) { QString jsText = newText; jsText.replace( - QString("</body>"), - QString("<script type=\"text/javascript\">").append(javascript).append("</script></body>") - ); + QString("</body>"), + QString("<script type=\"text/javascript\">").append(javascript).append("</script></body>") + ); - // Disconnect any previous connect and connect to slot that loads the javascript object + // Disconnect any previous connections and connect to slot that loads the javascript object QWebFrame* frame = mainFrame(); disconnect(frame, SIGNAL(javaScriptWindowObjectCleared()), 0, 0); bool ok = connect(frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(loadJSObject())); @@ -211,11 +211,11 @@ void BtHtmlReadDisplay::setText( const QString& newText ) { // Send text to the html viewer m_view->setHtml(jsText); - this->currentSource = jsText; + this->currentSource = jsText; } QString BtHtmlReadDisplay::getCurrentSource( ) { - return this->currentSource; + return this->currentSource; } // See if any text is selected @@ -233,10 +233,7 @@ QWidget* BtHtmlReadDisplay::view() { // Select all text in the viewer void BtHtmlReadDisplay::selectAll() { - m_jsObject->setBodyEditable(true); - m_view->triggerPageAction( QWebPage::MoveToStartOfDocument, true ); - m_view->triggerPageAction( QWebPage::SelectEndOfDocument, true ); - m_jsObject->setBodyEditable(false); + m_view->triggerPageAction( QWebPage::SelectAll, true ); } // Scroll QWebView to the correct location as specified by the anchor @@ -276,8 +273,8 @@ void BtHtmlReadDisplay::javaScriptConsoleMessage (const QString& message, int li // ----------------- BtHtmlReadDisplayView ------------------------------------- -BtHtmlReadDisplayView::BtHtmlReadDisplayView(BtHtmlReadDisplay* displayWidget, QWidget* parent) - : QWebView(parent), m_display(displayWidget) { +BtHtmlReadDisplayView::BtHtmlReadDisplayView(BtHtmlReadDisplay* displayWidget, QWidget* parent, CReadWindow* readWindow) + : QWebView(parent), m_display(displayWidget), m_readWindow(readWindow) { } BtHtmlReadDisplayView::~BtHtmlReadDisplayView() { @@ -307,17 +304,48 @@ void BtHtmlReadDisplayView::dropEvent( QDropEvent* e ) { } }; //don't accept the action! - e->ignore(); +// e->ignore(); } // Reimplementation from QWebView void BtHtmlReadDisplayView::dragEnterEvent( QDragEnterEvent* e ) { - if (e->mimeData()->hasFormat("BibleTime/Bookmark")) { - e->acceptProposedAction(); + if ( ! e->mimeData()->hasFormat("BibleTime/Bookmark")) + return; + + const QMimeData* mimedata = e->mimeData(); + if (mimedata == 0) + return; + + const BTMimeData* btmimedata = qobject_cast<const BTMimeData*>(mimedata); + if (btmimedata == 0) + return; + + BookmarkItem item = (qobject_cast<const BTMimeData*>(e->mimeData()))->bookmark(); + QString moduleName = item.module(); + CSwordModuleInfo *m = CSwordBackend::instance()->findModuleByName(moduleName); + Q_ASSERT(m); + if (m == 0) return; + + CSwordModuleInfo::ModuleType bookmarkType = m->type(); + CSwordModuleInfo::ModuleType windowType = CDisplayWindowFactory::getModuleType(m_readWindow); + + // Is bible reference bookmark compatible with the window type? + if ((bookmarkType == CSwordModuleInfo::Bible || + bookmarkType == CSwordModuleInfo::Commentary)) { + if (windowType == CSwordModuleInfo::Bible || + windowType == CSwordModuleInfo::Commentary) + e->acceptProposedAction(); + return; } - //don't accept the action! - e->ignore(); + + // Is reference type compatible with window type + if (bookmarkType == windowType) { + e->acceptProposedAction(); + return; + } + + return; } // Reimplementation from QWebView diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h index e4011d0..21724b9 100644 --- a/src/frontend/display/bthtmlreaddisplay.h +++ b/src/frontend/display/bthtmlreaddisplay.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -104,17 +104,18 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay { }; -class BtHtmlReadDisplayView : public QWebView, public CPointers { +class BtHtmlReadDisplayView : public QWebView { Q_OBJECT protected: friend class BtHtmlReadDisplay; void contextMenuEvent(QContextMenuEvent* event); - BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent); + BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent, CReadWindow* readWindow); ~BtHtmlReadDisplayView(); bool event(QEvent* e); private: BtHtmlReadDisplay* m_display; + CReadWindow* m_readWindow; void dropEvent( QDropEvent* e ); void dragEnterEvent( QDragEnterEvent* e ); void dragMoveEvent( QDragMoveEvent* e ); diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp index 8135d03..78d9038 100644 --- a/src/frontend/display/cdisplay.cpp +++ b/src/frontend/display/cdisplay.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -59,15 +59,18 @@ void CDisplayConnections::copyAll() { /** No descriptions */ void CDisplayConnections::copySelection() { - qWarning("copyign the selected text"); m_display->copy(CDisplay::PlainText, CDisplay::SelectedText); } -void CDisplayConnections::printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) { +void CDisplayConnections::printAll(const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ m_display->print(CDisplay::Document, displayOptions, filterOptions); } -void CDisplayConnections::printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) { +void CDisplayConnections::printAnchorWithText(const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ m_display->print(CDisplay::AnchorWithText, displayOptions, filterOptions); } @@ -177,7 +180,7 @@ void CDisplay::emitReferenceDropped( const QString& reference ) { m_connections->emitReferenceDropped(key); } -/** Returns the connections obect used for signas and slots. */ +/** Returns the connections object used for signals and slots. */ CDisplayConnections* CDisplay::connectionsProxy() const { return m_connections; } diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h index a7d6a03..af49178 100644 --- a/src/frontend/display/cdisplay.h +++ b/src/frontend/display/cdisplay.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -10,8 +10,6 @@ #ifndef CDISPLAY_H #define CDISPLAY_H -#include "util/cpointers.h" - #include <QMap> #include "backend/managers/cswordbackend.h" @@ -27,7 +25,7 @@ class QMenu; /** The base class for all display widgets. * @author The BibleTime team */ -class CDisplay : public CPointers { +class CDisplay { public: enum WriteDisplayType { HTMLDisplay = 0, @@ -84,15 +82,17 @@ class CDisplay : public CPointers { */ virtual void selectAll() = 0; /** - * Returns the connections obect used for signas and slots. + * Returns the connections object used for signals and slots. */ virtual CDisplayConnections* connectionsProxy() const; /** * Returns the parent window used for this display widget. */ CDisplayWindow* parentWindow() const; - virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, - CSwordBackend::FilterOptions filterOptions) = 0; + + virtual void print(const CDisplay::TextPart, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) = 0; /** * Installs the popup which should be opened when the right mouse button was pressed. */ @@ -151,9 +151,11 @@ class CDisplayConnections : public QObject { void saveAsHTML(); void saveAnchorWithText(); - void printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions); - void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, - CSwordBackend::FilterOptions filterOptions); + void printAll(const DisplayOptions &displayOptions, + const FilterOptions &filterOptions); + + void printAnchorWithText(const DisplayOptions &displayOptions, + const FilterOptions &filterOptions); void copySelection(); void copyAll(); diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp index 4d08666..ce7b94c 100644 --- a/src/frontend/display/chtmlwritedisplay.cpp +++ b/src/frontend/display/chtmlwritedisplay.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -25,13 +25,70 @@ class BtActionCollection; CHTMLWriteDisplay::CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent) - : CPlainWriteDisplay(parentWindow, parent), m_fontFamilyChooser(0), - m_fontSizeChooser(0), m_colorChooser(0) { +: CPlainWriteDisplay(parentWindow, parent) { m_actions.bold = 0; m_actions.italic = 0; m_actions.underline = 0; m_actions.selectAll = 0; + //--------------------bold toggle------------------------- + namespace DU = util::directory; + m_actions.bold = new QAction( + DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon), + tr("Bold"), + this); + m_actions.bold->setCheckable(true); + m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel); + m_actions.bold->setToolTip( tr("Bold") ); + connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool))); + + //--------------------italic toggle------------------------- + m_actions.italic = new QAction( + DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon), + tr("Italic"), + this ); + m_actions.italic->setCheckable(true); + m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel); + connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool))); + m_actions.italic->setToolTip( tr("Italic") ); + + //--------------------underline toggle------------------------- + m_actions.underline = new QAction( + DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon), + tr("Underline"), + this ); + m_actions.underline->setCheckable(true); + m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel); + connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool))); + m_actions.underline->setToolTip( tr("Underline") ); + + //--------------------align left toggle------------------------- + m_actions.alignLeft = new QAction( + DU::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon), + tr("Left"), this); + m_actions.alignLeft->setCheckable(true); + m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel); + connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool))); + m_actions.alignLeft->setToolTip( tr("Align left") ); + + //--------------------align center toggle------------------------- + m_actions.alignCenter = new QAction( + DU::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon), + tr("Center"), this); + m_actions.alignCenter->setCheckable(true); + m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel); + connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool))); + m_actions.alignCenter->setToolTip( tr("Center") ); + + //--------------------align right toggle------------------------- + m_actions.alignRight = new QAction( + DU::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon), + tr("Right"), this); + m_actions.alignRight->setCheckable(true); + m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel); + connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool))); + m_actions.alignRight->setToolTip( tr("Align right") ); + setAcceptRichText(true); setAcceptDrops(true); viewport()->setAcceptDrops(true); @@ -118,12 +175,12 @@ void CHTMLWriteDisplay::slotColorSelected( const QColor& c) { /** Is called when a text with another color was selected. */ void CHTMLWriteDisplay::slotColorChanged(const QColor& c) { - m_colorChooser->setColor(c); + emit setColor(c); } void CHTMLWriteDisplay::slotFontChanged( const QFont& font ) { - m_fontFamilyChooser->setCurrentFont(font); - m_fontSizeChooser->setFontSize( font.pointSize() ); + emit fontChanged(font); + emit fontSizeChanged(font.pointSize()); m_actions.bold->setChecked( font.bold() ); m_actions.italic->setChecked( font.italic() ); @@ -135,104 +192,46 @@ void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) { } void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) { - namespace DU = util::directory; //--------------------font chooser------------------------- - m_fontFamilyChooser = new QFontComboBox(this); - actions->addAction(CResMgr::displaywindows::writeWindow::fontFamily::actionName, m_fontFamilyChooser); - m_fontFamilyChooser->setToolTip( tr("Font") ); - bar->addWidget(m_fontFamilyChooser); - bool ok = connect(m_fontFamilyChooser, SIGNAL(currentFontChanged(const QFont&)), + QFontComboBox* fontFamilyCombo = new QFontComboBox(this); + fontFamilyCombo->setToolTip( tr("Font") ); + bar->addWidget(fontFamilyCombo); + bool ok = connect(fontFamilyCombo, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(slotFontFamilyChoosen(const QFont&))); Q_ASSERT(ok); + ok = connect(this, SIGNAL(fontChanged(const QFont&)), fontFamilyCombo, SLOT(setCurrentFont(const QFont&))); + Q_ASSERT(ok); //--------------------font size chooser------------------------- - m_fontSizeChooser = new BtFontSizeWidget(this); - m_fontSizeChooser->setToolTip( tr("Font size") ); - bar->addWidget(m_fontSizeChooser); - ok = connect(m_fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int))); + BtFontSizeWidget* fontSizeChooser = new BtFontSizeWidget(this); + fontSizeChooser->setToolTip( tr("Font size") ); + bar->addWidget(fontSizeChooser); + ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int))); + Q_ASSERT(ok); + ok = connect(this, SIGNAL(fontSizeChanged(int)), fontSizeChooser, SLOT(setFontSize(int))); Q_ASSERT(ok); //--------------------color button------------------------- - m_colorChooser = new BtColorWidget(); - m_colorChooser->setToolTip(tr("Font color")); - bar->addWidget(m_colorChooser); - ok = connect(m_colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&))); + BtColorWidget* colorChooser = new BtColorWidget(); + colorChooser->setToolTip(tr("Font color")); + bar->addWidget(colorChooser); + ok = connect(colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&))); + Q_ASSERT(ok); + ok = connect(this, SIGNAL(setColor(const QColor&)), colorChooser, SLOT(setColor(const QColor&))); Q_ASSERT(ok); bar->addSeparator(); - //--------------------bold toggle------------------------- - m_actions.bold = new QAction( - DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon), - tr("Bold"), - actions); - m_actions.bold->setCheckable(true); - m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel); - actions->addAction(CResMgr::displaywindows::writeWindow::boldText::actionName, m_actions.bold); - m_actions.bold->setToolTip( tr("Bold") ); - connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool))); - bar->addAction(m_actions.bold); - - //--------------------italic toggle------------------------- - m_actions.italic = new QAction( - DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon), - tr("Italic"), - actions ); - m_actions.italic->setCheckable(true); - m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel); - actions->addAction(CResMgr::displaywindows::writeWindow::italicText::actionName, m_actions.italic); - connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool))); - m_actions.italic->setToolTip( tr("Italic") ); bar->addAction(m_actions.italic); - - //--------------------underline toggle------------------------- - m_actions.underline = new QAction( - DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon), - tr("Underline"), - actions ); - m_actions.underline->setCheckable(true); - m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel); - actions->addAction(CResMgr::displaywindows::writeWindow::underlinedText::actionName, m_actions.underline); - connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool))); - m_actions.underline->setToolTip( tr("Underline") ); bar->addAction(m_actions.underline); //seperate formatting from alignment buttons bar->addSeparator(); - //--------------------align left toggle------------------------- - m_actions.alignLeft = new QAction( - DU::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon), - tr("Left"), actions); - m_actions.alignLeft->setCheckable(true); - m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel); - actions->addAction(CResMgr::displaywindows::writeWindow::alignLeft::actionName, m_actions.alignLeft); - connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool))); - m_actions.alignLeft->setToolTip( tr("Align left") ); bar->addAction(m_actions.alignLeft); - - //--------------------align center toggle------------------------- - m_actions.alignCenter = new QAction( - DU::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon), - tr("Center"), actions); - m_actions.alignCenter->setCheckable(true); - m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel); - actions->addAction(CResMgr::displaywindows::writeWindow::alignCenter::actionName, m_actions.alignCenter); - connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool))); - m_actions.alignCenter->setToolTip( tr("Center") ); bar->addAction(m_actions.alignCenter); - - //--------------------align right toggle------------------------- - m_actions.alignRight = new QAction( - DU::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon), - tr("Right"), actions); - m_actions.alignRight->setCheckable(true); - m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel); - actions->addAction(CResMgr::displaywindows::writeWindow::alignRight::actionName, m_actions.alignRight); - connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool))); - m_actions.alignRight->setToolTip( tr("Align right") ); bar->addAction(m_actions.alignRight); connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&))); @@ -244,16 +243,3 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action slotAlignmentChanged( alignment() ); slotColorChanged( textColor() ); } - -/** Reimplementation to show a popup menu if the right mouse button was clicked. */ -QMenu* CHTMLWriteDisplay::createPopupMenu( const QPoint& ) { - if (!m_actions.selectAll) { - m_actions.selectAll = new QAction(tr("Select all"), this); - connect(m_actions.selectAll, SIGNAL(triggered(bool)), SLOT(selectAll())); - } - - QMenu* popup = new QMenu(this); - popup->setTitle(tr("HTML editor window")); - popup->addAction(m_actions.selectAll); - return popup; -} diff --git a/src/frontend/display/chtmlwritedisplay.h b/src/frontend/display/chtmlwritedisplay.h index 56f3f53..e8e4e7c 100644 --- a/src/frontend/display/chtmlwritedisplay.h +++ b/src/frontend/display/chtmlwritedisplay.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2009 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -48,11 +48,6 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay { friend class CDisplay; CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent); ~CHTMLWriteDisplay(); - /** - * Reimplementation to show a popup menu if the right mouse button was clicked. - * (CPlainWriteDisplay) - */ - virtual QMenu* createPopupMenu( const QPoint& pos ); protected slots: void toggleBold(bool); @@ -81,6 +76,11 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay { */ void slotColorChanged( const QColor& ); + signals: + void fontChanged(const QFont& font); + void fontSizeChanged(int); + void setColor(const QColor&); + private: struct { QAction* bold; @@ -95,10 +95,6 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay { QAction* selectAll; } m_actions; - - QFontComboBox* m_fontFamilyChooser; - BtFontSizeWidget* m_fontSizeChooser; - BtColorWidget* m_colorChooser; }; #endif diff --git a/src/frontend/display/cplainwritedisplay.cpp b/src/frontend/display/cplainwritedisplay.cpp index 720aa72..bfcbe0b 100644 --- a/src/frontend/display/cplainwritedisplay.cpp +++ b/src/frontend/display/cplainwritedisplay.cpp @@ -2,14 +2,14 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ #include "frontend/display/cplainwritedisplay.h" -#include <boost/scoped_ptr.hpp> +#include <QSharedPointer> #include <QDragEnterEvent> #include <QDragMoveEvent> #include <QDropEvent> @@ -42,7 +42,7 @@ void CPlainWriteDisplay::selectAll() { void CPlainWriteDisplay::setText( const QString& newText ) { //make sure the text has been converted to show \n instead of <br/> QString text = newText; -// text.replace("\n<br /><!-- BT newline -->\n", "\n"); +// text.replace("\n<br /><!-- BT newline -->\n", "\n"); text.replace("<br />", "\n"); //inserted by BT or the Qt textedit widget QTextEdit::setText(text); @@ -62,9 +62,6 @@ const QString CPlainWriteDisplay::text( const CDisplay::TextType /*format*/, con return QString::null; } -void CPlainWriteDisplay::print( const CDisplay::TextPart, CSwordBackend::DisplayOptions, CSwordBackend::FilterOptions) { -} - /** Sets the current status of the edit widget. */ void CPlainWriteDisplay::setModified( const bool modified ) { document()->setModified(modified); @@ -86,16 +83,6 @@ const QString CPlainWriteDisplay::plainText() { return ret; } -/** Reimplementation from QTextEdit. Provides an popup menu for the given position. */ -QMenu* CPlainWriteDisplay::createPopupMenu( const QPoint& /*pos*/ ) { - return installedPopup(); -} -// -///** Reimplementation from QTextEdit. Provides an popup menu for the given position. */ -//QMenu* CPlainWriteDisplay::createPopupMenu( ) { -// return installedPopup(); -//} - /** Creates the necessary action objects and puts them on the toolbar. */ void CPlainWriteDisplay::setupToolbar(QToolBar*, BtActionCollection*) {} @@ -138,9 +125,9 @@ void CPlainWriteDisplay::dropEvent( QDropEvent* e ) { BTMimeData::ItemList::iterator it; for (it = items.begin(); it != items.end(); ++it) { - CSwordModuleInfo* module = backend()->findModuleByName((*it).module()); - boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) ); - key->key( (*it).key() ); + CSwordModuleInfo *module = CSwordBackend::instance()->findModuleByName((*it).module()); + QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) ); + key->setKey((*it).key()); QString moduleText = key->strippedText(); const QString text = QString::fromLatin1("%1\n(%2, %3)\n").arg(moduleText).arg((*it).key()).arg((*it).module()); diff --git a/src/frontend/display/cplainwritedisplay.h b/src/frontend/display/cplainwritedisplay.h index 30efc72..2c7e1be 100644 --- a/src/frontend/display/cplainwritedisplay.h +++ b/src/frontend/display/cplainwritedisplay.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -44,7 +44,14 @@ class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay { */ virtual QWidget* view(); virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document ); - virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ); + + /** + Reimplemented from CDisplay. + */ + virtual inline void print(const CDisplay::TextPart, + const DisplayOptions &, + const FilterOptions &) {} + /** * Reimplementation (CWriteDisplay). */ @@ -68,14 +75,7 @@ class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay { CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent); virtual ~CPlainWriteDisplay(); - /** - * Reimplementation from QTextEdit. Provides an popup menu for the given position. - */ - virtual QMenu* createPopupMenu( const QPoint& pos ); -// /** -// * Reimplementation from QTextEdit. Provides an popup menu. -// */ -// virtual QMenu* createPopupMenu(); + /** * Reimplementation from QTextEdit to manage drops of our drag and drop objects. */ diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp index 90175d4..690ee57 100644 --- a/src/frontend/display/creaddisplay.cpp +++ b/src/frontend/display/creaddisplay.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -46,10 +46,14 @@ bool CReadDisplay::hasActiveAnchor() { } -void CReadDisplay::print(const CDisplay::TextPart type, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) { +void CReadDisplay::print(const CDisplay::TextPart type, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ + typedef CSwordBibleModuleInfo CSBiMI; CDisplayWindow* window = parentWindow(); CSwordKey* const key = window->key(); - CSwordModuleInfo* module = key->module(); + const CSwordModuleInfo *module = key->module(); const CDisplayWindow *displayWindow = parentWindow(); CExportManager mgr(QObject::tr("Print keys"), false, QString::null, displayWindow->filterOptions(), displayWindow->displayOptions()); @@ -64,7 +68,7 @@ void CReadDisplay::print(const CDisplay::TextPart type, CSwordBackend::DisplayOp CSwordVerseKey stopKey(*vk); - CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module); + const CSBiMI *bible = dynamic_cast<const CSBiMI*>(module); if (bible) { stopKey.Verse( bible->verseCount( bible->bookNumber(startKey.book()), startKey.Chapter() ) ); } diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h index b766f5b..d1e81c4 100644 --- a/src/frontend/display/creaddisplay.h +++ b/src/frontend/display/creaddisplay.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -33,8 +33,10 @@ class CReadDisplay : public CDisplay { * Moves the widget to the given anchor. */ virtual void moveToAnchor( const QString& ) = 0; - virtual void print(const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, - CSwordBackend::FilterOptions filterOptions); + + virtual void print(const CDisplay::TextPart, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions); void setMouseTracking(const bool trackingEnabled) { m_useMouseTracking = trackingEnabled; diff --git a/src/frontend/display/cwritedisplay.cpp b/src/frontend/display/cwritedisplay.cpp index f30d217..47a3302 100644 --- a/src/frontend/display/cwritedisplay.cpp +++ b/src/frontend/display/cwritedisplay.cpp @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ diff --git a/src/frontend/display/cwritedisplay.h b/src/frontend/display/cwritedisplay.h index 33ef5a5..3591efe 100644 --- a/src/frontend/display/cwritedisplay.h +++ b/src/frontend/display/cwritedisplay.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ |