diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:21 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:21 -0400 |
commit | cbb6dcfb002dd5bc5f702a4909306be5c2878319 (patch) | |
tree | f5321b16bc6eb2e5f32dd9aa3cdf9f9fe9185466 /src | |
parent | 1af3b165c9377702ca62a64112bc089a6f575c30 (diff) |
Imported Upstream version 2.0
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/drivers/cswordbiblemoduleinfo.cpp | 6 | ||||
-rw-r--r-- | src/backend/drivers/cswordlexiconmoduleinfo.cpp | 5 | ||||
-rw-r--r-- | src/backend/filters/bt_osishtml.cpp | 2 | ||||
-rw-r--r-- | src/backend/filters/bt_osishtml.h | 3 | ||||
-rw-r--r-- | src/display-templates/Blue.tmpl | 5 | ||||
-rw-r--r-- | src/display-templates/Crazy.tmpl | 3 | ||||
-rw-r--r-- | src/display-templates/Green.tmpl | 6 | ||||
-rw-r--r-- | src/display-templates/HighContrast.tmpl | 5 | ||||
-rw-r--r-- | src/frontend/cinfodisplay.cpp | 42 | ||||
-rw-r--r-- | src/frontend/display/bthtmljsobject.cpp | 53 | ||||
-rw-r--r-- | src/frontend/display/bthtmljsobject.h | 2 | ||||
-rw-r--r-- | src/frontend/display/bthtmlreaddisplay.cpp | 22 | ||||
-rw-r--r-- | src/frontend/display/bthtmlreaddisplay.h | 22 | ||||
-rw-r--r-- | src/frontend/displaywindow/creadwindow.cpp | 4 | ||||
-rw-r--r-- | src/frontend/displaywindow/cwritewindow.cpp | 4 |
15 files changed, 114 insertions, 70 deletions
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp index 921157b..adf88b0 100644 --- a/src/backend/drivers/cswordbiblemoduleinfo.cpp +++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp @@ -167,9 +167,6 @@ unsigned int CSwordBibleModuleInfo::verseCount( const QString& book, const unsig unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) { unsigned int bookNumber = 0; - bool found = false; - int min = 0; - int max = 1; //find out if we have ot and nt, only ot or only nt initBounds(); @@ -182,6 +179,9 @@ unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) { bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book(); #else + bool found = false; + int min = 0; + int max = 1; if ((m_hasOT>0 && m_hasNT>0) || (m_hasOT == -1 && m_hasNT == -1)) { min = 0; diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp index a8b81e4..c84cd07 100644 --- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp +++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp @@ -63,6 +63,11 @@ QStringList* CSwordLexiconModuleInfo::entries() { return m_entryList; } + if ( name() == QString("EReo_en")) { + qWarning("Module EReo_en is buggy and will not be loaded."); + return m_entryList; + } + QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath()); QFile f1( QString(dir) diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp index b9c9746..bbcf8e5 100644 --- a/src/backend/filters/bt_osishtml.cpp +++ b/src/backend/filters/bt_osishtml.cpp @@ -262,7 +262,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo buf.append("<span class=\"crossreference\">"); #ifdef SWORD_SIMPLERENDER sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); - sword::SWBuf footnoteBody = myModule->getEntryAttributes()["Footnote"][footnoteNumber]["body"]; + sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"]; buf += myModule->RenderText(footnoteBody); #endif } diff --git a/src/backend/filters/bt_osishtml.h b/src/backend/filters/bt_osishtml.h index 7ae5e6d..175ee4b 100644 --- a/src/backend/filters/bt_osishtml.h +++ b/src/backend/filters/bt_osishtml.h @@ -12,6 +12,7 @@ //Sword includes #include <swbuf.h> +#include <swmodule.h> #include <osishtmlhref.h> namespace Filters { @@ -31,10 +32,12 @@ BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::OSI noteType = Unknown; swordFootnote = 1; inCrossrefNote = false; + entryAttributes = module->getEntryAttributes(); } unsigned short int swordFootnote; bool inCrossrefNote; + sword::AttributeTypeList entryAttributes; enum NoteType { Unknown, diff --git a/src/display-templates/Blue.tmpl b/src/display-templates/Blue.tmpl index db5844f..881ce1c 100644 --- a/src/display-templates/Blue.tmpl +++ b/src/display-templates/Blue.tmpl @@ -277,14 +277,12 @@ td.entry + td.entry { color:darkGray; font-weight:bold; border-bottom:1px solid gray; - font-size:90%; text-align: right; } #infodisplay > p, #infodisplay * > p, #infodisplay > .para, #infodisplay * > .para { /* We only format the first p child in a special way */ - font-size:95%; text-align:justify !important; color:black; margin:0px; @@ -295,7 +293,6 @@ td.entry + td.entry { #infodisplay .entry { padding:2px; text-align:justify !important; - font-size:95%; margin-bottom:10px; margin-left:15px; } @@ -303,7 +300,6 @@ td.entry + td.entry { text-align: right !important; } #infodisplay .entry .entry { /*No smaller font size for nested entries*/ - font-size:100%; margin:0px; } #infodisplay .entry .entry[dir=rtl] { /*No smaller font size for nested entries*/ @@ -314,7 +310,6 @@ td.entry + td.entry { margin:0px; text-align:left !important; font-weight:bold; - font-size:100%; } #infodisplay .rangeheading { diff --git a/src/display-templates/Crazy.tmpl b/src/display-templates/Crazy.tmpl index c0e9b63..df3133c 100644 --- a/src/display-templates/Crazy.tmpl +++ b/src/display-templates/Crazy.tmpl @@ -276,15 +276,12 @@ so something like .alternative:before { content:"'"attr(alternative); } is possi } #infodisplay > p, #infodisplay * > p { /* We only format the first p child in a special way */ - font-size:80%; } /*Required for cross references*/ #infodisplay .entry { - font-size:80%; } #infodisplay .entry .entry { /* No smaller font size for nested entries */ - font-size:100% !important; } #infodisplay .entryname { font-weight:bold; diff --git a/src/display-templates/Green.tmpl b/src/display-templates/Green.tmpl index 4616030..8dda232 100644 --- a/src/display-templates/Green.tmpl +++ b/src/display-templates/Green.tmpl @@ -257,7 +257,6 @@ td.entry + td.entry { #infodisplay { margin:0; padding:0; - font-size:100%; } #infodisplay .footnoteinfo h3, #infodisplay .strongsinfo h3, #infodisplay .morphinfo h3, #infodisplay .translationinfo h3, #infodisplay .crossrefinfo h3 { @@ -265,12 +264,10 @@ td.entry + td.entry { color:darkGray; font-weight:bold; border-bottom:1px solid gray; - font-size:100%; text-align:left !important; } #infodisplay > p, #infodisplay * > p { /* We only format the first p child in a special way */ - font-size:100%; text-align:justify; color:black; margin:0px; @@ -281,12 +278,10 @@ td.entry + td.entry { #infodisplay .entry { padding:2px; text-align:justify; - font-size:100%; margin-bottom:10px; margin-left:15px; } #infodisplay .entry .entry { /*No smaller font size for nested entries*/ - font-size:100%; margin:0px; } #infodisplay .entryname { @@ -294,7 +289,6 @@ td.entry + td.entry { margin:0px; text-align:left; font-weight:bold; - font-size:100%; } #infodisplay .rangeheading { diff --git a/src/display-templates/HighContrast.tmpl b/src/display-templates/HighContrast.tmpl index 4baf59d..820e832 100644 --- a/src/display-templates/HighContrast.tmpl +++ b/src/display-templates/HighContrast.tmpl @@ -279,12 +279,10 @@ td.entry + td.entry { color: black; font-weight: bold; border-bottom: 1px solid black; - font-size: 90%; margin: 0 0 3px 0; } #infodisplay > p { /* We only format the first p child in a special way */ - font-size: 90%; color: black; margin: 0px; padding: 0px; @@ -294,11 +292,9 @@ td.entry + td.entry { #infodisplay .entry { padding: 2px; text-align: justify; - font-size: 80%; margin: 0 0 10px 10px; } #infodisplay .entry .entry { /*No smaller font size for nested entries*/ - font-size: 100%; margin: 0px; } #infodisplay .entryname { @@ -306,7 +302,6 @@ td.entry + td.entry { margin: 0px; text-align: left; font-weight: bold; - font-size: 90%; } #infodisplay .rangeheading { diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp index 0c167c4..a8ad60d 100644 --- a/src/frontend/cinfodisplay.cpp +++ b/src/frontend/cinfodisplay.cpp @@ -77,18 +77,26 @@ void CInfoDisplay::lookupInfo(const QString &mod_name, const QString &key_text) Q_ASSERT(m); if (!m) return; - boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(m) ); key->key( key_text ); CDisplayTemplateMgr* mgr = CPointers::displayTemplateManager(); CDisplayTemplateMgr::Settings settings; settings.pageCSS_ID = "infodisplay"; - // settings.langAbbrev = ""; + + // lookup text and wrap in a "div" with language set to module language + QString lang = m->language()->abbrev(); + QString renderedText = key->renderedText(); + QString divText = "<div class=\"infodisplay\" lang=\""; + divText.append(lang); + divText.append("\">"); + divText.append(renderedText); + divText.append("</div>"); + QString content = mgr->fillTemplate(CBTConfig::get - (CBTConfig::displayStyle), key->renderedText(), settings); + (CBTConfig::displayStyle), divText, settings); + m_htmlPart->setText(content); - // qWarning("setting text:\n%s", content.latin1()); } void CInfoDisplay::setInfo(const InfoType type, const QString& data) { @@ -267,9 +275,13 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) { // qWarning("rendered the tree: %s", renderer.renderKeyTree(tree).latin1()); //spanns containing rtl text need dir=rtl on their parent tag to be aligned properly - return QString("<div class=\"crossrefinfo\"><h3>%1</h3><div class=\"para\" dir=\"%2\">%3</div></div>") + QString lang = "en"; // default english + if (module) + lang = module->language()->abbrev(); + return QString("<div class=\"crossrefinfo\" lang=\"%1\"><h3>%2</h3><div class=\"para\" dir=\"%3\">%4</div></div>") + .arg(lang) .arg(tr("Cross references")) - .arg(module ? ((module->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") : "") + .arg(module ? ((module->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") : "") .arg(renderer.renderKeyTree(tree)); } @@ -310,7 +322,8 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) { : (const char*)text.toLatin1() )); - return QString("<div class=\"footnoteinfo\"><h3>%1</h3><p>%2</p></div>") + return QString("<div class=\"footnoteinfo\" lang=\"%1\"><h3>%2</h3><p>%3</p></div>") + .arg(module->language()->abbrev()) .arg(tr("Footnote")) .arg(text); } @@ -336,8 +349,12 @@ const QString CInfoDisplay::decodeStrongs( const QString& data ) { } //if the module could not be found just display an empty lemma info + QString lang = "en"; // default english + if(module) + lang = module->language()->abbrev(); ret.append( - QString("<div class=\"strongsinfo\"><h3>%1: %2</h3><p>%3</p></div>") + QString("<div class=\"strongsinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>") + .arg(lang) .arg(tr("Strongs")) .arg(*it) .arg(text) @@ -415,7 +432,11 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) { } //if the module wasn't found just display an empty morph info - ret.append( QString("<div class=\"morphinfo\"><h3>%1: %2</h3><p>%3</p></div>") + QString lang = "en"; // default to english + if (module) + lang = module->language()->abbrev(); + ret.append( QString("<div class=\"morphinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>") + .arg(lang) .arg(tr("Morphology")) .arg(value) .arg(text) @@ -438,7 +459,8 @@ const QString CInfoDisplay::getWordTranslation( const QString& data ) { return QString::null; } - QString ret = QString("<div class=\"translationinfo\"><h3>%1: %2</h3><p>%3</p></div>") + QString ret = QString("<div class=\"translationinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>") + .arg(module->language()->abbrev()) .arg(tr("Word lookup")) .arg(data) .arg(key->renderedText()); diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp index 836a6a3..823a07c 100644 --- a/src/frontend/display/bthtmljsobject.cpp +++ b/src/frontend/display/bthtmljsobject.cpp @@ -78,14 +78,16 @@ void BtHtmlJsObject::mouseDownRight(const QString& url, const QString& lemma) m_display->setLemma(lemma); } -void BtHtmlJsObject::mouseMoveEvent(const QString& /*attributes*/, const int& x, const int& y, const bool& shiftKey) +// 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) { 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); if ((current - m_dndData.startPos).manhattanLength() > 4 /*qApp->startDragDistance()*/ ) { - QDrag* d = 0; + QDrag* drag = 0; if (m_dndData.url.size() != 0 ) { // create a new bookmark drag! @@ -94,9 +96,9 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& /*attributes*/, const int& x, CReferenceManager::Type type; if ( !CReferenceManager::decodeHyperlink(m_dndData.url, moduleName, keyName, type) ) return; - d = new QDrag(m_display->view()); + drag = new QDrag(m_display->view()); BTMimeData* mimedata = new BTMimeData(moduleName, keyName, QString::null); - d->setMimeData(mimedata); + drag->setMimeData(mimedata); //add real Bible text from module/key if (CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName)) { @@ -105,36 +107,33 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& /*attributes*/, const int& x, mimedata->setText(key->strippedText()); // This works across applications! } } -#if 0 - else if ((m_dndData.dragType == DNDData::Text) && !m_dndData.selection.isEmpty()) { - d = new QDrag(KHTMLPart::view()->viewport()); - BTMimeData* mimedata = new BTMimeData(m_dndData.selection); - d->setMimeData(mimedata); - } -#endif - if (d) { + if (drag) + { m_dndData.isDragging = true; m_dndData.mousePressed = false; - - //first make a virtual mouse click to end the selection, if it's in progress -// QMouseEvent e(QEvent::MouseButtonRelease, QPoint(0,0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); -// QApplication::sendEvent(view()->viewport(), &e); - d->exec(Qt::CopyAction, Qt::CopyAction); - + drag->exec(Qt::CopyAction, Qt::CopyAction); } } } else if (m_display->getMouseTracking() && !shiftKey) { - //no mouse button pressed and tracking enabled - // After some millisecs the new timer activates the Mag window update, see timerEvent() - // QObject has simple timer - emit startTimer(CBTConfig::get(CBTConfig::magDelay)); + // no mouse button pressed and tracking enabled + // start timer that updates the mag window + // Sets timer in javascript. See bthtml.js startTimer() + emit startTimer(CBTConfig::get(CBTConfig::magDelay)); + m_prev_attributes = attributes; + // When the javascript timer interupts, the see timerEvent() in bthtml.js + // will call the timeOutEvent in this class } } +// called from javascript timerEvent() in bthtml.js void BtHtmlJsObject::timeOutEvent(const QString& attributes) { + if (m_prev_attributes != attributes) + return; + + m_prev_attributes = ""; CInfoDisplay::ListInfoData infoList; QStringList attrList = attributes.split("||"); for (int i=0; i<attrList.count(); i++) @@ -167,9 +166,17 @@ void BtHtmlJsObject::timeOutEvent(const QString& attributes) } } } - // Update the mag if there is new content + // Update the mag if valid attributes were found if (!(infoList.isEmpty())) { CPointers::infoDisplay()->setInfo(infoList); } } + +// clearing the previous attribute effectively stops any time out event +// that is in progress +void BtHtmlJsObject::clearPrevAttribute() +{ + m_prev_attributes = ""; +} + diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h index a124c1c..eeba3af 100644 --- a/src/frontend/display/bthtmljsobject.h +++ b/src/frontend/display/bthtmljsobject.h @@ -23,6 +23,7 @@ public: ~BtHtmlJsObject(){} void moveToAnchor(const QString& anchor); void setBodyEditable(bool editable); + void clearPrevAttribute(); public slots: void mouseMoveEvent(const QString& attributes, const int& x, const int& y, const bool& shiftKey); void mouseClick(const QString& url); @@ -41,6 +42,7 @@ signals: private: int m_int; BtHtmlReadDisplay* m_display; + QString m_prev_attributes; struct DNDData { diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp index 7f016cd..6cb959c 100644 --- a/src/frontend/display/bthtmlreaddisplay.cpp +++ b/src/frontend/display/bthtmlreaddisplay.cpp @@ -213,10 +213,19 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD return QString(); } +#include <QTextStream> // Puts html text and javascript into QWebView void BtHtmlReadDisplay::setText( const QString& newText ) { QString jsText = newText; + + QFile file("out.txt"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + QTextStream out(&file); + out << newText << "\n"; + jsText.replace(body,jsBegin+javascript+jsEnd+body); // Disconnect any previous connect and connect to slot that loads the javascript object @@ -284,8 +293,8 @@ void BtHtmlReadDisplay::slotLoadFinished(bool) emit completed(); } -// For debugging javascript -#if 0 +// For debugging javascript - set breakpoint in this function to catch javascript error messages +#if DEBUG_JS void BtHtmlReadDisplay::javaScriptConsoleMessage (const QString& message, int lineNumber, const QString& sourceID ) { } @@ -362,3 +371,12 @@ void BtHtmlReadDisplayView::dragMoveEvent( QDragMoveEvent* e ) e->ignore(); } +bool BtHtmlReadDisplayView::event(QEvent* e) +{ + // If the mouse leaves the widget clear the previous attribute + // in bthtmljsobject. This cancels any time out event that + // is in progress. + if ( e->type() == QEvent::Leave ) + m_display->m_jsObject->clearPrevAttribute(); + return QWidget::event(e); +}
\ No newline at end of file diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h index 99a91cf..8a832bc 100644 --- a/src/frontend/display/bthtmlreaddisplay.h +++ b/src/frontend/display/bthtmlreaddisplay.h @@ -7,8 +7,6 @@ * **********/ - - #ifndef BTHTMLREADDISPLAY_H #define BTHTMLREADDISPLAY_H @@ -17,7 +15,6 @@ #include "creaddisplay.h" //Qt includes -//Added by qt3to4: #include <QDragEnterEvent> #include <QDropEvent> #include <QTimerEvent> @@ -31,17 +28,22 @@ class QScrollArea; class QWidget; class QString; class BtHtmlReadDisplay; - +class QEvent; /** The implementation for the HTML read display. * @author The BibleTime team */ -class BtHtmlReadDisplay : public QWebPage, public CReadDisplay { +class BtHtmlReadDisplay : public QWebPage, public CReadDisplay +{ Q_OBJECT + + friend class BtHtmlReadDisplayView; + public: //reimplemented functions from CDisplay // Returns the right text part in the specified format. - virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document ); + virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, + const CDisplay::TextPart part = CDisplay::Document ); // Sets the new text for this display widget. virtual void setText( const QString& newText ); @@ -87,8 +89,11 @@ protected: QMap<NodeInfoType, QString> m_nodeInfo; int m_magTimerId; -// For debugging javascript -// void javaScriptConsoleMessage (const QString & message, int lineNumber, const QString & sourceID ); +// For debugging javascript - setbreakpoint in this function to catch javascript error messages +//#define DEBUG_JS +#ifdef DEBUG_JS + void javaScriptConsoleMessage (const QString & message, int lineNumber, const QString & sourceID ); +#endif private: void initJavascript(); @@ -107,6 +112,7 @@ protected: void contextMenuEvent(QContextMenuEvent* event); BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent); ~BtHtmlReadDisplayView(); + bool event(QEvent* e); private: BtHtmlReadDisplay* m_display; diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp index d446d30..a7d53ac 100644 --- a/src/frontend/displaywindow/creadwindow.cpp +++ b/src/frontend/displaywindow/creadwindow.cpp @@ -126,8 +126,8 @@ void CReadWindow::storeProfileSettings(CProfileWindow * const settings) { QRect rect; rect.setX(parentWidget()->x()); rect.setY(parentWidget()->y()); - rect.setWidth(width()); - rect.setHeight(height()); + rect.setWidth(parentWidget()->width()); + rect.setHeight(parentWidget()->height()); settings->setGeometry(rect); // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() ); diff --git a/src/frontend/displaywindow/cwritewindow.cpp b/src/frontend/displaywindow/cwritewindow.cpp index 0c58bf7..62009c0 100644 --- a/src/frontend/displaywindow/cwritewindow.cpp +++ b/src/frontend/displaywindow/cwritewindow.cpp @@ -46,8 +46,8 @@ void CWriteWindow::storeProfileSettings(CProfileWindow * const settings) { QRect rect; rect.setX(parentWidget()->x()); rect.setY(parentWidget()->y()); - rect.setWidth(width()); - rect.setHeight(height()); + rect.setWidth(parentWidget()->width()); + rect.setHeight(parentWidget()->height()); settings->setGeometry(rect); // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() ); |