summaryrefslogtreecommitdiffstats
path: root/knewsticker/newsscroller.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:48:06 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:48:06 +0000
commit47c8a359c5276062c4bc17f0e82410f29081b502 (patch)
tree2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /knewsticker/newsscroller.cpp
parent6f82532777a35e0e60bbd2b290b2e93e646f349b (diff)
downloadtdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz
tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knewsticker/newsscroller.cpp')
-rw-r--r--knewsticker/newsscroller.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/knewsticker/newsscroller.cpp b/knewsticker/newsscroller.cpp
index 9d11f19e..060b7cd9 100644
--- a/knewsticker/newsscroller.cpp
+++ b/knewsticker/newsscroller.cpp
@@ -11,9 +11,9 @@
*/
#include <dcopclient.h>
-#include <qpainter.h>
-#include <qregexp.h>
-#include <qtimer.h>
+#include <tqpainter.h>
+#include <tqregexp.h>
+#include <tqtimer.h>
#include <kcursor.h>
#include <kstandarddirs.h>
@@ -46,11 +46,11 @@ public:
int width() { return pixmap()->width(); }
int height() { return pixmap()->height(); }
- QPixmap *pixmap(bool highlighted = false, bool underlineHighlighted = true)
+ TQPixmap *pixmap(bool highlighted = false, bool underlineHighlighted = true)
{
- QPixmap *result = highlighted ? m_highlighted : m_normal;
+ TQPixmap *result = highlighted ? m_highlighted : m_normal;
if (!result) {
- const QFontMetrics &metrics = m_scroller->fontMetrics();
+ const TQFontMetrics &metrics = m_scroller->fontMetrics();
int w, h;
if (m_scroller->m_cfg->showIcons()) {
@@ -62,13 +62,13 @@ public:
}
if (ConfigAccess::rotated(static_cast<ConfigAccess::Direction>(m_scroller->m_cfg->scrollingDirection())))
- result = new QPixmap(h, w);
+ result = new TQPixmap(h, w);
else
- result = new QPixmap(w, h);
+ result = new TQPixmap(w, h);
result->fill(m_scroller->m_cfg->backgroundColor());
- QPainter p(result);
- QFont f = m_scroller->font();
+ TQPainter p(result);
+ TQFont f = m_scroller->font();
if (highlighted)
f.setUnderline(underlineHighlighted);
@@ -124,14 +124,14 @@ public:
private:
NewsScroller *m_scroller;
Article::Ptr m_article;
- QPixmap *m_normal;
- QPixmap *m_highlighted;
+ TQPixmap *m_normal;
+ TQPixmap *m_highlighted;
};
-NewsScroller::NewsScroller(QWidget *parent, ConfigAccess *cfg, const char *name)
- : QFrame(parent, name, WNoAutoErase),
+NewsScroller::NewsScroller(TQWidget *parent, ConfigAccess *cfg, const char *name)
+ : TQFrame(parent, name, WNoAutoErase),
m_cfg(cfg),
- m_scrollTimer(new QTimer(this)),
+ m_scrollTimer(new TQTimer(this)),
m_activeHeadline(0),
m_mouseDrag(false),
m_totalStepping(0.0)
@@ -143,21 +143,21 @@ NewsScroller::NewsScroller(QWidget *parent, ConfigAccess *cfg, const char *name)
m_headlines.setAutoDelete(true);
- connect(m_scrollTimer, SIGNAL(timeout()), SLOT(slotTimeout()));
+ connect(m_scrollTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotTimeout()));
setAcceptDrops(true);
reset();
}
-QSize NewsScroller::sizeHint() const
+TQSize NewsScroller::sizeHint() const
{
- return QSize(fontMetrics().width(QString::fromLatin1("X")) * 20, fontMetrics().height() * 2);
+ return TQSize(fontMetrics().width(TQString::fromLatin1("X")) * 20, fontMetrics().height() * 2);
}
-QSizePolicy NewsScroller::sizePolicy() const
+TQSizePolicy NewsScroller::sizePolicy() const
{
- return QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ return TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding);
}
void NewsScroller::clear()
@@ -166,30 +166,30 @@ void NewsScroller::clear()
reset();
}
-void NewsScroller::dragEnterEvent(QDragEnterEvent* event)
+void NewsScroller::dragEnterEvent(TQDragEnterEvent* event)
{
- event->accept(QTextDrag::canDecode(event));
+ event->accept(TQTextDrag::canDecode(event));
}
-void NewsScroller::dropEvent(QDropEvent* event)
+void NewsScroller::dropEvent(TQDropEvent* event)
{
- QString newSourceUrl;
- if ( QTextDrag::decode(event, newSourceUrl) ) {
+ TQString newSourceUrl;
+ if ( TQTextDrag::decode(event, newSourceUrl) ) {
// <HACK>
// This is just for http://www.webreference.com/services/news/
- newSourceUrl = newSourceUrl.replace(QRegExp(
- QString::fromLatin1("^view-source:http%3A//")),
- QString::fromLatin1("http://"));
+ newSourceUrl = newSourceUrl.replace(TQRegExp(
+ TQString::fromLatin1("^view-source:http%3A//")),
+ TQString::fromLatin1("http://"));
// </HACK>
newSourceUrl = newSourceUrl.stripWhiteSpace();
if (!isHeadline(newSourceUrl) && KMessageBox::questionYesNo(this, i18n("<p>Do you really want to add '%1' to"
" the list of news sources?</p>")
- .arg(newSourceUrl), QString::null, i18n("Add"), KStdGuiItem::cancel()) == KMessageBox::Yes) {
- KConfig cfg(QString::fromLatin1("knewsticker_panelappletrc"), false, false);
+ .arg(newSourceUrl), TQString::null, i18n("Add"), KStdGuiItem::cancel()) == KMessageBox::Yes) {
+ KConfig cfg(TQString::fromLatin1("knewsticker_panelappletrc"), false, false);
ConfigAccess configFrontend(&cfg);
- QStringList newsSources = configFrontend.newsSources();
+ TQStringList newsSources = configFrontend.newsSources();
- QString name = i18n("Unknown");
+ TQString name = i18n("Unknown");
if (newsSources.contains(name))
for (unsigned int i = 0; ; i++)
if (!newsSources.contains(i18n("Unknown %1").arg(i))) {
@@ -201,13 +201,13 @@ void NewsScroller::dropEvent(QDropEvent* event)
configFrontend.setNewsSource(NewsSourceBase::Data(name, newSourceUrl));
configFrontend.setNewsSources(newsSources);
- QByteArray data;
+ TQByteArray data;
kapp->dcopClient()->send("knewsticker", "KNewsTicker", "reparseConfig()", data);
}
}
}
-bool NewsScroller::isHeadline(const QString &location) const
+bool NewsScroller::isHeadline(const TQString &location) const
{
for (Headline *h = m_headlines.first(); h; h = m_headlines.next())
if (h->article()->address() == location)
@@ -254,7 +254,7 @@ void NewsScroller::scroll(int distance, bool interpret_directions)
m_offset = m_offset + m_separator.height() - scrollHeight();
}
- QPoint pt = mapFromGlobal(QCursor::pos());
+ TQPoint pt = mapFromGlobal(TQCursor::pos());
if (contentsRect().contains(pt))
updateActive(pt);
@@ -262,15 +262,15 @@ void NewsScroller::scroll(int distance, bool interpret_directions)
update();
}
-void NewsScroller::enterEvent(QEvent *)
+void NewsScroller::enterEvent(TQEvent *)
{
if (m_cfg->slowedScrolling() && m_cfg->scrollingSpeed() > 1)
m_scrollTimer->changeInterval(speedAsInterval(m_cfg->scrollingSpeed() / 2));
}
-void NewsScroller::mousePressEvent(QMouseEvent *e)
+void NewsScroller::mousePressEvent(TQMouseEvent *e)
{
- if (e->button() == QMouseEvent::LeftButton || e->button() == QMouseEvent::MidButton) {
+ if (e->button() == TQMouseEvent::LeftButton || e->button() == TQMouseEvent::MidButton) {
m_dragPos = e->pos();
if (m_activeHeadline)
@@ -278,16 +278,16 @@ void NewsScroller::mousePressEvent(QMouseEvent *e)
}
}
-void NewsScroller::mouseReleaseEvent(QMouseEvent *e)
+void NewsScroller::mouseReleaseEvent(TQMouseEvent *e)
{
- if ((e->button() == QMouseEvent::LeftButton || e->button() == QMouseEvent::MidButton)
+ if ((e->button() == TQMouseEvent::LeftButton || e->button() == TQMouseEvent::MidButton)
&& m_activeHeadline && m_activeHeadline->article()->headline() == m_tempHeadline
&& !m_mouseDrag) {
m_activeHeadline->article()->open();
- m_tempHeadline = QString::null;
+ m_tempHeadline = TQString::null;
}
- if (e->button() == QMouseEvent::RightButton)
+ if (e->button() == TQMouseEvent::RightButton)
emit(contextMenu());
if (m_mouseDrag) {
@@ -297,7 +297,7 @@ void NewsScroller::mouseReleaseEvent(QMouseEvent *e)
}
}
-void NewsScroller::mouseMoveEvent(QMouseEvent *e)
+void NewsScroller::mouseMoveEvent(TQMouseEvent *e)
{
// Are we in a drag phase?
if (!m_mouseDrag) {
@@ -307,7 +307,7 @@ void NewsScroller::mouseMoveEvent(QMouseEvent *e)
dragDistance = QABS(e->x() - m_dragPos.x());
else
dragDistance = QABS(e->y() - m_dragPos.y());
- m_mouseDrag = (e->state() & QMouseEvent::LeftButton != 0) &&
+ m_mouseDrag = (e->state() & TQMouseEvent::LeftButton != 0) &&
dragDistance >= KGlobal::config()->readNumEntry("StartDragDist", KApplication::startDragDistance());
if (m_mouseDrag) // Stop the scroller if we just started a drag.
m_scrollTimer->stop();
@@ -327,7 +327,7 @@ void NewsScroller::mouseMoveEvent(QMouseEvent *e)
if (createDrag && m_activeHeadline) {
KURL::List url;
url.append(m_activeHeadline->article()->address());
- QDragObject *drag = new KURLDrag(url, this);
+ TQDragObject *drag = new KURLDrag(url, this);
drag->setPixmap(m_activeHeadline->article()->newsSource()->icon());
drag->drag();
m_mouseDrag = false;
@@ -340,20 +340,20 @@ void NewsScroller::mouseMoveEvent(QMouseEvent *e)
update();
}
-void NewsScroller::wheelEvent(QWheelEvent *e)
+void NewsScroller::wheelEvent(TQWheelEvent *e)
{
// ### This 11 - m_cfg->mouseWheelSpeed() could be eliminated by swapping
- // the labels of the QSlider. :]
+ // the labels of the TQSlider. :]
int distance = qRound(QABS(e->delta()) / (11 - m_cfg->mouseWheelSpeed()));
int direction = e->delta() > 0 ? -1 : 1;
for (int i = 0; i < distance; i++)
scroll(direction);
- QFrame::wheelEvent(e);
+ TQFrame::wheelEvent(e);
}
-void NewsScroller::leaveEvent(QEvent *)
+void NewsScroller::leaveEvent(TQEvent *)
{
if (m_cfg->slowedScrolling() && m_cfg->scrollingSpeed() > 1)
m_scrollTimer->changeInterval(speedAsInterval(m_cfg->scrollingSpeed()));
@@ -364,13 +364,13 @@ void NewsScroller::leaveEvent(QEvent *)
}
}
-void NewsScroller::drawContents(QPainter *p)
+void NewsScroller::drawContents(TQPainter *p)
{
if (!scrollWidth() || // No news and no "No News Available": uninitialized
m_headlines.isEmpty()) // Happens when we're currently fetching new news
return;
- QPixmap buffer(contentsRect().width(), contentsRect().height());
+ TQPixmap buffer(contentsRect().width(), contentsRect().height());
buffer.fill(m_cfg->backgroundColor());
int pos = m_offset;
@@ -393,7 +393,7 @@ void NewsScroller::drawContents(QPainter *p)
// Now do the headlines themselves
do {
- QPtrListIterator<Headline> it(m_headlines);
+ TQPtrListIterator<Headline> it(m_headlines);
for(; *it; ++it) {
if (horizontal()) {
if (pos + (*it)->width() >= 0)
@@ -440,7 +440,7 @@ void NewsScroller::reset(bool bSeparatorOnly)
if (m_cfg->scrollingSpeed())
m_scrollTimer->start(speedAsInterval(m_cfg->scrollingSpeed()));
- QString sep = m_headlines.isEmpty() ? i18n(" +++ No News Available +++") : QString::fromLatin1(" +++ ");
+ TQString sep = m_headlines.isEmpty() ? i18n(" +++ No News Available +++") : TQString::fromLatin1(" +++ ");
int w = fontMetrics().width(sep);
int h = fontMetrics().height();
@@ -452,7 +452,7 @@ void NewsScroller::reset(bool bSeparatorOnly)
m_separator.fill(m_cfg->backgroundColor());
- QPainter p(&m_separator);
+ TQPainter p(&m_separator);
p.setFont(font());
p.setPen(m_cfg->foregroundColor());
@@ -469,7 +469,7 @@ void NewsScroller::reset(bool bSeparatorOnly)
p.end();
if (!bSeparatorOnly)
- for (QPtrListIterator<Headline> it(m_headlines); *it; ++it)
+ for (TQPtrListIterator<Headline> it(m_headlines); *it; ++it)
(*it)->reset();
switch (m_cfg->scrollingDirection()) {
@@ -495,7 +495,7 @@ int NewsScroller::scrollWidth() const
{
int result = (m_headlines.count() + 1) * m_separator.width();
- for (QPtrListIterator<Headline> it(m_headlines); *it; ++it)
+ for (TQPtrListIterator<Headline> it(m_headlines); *it; ++it)
result += (*it)->width();
return result;
@@ -505,13 +505,13 @@ int NewsScroller::scrollHeight() const
{
int result = (m_headlines.count() + 1) * m_separator.height();
- for (QPtrListIterator<Headline> it(m_headlines); *it; ++it)
+ for (TQPtrListIterator<Headline> it(m_headlines); *it; ++it)
result += (*it)->height();
return result;
}
-bool NewsScroller::updateActive(const QPoint &pt)
+bool NewsScroller::updateActive(const TQPoint &pt)
{
int pos = m_offset;
@@ -525,19 +525,19 @@ bool NewsScroller::updateActive(const QPoint &pt)
pos -= scrollHeight() - m_separator.height();
do {
- QPtrListIterator<Headline> it(m_headlines);
+ TQPtrListIterator<Headline> it(m_headlines);
for (; (headline = *it); ++it) {
- QRect rect;
+ TQRect rect;
if (horizontal()) {
pos += m_separator.width();
- rect.moveTopLeft(QPoint(pos, (contentsRect().height() - (*it)->height()) / 2));
+ rect.moveTopLeft(TQPoint(pos, (contentsRect().height() - (*it)->height()) / 2));
pos += (*it)->width();
} else {
pos += m_separator.height();
- rect.moveTopLeft(QPoint((contentsRect().width() - (*it)->width()) / 2, pos));
+ rect.moveTopLeft(TQPoint((contentsRect().width() - (*it)->width()) / 2, pos));
pos += (*it)->height();
}
- rect.setSize(QSize((*it)->width(), (*it)->height()));
+ rect.setSize(TQSize((*it)->width(), (*it)->height()));
if (m_mouseDrag)
if (horizontal()) {