summaryrefslogtreecommitdiffstats
path: root/src/bookwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookwidget.cpp')
-rw-r--r--src/bookwidget.cpp176
1 files changed, 88 insertions, 88 deletions
diff --git a/src/bookwidget.cpp b/src/bookwidget.cpp
index 8eec9df..880219b 100644
--- a/src/bookwidget.cpp
+++ b/src/bookwidget.cpp
@@ -16,15 +16,15 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#include <qpainter.h>
-#include <qevent.h>
-#include <qimage.h>
+#include <tqpainter.h>
+#include <tqevent.h>
+#include <tqimage.h>
#include <kdebug.h>
#include <kprogress.h>
-#include <qfile.h>
-#include <qtextstream.h>
-#include <qtextcodec.h>
-#include <qstring.h>
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tqtextcodec.h>
+#include <tqstring.h>
#include <kglobal.h>
#include <kstandarddirs.h>
#include "bookwidget.h"
@@ -33,12 +33,12 @@
#include "renderer.h"
//#include "ktextprogressdlg.h"
-class QStringList;
-class QRect;
-class QPixmap;
+class TQStringList;
+class TQRect;
+class TQPixmap;
-BookWidget::BookWidget(QWidget *parent, const char *name)
- : QWidget(parent, name),
+BookWidget::BookWidget(TQWidget *tqparent, const char *name)
+ : TQWidget(tqparent, name),
m_modified(true),
m_currentPage(0),
m_left_margin(0),
@@ -61,11 +61,11 @@ BookWidget::BookWidget(QWidget *parent, const char *name)
Theme::self()->loadTheme("default");
- setWFlags(Qt::WNoAutoErase);
- setFocusPolicy(QWidget::StrongFocus);
+ setWFlags(TQt::WNoAutoErase);
+ setFocusPolicy(TQ_StrongFocus);
- connect(&m_timer, SIGNAL(timeout()), this, SLOT(loadLine()));
- connect(m_renderer.get(), SIGNAL(renderingFinished()), this, SLOT(renderingFinished()));
+ connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(loadLine()));
+ connect(m_renderer.get(), TQT_SIGNAL(renderingFinished()), this, TQT_SLOT(renderingFinished()));
}
@@ -80,10 +80,10 @@ void BookWidget::openURL(const KURL & url)
if (! m_file.open(IO_ReadOnly)) return;
///@todo Write encoding detection
- m_stream.reset(new QTextStream(&m_file));
- m_textLines.reset(new QStringList);
- QString name(encoding());
- QTextCodec *codec = QTextCodec::codecForName(encoding()); // get the codec
+ m_stream.reset(new TQTextStream(&m_file));
+ m_textLines.reset(new TQStringList);
+ TQString name(encoding());
+ TQTextCodec *codec = TQTextCodec::codecForName(encoding()); // get the codec
if (codec)
m_stream->setCodec(codec);
//show progress dialog
@@ -92,7 +92,7 @@ void BookWidget::openURL(const KURL & url)
m_progressDlg->setLabel("Loading file " + m_url.path());
m_progressDlg->setAllowCancel(true);
m_progressDlg->progressBar()->setTotalSteps(0);
- connect(m_progressDlg.get(), SIGNAL(cancelClicked()), SLOT(cancelLoading()));
+ connect(m_progressDlg.get(), TQT_SIGNAL(cancelClicked()), TQT_SLOT(cancelLoading()));
KDialog::centerOnScreen(m_progressDlg.get());
m_progressDlg->show();
//start timer for processing gui events
@@ -103,90 +103,90 @@ void BookWidget::openURL(const KURL & url)
emit signalChangeStatusbar(m_url.prettyURL());
}
-QString BookWidget::currentURL()
+TQString BookWidget::currentURL()
{
return m_url.path();
}
-void BookWidget::drawContent(QPainter& paint)
+void BookWidget::drawContent(TQPainter& paint)
{
- const QRect lrect (rectLeftPage());
- const QRect rrect(rectRightPage());
+ const TQRect lrect (rectLeftPage());
+ const TQRect rrect(rectRightPage());
const unsigned int curPage = currentPage();
//draw pages
m_renderer->drawPage(paint, lrect, curPage);
m_renderer->drawPage(paint, rrect, curPage + 1);
}
-void BookWidget::drawPageNumbers(QPainter & paint)
+void BookWidget::drawPageNumbers(TQPainter & paint)
{
if (m_renderer->isEmpty())
return;
- const QRect lrect (rectLeftPage());
- const QRect rrect(rectRightPage());
- const QString number = QString::number(currentPage() + 2);
+ const TQRect lrect (rectLeftPage());
+ const TQRect rrect(rectRightPage());
+ const TQString number = TQString::number(currentPage() + 2);
// setup font
- QFont pageFont(font());
+ TQFont pageFont(font());
int pointSize = 10;
pageFont.setPointSize(pointSize);
pageFont.setBold(false);
pageFont.setItalic(false);
pageFont.setUnderline(false);
paint.setFont(pageFont);
- const QFontMetrics fm(pageFont);
+ const TQFontMetrics fm(pageFont);
const int width = fm.width(number);
//paint page numbers
const int offset = 8;
- paint.drawText(lrect.left(), QWidget::height() - offset,
- QString::number(currentPage() + 1));
+ paint.drawText(lrect.left(), TQWidget::height() - offset,
+ TQString::number(currentPage() + 1));
paint.drawText(rrect.left() + rrect.width() - width,
- QWidget::height() - offset, number);
+ TQWidget::height() - offset, number);
}
-void BookWidget::drawBookmark(QPainter & paint, Bookmark const& bm)
+void BookWidget::drawBookmark(TQPainter & paint, Bookmark const& bm)
{
- const QRect lrect (rectLeftPage());
- const QRect rrect(rectRightPage());
- const QPixmap & bookmarkImage = Theme::self()->bookmarkPixmap();
+ const TQRect lrect (rectLeftPage());
+ const TQRect rrect(rectRightPage());
+ const TQPixmap & bookmarkImage = Theme::self()->bookmarkPixmap();
const int width = bookmarkImage.width();
- paint.drawPixmap(QWidget::width()/2 - width/2, 0, bookmarkImage);
+ paint.drawPixmap(TQWidget::width()/2 - width/2, 0, bookmarkImage);
if (!bm.name().isEmpty())
{
paint.save();
- paint.translate(QWidget::width()/2., 20.);
+ paint.translate(TQWidget::width()/2., 20.);
paint.rotate(90.);
- const QString text = bm.name() + " (" + bm.dateTime().toString(Qt::LocalDate) + ")";
+ const TQString text = bm.name() + " (" + bm.dateTime().toString(Qt::LocalDate) + ")";
paint.drawText(0, 0, text);
paint.restore();
}
}
-void BookWidget::paintEvent(QPaintEvent* event)
+void BookWidget::paintEvent(TQPaintEvent* event)
{
// use cached page pixmap if the page wasn't modified
if (!modified())
{
- QRect rect(event->rect());
+ TQRect rect(event->rect());
bitBlt(this, rect.x(), rect.y(), &m_cachePixmap, rect.x(), rect.y(), rect.width(), rect.height());
return;
}
// do full painting otherwise
setupPageSize();
- const QRect lrect (rectLeftPage());
- const QRect rrect(rectRightPage());
+ const TQRect lrect (rectLeftPage());
+ const TQRect rrect(rectRightPage());
const unsigned int curPage = currentPage();
- QPixmap pm(size());
- QPainter paint(&pm);
+ TQPixmap pm(size());
+ TQPainter paint(&pm);
//draw background image
- const QPixmap & image = Theme::self()->bgPixmap(QWidget::size());
+ const TQPixmap & image = Theme::self()->bgPixmap(TQWidget::size());
paint.drawPixmap(0, 0, image);
if (m_renderer->busy())
{
- QFont f(font());
+ TQFont f(font());
f.setPointSize(20);
paint.setFont(f);
- const QFontMetrics fm(f);
- QString text = tr("Rendering...");
+ const TQFontMetrics fm(f);
+ TQString text = tr("Rendering...");
const int w = fm.width(text);
const int h = fm.height();
const int dx = (lrect.width() - w) / 2;
@@ -215,37 +215,37 @@ void BookWidget::paintEvent(QPaintEvent* event)
void BookWidget::setupPageSize()
{
- QSize size((width() - m_left_margin - m_right_margin - 2 * m_middle_margin) / 2,
+ TQSize size((width() - m_left_margin - m_right_margin - 2 * m_middle_margin) / 2,
(height() - m_top_margin - m_bottom_margin));
m_renderer->setPageSize(size);
}
-void BookWidget::mousePressEvent(QMouseEvent * event)
+void BookWidget::mousePressEvent(TQMouseEvent * event)
{
- if (event->button() == LeftButton)
+ if (event->button() == Qt::LeftButton)
{
- if (rectLeftPage().contains(event->pos()))
+ if (rectLeftPage().tqcontains(event->pos()))
{
prevPage();
}
- else if (rectRightPage().contains(event->pos()))
+ else if (rectRightPage().tqcontains(event->pos()))
{
nextPage();
}
}
- QWidget::mousePressEvent(event);
+ TQWidget::mousePressEvent(event);
}
-const QRect BookWidget::rectLeftPage() const
+const TQRect BookWidget::rectLeftPage() const
{
- return QRect(m_left_margin, m_top_margin,
+ return TQRect(m_left_margin, m_top_margin,
m_renderer->pageSize().width(),
m_renderer->pageSize().height());
}
-const QRect BookWidget::rectRightPage() const
+const TQRect BookWidget::rectRightPage() const
{
- return QRect(m_left_margin + 2 * m_middle_margin + m_renderer->pageSize().width(),
+ return TQRect(m_left_margin + 2 * m_middle_margin + m_renderer->pageSize().width(),
m_top_margin,
m_renderer->pageSize().width(),
m_renderer->pageSize().height());
@@ -277,7 +277,7 @@ void BookWidget::lastPage()
setCurrentPage(m_renderer->pageCount() - 1);
}
-void BookWidget::wheelEvent(QWheelEvent * e)
+void BookWidget::wheelEvent(TQWheelEvent * e)
{
e->accept();
if (e->delta() > 0)
@@ -285,7 +285,7 @@ void BookWidget::wheelEvent(QWheelEvent * e)
else nextPage();
}
-void BookWidget::resizeEvent(QResizeEvent * e)
+void BookWidget::resizeEvent(TQResizeEvent * e)
{
m_modified = true;
setupPageSize();
@@ -293,18 +293,18 @@ void BookWidget::resizeEvent(QResizeEvent * e)
// //if size become lower recalc current page
// if (currentPage() > m_renderer->pageCount())
// lastPage();
- QWidget::resizeEvent(e);
+ TQWidget::resizeEvent(e);
}
-QSize BookWidget::minimumSizeHint() const
+TQSize BookWidget::tqminimumSizeHint() const
{
- return QSize(400, 300);
+ return TQSize(400, 300);
}
-void BookWidget::setFont(const QFont & font)
+void BookWidget::setFont(const TQFont & font)
{
m_modified = true;
- QWidget::setFont(font);
+ TQWidget::setFont(font);
m_renderer->setFont(font);
update();
}
@@ -325,27 +325,27 @@ void BookWidget::setCurrentPage(int number)
update();
}
-void BookWidget::keyPressEvent(QKeyEvent * e)
+void BookWidget::keyPressEvent(TQKeyEvent * e)
{
- if (e->key() == Qt::Key_Right || e->key() == Qt::Key_Down
- || e->key() == Qt::Key_Space)
+ if (e->key() == TQt::Key_Right || e->key() == TQt::Key_Down
+ || e->key() == TQt::Key_Space)
{
nextPage();
}
- else if (e->key() == Qt::Key_Left || e->key() == Qt::Key_Up)
+ else if (e->key() == TQt::Key_Left || e->key() == TQt::Key_Up)
{
prevPage();
}
- else if (e->key() == Qt::Key_Home)
+ else if (e->key() == TQt::Key_Home)
{
firstPage();
}
- else if (e->key() == Qt::Key_End)
+ else if (e->key() == TQt::Key_End)
{
lastPage();
}
- QWidget::keyPressEvent(e);
+ TQWidget::keyPressEvent(e);
}
void BookWidget::loadLine()
@@ -378,7 +378,7 @@ void BookWidget::cancelLoading()
{
m_timer.stop();
if (parentWidget())
- parentWidget()->setCaption("");
+ TQT_TQWIDGET(parentWidget())->setCaption("");
//clean up
m_progressDlg->hide();
m_stream.reset(0);
@@ -401,17 +401,17 @@ void BookWidget::setEncoding(int a_encoding)
m_encoding = a_encoding;
}
-void BookWidget::setEncodings(const QStringList & a_encodings)
+void BookWidget::setEncodings(const TQStringList & a_encodings)
{
m_encodings = a_encodings;
}
-void BookWidget::setEncoding(const QString & a_encoding)
+void BookWidget::setEncoding(const TQString & a_encoding)
{
- m_encoding = (m_encodings.findIndex(a_encoding));
+ m_encoding = (m_encodings.tqfindIndex(a_encoding));
}
-void BookWidget::addBookmark(const QString& name)
+void BookWidget::addBookmark(const TQString& name)
{
m_bookmarks.push_back(Bookmark(currentPage(), name));
std::sort(m_bookmarks.begin(), m_bookmarks.end());
@@ -423,13 +423,13 @@ void BookWidget::addBookmark(const QString& name)
void BookWidget::saveBookmarks( )
{
- const QString fileName = "bookreader/" + m_url.fileName();
- QFile::remove(KGlobal::dirs()->findResource("appdata", m_url.fileName()));
+ const TQString fileName = "bookreader/" + m_url.fileName();
+ TQFile::remove(KGlobal::dirs()->findResource("appdata", m_url.fileName()));
KConfig config(fileName, false, false, "data");
for (Bookmarks::size_type i = 0; i < m_bookmarks.size(); ++i)
{
const Bookmark & bm = m_bookmarks[i];
- config.setGroup(tr("Bookmark %1").arg(i));
+ config.setGroup(tqtr("Bookmark %1").tqarg(i));
config.writeEntry("page", bm.page());
config.writeEntry("name", bm.name());
config.writeEntry("dateTime", bm.dateTime());
@@ -439,16 +439,16 @@ void BookWidget::saveBookmarks( )
void BookWidget::loadBookmarks()
{
m_bookmarks.clear();
- const QString fileName = "bookreader/" + m_url.fileName();
+ const TQString fileName = "bookreader/" + m_url.fileName();
KConfig config(fileName, true, false, "data");
- QStringList groups = config.groupList();
- typedef QStringList::const_iterator IT;
+ TQStringList groups = config.groupList();
+ typedef TQStringList::const_iterator IT;
for (IT it = groups.constBegin(); it != groups.constEnd(); ++it)
{
config.setGroup(*it);
- const QString name = config.readEntry("name");
+ const TQString name = config.readEntry("name");
const unsigned int page = config.readUnsignedNumEntry("page");
- const QDateTime dateTime = config.readDateTimeEntry("dateTime");
+ const TQDateTime dateTime = config.readDateTimeEntry("dateTime");
const Bookmark bm(page, name, dateTime);
m_bookmarks.push_back(bm);
}