summaryrefslogtreecommitdiff
path: root/src/frontend/display
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/display')
-rw-r--r--src/frontend/display/btcolorwidget.cpp68
-rw-r--r--src/frontend/display/btcolorwidget.h31
-rw-r--r--src/frontend/display/btfontsizewidget.cpp51
-rw-r--r--src/frontend/display/btfontsizewidget.h29
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp113
-rw-r--r--src/frontend/display/bthtmlfindtext.h29
-rw-r--r--src/frontend/display/bthtmljsobject.cpp224
-rw-r--r--src/frontend/display/bthtmljsobject.h82
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp479
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h147
-rw-r--r--src/frontend/display/cdisplay.cpp137
-rw-r--r--src/frontend/display/cdisplay.h268
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp404
-rw-r--r--src/frontend/display/chtmlwritedisplay.h148
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp139
-rw-r--r--src/frontend/display/cplainwritedisplay.h112
-rw-r--r--src/frontend/display/creaddisplay.cpp116
-rw-r--r--src/frontend/display/creaddisplay.h78
-rw-r--r--src/frontend/display/cwritedisplay.h46
19 files changed, 1286 insertions, 1415 deletions
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp
index f807b05..735f23f 100644
--- a/src/frontend/display/btcolorwidget.cpp
+++ b/src/frontend/display/btcolorwidget.cpp
@@ -14,52 +14,44 @@
#include <QColorDialog>
BtColorWidget::BtColorWidget(QWidget* parent)
- : QFrame(parent)
-{
- setFrameShadow(QFrame::Sunken);
- setFrameShape(QFrame::StyledPanel);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setAutoFillBackground(true);
+ : QFrame(parent) {
+ setFrameShadow(QFrame::Sunken);
+ setFrameShape(QFrame::StyledPanel);
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ setAutoFillBackground(true);
}
-BtColorWidget::~BtColorWidget()
-{
+BtColorWidget::~BtColorWidget() {
}
-QSize BtColorWidget::sizeHint() const
-{
- return QSize(35,18);
+QSize BtColorWidget::sizeHint() const {
+ return QSize(35, 18);
}
-void BtColorWidget::setColor(const QColor& color)
-{
- QPalette p = palette();
- p.setColor(QPalette::Normal, QPalette::Window, color);
- setPalette(p);
-
- if (color.isValid())
- m_color = color;
- else
- m_color = QColor(0,0,0);
- update();
+void BtColorWidget::setColor(const QColor& color) {
+ QPalette p = palette();
+ p.setColor(QPalette::Normal, QPalette::Window, color);
+ setPalette(p);
+
+ if (color.isValid())
+ m_color = color;
+ else
+ m_color = QColor(0, 0, 0);
+ update();
}
-void BtColorWidget::mouseReleaseEvent(QMouseEvent* event)
-{
- if (event->button() == Qt::LeftButton)
- {
- event->accept();
- showColorDialog();
- return;
- }
+void BtColorWidget::mouseReleaseEvent(QMouseEvent* event) {
+ if (event->button() == Qt::LeftButton) {
+ event->accept();
+ showColorDialog();
+ return;
+ }
}
-void BtColorWidget::showColorDialog()
-{
- QColor color = QColorDialog::getColor(m_color, this);
- if (color.isValid())
- {
- m_color = color;
- emit changed(m_color);
- }
+void BtColorWidget::showColorDialog() {
+ QColor color = QColorDialog::getColor(m_color, this);
+ if (color.isValid()) {
+ m_color = color;
+ emit changed(m_color);
+ }
}
diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h
index 0309832..aac8615 100644
--- a/src/frontend/display/btcolorwidget.h
+++ b/src/frontend/display/btcolorwidget.h
@@ -16,27 +16,26 @@
#include <QFrame>
class QPaintEvent;
-class BtColorWidget : public QFrame
-{
- Q_OBJECT
+class BtColorWidget : public QFrame {
+ Q_OBJECT
-public:
- BtColorWidget(QWidget* parent=0);
- ~BtColorWidget();
- QSize sizeHint() const;
- void setColor(const QColor& color);
+ public:
+ BtColorWidget(QWidget* parent = 0);
+ ~BtColorWidget();
+ QSize sizeHint() const;
+ void setColor(const QColor& color);
-protected:
+ protected:
// void paintEvent( QPaintEvent* );
- void mouseReleaseEvent(QMouseEvent* event);
+ void mouseReleaseEvent(QMouseEvent* event);
-private:
- void showColorDialog();
+ private:
+ void showColorDialog();
- QColor m_color;
-
-signals:
- void changed(const QColor& color);
+ QColor m_color;
+
+ signals:
+ void changed(const QColor& color);
};
#endif
diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp
index 3f03693..9d45a6a 100644
--- a/src/frontend/display/btfontsizewidget.cpp
+++ b/src/frontend/display/btfontsizewidget.cpp
@@ -12,40 +12,35 @@
#include <QCompleter>
BtFontSizeWidget::BtFontSizeWidget(QWidget* parent)
- : QComboBox(parent)
-{
- setEditable(true);
- completer()->setCompletionMode(QCompleter::PopupCompletion);
-
- QFontDatabase database;
- const QList<int> sizes = database.standardSizes();
- QStringList list;
- for ( QList<int>::ConstIterator it = sizes.begin(); it != sizes.end(); ++it )
- list.append( QString::number( *it ) );
- addItems(list);
-
- bool ok = connect(this, SIGNAL(currentIndexChanged(const QString&)),
- this, SLOT(changed(const QString&)));
- Q_ASSERT(ok);
+ : QComboBox(parent) {
+ setEditable(true);
+ completer()->setCompletionMode(QCompleter::PopupCompletion);
+
+ QFontDatabase database;
+ const QList<int> sizes = database.standardSizes();
+ QStringList list;
+ for ( QList<int>::ConstIterator it = sizes.begin(); it != sizes.end(); ++it )
+ list.append( QString::number( *it ) );
+ addItems(list);
+
+ bool ok = connect(this, SIGNAL(currentIndexChanged(const QString&)),
+ this, SLOT(changed(const QString&)));
+ Q_ASSERT(ok);
}
-BtFontSizeWidget::~BtFontSizeWidget()
-{
+BtFontSizeWidget::~BtFontSizeWidget() {
}
-void BtFontSizeWidget::changed(const QString& text)
-{
- emit fontSizeChanged(text.toInt());
+void BtFontSizeWidget::changed(const QString& text) {
+ emit fontSizeChanged(text.toInt());
}
-void BtFontSizeWidget::setFontSize(int size)
-{
- int index = findText(QString::number(size));
- if (index >= 0)
- setCurrentIndex(index);
+void BtFontSizeWidget::setFontSize(int size) {
+ int index = findText(QString::number(size));
+ if (index >= 0)
+ setCurrentIndex(index);
}
-int BtFontSizeWidget::fontSize() const
-{
- return currentText().toInt();
+int BtFontSizeWidget::fontSize() const {
+ return currentText().toInt();
}
diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h
index 2366744..81cfa86 100644
--- a/src/frontend/display/btfontsizewidget.h
+++ b/src/frontend/display/btfontsizewidget.h
@@ -16,21 +16,20 @@
#include <QComboBox>
-class BtFontSizeWidget : public QComboBox
-{
- Q_OBJECT
-
-public:
- BtFontSizeWidget(QWidget* parent=0);
- ~BtFontSizeWidget();
- void setFontSize(int size);
- int fontSize() const;
-
-private slots:
- virtual void changed(const QString& text);
-
-signals:
- void fontSizeChanged( int );
+class BtFontSizeWidget : public QComboBox {
+ Q_OBJECT
+
+ public:
+ BtFontSizeWidget(QWidget* parent = 0);
+ ~BtFontSizeWidget();
+ void setFontSize(int size);
+ int fontSize() const;
+
+ private slots:
+ virtual void changed(const QString& text);
+
+ signals:
+ void fontSizeChanged( int );
};
#endif
diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp
index 9041173..9e0feff 100644
--- a/src/frontend/display/bthtmlfindtext.cpp
+++ b/src/frontend/display/bthtmlfindtext.cpp
@@ -16,86 +16,77 @@
static BtHtmlFindText* dialog = 0;
-void showBtHtmlFindText(CMDIArea* mdiArea)
-{
- if (dialog == 0)
- dialog = new BtHtmlFindText(mdiArea, mdiArea);
- dialog->show();
+void showBtHtmlFindText(CMDIArea* mdiArea) {
+ if (dialog == 0)
+ dialog = new BtHtmlFindText(mdiArea, mdiArea);
+ dialog->show();
}
BtHtmlFindText::BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent, Qt::WindowFlags f)
- : QDialog(parent,f), m_mdiArea(mdiArea)
-{
- ui.setupUi(this);
- bool ok;
- ok = connect(ui.nextButton,SIGNAL(clicked()), this, SLOT(findNext()));
- Q_ASSERT(ok);
- ok = connect(ui.previousButton,SIGNAL(clicked()), this, SLOT(findPrevious()));
- Q_ASSERT(ok);
+ : QDialog(parent, f), m_mdiArea(mdiArea) {
+ ui.setupUi(this);
+ bool ok;
+ ok = connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(findNext()));
+ Q_ASSERT(ok);
+ ok = connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(findPrevious()));
+ Q_ASSERT(ok);
}
-BtHtmlFindText::~BtHtmlFindText()
-{
+BtHtmlFindText::~BtHtmlFindText() {
}
-void BtHtmlFindText::findNext()
-{
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0)
- {
- QWebPage::FindFlags options = 0;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
+void BtHtmlFindText::findNext() {
+ QWebView* webView = getActiveWindowWebView();
+ if (webView != 0) {
+ QWebPage::FindFlags options = 0;
+ if (ui.caseBox->checkState() == Qt::Checked)
+ options |= QWebPage::FindCaseSensitively;
+ QString searchText = ui.findTextComboBox->currentText();
+ if (!searchText.isEmpty())
+ webView->findText(searchText, options);
+ }
}
-void BtHtmlFindText::doHide()
-{
- hide();
+void BtHtmlFindText::doHide() {
+ hide();
}
-void BtHtmlFindText::findPrevious()
-{
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0)
- {
- QWebPage::FindFlags options = QWebPage::FindBackward;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText,options);
- }
+void BtHtmlFindText::findPrevious() {
+ QWebView* webView = getActiveWindowWebView();
+ if (webView != 0) {
+ QWebPage::FindFlags options = QWebPage::FindBackward;
+ if (ui.caseBox->checkState() == Qt::Checked)
+ options |= QWebPage::FindCaseSensitively;
+ QString searchText = ui.findTextComboBox->currentText();
+ if (!searchText.isEmpty())
+ webView->findText(searchText, options);
+ }
}
-QWebView* BtHtmlFindText::getActiveWindowWebView()
-{
- QMdiSubWindow* activeSubWindow = m_mdiArea->activeSubWindow();
- if (activeSubWindow == 0)
- return 0;
+QWebView* BtHtmlFindText::getActiveWindowWebView() {
+ QMdiSubWindow* activeSubWindow = m_mdiArea->activeSubWindow();
+ if (activeSubWindow == 0)
+ return 0;
- QWidget* activeWindowWidget = activeSubWindow->widget();
- if (activeWindowWidget == 0)
- return 0;
+ QWidget* activeWindowWidget = activeSubWindow->widget();
+ if (activeWindowWidget == 0)
+ return 0;
- CDisplayWindow* cDisplayWindow = qobject_cast<CDisplayWindow*>(activeWindowWidget);
- if (cDisplayWindow == 0)
- return 0;
+ CDisplayWindow* cDisplayWindow = qobject_cast<CDisplayWindow*>(activeWindowWidget);
+ if (cDisplayWindow == 0)
+ return 0;
- CDisplay* cDisplay = cDisplayWindow->displayWidget();
- if (cDisplay == 0)
- return 0;
+ CDisplay* cDisplay = cDisplayWindow->displayWidget();
+ if (cDisplay == 0)
+ return 0;
- QWidget* textView = cDisplay->view();
- if (textView == 0)
- return 0;
+ QWidget* textView = cDisplay->view();
+ if (textView == 0)
+ return 0;
- QWebView* webView = qobject_cast<QWebView*>(textView);
- return webView;
+ QWebView* webView = qobject_cast<QWebView*>(textView);
+ return webView;
}
diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h
index d6a1fe9..0500247 100644
--- a/src/frontend/display/bthtmlfindtext.h
+++ b/src/frontend/display/bthtmlfindtext.h
@@ -14,22 +14,21 @@
class CMDIArea;
class QWebView;
-class BtHtmlFindText : public QDialog
-{
- Q_OBJECT
+class BtHtmlFindText : public QDialog {
+ Q_OBJECT
-public:
- BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent=0, Qt::WindowFlags f=0);
- ~BtHtmlFindText();
-public slots:
- void findNext();
- void findPrevious();
- void doHide();
-private:
- QWebView* getActiveWindowWebView();
- Ui_findTextDialog ui;
- CMDIArea* m_mdiArea;
+ public:
+ BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent = 0, Qt::WindowFlags f = 0);
+ ~BtHtmlFindText();
+ public slots:
+ void findNext();
+ void findPrevious();
+ void doHide();
+ private:
+ QWebView* getActiveWindowWebView();
+ Ui_findTextDialog ui;
+ CMDIArea* m_mdiArea;
};
-#endif
+#endif
diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp
index 823a07c..b1b97a6 100644
--- a/src/frontend/display/bthtmljsobject.cpp
+++ b/src/frontend/display/bthtmljsobject.cpp
@@ -24,159 +24,135 @@ using namespace InfoDisplay;
// so that Javascript can call this class, or this class can call Javascript.
// Access to DOM objects is implemented in Javascript and is communicated back to c++ through this class
-BtHtmlJsObject::BtHtmlJsObject(BtHtmlReadDisplay* display)
- : m_display(display)
-{
+BtHtmlJsObject::BtHtmlJsObject(BtHtmlReadDisplay* display)
+ : m_display(display) {
}
-void BtHtmlJsObject::moveToAnchor(const QString& anchor)
-{
- // Call gotoAnchor in Javascript
- emit gotoAnchor(anchor);
+void BtHtmlJsObject::moveToAnchor(const QString& anchor) {
+ // Call gotoAnchor in Javascript
+ emit gotoAnchor(anchor);
}
-void BtHtmlJsObject::setBodyEditable(bool editable)
-{
- if (editable)
- emit setDocumentEditable();
- else
- emit setDocumentNotEditable();
+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;
- m_dndData.startPos = QPoint(x,y);
- m_dndData.url = url;
+void BtHtmlJsObject::mouseDownLeft(const QString& url, const int& x, const int& y) {
+ m_dndData.mousePressed = true;
+ m_dndData.isDragging = false;
+ m_dndData.startPos = QPoint(x, y);
+ m_dndData.url = url;
}
-
-void BtHtmlJsObject::mouseClick(const QString& url)
-{
- m_dndData.mousePressed = false;
- if (!url.isEmpty() && CReferenceManager::isHyperlink(url))
- {
- QString module;
- QString key;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(url, module, key, type);
- if (module.isEmpty())
- {
- module = CReferenceManager::preferredModule( type );
- }
- m_display->connectionsProxy()->emitReferenceClicked(module,key);
- }
+void BtHtmlJsObject::mouseClick(const QString& url) {
+ m_dndData.mousePressed = false;
+ if (!url.isEmpty() && CReferenceManager::isHyperlink(url)) {
+ QString module;
+ QString key;
+ CReferenceManager::Type type;
+
+ CReferenceManager::decodeHyperlink(url, module, key, type);
+ if (module.isEmpty()) {
+ module = CReferenceManager::preferredModule( type );
+ }
+ m_display->connectionsProxy()->emitReferenceClicked(module, key);
+ }
}
-void BtHtmlJsObject::mouseDownRight(const QString& url, const QString& lemma)
-{
- m_display->setActiveAnchor(url);
- if (lemma.isEmpty())
- m_display->setLemma(QString::null);
- else
- m_display->setLemma(lemma);
+void BtHtmlJsObject::mouseDownRight(const QString& url, const QString& lemma) {
+ m_display->setActiveAnchor(url);
+ if (lemma.isEmpty())
+ m_display->setLemma(QString::null);
+ else
+ m_display->setLemma(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)
-{
- if(!m_dndData.isDragging && m_dndData.mousePressed)
- {
+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);
- if ((current - m_dndData.startPos).manhattanLength() > 4 /*qApp->startDragDistance()*/ )
- {
- QDrag* drag = 0;
- if (m_dndData.url.size() != 0 )
- {
- // create a new bookmark drag!
- QString moduleName = QString::null;
- QString keyName = QString::null;
- CReferenceManager::Type type;
- if ( !CReferenceManager::decodeHyperlink(m_dndData.url, moduleName, keyName, type) )
- return;
- drag = new QDrag(m_display->view());
- 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 );
- mimedata->setText(key->strippedText()); // This works across applications!
- }
- }
- if (drag)
- {
- m_dndData.isDragging = true;
- m_dndData.mousePressed = false;
- drag->exec(Qt::CopyAction, Qt::CopyAction);
- }
- }
- }
- else if (m_display->getMouseTracking() && !shiftKey)
- {
- // no mouse button pressed and tracking enabled
+ QPoint current(x, y);
+ if ((current - m_dndData.startPos).manhattanLength() > 4 /*qApp->startDragDistance()*/ ) {
+ QDrag* drag = 0;
+ if (m_dndData.url.size() != 0 ) {
+ // create a new bookmark drag!
+ QString moduleName = QString::null;
+ QString keyName = QString::null;
+ CReferenceManager::Type type;
+ if ( !CReferenceManager::decodeHyperlink(m_dndData.url, moduleName, keyName, type) )
+ return;
+ drag = new QDrag(m_display->view());
+ 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 );
+ mimedata->setText(key->strippedText()); // This works across applications!
+ }
+ }
+ if (drag) {
+ m_dndData.isDragging = true;
+ m_dndData.mousePressed = false;
+ drag->exec(Qt::CopyAction, Qt::CopyAction);
+ }
+ }
+ }
+ else if (m_display->getMouseTracking() && !shiftKey) {
+ // 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));
+ 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)
-{
+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++)
- {
- QString attrPair = attrList[i];
- QStringList attr = attrPair.split("=");
- if (attr.count() == 2)
- {
- QString attrName = attr[0];
- QString attrValue= attr[1];
- if (attrName == "note")
- {
- infoList.append( qMakePair(CInfoDisplay::Footnote, attrValue));
- }
- if (attrName == "lemma")
- {
- infoList.append( qMakePair(CInfoDisplay::Lemma, attrValue));
- }
- if (attrName == "morph")
- {
- infoList.append( qMakePair(CInfoDisplay::Morph, attrValue));
- }
- if (attrName == "expansion")
- {
- infoList.append( qMakePair(CInfoDisplay::Abbreviation, attrValue));
- }
- if (attrName == "crossrefs")
- {
- infoList.append( qMakePair(CInfoDisplay::CrossReference, attrValue));
- }
- }
- }
- // Update the mag if valid attributes were found
- if (!(infoList.isEmpty()))
- {
- CPointers::infoDisplay()->setInfo(infoList);
- }
+ CInfoDisplay::ListInfoData infoList;
+ QStringList attrList = attributes.split("||");
+ for (int i = 0; i < attrList.count(); i++) {
+ QString attrPair = attrList[i];
+ QStringList attr = attrPair.split("=");
+ if (attr.count() == 2) {
+ QString attrName = attr[0];
+ QString attrValue = attr[1];
+ if (attrName == "note") {
+ infoList.append( qMakePair(CInfoDisplay::Footnote, attrValue));
+ }
+ if (attrName == "lemma") {
+ infoList.append( qMakePair(CInfoDisplay::Lemma, attrValue));
+ }
+ if (attrName == "morph") {
+ infoList.append( qMakePair(CInfoDisplay::Morph, attrValue));
+ }
+ if (attrName == "expansion") {
+ infoList.append( qMakePair(CInfoDisplay::Abbreviation, attrValue));
+ }
+ if (attrName == "crossrefs") {
+ infoList.append( qMakePair(CInfoDisplay::CrossReference, attrValue));
+ }
+ }
+ }
+ // 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
+// clearing the previous attribute effectively stops any time out event
// that is in progress
-void BtHtmlJsObject::clearPrevAttribute()
-{
+void BtHtmlJsObject::clearPrevAttribute() {
m_prev_attributes = "";
}
diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h
index eeba3af..d418b71 100644
--- a/src/frontend/display/bthtmljsobject.h
+++ b/src/frontend/display/bthtmljsobject.h
@@ -14,48 +14,46 @@
class BtHtmlReadDisplay;
-class BtHtmlJsObject: public QObject
-{
- Q_OBJECT
-
-public:
- BtHtmlJsObject(BtHtmlReadDisplay* display);
- ~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);
- void mouseDownLeft(const QString& url, const int& X, const int& Y);
- void mouseDownRight(const QString& url, const QString& lemma);
- void timeOutEvent(const QString& attributes);
-
-signals:
- void startTimer(int time);
- void mouseMoveAttribute(const QString& attrName, const QString& attrValue);
- void gotoAnchor(const QString& anchor);
- void selectAll();
- void setDocumentEditable();
- void setDocumentNotEditable();
-
-private:
- int m_int;
- BtHtmlReadDisplay* m_display;
- QString m_prev_attributes;
-
- struct DNDData
- {
- bool mousePressed;
- bool isDragging;
- QPoint startPos;
- QString url;
- enum DragType
- {
- Link,
- Text
- } dragType;
- } m_dndData;
+class BtHtmlJsObject: public QObject {
+ Q_OBJECT
+
+ public:
+ BtHtmlJsObject(BtHtmlReadDisplay* display);
+ ~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);
+ void mouseDownLeft(const QString& url, const int& X, const int& Y);
+ void mouseDownRight(const QString& url, const QString& lemma);
+ void timeOutEvent(const QString& attributes);
+
+ signals:
+ void startTimer(int time);
+ void mouseMoveAttribute(const QString& attrName, const QString& attrValue);
+ void gotoAnchor(const QString& anchor);
+ void selectAll();
+ void setDocumentEditable();
+ void setDocumentNotEditable();
+
+ private:
+ int m_int;
+ BtHtmlReadDisplay* m_display;
+ QString m_prev_attributes;
+
+ struct DNDData {
+ bool mousePressed;
+ bool isDragging;
+ QPoint startPos;
+ QString url;
+ enum DragType {
+ Link,
+ Text
+ } dragType;
+ } m_dndData;
};
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index 53d10e7..7ce6f40 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -34,261 +34,231 @@ static QString javascript; // Initialized from file bthtml.js
BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWidget)
- : QWebPage(parentWidget),CReadDisplay(readWindow), m_magTimerId(0), m_view(0), m_jsObject(0)
+ : QWebPage(parentWidget), CReadDisplay(readWindow), m_magTimerId(0), m_view(0), m_jsObject(0)
{
- settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
- m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow);
- m_view->setAcceptDrops(true);
- m_view->setPage(this);
- setParent(m_view);
- m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- m_view->setHtml("");
- initJavascript();
- bool ok = connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
- Q_ASSERT(ok);
+ settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
+ m_view = new BtHtmlReadDisplayView(this, parentWidget ? parentWidget : readWindow);
+ m_view->setAcceptDrops(true);
+ m_view->setPage(this);
+ setParent(m_view);
+ m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_view->setHtml("");
+ initJavascript();
+ bool ok = connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
+ Q_ASSERT(ok);
}
-BtHtmlReadDisplay::~BtHtmlReadDisplay()
-{
- setView(0);
+BtHtmlReadDisplay::~BtHtmlReadDisplay() {
+ setView(0);
}
// Read javascript into memory once and create the c++ javascript object
-void BtHtmlReadDisplay::initJavascript()
-{
- // read bthtml.js javascript file once
- if (javascript.size() == 0)
- {
- QString jsFile = util::filesystem::DirectoryUtil::getJavascriptDir().canonicalPath() + "/bthtml.js";
- QFile file(jsFile);
- if (file.open(QFile::ReadOnly))
- {
- while (!file.atEnd())
- {
- QByteArray line = file.readLine();
- javascript = javascript + line;
- }
- file.close();
- }
- }
-
- // Setup BtHtmlJsObject which will be called from javascript
- m_jsObject = new BtHtmlJsObject(this);
- m_jsObject->setObjectName("btHtmlJsObject");
+void BtHtmlReadDisplay::initJavascript() {
+ // read bthtml.js javascript file once
+ if (javascript.size() == 0) {
+ QString jsFile = util::filesystem::DirectoryUtil::getJavascriptDir().canonicalPath() + "/bthtml.js";
+ QFile file(jsFile);
+ if (file.open(QFile::ReadOnly)) {
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine();
+ javascript = javascript + line;
+ }
+ file.close();
+ }
+ }
+
+ // Setup BtHtmlJsObject which will be called from javascript
+ m_jsObject = new BtHtmlJsObject(this);
+ m_jsObject->setObjectName("btHtmlJsObject");
}
-// When the QWebFrame is cleared, this function is called to install the
+// When the QWebFrame is cleared, this function is called to install the
// javascript object (BtHtmlJsObject class) into the Javascript model
-void BtHtmlReadDisplay::loadJSObject()
-{
- mainFrame()->addToJavaScriptWindowObject(m_jsObject->objectName(), m_jsObject);
+void BtHtmlReadDisplay::loadJSObject() {
+ mainFrame()->addToJavaScriptWindowObject(m_jsObject->objectName(), m_jsObject);
}
-const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CDisplay::TextPart part)
-{
- switch (part)
- {
- case Document:
- {
- if (format == HTMLText)
- {
- return mainFrame()->toHtml();
- }
- else
- {
- CDisplayWindow* window = parentWindow();
- CSwordKey* const key = window->key();
- 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.
- Q_ASSERT(module->type() == CSwordModuleInfo::Lexicon ||
- module->type() == CSwordModuleInfo::Commentary ||
- module->type() == CSwordModuleInfo::GenericBook);
- if (module->type() == CSwordModuleInfo::Lexicon ||
- 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.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CPointers::backend()->setFilterOptions(filterOptions);
-
- return QString(key->strippedText()).append("\n(")
- .append(key->key())
- .append(", ")
- .append(key->module()->name())
- .append(")");
- }
- }
- }
-
- case SelectedText:
- {
- if (!hasSelection())
- {
- return QString::null;
- }
- else if (format == HTMLText)
- {
- // TODO: It does not appear this is ever called
- }
- else
- { //plain text requested
- return selectedText();
- }
- }
-
- case AnchorOnly:
- {
- QString moduleName;
- QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
-
- return keyName;
- }
-
- case AnchorTextOnly:
- {
- QString moduleName;
- QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
-
- if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName))
- {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( keyName );
-
- return key->strippedText();
- }
- return QString::null;
- }
-
- case AnchorWithText:
- {
- QString moduleName;
- QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
-
- if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName))
- {
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
- key->key( keyName );
-
- //TODO: This is a BAD HACK, we have to fnd a better solution to manage the settings now
- CSwordBackend::FilterOptions filterOptions;
- filterOptions.footnotes = false;
- filterOptions.strongNumbers = false;
- filterOptions.morphTags = false;
- filterOptions.lemmas = false;
- filterOptions.scriptureReferences = false;
- filterOptions.textualVariants = false;
-
- CPointers::backend()->setFilterOptions(filterOptions);
-
- return QString(key->strippedText()).append("\n(")
- .append(key->key())
- .append(", ")
- .append(key->module()->name())
- .append(")");
- /* ("%1\n(%2, %3)")
- .arg()
- .arg(key->key())
- .arg(key->module()->name());*/
- }
- return QString::null;
- }
- default:
- return QString::null;
- }
- return QString();
+const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CDisplay::TextPart part) {
+ switch (part) {
+ case Document: {
+ if (format == HTMLText) {
+ return mainFrame()->toHtml();
+ }
+ else {
+ CDisplayWindow* window = parentWindow();
+ CSwordKey* const key = window->key();
+ 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.
+ Q_ASSERT(module->type() == CSwordModuleInfo::Lexicon ||
+ module->type() == CSwordModuleInfo::Commentary ||
+ module->type() == CSwordModuleInfo::GenericBook);
+ if (module->type() == CSwordModuleInfo::Lexicon ||
+ 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.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CPointers::backend()->setFilterOptions(filterOptions);
+
+ return QString(key->strippedText()).append("\n(")
+ .append(key->key())
+ .append(", ")
+ .append(key->module()->name())
+ .append(")");
+ }
+ }
+ }
+
+ case SelectedText: {
+ if (!hasSelection()) {
+ return QString::null;
+ }
+ else if (format == HTMLText) {
+ // TODO: It does not appear this is ever called
+ }
+ else { //plain text requested
+ return selectedText();
+ }
+ }
+
+ case AnchorOnly: {
+ QString moduleName;
+ QString keyName;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+
+ return keyName;
+ }
+
+ case AnchorTextOnly: {
+ QString moduleName;
+ QString keyName;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+
+ if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) {
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key( keyName );
+
+ return key->strippedText();
+ }
+ return QString::null;
+ }
+
+ case AnchorWithText: {
+ QString moduleName;
+ QString keyName;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+
+ if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) {
+ boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
+ key->key( keyName );
+
+ //TODO: This is a BAD HACK, we have to fnd a better solution to manage the settings now
+ CSwordBackend::FilterOptions filterOptions;
+ filterOptions.footnotes = false;
+ filterOptions.strongNumbers = false;
+ filterOptions.morphTags = false;
+ filterOptions.lemmas = false;
+ filterOptions.scriptureReferences = false;
+ filterOptions.textualVariants = false;
+
+ CPointers::backend()->setFilterOptions(filterOptions);
+
+ return QString(key->strippedText()).append("\n(")
+ .append(key->key())
+ .append(", ")
+ .append(key->module()->name())
+ .append(")");
+ /* ("%1\n(%2, %3)")
+ .arg()
+ .arg(key->key())
+ .arg(key->module()->name());*/
+ }
+ return QString::null;
+ }
+ default:
+ return QString::null;
+ }
+ return QString();
}
// Puts html text and javascript into QWebView
-void BtHtmlReadDisplay::setText( const QString& newText )
-{
- QString jsText = newText;
+void BtHtmlReadDisplay::setText( const QString& newText ) {
+ QString jsText = newText;
- jsText.replace(body,jsBegin+javascript+jsEnd+body);
+ jsText.replace(body, jsBegin + javascript + jsEnd + body);
- // Disconnect any previous connect 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()));
- Q_ASSERT(ok);
+ // Disconnect any previous connect 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()));
+ Q_ASSERT(ok);
- // Send text to the html viewer
- m_view->setHtml(jsText);
+ // Send text to the html viewer
+ m_view->setHtml(jsText);
}
// See if any text is selected
-bool BtHtmlReadDisplay::hasSelection()
-{
- if (selectedText().isEmpty())
- return false;
- return true;
+bool BtHtmlReadDisplay::hasSelection() {
+ if (selectedText().isEmpty())
+ return false;
+ return true;
}
// Reimplementation
// Returns the BtHtmlReadDisplayView object
-QWidget* BtHtmlReadDisplay::view()
-{
- return m_view;
+QWidget* BtHtmlReadDisplay::view() {
+ return m_view;
}
// Select all text in the viewer
-void BtHtmlReadDisplay::selectAll()
-{
- m_jsObject->setBodyEditable(true);
+void BtHtmlReadDisplay::selectAll() {
+ m_jsObject->setBodyEditable(true);
m_view->triggerPageAction( QWebPage::MoveToStartOfDocument, true );
m_view->triggerPageAction( QWebPage::SelectEndOfDocument, true );
- m_jsObject->setBodyEditable(false);
+ m_jsObject->setBodyEditable(false);
}
// Scroll QWebView to the correct location as specified by the anchor
-void BtHtmlReadDisplay::moveToAnchor( const QString& anchor )
-{
- slotGoToAnchor(anchor);
+void BtHtmlReadDisplay::moveToAnchor( const QString& anchor ) {
+ slotGoToAnchor(anchor);
}
// Scroll the QWebView to the correct location specified by anchor
-void BtHtmlReadDisplay::slotGoToAnchor(const QString& anchor)
-{
- m_jsObject->moveToAnchor(anchor);
+void BtHtmlReadDisplay::slotGoToAnchor(const QString& anchor) {
+ m_jsObject->moveToAnchor(anchor);
}
-// Save the Lemma (Strongs number) attribute
-void BtHtmlReadDisplay::setLemma(const QString& lemma)
-{
- m_nodeInfo[ CDisplay::Lemma ] = lemma;
+// Save the Lemma (Strongs number) attribute
+void BtHtmlReadDisplay::setLemma(const QString& lemma) {
+ m_nodeInfo[ CDisplay::Lemma ] = lemma;
}
// Open the Find text dialog
-void BtHtmlReadDisplay::openFindTextDialog()
-{
- CMDIArea* mdiArea = parentWindow()->mdi();
- showBtHtmlFindText(mdiArea);
+void BtHtmlReadDisplay::openFindTextDialog() {
+ CMDIArea* mdiArea = parentWindow()->mdi();
+ showBtHtmlFindText(mdiArea);
}
// Send "completed" signal when the text is finished loading into the viewer
-void BtHtmlReadDisplay::slotLoadFinished(bool)
-{
- emit completed();
+void BtHtmlReadDisplay::slotLoadFinished(bool) {
+ emit completed();
}
// 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 )
-{
+void BtHtmlReadDisplay::javaScriptConsoleMessage (const QString& message, int lineNumber, const QString& sourceID ) {
}
#endif
@@ -297,77 +267,64 @@ 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)
+ : QWebView(parent), m_display(displayWidget) {
}
-BtHtmlReadDisplayView::~BtHtmlReadDisplayView()
- {
- setPage(0);
- }
+BtHtmlReadDisplayView::~BtHtmlReadDisplayView() {
+ setPage(0);
+}
// Create the right mouse context menus
-void BtHtmlReadDisplayView::contextMenuEvent(QContextMenuEvent* event)
-{
- if (QMenu* popup = m_display->installedPopup())
- {
- popup->exec(event->globalPos());
- }
+void BtHtmlReadDisplayView::contextMenuEvent(QContextMenuEvent* event) {
+ if (QMenu* popup = m_display->installedPopup()) {
+ popup->exec(event->globalPos());
+ }
}
// Reimplementation from QWidget
-void BtHtmlReadDisplayView::dropEvent( QDropEvent* e )
-{
- if (e->mimeData()->hasFormat("BibleTime/Bookmark"))
- {
- //see docs for BTMimeData and QMimeData
- const QMimeData* mimedata = e->mimeData();
- if (mimedata != 0)
- {
- const BTMimeData* btmimedata = qobject_cast<const BTMimeData*>(mimedata);
- if (btmimedata != 0)
- {
- BookmarkItem item = (qobject_cast<const BTMimeData*>(e->mimeData()))->bookmark();
- m_display->connectionsProxy()->emitReferenceDropped(item.key());
- e->acceptProposedAction();
- return;
- }
- }
- };
- //don't accept the action!
- e->ignore();
+void BtHtmlReadDisplayView::dropEvent( QDropEvent* e ) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark")) {
+ //see docs for BTMimeData and QMimeData
+ const QMimeData* mimedata = e->mimeData();
+ if (mimedata != 0) {
+ const BTMimeData* btmimedata = qobject_cast<const BTMimeData*>(mimedata);
+ if (btmimedata != 0) {
+ BookmarkItem item = (qobject_cast<const BTMimeData*>(e->mimeData()))->bookmark();
+ m_display->connectionsProxy()->emitReferenceDropped(item.key());
+ e->acceptProposedAction();
+ return;
+ }
+ }
+ };
+ //don't accept the action!
+ e->ignore();
}
// Reimplementation from QWebView
-void BtHtmlReadDisplayView::dragEnterEvent( QDragEnterEvent* e )
-{
- if (e->mimeData()->hasFormat("BibleTime/Bookmark"))
- {
- e->acceptProposedAction();
- return;
- }
- //don't accept the action!
- e->ignore();
+void BtHtmlReadDisplayView::dragEnterEvent( QDragEnterEvent* e ) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark")) {
+ e->acceptProposedAction();
+ return;
+ }
+ //don't accept the action!
+ e->ignore();
}
// Reimplementation from QWebView
-void BtHtmlReadDisplayView::dragMoveEvent( QDragMoveEvent* e )
-{
- if (e->mimeData()->hasFormat("BibleTime/Bookmark"))
- {
- e->acceptProposedAction();
- return;
- }
- //don't accept the action!
- e->ignore();
+void BtHtmlReadDisplayView::dragMoveEvent( QDragMoveEvent* e ) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark")) {
+ e->acceptProposedAction();
+ return;
+ }
+ //don't accept the action!
+ e->ignore();
}
-bool BtHtmlReadDisplayView::event(QEvent* e)
-{
+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.
+ // is in progress.
if ( e->type() == QEvent::Leave )
m_display->m_jsObject->clearPrevAttribute();
return QWidget::event(e);
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index 8a832bc..020a685 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -33,92 +33,87 @@ class QEvent;
/** The implementation for the HTML read display.
* @author The BibleTime team
*/
-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 );
-
- // Sets the new text for this display widget.
- virtual void setText( const QString& newText );
- virtual bool hasSelection();
-
- // Reimplementation.
- virtual void selectAll();
- virtual void moveToAnchor( const QString& anchor );
- virtual void openFindTextDialog();
- virtual QMap<CDisplay::NodeInfoType, QString> getCurrentNodeInfo()
- {
- return m_nodeInfo;
- }
- QWidget* view();
- void setLemma(const QString& lemma);
-
-public slots:
- void loadJSObject();
- void slotLoadFinished(bool);
-
-signals:
- void completed();
-
-protected:
- friend class CDisplay;
- BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
- virtual ~BtHtmlReadDisplay();
- void slotGoToAnchor(const QString& anchor);
- struct DNDData
- {
- bool mousePressed;
- bool isDragging;
- QString selection;
- QPoint startPos;
- enum DragType
- {
- Link,
- Text
- } dragType;
- }
- m_dndData;
-
- QMap<NodeInfoType, QString> m_nodeInfo;
- int m_magTimerId;
+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 );
+
+ // Sets the new text for this display widget.
+ virtual void setText( const QString& newText );
+ virtual bool hasSelection();
+
+ // Reimplementation.
+ virtual void selectAll();
+ virtual void moveToAnchor( const QString& anchor );
+ virtual void openFindTextDialog();
+ virtual QMap<CDisplay::NodeInfoType, QString> getCurrentNodeInfo() {
+ return m_nodeInfo;
+ }
+ QWidget* view();
+ void setLemma(const QString& lemma);
+
+ public slots:
+ void loadJSObject();
+ void slotLoadFinished(bool);
+
+ signals:
+ void completed();
+
+ protected:
+ friend class CDisplay;
+ BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
+ virtual ~BtHtmlReadDisplay();
+ void slotGoToAnchor(const QString& anchor);
+ struct DNDData {
+ bool mousePressed;
+ bool isDragging;
+ QString selection;
+ QPoint startPos;
+ enum DragType {
+ Link,
+ Text
+ } dragType;
+ }
+ m_dndData;
+
+ QMap<NodeInfoType, QString> m_nodeInfo;
+ int m_magTimerId;
// 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 );
+ void javaScriptConsoleMessage (const QString & message, int lineNumber, const QString & sourceID );
#endif
-private:
- void initJavascript();
- BtHtmlReadDisplayView* m_view;
- BtHtmlJsObject* m_jsObject;
- QString m_currentAnchorCache;
+ private:
+ void initJavascript();
+ BtHtmlReadDisplayView* m_view;
+ BtHtmlJsObject* m_jsObject;
+ QString m_currentAnchorCache;
};
-class BtHtmlReadDisplayView : public QWebView, public CPointers
-{
- Q_OBJECT
-protected:
- friend class BtHtmlReadDisplay;
- void contextMenuEvent(QContextMenuEvent* event);
- BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent);
- ~BtHtmlReadDisplayView();
- bool event(QEvent* e);
-
-private:
- BtHtmlReadDisplay* m_display;
- void dropEvent( QDropEvent* e );
- void dragEnterEvent( QDragEnterEvent* e );
- void dragMoveEvent( QDragMoveEvent* e );
+class BtHtmlReadDisplayView : public QWebView, public CPointers {
+ Q_OBJECT
+ protected:
+ friend class BtHtmlReadDisplay;
+ void contextMenuEvent(QContextMenuEvent* event);
+ BtHtmlReadDisplayView(BtHtmlReadDisplay* display, QWidget* parent);
+ ~BtHtmlReadDisplayView();
+ bool event(QEvent* e);
+
+ private:
+ BtHtmlReadDisplay* m_display;
+ void dropEvent( QDropEvent* e );
+ void dragEnterEvent( QDragEnterEvent* e );
+ void dragMoveEvent( QDragMoveEvent* e );
};
#endif
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index 9333bd9..b66f8af 100644
--- a/src/frontend/display/cdisplay.cpp
+++ b/src/frontend/display/cdisplay.cpp
@@ -34,175 +34,174 @@ typedef BtHtmlReadDisplay HTMLREADDISPLAY;
CDisplayConnections::CDisplayConnections( CDisplay* display ) : m_display(display) {}
void CDisplayConnections::selectAll() {
- m_display->selectAll();
+ m_display->selectAll();
}
void CDisplayConnections::saveAsHTML() {
- m_display->save(CDisplay::HTMLText, CDisplay::Document);
+ m_display->save(CDisplay::HTMLText, CDisplay::Document);
}
void CDisplayConnections::saveAsPlain() {
- m_display->save(CDisplay::PlainText, CDisplay::Document);
+ m_display->save(CDisplay::PlainText, CDisplay::Document);
}
/** Emits the signal. */
void CDisplayConnections::emitReferenceClicked( const QString& module, const QString& key) {
- qDebug("CDisplayConnections::emitReferenceClicked");
- qDebug() << "Module: " << module << " key: " << key;
- emit referenceClicked( module, key );
+ qDebug("CDisplayConnections::emitReferenceClicked");
+ qDebug() << "Module: " << module << " key: " << key;
+ emit referenceClicked( module, key );
}
/** Emits the signal. */
void CDisplayConnections::emitReferenceDropped( const QString& key) {
- emit referenceDropped(key);
+ emit referenceDropped(key);
}
/** Emits the signal. */
void CDisplayConnections::emitTextChanged() {
- emit textChanged();
+ emit textChanged();
}
void CDisplayConnections::copyAll() {
- m_display->copy(CDisplay::PlainText, CDisplay::Document);
+ m_display->copy(CDisplay::PlainText, CDisplay::Document);
}
/** No descriptions */
void CDisplayConnections::copySelection() {
- qWarning("copyign the selected text");
- m_display->copy(CDisplay::PlainText, CDisplay::SelectedText);
+ qWarning("copyign the selected text");
+ m_display->copy(CDisplay::PlainText, CDisplay::SelectedText);
}
void CDisplayConnections::printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- m_display->print(CDisplay::Document, displayOptions, filterOptions);
+ m_display->print(CDisplay::Document, displayOptions, filterOptions);
}
void CDisplayConnections::printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- m_display->print(CDisplay::AnchorWithText, displayOptions, filterOptions);
+ m_display->print(CDisplay::AnchorWithText, displayOptions, filterOptions);
}
void CDisplayConnections::copyAnchorOnly() {
- m_display->copy(CDisplay::PlainText, CDisplay::AnchorOnly);
+ m_display->copy(CDisplay::PlainText, CDisplay::AnchorOnly);
}
void CDisplayConnections::copyAnchorTextOnly() {
- m_display->copy(CDisplay::PlainText, CDisplay::AnchorTextOnly);
+ m_display->copy(CDisplay::PlainText, CDisplay::AnchorTextOnly);
}
void CDisplayConnections::copyAnchorWithText() {
- m_display->copy(CDisplay::PlainText, CDisplay::AnchorWithText);
+ m_display->copy(CDisplay::PlainText, CDisplay::AnchorWithText);
}
void CDisplayConnections::saveAnchorWithText() {
- m_display->save(CDisplay::PlainText, CDisplay::AnchorWithText);
+ m_display->save(CDisplay::PlainText, CDisplay::AnchorWithText);
}
void CDisplayConnections::clear() {
- m_display->setText(QString::null);
+ m_display->setText(QString::null);
}
void CDisplayConnections::zoomIn() {
- m_display->zoomIn();
+ m_display->zoomIn();
}
void CDisplayConnections::zoomOut() {
- m_display->zoomOut();
+ m_display->zoomOut();
}
void CDisplayConnections::openFindTextDialog() {
- m_display->openFindTextDialog();
+ m_display->openFindTextDialog();
}
/*----------------------*/
-CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent )
-{
- return new HTMLREADDISPLAY(readWindow, parent);
+CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent ) {
+ return new HTMLREADDISPLAY(readWindow, parent);
}
CWriteDisplay* CDisplay::createWriteInstance( CWriteWindow* writeWindow, const CWriteDisplay::WriteDisplayType& type, QWidget* parent ) {
- // qWarning("CDisplay::createWriteInstance");
- if (type == PlainTextDisplay) {
- return new CPlainWriteDisplay(writeWindow, parent);
- }
- else {
- return new CHTMLWriteDisplay(writeWindow, parent);
- };
+ // qWarning("CDisplay::createWriteInstance");
+ if (type == PlainTextDisplay) {
+ return new CPlainWriteDisplay(writeWindow, parent);
+ }
+ else {
+ return new CHTMLWriteDisplay(writeWindow, parent);
+ };
}
CDisplay::CDisplay(CDisplayWindow* parent) :
-m_parentWindow(parent),
-m_connections( new CDisplayConnections( this ) ),
-m_popup(0) {}
+ m_parentWindow(parent),
+ m_connections( new CDisplayConnections( this ) ),
+ m_popup(0) {}
CDisplay::~CDisplay() {
- delete m_connections;
+ delete m_connections;
}
bool CDisplay::copy( const CDisplay::TextType format, const CDisplay::TextPart part ) {
- QApplication::clipboard()->setText( this->text(format, part) );
- return true;
+ QApplication::clipboard()->setText( this->text(format, part) );
+ return true;
}
bool CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart part ) {
- // qWarning("CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart part )");
- const QString content = text(format, part);
- QString filter = QString::null;
+ // qWarning("CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart part )");
+ const QString content = text(format, part);
+ QString filter = QString::null;
- switch (format) {
- case HTMLText:
- filter = QObject::tr("HTML files") + QString(" (*.html *.htm);;") + QObject::tr("All files") + QString(" (*.*)");
- break;
- case PlainText:
- filter = QObject::tr("Text files") + QString(" (*.txt);;") + QObject::tr("All files") + QString(" (*.*)");
- break;
- }
+ switch (format) {
+ case HTMLText:
+ filter = QObject::tr("HTML files") + QString(" (*.html *.htm);;") + QObject::tr("All files") + QString(" (*.*)");
+ break;
+ case PlainText:
+ filter = QObject::tr("Text files") + QString(" (*.txt);;") + QObject::tr("All files") + QString(" (*.*)");
+ break;
+ }
- const QString filename = QFileDialog::getSaveFileName(0, QObject::tr("Save document ..."), "", filter);
+ const QString filename = QFileDialog::getSaveFileName(0, QObject::tr("Save document ..."), "", filter);
- if (!filename.isEmpty()) {
- CToolClass::savePlainFile(filename, content);
- }
- return true;
+ if (!filename.isEmpty()) {
+ CToolClass::savePlainFile(filename, content);
+ }
+ return true;
}
/** Emits the signal which used when a reference was clicked. */
void CDisplay::emitReferenceClicked( const QString& reference ) {
- QString module, key;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(reference, module, key, type);
- if (module.isEmpty()) {
- module = CReferenceManager::preferredModule( type );
- }
- m_connections->emitReferenceClicked(module, key);
+ QString module, key;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(reference, module, key, type);
+ if (module.isEmpty()) {
+ module = CReferenceManager::preferredModule( type );
+ }
+ m_connections->emitReferenceClicked(module, key);
}
/** Used when a reference was dropped onto the widget. */
void CDisplay::emitReferenceDropped( const QString& reference ) {
- QString module;
- QString key;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(reference, module, key, type);
- m_connections->emitReferenceDropped(key);
+ QString module;
+ QString key;
+ CReferenceManager::Type type;
+ CReferenceManager::decodeHyperlink(reference, module, key, type);
+ m_connections->emitReferenceDropped(key);
}
/** Returns the connections obect used for signas and slots. */
CDisplayConnections* CDisplay::connectionsProxy() const {
- return m_connections;
+ return m_connections;
}
CDisplayWindow* CDisplay::parentWindow() const {
- return m_parentWindow;
+ return m_parentWindow;
}
/** Installs the popup which should be opened when the right mouse button was pressed. */
void CDisplay::installPopup( QMenu* popup ) {
- m_popup = popup;
+ m_popup = popup;
}
/** Returns the popup menu which was set by installPopupMenu() */
QMenu* CDisplay::installedPopup() {
- return m_popup;
+ return m_popup;
}
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index 59a6a37..0fdaa0e 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -34,153 +34,153 @@ class QMenu;
* @author The BibleTime team
*/
class CDisplay : public CPointers {
-public:
- enum WriteDisplayType {
- HTMLDisplay = 0,
- PlainTextDisplay
- };
-
- static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
- static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow, const WriteDisplayType& type = PlainTextDisplay, QWidget* parent = 0 );
-
- enum TextType {
- HTMLText, /* Used for HTML markup */
- PlainText /* Plain text without links etc. */
- };
- enum TextPart {
- Document, /* All text */
- SelectedText, /* Only the selected text */
- AnchorOnly,
- AnchorTextOnly,
- AnchorWithText
- };
-
- /**
- * Copies the given text with the specified format into the applications clipboard.
- */
- virtual bool copy( const CDisplay::TextType format, const CDisplay::TextPart part );
- /**
- * Saves the given text with the specified format into the applications clipboard.
- */
- virtual bool save( const CDisplay::TextType format, const CDisplay::TextPart part );
-
- //the pure virtual methods of this base class
-
- /** Returns the text in the given format.
- *
- */
- virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document ) = 0;
- /**
- * Sets the new text for this display widget.
- */
- virtual void setText( const QString& newText ) = 0;
- /**
- * Returns true if the display widget has a selection. Otherwise false.
- */
- virtual bool hasSelection() = 0;
- /**
- * Returns the view of this display widget.
- */
- virtual QWidget* view() = 0;
- /**
- * Selects the document text.
- */
- virtual void selectAll() = 0;
- /**
- * Returns the connections obect used for signas 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;
- /**
- * Installs the popup which should be opened when the right mouse button was pressed.
- */
- void installPopup( QMenu* popup );
- /**
- * Returns the popup menu which was set by installPopupMenu()
- */
- QMenu* installedPopup();
-
- virtual void zoomIn() {}
- virtual void zoomOut() {}
- virtual void openFindTextDialog() {}
-
- enum NodeInfoType {
- Lemma
- };
-
-
- virtual QMap<NodeInfoType, QString> getCurrentNodeInfo() {
- return QMap<NodeInfoType, QString>();
- }
-
-protected:
- /**
- * Used when a reference was dropped onto the widget.
- */
- void emitReferenceDropped( const QString& reference );
- /**
- * Emits the signal which used when a reference was clicked.
- */
- void emitReferenceClicked( const QString& reference );
-
-protected:
- CDisplay(CDisplayWindow* parent);
- virtual ~CDisplay();
-
-private:
- CDisplayWindow* m_parentWindow;
- CDisplayConnections* m_connections;
- QMenu* m_popup;
+ public:
+ enum WriteDisplayType {
+ HTMLDisplay = 0,
+ PlainTextDisplay
+ };
+
+ static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
+ static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow, const WriteDisplayType& type = PlainTextDisplay, QWidget* parent = 0 );
+
+ enum TextType {
+ HTMLText, /* Used for HTML markup */
+ PlainText /* Plain text without links etc. */
+ };
+ enum TextPart {
+ Document, /* All text */
+ SelectedText, /* Only the selected text */
+ AnchorOnly,
+ AnchorTextOnly,
+ AnchorWithText
+ };
+
+ /**
+ * Copies the given text with the specified format into the applications clipboard.
+ */
+ virtual bool copy( const CDisplay::TextType format, const CDisplay::TextPart part );
+ /**
+ * Saves the given text with the specified format into the applications clipboard.
+ */
+ virtual bool save( const CDisplay::TextType format, const CDisplay::TextPart part );
+
+ //the pure virtual methods of this base class
+
+ /** Returns the text in the given format.
+ *
+ */
+ virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document ) = 0;
+ /**
+ * Sets the new text for this display widget.
+ */
+ virtual void setText( const QString& newText ) = 0;
+ /**
+ * Returns true if the display widget has a selection. Otherwise false.
+ */
+ virtual bool hasSelection() = 0;
+ /**
+ * Returns the view of this display widget.
+ */
+ virtual QWidget* view() = 0;
+ /**
+ * Selects the document text.
+ */
+ virtual void selectAll() = 0;
+ /**
+ * Returns the connections obect used for signas 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;
+ /**
+ * Installs the popup which should be opened when the right mouse button was pressed.
+ */
+ void installPopup( QMenu* popup );
+ /**
+ * Returns the popup menu which was set by installPopupMenu()
+ */
+ QMenu* installedPopup();
+
+ virtual void zoomIn() {}
+ virtual void zoomOut() {}
+ virtual void openFindTextDialog() {}
+
+ enum NodeInfoType {
+ Lemma
+ };
+
+
+ virtual QMap<NodeInfoType, QString> getCurrentNodeInfo() {
+ return QMap<NodeInfoType, QString>();
+ }
+
+ protected:
+ /**
+ * Used when a reference was dropped onto the widget.
+ */
+ void emitReferenceDropped( const QString& reference );
+ /**
+ * Emits the signal which used when a reference was clicked.
+ */
+ void emitReferenceClicked( const QString& reference );
+
+ protected:
+ CDisplay(CDisplayWindow* parent);
+ virtual ~CDisplay();
+
+ private:
+ CDisplayWindow* m_parentWindow;
+ CDisplayConnections* m_connections;
+ QMenu* m_popup;
};
class CDisplayConnections : public QObject {
- Q_OBJECT
-public:
- CDisplayConnections( CDisplay* parent );
+ Q_OBJECT
+ public:
+ CDisplayConnections( CDisplay* parent );
-public slots:
- virtual void selectAll();
- void emitReferenceClicked( const QString& module, const QString& key);
- void emitReferenceDropped( const QString& key );
- void emitTextChanged();
+ public slots:
+ virtual void selectAll();
+ void emitReferenceClicked( const QString& module, const QString& key);
+ void emitReferenceDropped( const QString& key );
+ void emitTextChanged();
- //stuff which works in every CDisplay
- void saveAsPlain();
- void saveAsHTML();
- void saveAnchorWithText();
+ //stuff which works in every CDisplay
+ void saveAsPlain();
+ void saveAsHTML();
+ void saveAnchorWithText();
- void printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ void printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- void copySelection();
- void copyAll();
- void copyAnchorWithText();
- void copyAnchorTextOnly();
- void copyAnchorOnly();
+ void copySelection();
+ void copyAll();
+ void copyAnchorWithText();
+ void copyAnchorTextOnly();
+ void copyAnchorOnly();
- void clear();
+ void clear();
- void zoomIn();
- void zoomOut();
+ void zoomIn();
+ void zoomOut();
- void openFindTextDialog();
+ void openFindTextDialog();
-signals:
- void referenceClicked(const QString& module, const QString& key);
- void referenceDropped(const QString& key);
- void textChanged();
+ signals:
+ void referenceClicked(const QString& module, const QString& key);
+ void referenceDropped(const QString& key);
+ void textChanged();
-private:
- CDisplay* m_display;
+ private:
+ CDisplay* m_display;
- struct {
- QString module;
- QString key;
- } m_referenceClickedCache;
+ struct {
+ QString module;
+ QString key;
+ } m_referenceClickedCache;
};
#endif
diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp
index 4b9246e..d238b0d 100644
--- a/src/frontend/display/chtmlwritedisplay.cpp
+++ b/src/frontend/display/chtmlwritedisplay.cpp
@@ -27,259 +27,233 @@
class BtActionCollection;
CHTMLWriteDisplay::CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent)
-: CPlainWriteDisplay(parentWindow,parent), m_fontFamilyChooser(0),
- m_fontSizeChooser(0), m_colorChooser(0)
-{
- m_actions.bold = 0;
- m_actions.italic = 0;
- m_actions.underline = 0;
- m_actions.selectAll = 0;
-
- setAcceptRichText(true);
- setAcceptDrops(true);
- viewport()->setAcceptDrops(true);
+ : CPlainWriteDisplay(parentWindow, parent), m_fontFamilyChooser(0),
+ m_fontSizeChooser(0), m_colorChooser(0) {
+ m_actions.bold = 0;
+ m_actions.italic = 0;
+ m_actions.underline = 0;
+ m_actions.selectAll = 0;
+
+ setAcceptRichText(true);
+ setAcceptDrops(true);
+ viewport()->setAcceptDrops(true);
}
-CHTMLWriteDisplay::~CHTMLWriteDisplay()
-{
+CHTMLWriteDisplay::~CHTMLWriteDisplay() {
}
-void CHTMLWriteDisplay::setText( const QString& newText )
-{
- QTextEdit::setHtml(newText);
+void CHTMLWriteDisplay::setText( const QString& newText ) {
+ QTextEdit::setHtml(newText);
}
-const QString CHTMLWriteDisplay::plainText()
-{
- return QTextEdit::toPlainText();
+const QString CHTMLWriteDisplay::plainText() {
+ return QTextEdit::toPlainText();
}
-void CHTMLWriteDisplay::toggleBold(bool)
-{
- setFontWeight( m_actions.bold->isChecked() ? QFont::Bold : QFont::Normal );
+void CHTMLWriteDisplay::toggleBold(bool) {
+ setFontWeight( m_actions.bold->isChecked() ? QFont::Bold : QFont::Normal );
}
-void CHTMLWriteDisplay::toggleItalic(bool)
-{
- setFontItalic( m_actions.italic->isChecked() );
+void CHTMLWriteDisplay::toggleItalic(bool) {
+ setFontItalic( m_actions.italic->isChecked() );
}
-void CHTMLWriteDisplay::toggleUnderline(bool)
-{
- setFontUnderline( m_actions.underline->isChecked() );
+void CHTMLWriteDisplay::toggleUnderline(bool) {
+ setFontUnderline( m_actions.underline->isChecked() );
}
-void CHTMLWriteDisplay::alignLeft(bool set)
-{
- if (set && (alignment() != Qt::AlignLeft))
- {
- setAlignment(Qt::AlignLeft);
- slotAlignmentChanged(Qt::AlignLeft);
- }
+void CHTMLWriteDisplay::alignLeft(bool set) {
+ if (set && (alignment() != Qt::AlignLeft)) {
+ setAlignment(Qt::AlignLeft);
+ slotAlignmentChanged(Qt::AlignLeft);
+ }
}
-void CHTMLWriteDisplay::alignCenter(bool set)
-{
- if (set && (alignment() != Qt::AlignHCenter))
- {
- setAlignment(Qt::AlignHCenter);
- slotAlignmentChanged(Qt::AlignHCenter);
- }
+void CHTMLWriteDisplay::alignCenter(bool set) {
+ if (set && (alignment() != Qt::AlignHCenter)) {
+ setAlignment(Qt::AlignHCenter);
+ slotAlignmentChanged(Qt::AlignHCenter);
+ }
}
-void CHTMLWriteDisplay::alignRight(bool set)
-{
- if (set && (alignment() != Qt::AlignRight))
- {
- setAlignment(Qt::AlignRight);
- slotAlignmentChanged(Qt::AlignRight);
- }
+void CHTMLWriteDisplay::alignRight(bool set) {
+ if (set && (alignment() != Qt::AlignRight)) {
+ setAlignment(Qt::AlignRight);
+ slotAlignmentChanged(Qt::AlignRight);
+ }
}
/** The text's alignment changed. Enable the right buttons. */
-void CHTMLWriteDisplay::slotAlignmentChanged( int a )
-{
- bool alignLeft = false;
- bool alignCenter = false;
- bool alignRight = false;
-
- if (a & Qt::AlignLeft)
- {
- alignLeft = true;
- }
- else if ((a & Qt::AlignHCenter) || (a & Qt::AlignCenter))
- {
- alignCenter = true;
- }
- else if (a & Qt::AlignRight)
- {
- alignRight = true;
- }
- else
- {
- alignLeft = true;
- qWarning("unknown alignment %i", a);
- }
-
- m_actions.alignLeft->setChecked( alignLeft );
- m_actions.alignCenter->setChecked( alignCenter );
- m_actions.alignRight->setChecked( alignRight );
+void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
+ bool alignLeft = false;
+ bool alignCenter = false;
+ bool alignRight = false;
+
+ if (a & Qt::AlignLeft) {
+ alignLeft = true;
+ }
+ else if ((a & Qt::AlignHCenter) || (a & Qt::AlignCenter)) {
+ alignCenter = true;
+ }
+ else if (a & Qt::AlignRight) {
+ alignRight = true;
+ }
+ else {
+ alignLeft = true;
+ qWarning("unknown alignment %i", a);
+ }
+
+ m_actions.alignLeft->setChecked( alignLeft );
+ m_actions.alignCenter->setChecked( alignCenter );
+ m_actions.alignRight->setChecked( alignRight );
}
-void CHTMLWriteDisplay::changeFontSize(int newSize)
-{
- setFontPointSize((qreal)newSize);
+void CHTMLWriteDisplay::changeFontSize(int newSize) {
+ setFontPointSize((qreal)newSize);
}
/** Is called when a new color was selected. */
-void CHTMLWriteDisplay::slotColorSelected( const QColor& c)
-{
- setTextColor( c );
+void CHTMLWriteDisplay::slotColorSelected( const QColor& c) {
+ setTextColor( c );
}
/** Is called when a text with another color was selected. */
-void CHTMLWriteDisplay::slotColorChanged(const QColor& c)
-{
- m_colorChooser->setColor(c);
+void CHTMLWriteDisplay::slotColorChanged(const QColor& c) {
+ m_colorChooser->setColor(c);
}
-void CHTMLWriteDisplay::slotFontChanged( const QFont& font )
-{
- m_fontFamilyChooser->setCurrentFont(font);
- m_fontSizeChooser->setFontSize( font.pointSize() );
+void CHTMLWriteDisplay::slotFontChanged( const QFont& font ) {
+ m_fontFamilyChooser->setCurrentFont(font);
+ m_fontSizeChooser->setFontSize( font.pointSize() );
- m_actions.bold->setChecked( font.bold() );
- m_actions.italic->setChecked( font.italic() );
- m_actions.underline->setChecked( font.underline() );
+ m_actions.bold->setChecked( font.bold() );
+ m_actions.italic->setChecked( font.italic() );
+ m_actions.underline->setChecked( font.underline() );
}
-void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font)
-{
- setFontFamily(font.family());
+void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) {
+ setFontFamily(font.family());
}
-void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions)
-{
- //--------------------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&)),
- this, SLOT(slotFontFamilyChoosen(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)));
- 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&)));
- Q_ASSERT(ok);
-
- bar->addSeparator();
-
- //--------------------bold toggle-------------------------
- m_actions.bold = new QAction(
- util::filesystem::DirectoryUtil::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(
- util::filesystem::DirectoryUtil::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(
- util::filesystem::DirectoryUtil::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(
- util::filesystem::DirectoryUtil::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(
- util::filesystem::DirectoryUtil::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(
- util::filesystem::DirectoryUtil::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&)));
- connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int)));
- connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&)));
-
- //set initial values for toolbar items
- slotFontChanged( font() );
- slotAlignmentChanged( alignment() );
- slotColorChanged( textColor() );
+void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) {
+ //--------------------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&)),
+ this, SLOT(slotFontFamilyChoosen(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)));
+ 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&)));
+ Q_ASSERT(ok);
+
+ bar->addSeparator();
+
+ //--------------------bold toggle-------------------------
+ m_actions.bold = new QAction(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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&)));
+ connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int)));
+ connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&)));
+
+ //set initial values for toolbar items
+ slotFontChanged( font() );
+ 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;
+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 155966a..5ea7527 100644
--- a/src/frontend/display/chtmlwritedisplay.h
+++ b/src/frontend/display/chtmlwritedisplay.h
@@ -26,81 +26,79 @@ class BtActionCollection;
/** The WYSIWYG implementation of the write display interface.
* @author The BibleTime team
*/
-class CHTMLWriteDisplay : public CPlainWriteDisplay
-{
- Q_OBJECT
-public:
- /**
- * Sets the new text for this display widget. (CPlainWriteDisplay).
- */
- virtual void setText( const QString& newText );
- /**
- * Returns the text of this edit widget. (CPlainWriteDisplay).
- */
- virtual const QString plainText();
-
- /**
- * Creates the necessary action objects and puts them on the toolbar.
- * (CPlainWriteDisplay)
- */
- virtual void setupToolbar(QToolBar * bar, BtActionCollection * actionCollection);
-
-protected:
- 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);
- void toggleItalic(bool);
- void toggleUnderline(bool);
-
- void alignLeft(bool);
- void alignCenter(bool);
- void alignRight(bool);
-
- void changeFontSize(int);
-
- void slotFontChanged( const QFont& );
- void slotFontFamilyChoosen(const QFont&);
-
- /**
- * The text's alignment changed. Enable the right buttons.
- */
- void slotAlignmentChanged( int );
- /**
- * Is called when a new color was selected.
- */
- void slotColorSelected( const QColor& );
- /**
- * Is called when a text with another color was selected.
- */
- void slotColorChanged( const QColor& );
-
-private:
- struct
- {
- QAction* bold;
- QAction* italic;
- QAction* underline;
-
- QAction* alignLeft;
- QAction* alignCenter;
- QAction* alignRight;
-
- //popup menu
- QAction* selectAll;
- }
- m_actions;
-
- QFontComboBox* m_fontFamilyChooser;
- BtFontSizeWidget* m_fontSizeChooser;
- BtColorWidget* m_colorChooser;
+class CHTMLWriteDisplay : public CPlainWriteDisplay {
+ Q_OBJECT
+ public:
+ /**
+ * Sets the new text for this display widget. (CPlainWriteDisplay).
+ */
+ virtual void setText( const QString& newText );
+ /**
+ * Returns the text of this edit widget. (CPlainWriteDisplay).
+ */
+ virtual const QString plainText();
+
+ /**
+ * Creates the necessary action objects and puts them on the toolbar.
+ * (CPlainWriteDisplay)
+ */
+ virtual void setupToolbar(QToolBar * bar, BtActionCollection * actionCollection);
+
+ protected:
+ 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);
+ void toggleItalic(bool);
+ void toggleUnderline(bool);
+
+ void alignLeft(bool);
+ void alignCenter(bool);
+ void alignRight(bool);
+
+ void changeFontSize(int);
+
+ void slotFontChanged( const QFont& );
+ void slotFontFamilyChoosen(const QFont&);
+
+ /**
+ * The text's alignment changed. Enable the right buttons.
+ */
+ void slotAlignmentChanged( int );
+ /**
+ * Is called when a new color was selected.
+ */
+ void slotColorSelected( const QColor& );
+ /**
+ * Is called when a text with another color was selected.
+ */
+ void slotColorChanged( const QColor& );
+
+ private:
+ struct {
+ QAction* bold;
+ QAction* italic;
+ QAction* underline;
+
+ QAction* alignLeft;
+ QAction* alignCenter;
+ QAction* alignRight;
+
+ //popup menu
+ 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 3880f35..ff70c0a 100644
--- a/src/frontend/display/cplainwritedisplay.cpp
+++ b/src/frontend/display/cplainwritedisplay.cpp
@@ -25,42 +25,42 @@
CPlainWriteDisplay::CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent) : QTextEdit(parentWindow ? parentWindow : parent), CWriteDisplay(parentWindow) {
- setAcceptRichText(false);
- setAcceptDrops(true);
- viewport()->setAcceptDrops(true);
+ setAcceptRichText(false);
+ setAcceptDrops(true);
+ viewport()->setAcceptDrops(true);
- connect(this, SIGNAL(textChanged()),
- connectionsProxy(), SLOT(emitTextChanged()));
+ connect(this, SIGNAL(textChanged()),
+ connectionsProxy(), SLOT(emitTextChanged()));
}
CPlainWriteDisplay::~CPlainWriteDisplay() {}
/** Reimplementation. */
void CPlainWriteDisplay::selectAll() {
- QTextEdit::selectAll();
+ QTextEdit::selectAll();
}
void CPlainWriteDisplay::setText( const QString& newText ) {
- //make sure the text has been converted to show \n instead of <br/>
- QString text = 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("<br />", "\n"); //inserted by BT or the Qt textedit widget
+ text.replace("<br />", "\n"); //inserted by BT or the Qt textedit widget
- QTextEdit::setText(text);
+ QTextEdit::setText(text);
}
bool CPlainWriteDisplay::hasSelection() {
- //TODO: test this
- return textCursor().hasSelection();
+ //TODO: test this
+ return textCursor().hasSelection();
}
QWidget* CPlainWriteDisplay::view() {
- qDebug("CPlainWriteDisplay::view()");
- return this;
+ qDebug("CPlainWriteDisplay::view()");
+ return this;
}
const QString CPlainWriteDisplay::text( const CDisplay::TextType /*format*/, const CDisplay::TextPart /*part*/) {
- return QString::null;
+ return QString::null;
}
void CPlainWriteDisplay::print( const CDisplay::TextPart, CSwordBackend::DisplayOptions, CSwordBackend::FilterOptions) {
@@ -68,28 +68,28 @@ void CPlainWriteDisplay::print( const CDisplay::TextPart, CSwordBackend::Display
/** Sets the current status of the edit widget. */
void CPlainWriteDisplay::setModified( const bool modified ) {
- document()->setModified(modified);
+ document()->setModified(modified);
}
/** Reimplementation. */
bool CPlainWriteDisplay::isModified() const {
- return document()->isModified();
+ return document()->isModified();
}
/** Returns the text of this edit widget. */
const QString CPlainWriteDisplay::plainText() {
- QString ret = QTextEdit::toPlainText();
+ QString ret = QTextEdit::toPlainText();
- //in plain text mode the text just contains newlines, convert them into <br/> before we return the text for display in a HTML widget
- ret.replace("\n", "<br />");
+ //in plain text mode the text just contains newlines, convert them into <br/> before we return the text for display in a HTML widget
+ ret.replace("\n", "<br />");
- return ret;
+ return ret;
}
/** Reimplementation from QTextEdit. Provides an popup menu for the given position. */
QMenu* CPlainWriteDisplay::createPopupMenu( const QPoint& /*pos*/ ) {
- return installedPopup();
+ return installedPopup();
}
//
///** Reimplementation from QTextEdit. Provides an popup menu for the given position. */
@@ -102,59 +102,58 @@ void CPlainWriteDisplay::setupToolbar(QToolBar*, BtActionCollection*) {}
/** Reimplementation to insert the text of a dragged reference into the edit view. */
void CPlainWriteDisplay::dragEnterEvent( QDragEnterEvent* e ) {
- //if (CDragDropMgr::canDecode(e)) {
- if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
- e->acceptProposedAction();
- }
- else {
- //e->accept(false);
- e->ignore();
- }
+ //if (CDragDropMgr::canDecode(e)) {
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
+ e->acceptProposedAction();
+ }
+ else {
+ //e->accept(false);
+ e->ignore();
+ }
}
/** Reimplementation to insert the text of a dragged reference into the edit view. */
void CPlainWriteDisplay::dragMoveEvent( QDragMoveEvent* e ) {
- if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
- //placeCursor(e->pos());
- setTextCursor(cursorForPosition(e->pos()));
- ensureCursorVisible();
- e->acceptProposedAction();
- }
- else {
- //e->accept(false);
- e->ignore();
- }
+ if (e->mimeData()->hasFormat("BibleTime/Bookmark") || e->mimeData()->hasFormat("text/plain")) {
+ //placeCursor(e->pos());
+ setTextCursor(cursorForPosition(e->pos()));
+ ensureCursorVisible();
+ e->acceptProposedAction();
+ }
+ else {
+ //e->accept(false);
+ e->ignore();
+ }
}
/** Reimplementation to manage drops of our drag and drop objects. */
-void CPlainWriteDisplay::dropEvent( QDropEvent* e )
-{
- //qDebug("CPlainWriteDisplay::dropEvent");
- const BTMimeData* mimedata = qobject_cast<const BTMimeData*>(e->mimeData());
-
- if ( mimedata && mimedata->hasFormat("BibleTime/Bookmark") ) {
- //qDebug("format was bookmark");
- e->acceptProposedAction();
-
- BTMimeData::ItemList items = mimedata->bookmarks();
- 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() );
- QString moduleText = key->strippedText();
-
- const QString text = QString::fromLatin1("%1\n(%2, %3)\n").arg(moduleText).arg((*it).key()).arg((*it).module());
-
- setTextCursor(cursorForPosition(e->pos()));
- textCursor().insertText( text );
- }
- }
- else if ( e->mimeData()->hasFormat("text/plain")) {
- //qDebug("format was plain text");
- e->acceptProposedAction();
- setTextCursor(cursorForPosition(e->pos()));
- textCursor().insertText( e->mimeData()->text() );
- }
+void CPlainWriteDisplay::dropEvent( QDropEvent* e ) {
+ //qDebug("CPlainWriteDisplay::dropEvent");
+ const BTMimeData* mimedata = qobject_cast<const BTMimeData*>(e->mimeData());
+
+ if ( mimedata && mimedata->hasFormat("BibleTime/Bookmark") ) {
+ //qDebug("format was bookmark");
+ e->acceptProposedAction();
+
+ BTMimeData::ItemList items = mimedata->bookmarks();
+ 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() );
+ QString moduleText = key->strippedText();
+
+ const QString text = QString::fromLatin1("%1\n(%2, %3)\n").arg(moduleText).arg((*it).key()).arg((*it).module());
+
+ setTextCursor(cursorForPosition(e->pos()));
+ textCursor().insertText( text );
+ }
+ }
+ else if ( e->mimeData()->hasFormat("text/plain")) {
+ //qDebug("format was plain text");
+ e->acceptProposedAction();
+ setTextCursor(cursorForPosition(e->pos()));
+ textCursor().insertText( e->mimeData()->text() );
+ }
}
diff --git a/src/frontend/display/cplainwritedisplay.h b/src/frontend/display/cplainwritedisplay.h
index eca0a3a..3968f74 100644
--- a/src/frontend/display/cplainwritedisplay.h
+++ b/src/frontend/display/cplainwritedisplay.h
@@ -32,68 +32,68 @@ class BtActionCollection;
* @author The BibleTime team
*/
class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
-public:
- /**
- * Reimplementation.
- */
- virtual void selectAll();
- /**
- * Sets the new text for this display widget.
- */
- virtual void setText( const QString& newText );
- /**
- * Returns true if the display widget has a selection. Otherwise false.
- */
- virtual bool hasSelection();
- /**
- * Returns the view of this display widget.
- */
- 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 );
- /**
- * Reimplementation (CWriteDisplay).
- */
- virtual bool isModified() const;
- /**
- * Sets the current status of the edit widget (CWriteDisplay).
- */
- virtual void setModified( const bool modified );
- /**
- * Returns the text of this edit widget (CWriteDisplay).
- */
- virtual const QString plainText();
- /**
- * Creates the necessary action objects and puts them on the toolbar (CWriteDisplay).
- */
- virtual void setupToolbar(QToolBar*, BtActionCollection*);
+ public:
+ /**
+ * Reimplementation.
+ */
+ virtual void selectAll();
+ /**
+ * Sets the new text for this display widget.
+ */
+ virtual void setText( const QString& newText );
+ /**
+ * Returns true if the display widget has a selection. Otherwise false.
+ */
+ virtual bool hasSelection();
+ /**
+ * Returns the view of this display widget.
+ */
+ 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 );
+ /**
+ * Reimplementation (CWriteDisplay).
+ */
+ virtual bool isModified() const;
+ /**
+ * Sets the current status of the edit widget (CWriteDisplay).
+ */
+ virtual void setModified( const bool modified );
+ /**
+ * Returns the text of this edit widget (CWriteDisplay).
+ */
+ virtual const QString plainText();
+ /**
+ * Creates the necessary action objects and puts them on the toolbar (CWriteDisplay).
+ */
+ virtual void setupToolbar(QToolBar*, BtActionCollection*);
-protected:
- friend class CDisplay;
- friend class CHTMLWriteDisplay;
+ protected:
+ friend class CDisplay;
+ friend class CHTMLWriteDisplay;
- CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
- virtual ~CPlainWriteDisplay();
- /**
- * Reimplementation from QTextEdit. Provides an popup menu for the given position.
- */
- virtual QMenu* createPopupMenu( const QPoint& pos );
+ 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.
- */
- virtual void dropEvent( QDropEvent* e );
- /**
- * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
- */
- virtual void dragEnterEvent( QDragEnterEvent* e );
- /**
- * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
- */
- virtual void dragMoveEvent( QDragMoveEvent* e );
+ /**
+ * Reimplementation from QTextEdit to manage drops of our drag and drop objects.
+ */
+ virtual void dropEvent( QDropEvent* e );
+ /**
+ * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
+ */
+ virtual void dragEnterEvent( QDragEnterEvent* e );
+ /**
+ * Reimplementation from QTextEdit to insert the text of a dragged reference into the edit view.
+ */
+ virtual void dragMoveEvent( QDragMoveEvent* e );
};
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index 383d332..afe00cd 100644
--- a/src/frontend/display/creaddisplay.cpp
+++ b/src/frontend/display/creaddisplay.cpp
@@ -32,81 +32,81 @@
CReadDisplay::CReadDisplay(CReadWindow* readWindow) :
-CDisplay(readWindow),
-m_activeAnchor(QString::null),
-m_useMouseTracking(true) {}
+ CDisplay(readWindow),
+ m_activeAnchor(QString::null),
+ m_useMouseTracking(true) {}
CReadDisplay::~CReadDisplay() {}
/** Returns the current active anchor. */
const QString& CReadDisplay::activeAnchor() {
- return m_activeAnchor;
+ return m_activeAnchor;
}
/** Sets the current anchor to the parameter. */
void CReadDisplay::setActiveAnchor( const QString& anchor ) {
- m_activeAnchor = anchor;
+ m_activeAnchor = anchor;
}
/** Returns true if the display has an active anchor. */
bool CReadDisplay::hasActiveAnchor() {
- return !activeAnchor().isEmpty();
+ return !activeAnchor().isEmpty();
}
void CReadDisplay::print(const CDisplay::TextPart type, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) {
- CDisplayWindow* window = parentWindow();
- CSwordKey* const key = window->key();
- CSwordModuleInfo* module = key->module();
-
-
- CExportManager mgr(QObject::tr("Print keys"),false, QString::null, parentWindow()->filterOptions(), parentWindow()->displayOptions());
-
- switch (type) {
- case Document: {
- if (module->type() == CSwordModuleInfo::Bible) {
- CSwordVerseKey* vk = dynamic_cast<CSwordVerseKey*>(key);
-
- CSwordVerseKey startKey(*vk);
- startKey.Verse(1);
-
- CSwordVerseKey stopKey(*vk);
-
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
- if (bible) {
- stopKey.Verse( bible->verseCount( bible->bookNumber(startKey.book()), startKey.Chapter() ) );
- }
-
- mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
- }
- else if (module->type() == CSwordModuleInfo::Lexicon || module->type() == CSwordModuleInfo::Commentary ) {
- mgr.printKey(module, key->key(), key->key(), displayOptions, filterOptions);
- }
- else if (module->type() == CSwordModuleInfo::GenericBook) {
- CSwordTreeKey* tree = dynamic_cast<CSwordTreeKey*>(key);
-
- CSwordTreeKey startKey(*tree);
- // while (startKey.previousSibling()) { // go to first sibling on this level!
- // }
-
- CSwordTreeKey stopKey(*tree);
- // if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(module)) {
- // while ( stopKey.nextSibling() ) { //go to last displayed sibling!
- // }
- // }
- mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
- }
- }
-
- case AnchorWithText: {
- if (hasActiveAnchor()) {
- mgr.printByHyperlink( activeAnchor(), displayOptions, filterOptions );
- }
- }
-
- default:
- break;
- }
+ CDisplayWindow* window = parentWindow();
+ CSwordKey* const key = window->key();
+ CSwordModuleInfo* module = key->module();
+
+
+ CExportManager mgr(QObject::tr("Print keys"), false, QString::null, parentWindow()->filterOptions(), parentWindow()->displayOptions());
+
+ switch (type) {
+ case Document: {
+ if (module->type() == CSwordModuleInfo::Bible) {
+ CSwordVerseKey* vk = dynamic_cast<CSwordVerseKey*>(key);
+
+ CSwordVerseKey startKey(*vk);
+ startKey.Verse(1);
+
+ CSwordVerseKey stopKey(*vk);
+
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
+ if (bible) {
+ stopKey.Verse( bible->verseCount( bible->bookNumber(startKey.book()), startKey.Chapter() ) );
+ }
+
+ mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
+ }
+ else if (module->type() == CSwordModuleInfo::Lexicon || module->type() == CSwordModuleInfo::Commentary ) {
+ mgr.printKey(module, key->key(), key->key(), displayOptions, filterOptions);
+ }
+ else if (module->type() == CSwordModuleInfo::GenericBook) {
+ CSwordTreeKey* tree = dynamic_cast<CSwordTreeKey*>(key);
+
+ CSwordTreeKey startKey(*tree);
+ // while (startKey.previousSibling()) { // go to first sibling on this level!
+ // }
+
+ CSwordTreeKey stopKey(*tree);
+ // if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(module)) {
+ // while ( stopKey.nextSibling() ) { //go to last displayed sibling!
+ // }
+ // }
+ mgr.printKey(module, startKey.key(), stopKey.key(), displayOptions, filterOptions);
+ }
+ }
+
+ case AnchorWithText: {
+ if (hasActiveAnchor()) {
+ mgr.printByHyperlink( activeAnchor(), displayOptions, filterOptions );
+ }
+ }
+
+ default:
+ break;
+ }
}
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index f4a00c4..c94bd41 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -22,52 +22,52 @@
*/
class CReadDisplay : public CDisplay {
-public:
- /**
- * Returns true if the display has an active anchor.
- */
- bool hasActiveAnchor();
- /**
- * Returns the current active anchor.
- */
- const QString& activeAnchor();
- /**
- * 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);
+ public:
+ /**
+ * Returns true if the display has an active anchor.
+ */
+ bool hasActiveAnchor();
+ /**
+ * Returns the current active anchor.
+ */
+ const QString& activeAnchor();
+ /**
+ * 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);
- void setMouseTracking(const bool trackingEnabled) {
- m_useMouseTracking = trackingEnabled;
- };
- bool getMouseTracking() const {
- return m_useMouseTracking;
- };
+ void setMouseTracking(const bool trackingEnabled) {
+ m_useMouseTracking = trackingEnabled;
+ };
+ bool getMouseTracking() const {
+ return m_useMouseTracking;
+ };
-protected: // Protected methods
- friend class BtHtmlReadDisplay;
- friend class BtHtmlReadDisplayView;
- friend class BtHtmlJsObject;
- friend class CDisplay;
- friend class CHTMLReadDisplay;
- friend class CHTMLReadDisplayView;
+ protected: // Protected methods
+ friend class BtHtmlReadDisplay;
+ friend class BtHtmlReadDisplayView;
+ friend class BtHtmlJsObject;
+ friend class CDisplay;
+ friend class CHTMLReadDisplay;
+ friend class CHTMLReadDisplayView;
- CReadDisplay( CReadWindow* readWindow );
- ~CReadDisplay();
+ CReadDisplay( CReadWindow* readWindow );
+ ~CReadDisplay();
- /**
- * Sets the current anchor to the parameter.
- */
- void setActiveAnchor( const QString& );
+ /**
+ * Sets the current anchor to the parameter.
+ */
+ void setActiveAnchor( const QString& );
-private: // Public attributes
- /**
- * The member which hols the current anchor.
- */
+ private: // Public attributes
+ /**
+ * The member which hols the current anchor.
+ */
- QString m_activeAnchor;
+ QString m_activeAnchor;
- bool m_useMouseTracking;
+ bool m_useMouseTracking;
};
#endif
diff --git a/src/frontend/display/cwritedisplay.h b/src/frontend/display/cwritedisplay.h
index eaa2d9d..24dd29f 100644
--- a/src/frontend/display/cwritedisplay.h
+++ b/src/frontend/display/cwritedisplay.h
@@ -23,29 +23,29 @@ class BtActionCollection;
*/
class CWriteDisplay : public CDisplay {
-protected:
- friend class CDisplay;
- friend class CPlainWriteDisplay;
- CWriteDisplay( CWriteWindow* writeWindow );
- ~CWriteDisplay();
-
-public: // Public methods
- /**
- * Sets the current modified status of the widget.
- */
- virtual void setModified( const bool modified ) = 0;
- /**
- * Returns true if the current text was modified.
- */
- virtual bool isModified() const = 0;
- /**
- * Returns the text of this edit widget.
- */
- virtual const QString plainText() = 0;
- /**
- * Creates the necessary action objects and puts them on the toolbar.
- */
- virtual void setupToolbar( QToolBar* bar, BtActionCollection* actionCollection ) = 0;
+ protected:
+ friend class CDisplay;
+ friend class CPlainWriteDisplay;
+ CWriteDisplay( CWriteWindow* writeWindow );
+ ~CWriteDisplay();
+
+ public: // Public methods
+ /**
+ * Sets the current modified status of the widget.
+ */
+ virtual void setModified( const bool modified ) = 0;
+ /**
+ * Returns true if the current text was modified.
+ */
+ virtual bool isModified() const = 0;
+ /**
+ * Returns the text of this edit widget.
+ */
+ virtual const QString plainText() = 0;
+ /**
+ * Creates the necessary action objects and puts them on the toolbar.
+ */
+ virtual void setupToolbar( QToolBar* bar, BtActionCollection* actionCollection ) = 0;
};
#endif