00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef QVSIMON_PLUGIN_H
00023 #define QVSIMON_PLUGIN_H
00024
00025 #include <qguardedptr.h>
00026
00027 #include <kurl.h>
00028
00029 #include <qvmiscplugin.h>
00030
00031 class QCheckBox;
00032 class QComboBox;
00033
00034 struct vbi_decoder;
00035
00036 namespace Telex
00037 {
00038 class Display;
00039 class Worker;
00040 class Page
00041 {
00042 public:
00043 Page();
00044 Page( vbi_decoder* decoder, int page, int sub = -1 );
00045 Page( const Page& other )
00046 : m_data( 0 ) { *this = other; }
00047 ~Page() { release(); }
00048 Page& operator =( const Page& );
00049
00050 operator const void*() const { return m_decoder; }
00051 bool operator ==( const Page& rhs ) const;
00052 bool operator !=( const Page& rhs ) const
00053 { return !( *this == rhs ); }
00054
00055 int number() const { return m_number; }
00056 int sub() const { return m_sub; }
00057
00058 void refresh();
00059 QPixmap header( int width, int height, int current = -1, int request = -1 ) const;
00060 QPixmap render( int width, int height, int request = -1 ) const;
00061
00062 bool available() const;
00063 int columns() const;
00064 int rows() const;
00065 bool isLink( int, int ) const;
00066 class Link
00067 {
00068
00069
00070 public:
00071 Link() : m_type( Null ), m_data( 0 ) {}
00072 Link( const Page& p );
00073 Link( const KURL& u );
00074 ~Link();
00075
00076 enum Type { Null, TTX, URL };
00077 Type type() const { return m_type; }
00078 const Page& page() const;
00079 const KURL& url() const;
00080
00081 private:
00082 Type m_type;
00083 struct Data;
00084 Data* m_data;
00085 };
00086 Link link( int, int ) const;
00087
00088 static int pageOffset;
00089
00090 private:
00091 enum Validity { None = -1, Header, All };
00092 void release() const;
00093 bool require( Validity, int = -1, int = -1 ) const;
00094
00095 mutable vbi_decoder* m_decoder;
00096 int m_number;
00097 int m_sub;
00098 struct Data;
00099 mutable Data* m_data;
00100 };
00101
00102 class Plugin : public QVMiscPlugin
00103 {
00104 Q_OBJECT
00105 public:
00106 Plugin( QtVision *qtv, QWidget* parent );
00107 virtual ~Plugin();
00108
00109 virtual bool filterNumberKey( int );
00110
00111 public slots:
00112 virtual QWidget* configWidget( QWidget* parent, const char* name );
00113 virtual void saveConfig();
00114
00115 private slots:
00116 void channelChanged();
00117 void navigate( const Page::Link& );
00118
00119 protected:
00120 virtual void customEvent( QCustomEvent* );
00121
00122 private:
00123 QGuardedPtr< Display > m_display;
00124 Worker* m_worker;
00125
00126 Page m_page;
00127 int m_pageInput;
00128 };
00129
00130 class Display : public QWidget
00131 {
00132 Q_OBJECT
00133 public:
00134 Display( QWidget* parent );
00135 virtual ~Display();
00136
00137 virtual bool eventFilter( QObject*, QEvent* );
00138
00139 public slots:
00140 void setTransparent( bool );
00141 void setHeader( const Page& );
00142 void setPage( const Page& );
00143 void setRequest( int );
00144 void refresh();
00145
00146 protected:
00147 virtual void updateMask();
00148 virtual void resizeEvent( QResizeEvent* );
00149 virtual void paintEvent( QPaintEvent* );
00150 virtual void mouseMoveEvent( QMouseEvent* );
00151 virtual void mousePressEvent( QMouseEvent* );
00152
00153 signals:
00154 void navigate( const Page::Link& );
00155
00156 private:
00157 void updatePage();
00158
00159 Page m_page;
00160 QPixmap m_scaled;
00161 bool m_transparent;
00162 int m_request;
00163 };
00164 }
00165
00166 #endif
00167
00168