blob: efe0c3c24b0be246520522229d9cb2ad7d9b90c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* newsscroller.h
*
* Copyright (c) 2000, 2001 Frerich Raabe <[email protected]>
* Copyright (c) 2001 Malte Starostik <[email protected]>
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. For licensing and distribution details, check the
* accompanying file 'COPYING'.
*/
#ifndef NEWSSCROLLER_H
#define NEWSSCROLLER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "configaccess.h"
#include "newsengine.h"
#include <qframe.h>
#include <qptrlist.h>
#include <qpixmap.h>
class QTimer;
class Headline;
template <class> class QPtrList;
typedef QPtrList<Headline> HeadlineList;
class NewsScroller : public QFrame
{
Q_OBJECT
public:
NewsScroller(QWidget *, ConfigAccess *, const char * = 0);
virtual QSize sizeHint() const;
virtual QSizePolicy sizePolicy() const;
// Convenience stuff. Somehow ugly, no?
inline bool horizontal() const
{
return m_cfg->horizontal(static_cast<ConfigAccess::Direction>(m_cfg->scrollingDirection()));
}
inline bool vertical() const
{
return m_cfg->vertical(static_cast<ConfigAccess::Direction>(m_cfg->scrollingDirection()));
}
inline bool rotated() const
{
return m_cfg->rotated(static_cast<ConfigAccess::Direction>(m_cfg->scrollingDirection()));
}
public slots:
void clear();
void addHeadline(Article::Ptr);
void reset(bool bSeparatorOnly = false);
signals:
void contextMenu();
protected:
virtual void enterEvent(QEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseReleaseEvent(QMouseEvent *);
virtual void mouseMoveEvent(QMouseEvent *);
virtual void wheelEvent(QWheelEvent *);
virtual void leaveEvent(QEvent *);
virtual void drawContents(QPainter *);
virtual void dragEnterEvent( QDragEnterEvent *);
virtual void dropEvent(QDropEvent *);
protected slots:
void scroll(int = 1, bool = true);
void slotTimeout();
private:
int scrollWidth() const;
int scrollHeight() const;
bool updateActive(const QPoint &);
bool isHeadline(const QString &) const;
int speedAsInterval( int speed );
private:
friend class Headline;
ConfigAccess *m_cfg;
QTimer *m_scrollTimer;
mutable HeadlineList m_headlines;
Headline *m_activeHeadline;
QPixmap m_separator;
int m_offset;
QPoint m_dragPos;
bool m_mouseDrag;
QString m_tempHeadline;
float m_totalStepping;
float m_stepping;
};
#endif // NEWSSCROLLER_H
|