summaryrefslogtreecommitdiff
path: root/src/frontend/display/cplainwritedisplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/display/cplainwritedisplay.cpp')
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp139
1 files changed, 69 insertions, 70 deletions
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() );
+ }
}