"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/c2bTextEdit.cpp" between
cb2bib-1.9.9.tar.gz and cb2bib-2.0.0.tar.gz

About: cb2Bib is a multiplatform application for rapidly extracting unformatted, or unstandardized bibliographic references from email alerts, journal Web pages, and PDF files.

c2bTextEdit.cpp  (cb2bib-1.9.9):c2bTextEdit.cpp  (cb2bib-2.0.0)
/*************************************************************************** /***************************************************************************
* Copyright (C) 2004-2018 by Pere Constans * Copyright (C) 2004-2019 by Pere Constans
* constans@molspaces.com * constans@molspaces.com
* cb2Bib version 1.9.9. Licensed under the GNU GPL version 3. * cb2Bib version 2.0.0. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution. * See the LICENSE file that comes with this distribution.
***************************************************************************/ ***************************************************************************/
#include "c2bTextEdit.h" #include "c2bTextEdit.h"
#include "c2bSettings.h" #include "c2bSettings.h"
#include "c2bUtils.h" #include "c2bUtils.h"
#include <QMenu> #include <QMenu>
#include <QPainter> #include <QPainter>
#include <QScrollBar> #include <QScrollBar>
skipping to change at line 28 skipping to change at line 28
{ {
setFrameShape(QPlainTextEdit::StyledPanel); setFrameShape(QPlainTextEdit::StyledPanel);
setFrameShadow(QPlainTextEdit::Raised); setFrameShadow(QPlainTextEdit::Raised);
_settingsP = c2bSettingsP; _settingsP = c2bSettingsP;
connect(_settingsP, SIGNAL(newSettings()), this, SLOT(loadSettings())); connect(_settingsP, SIGNAL(newSettings()), this, SLOT(loadSettings()));
_line_number_area = new LineNumberArea(this); _line_number_area = new LineNumberArea(this);
_line_number_area_color = palette().color(QPalette::Active, QPalette::Base). darker(110); _line_number_area_color = palette().color(QPalette::Active, QPalette::Base). darker(110);
_line_number_color_p = &_settingsP->colors.comment_color; _line_number_color_p = &_settingsP->colors.comment_color;
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAre aWidth())); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAre aWidth()));
connect(this, SIGNAL(updateRequest(const QRect&, int)), this, SLOT(updateLin eNumberArea(const QRect&, int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberA rea(QRect,int)));
updateLineNumberAreaWidth(); updateLineNumberAreaWidth();
c2bUtils::addSeparator(this); c2bUtils::addSeparator(this);
toggleWordWrappingAction = new QAction(this); toggleWordWrappingAction = new QAction(this);
addAction(toggleWordWrappingAction); addAction(toggleWordWrappingAction);
toggleWordWrappingAction->setText(tr("Toggle Word Wrapping")); toggleWordWrappingAction->setText(tr("Toggle Word Wrapping"));
toggleWordWrappingAction->setStatusTip(tr("Toggle word wrapping")); toggleWordWrappingAction->setStatusTip(tr("Toggle word wrapping"));
_settingsP->setKeysequence("Shortcuts/Editor/", toggleWordWrappingAction); _settingsP->setKeysequence("Shortcuts/Editor/", toggleWordWrappingAction);
connect(toggleWordWrappingAction, SIGNAL(triggered()), this, SLOT(toggleWord Wrapping())); connect(toggleWordWrappingAction, SIGNAL(triggered()), this, SLOT(toggleWord Wrapping()));
if (_settingsP->value("c2bTextEdit/WrapMode", false).toBool()) if (_settingsP->value("c2bTextEdit/WrapMode", false).toBool())
skipping to change at line 144 skipping to change at line 144
setLineWrapMode(QPlainTextEdit::WidgetWidth); setLineWrapMode(QPlainTextEdit::WidgetWidth);
} }
void c2bTextEdit::updatePlainText(const QString& text) void c2bTextEdit::updatePlainText(const QString& text)
{ {
const int scrollPosition(verticalScrollBar()->value()); const int scrollPosition(verticalScrollBar()->value());
const int cursorBlock(textCursor().blockNumber()); const int cursorBlock(textCursor().blockNumber());
const int cursorColumn(textCursor().columnNumber()); const int cursorColumn(textCursor().columnNumber());
setPlainText(text); setPlainText(text);
QTextBlock p = document()->begin(); const int lposition(document()->findBlockByNumber(cursorBlock).position());
int i(0); QTextCursor tcursor(textCursor());
while (p.isValid()) tcursor.setPosition(lposition + cursorColumn, QTextCursor::MoveAnchor);
{
if (cursorBlock == i)
break;
i++;
p = p.next();
}
QTextCursor tcursor = textCursor();
tcursor.setPosition(p.position() + cursorColumn, QTextCursor::MoveAnchor);
setTextCursor(tcursor); setTextCursor(tcursor);
verticalScrollBar()->setValue(scrollPosition); verticalScrollBar()->setValue(scrollPosition);
} }
void c2bTextEdit::cursorPosition(int* line_number, int* line_position) const
{
*line_number = textCursor().blockNumber() + 1;
*line_position = textCursor().positionInBlock() + 1;
}
void c2bTextEdit::convert2LaTeX() void c2bTextEdit::convert2LaTeX()
{ {
QString txt(textCursor().selectedText()); QString txt(textCursor().selectedText());
// Better do the long way: Convert anything to c2b, and then // Better do the long way: Convert anything to c2b, and then
// translate to TeX // translate to TeX
c2bUtils::fullBibToC2b(txt); c2bUtils::fullBibToC2b(txt);
insertPlainText(c2bUtils::c2bToBib(txt)); insertPlainText(c2bUtils::c2bToBib(txt));
} }
void c2bTextEdit::convert2Unicode() void c2bTextEdit::convert2Unicode()
 End of changes. 5 change blocks. 
14 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)