diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-21 04:48:07 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-21 04:48:07 +0000 |
commit | 0525bd68b1324389d0825761afec5d2ed252a9a5 (patch) | |
tree | 8a1cb1649c11510a8a8c9fbacc353bfdad74bad2 /src/renderer.cpp | |
parent | 5cce0292935a57e7fab4417d428637fcb84315a9 (diff) | |
download | kbookreader-0525bd68b1324389d0825761afec5d2ed252a9a5.tar.gz kbookreader-0525bd68b1324389d0825761afec5d2ed252a9a5.zip |
TQt4 port kbookreader
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kbookreader@1242484 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/renderer.cpp')
-rw-r--r-- | src/renderer.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/renderer.cpp b/src/renderer.cpp index a04b0d0..fcc6eb7 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include <kdebug.h> -#include <qfontmetrics.h> -#include <qpainter.h> +#include <tqfontmetrics.h> +#include <tqpainter.h> #include <vector> #include <cmath> #include <iostream> @@ -29,11 +29,11 @@ Renderer::Renderer(): m_pageCount(0), m_linesPerPage(0), m_paraOffset(50), - m_fontMetrics(new QFontMetrics(m_font)), + m_fontMetrics(new TQFontMetrics(m_font)), m_curParagraph(0), m_isRendering(false) { - connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout())); + connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timeout())); } @@ -45,13 +45,13 @@ Renderer::~Renderer() * If the list is empty do nothing. * \param a_list List of strings to render */ -void Renderer::load(const QStringList & a_list) +void Renderer::load(const TQStringList & a_list) { if (a_list.isEmpty()) return; m_text.clear(); - QString string; + TQString string; TStringIter it(a_list.constBegin()); while (it != a_list.constEnd()) @@ -61,7 +61,7 @@ void Renderer::load(const QStringList & a_list) //process string until paragraph ends while (++it != a_list.constEnd()) { - QChar const ch((*it)[0]); + TQChar const ch((*it)[0]); //insert empty lines if ((*it).isEmpty()) break; @@ -96,7 +96,7 @@ void Renderer::render() cancel(); clear(); m_isRendering = true; - m_linesPerPage = m_pageSize.height() / (QFontMetrics(font()).height()); + m_linesPerPage = m_pageSize.height() / (TQFontMetrics(font()).height()); m_timer.start(0, false); } @@ -142,11 +142,11 @@ void Renderer::clear() void Renderer::parseParagraph(TIndex paraIndex) { //Don't parse empty lines - const QString a_string(m_text[paraIndex]); + const TQString a_string(m_text[paraIndex]); if (a_string.isEmpty()) return; - QString string(a_string); + TQString string(a_string); const int avgCharWidth = m_fontMetrics->width(" "); //calc approx string width unsigned int avgLen = m_pageSize.width() / avgCharWidth; @@ -248,7 +248,7 @@ void Renderer::parseParagraph(TIndex paraIndex) addLine(TextLine(paraIndex, begin, begin + len, TextLine::PARA_END)); } -int Renderer::width(const QString & a_string) const +int Renderer::width(const TQString & a_string) const { int w = m_fontMetrics->width(a_string); return m_isStartAdded ? w : w + paraOffset(); @@ -262,7 +262,7 @@ void Renderer::addLine(TextLine line) m_isStartAdded = true; } -int Renderer::wordAt(const QString & string, int len) +int Renderer::wordAt(const TQString & string, int len) { while (--len >= 0) if (string[len] == ' ') @@ -270,18 +270,18 @@ int Renderer::wordAt(const QString & string, int len) return 0; } -QString Renderer::getWord(const QString & a_string, int a_idx) +TQString Renderer::getWord(const TQString & a_string, int a_idx) { int idx = a_idx; while (a_string[++idx] != ' ' && idx < a_string.length()); - return QString(a_string.mid(a_idx, idx - a_idx)); + return TQString(a_string.mid(a_idx, idx - a_idx)); } /** * Draws page number \c pageNumber on \c paint * bounding \c rect rectangle */ -void Renderer::drawPage(QPainter & paint, QRect rect, int pageNumber) +void Renderer::drawPage(TQPainter & paint, TQRect rect, int pageNumber) { int height = m_fontMetrics->height(); int line = 1; @@ -298,12 +298,12 @@ void Renderer::drawPage(QPainter & paint, QRect rect, int pageNumber) drawLine(paint, rect.left(), rect.top() + line * height, idx); } -void Renderer::drawLine(QPainter & paint, int x, int y, const TLines::size_type index) +void Renderer::drawLine(TQPainter & paint, int x, int y, const TLines::size_type index) { const TextLine textLine(m_lines[index]); const int length = textLine.size(); - const QString & paragraph = m_text[textLine.paragraphIndex()]; - const QString string = paragraph.mid(textLine.begin(), textLine.size()); + const TQString & paragraph = m_text[textLine.paragraphIndex()]; + const TQString string = paragraph.mid(textLine.begin(), textLine.size()); // indent paragraph if (textLine.isParaStart()) @@ -332,7 +332,7 @@ void Renderer::drawLine(QPainter & paint, int x, int y, const TLines::size_type //count spaces std::vector<int> spaces; spaces.reserve(50); - while (((pos = string.find(' ', off)) != -1) && (pos < length)) + while (((pos = string.tqfind(' ', off)) != -1) && (pos < length)) { spaces.push_back(pos); off = pos + 1; @@ -349,7 +349,7 @@ void Renderer::drawLine(QPainter & paint, int x, int y, const TLines::size_type // calc average space width const double avgLen = ((double)(pageWidth - curWidth) / spacesCount); int start = 0; - QString tmp; + TQString tmp; for (std::vector<int>::size_type i = 0; i < spacesCount; ++i) { pos = spaces[i]; @@ -367,11 +367,11 @@ void Renderer::drawLine(QPainter & paint, int x, int y, const TLines::size_type * Sets current font to \c font and re-renders text. * You don't need to directly call render(). */ -void Renderer::setFont(const QFont & font) +void Renderer::setFont(const TQFont & font) { if (font == m_font) return; m_font = font; - m_fontMetrics.reset(new QFontMetrics(m_font)); + m_fontMetrics.reset(new TQFontMetrics(m_font)); render(); } @@ -390,7 +390,7 @@ void Renderer::setParaOffset(int offset) * Sets current page size to \c size. * \note It don't call render() after changing. */ -void Renderer::setPageSize(const QSize & size) +void Renderer::setPageSize(const TQSize & size) { m_pageSize = size; } |