summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/stockticker/stocktickerlib
Unidiff
Diffstat (limited to 'noncore/todayplugins/stockticker/stocktickerlib') (more/less context) (show whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/.cvsignore3
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro27
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp56
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.h47
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.cpp45
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.h40
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp239
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h62
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktimerpluginwidget.h45
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/ticker.cpp93
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/ticker.h32
11 files changed, 689 insertions, 0 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/.cvsignore b/noncore/todayplugins/stockticker/stocktickerlib/.cvsignore
new file mode 100644
index 0000000..c9bb88e
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/.cvsignore
@@ -0,0 +1,3 @@
1Makefile*
2moc_*
3*.moc \ No newline at end of file
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro
new file mode 100644
index 0000000..28ef072
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro
@@ -0,0 +1,27 @@
1TEMPLATE = lib
2CONFIG -= moc
3CONFIG += qt debug
4
5HEADERS = stocktickerplugin.h stocktickeruginimpl.h stocktickerpluginwidget.h ticker.h \
6 ../libstocks/csv.h \
7 ../libstocks/http.h \
8 ../libstocks/lists.h \
9 ../libstocks/stocks.h
10SOURCES = stocktickerplugin.cpp stocktickerpluginimpl.cpp stocktickerpluginwidget.cpp ticker.cpp \
11 ../libstocks/csv.c \
12 ../libstocks/currency.c \
13 ../libstocks/history.c \
14 ../libstocks/http.c \
15 ../libstocks/lists.c \
16 ../libstocks/stocks.c
17
18INCLUDEPATH += $(OPIEDIR)/include \
19 ../ ../library
20DEPENDPATH += $(OPIEDIR)/include \
21 ../ ../library
22
23LIBS+= -lqpe -lopie
24TMAKE_CFLAGS += -D__UNIX__
25
26DESTDIR = $(OPIEDIR)/plugins/today
27TARGET = todaystocktickerplugin
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp
new file mode 100644
index 0000000..82dfb13
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp
@@ -0,0 +1,56 @@
1/*
2 * stocktickerplugin.cpp
3 *
4 * copyright : (c) 2002 by L.J. Potter
5 * email : llornkcor@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18#include "stocktickerplugin.h"
19#include "stocktickerpluginwidget.h"
20
21
22StockTickerPlugin::StockTickerPlugin() {
23}
24
25StockTickerPlugin::~StockTickerPlugin() {
26}
27
28QString StockTickerPlugin::pluginName() const {
29 return QObject::tr( "StockTicker plugin" );
30}
31
32double StockTickerPlugin::versionNumber() const {
33 return 0.6;
34}
35
36QString StockTickerPlugin::pixmapNameWidget() const {
37 return "pass";
38}
39
40QWidget* StockTickerPlugin::widget( QWidget * wid ) {
41 return new StockTickerPluginWidget( wid, "StockTicker " );
42}
43
44QString StockTickerPlugin::pixmapNameConfig() const {
45 return 0l;
46}
47
48TodayConfigWidget* StockTickerPlugin::configWidget( QWidget* wid ) {
49 return 0l;
50}
51
52QString StockTickerPlugin::appName() const {
53 return "stockticker";
54}
55
56
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.h
new file mode 100644
index 0000000..9f174bf
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.h
@@ -0,0 +1,47 @@
1/*
2 * stocktickerplugin.h
3 *
4 * copyright : (c) 2002 by L.J. Potter
5 * email : llornkcor@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18#ifndef STOCKTICKER_PLUGIN_H
19#define STOCKTICKER_PLUGIN_H
20
21#include <qstring.h>
22#include <qwidget.h>
23
24#include <opie/tododb.h>
25#include <opie/oclickablelabel.h>
26
27#include <opie/todayplugininterface.h>
28#include <opie/todayconfigwidget.h>
29
30class StockTickerPlugin : public TodayPluginObject {
31
32public:
33 StockTickerPlugin();
34 ~StockTickerPlugin();
35
36 QString pluginName() const;
37 double versionNumber() const;
38 QString pixmapNameWidget() const;
39 QWidget* widget(QWidget *);
40 QString pixmapNameConfig() const;
41 TodayConfigWidget* configWidget(QWidget *);
42 QString appName() const;
43
44
45};
46
47#endif
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.cpp
new file mode 100644
index 0000000..9a640d4
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.cpp
@@ -0,0 +1,45 @@
1/*
2 * stocktickerpluginimpl.cpp
3 *
4 * copyright : (c) 2002 by L.J. Potter
5 * email : llornkcor@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18
19#include "stocktickerplugin.h"
20#include "stocktickerpluginimpl.h"
21
22StockTickerPluginImpl::StockTickerPluginImpl() {
23 stocktickerPlugin = new StockTickerPlugin();
24}
25
26StockTickerPluginImpl::~StockTickerPluginImpl() {
27}
28
29
30TodayPluginObject* StockTickerPluginImpl::guiPart() {
31 return stocktickerPlugin;
32}
33
34QRESULT StockTickerPluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
35 *iface = 0;
36 if ( ( uuid == IID_QUnknown ) || ( uuid == IID_TodayPluginInterface ) ) {
37 *iface = this, (*iface)->addRef();
38 }
39 return QS_OK;
40
41}
42
43Q_EXPORT_INTERFACE() {
44 Q_CREATE_INSTANCE( StockTickerPluginImpl );
45}
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.h
new file mode 100644
index 0000000..300c545
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginimpl.h
@@ -0,0 +1,40 @@
1/*
2 * stocktickerpluginimpl.h
3 *
4 * copyright : (c) 2002 by L.J. Potter
5 * email : llornkcor@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef STOCKTICKER_PLUGIN_IMPL_H
18#define STOCKTICKER_PLUGIN_IMPL_H
19
20#include <opie/todayplugininterface.h>
21
22class StockTickerPlugin;
23
24class StockTickerPluginImpl : public TodayPluginInterface{
25
26public:
27 StockTickerPluginImpl();
28 virtual ~StockTickerPluginImpl();
29
30 QRESULT queryInterface( const QUuid &, QUnknownInterface** );
31 Q_REFCOUNT
32
33 virtual TodayPluginObject *guiPart();
34
35private:
36 StockTickerPlugin *stocktickerPlugin;
37 ulong ref;
38};
39
40#endif
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
new file mode 100644
index 0000000..3eaade4
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -0,0 +1,239 @@
1/*
2 * stocktickerpluginwidget.cpp
3 *
4 * copyright : (c) 2002 by L.J. Potter
5 * email : llornkcor@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#include <qvaluelist.h>
18#include <qtl.h>
19#include <qstring.h>
20#include <qstringlist.h>
21#include <qobject.h>
22#include <qlayout.h>
23#include <qlineedit.h>
24#include <qregexp.h>
25
26#include <qpe/config.h>
27#include <qpe/timestring.h>
28#include <qpe/qcopenvelope_qws.h>
29
30#include "ticker.h"
31
32extern "C" {
33#include "libstocks/stocks.h"
34}
35
36#include "stocktickerpluginwidget.h"
37
38StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name)
39 : QWidget(parent, name ) {
40 init();
41}
42
43StockTickerPluginWidget::~StockTickerPluginWidget() {
44}
45
46void StockTickerPluginWidget::init() {
47
48 QHBoxLayout* layout = new QHBoxLayout( this );
49
50 stocktickerTicker = new Ticker(this);
51 stocktickerTicker->setMinimumHeight(15);
52 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( doStocks() ));
53
54 layout->addWidget( stocktickerTicker);
55}
56
57void StockTickerPluginWidget::doStocks() {
58
59 Config cfg( "stockticker");
60 cfg.setGroup( "Symbols" );
61 QString symbollist;
62 symbollist = cfg.readEntry("Symbols", "");
63 symbollist.replace(QRegExp(" "),"+");//seperated by +
64// qDebug(symbollist);
65
66 getStocks( symbollist.latin1());
67
68 stocktickerTicker->setText( output );
69}
70
71void StockTickerPluginWidget::getStocks( const char *blah) {
72
73 stock *stocks_quotes=NULL;
74 stock *stocks_tmp;
75
76 QString tempString;
77 output = "";
78
79 libstocks_return_code error;
80
81 Config cfg( "stockticker");
82 cfg.setGroup( "Fields" );
83 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
84 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
85 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
86
87 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
88
89 dotimeCheck=cfg.readBoolEntry("timeCheck",1);
90 dodateCheck=cfg.readBoolEntry("dateCheck",1);
91 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1);
92 donameCheck=cfg.readBoolEntry("nameCheck",1);
93 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1);
94 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1);
95 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1);
96 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1);
97 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1);
98 dovariationCheck=cfg.readBoolEntry("variationCheck",1);
99 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1);
100
101 DefProxy();
102 char *stock_liste = (char *)blah;
103 /* Get the stocks and process errors */
104 error = get_stocks( stock_liste, &stocks_quotes);
105
106 if (error) {
107 printf("Error in getting stocks (%d)\n", error);
108 tempString.sprintf("Error in getting stocks (%d)\n", error);
109 output =tempString;
110 return;
111// exit(1);
112 }
113
114 stocks_tmp = stocks_quotes;
115
116 /* Displays the stocks */
117 while(stocks_tmp!=0){
118
119 if (stocks_tmp->Time) {
120// printf("%s ", stocks_tmp->Time);
121 tempString.sprintf("|| %s ", stocks_tmp->Time);
122 tempString.replace(QRegExp("\""),"");
123 if( dotimeCheck)
124 output +=tempString;
125 }
126 if (stocks_tmp->Date) {
127// printf("%s ", stocks_tmp->Date);
128 tempString.sprintf("| %s ", stocks_tmp->Date);
129 tempString.replace(QRegExp("\""),"");
130 if(dodateCheck)
131 output +=tempString;
132 }
133// printf("\n");
134
135// printf("----------------------------------------\n");
136
137 if ( strlen(stocks_tmp->Symbol) > 20 ) {
138// printf("| Symbol | %.20s |\n",stocks_tmp->Symbol);
139 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
140 if(dosymbolCheck)
141 output +=tempString;
142 }
143 else {
144// printf("| Symbol | %-20s |\n",stocks_tmp->Symbol);
145 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
146 if(dosymbolCheck)
147 output +=tempString;
148 }
149
150 if (stocks_tmp->Name) {
151 if ( strlen(stocks_tmp->Name) > 20 ) {
152// printf("| Name %.20s |\n",stocks_tmp->Name);
153 tempString.sprintf("| Name %s ",stocks_tmp->Name);
154 tempString.stripWhiteSpace();
155 if(donameCheck)
156 output +=tempString;
157 } else {
158// printf("| Name | %-20s |\n",stocks_tmp->Name);
159 tempString.sprintf("| Name %s ",stocks_tmp->Name);
160 tempString.stripWhiteSpace();
161 if(donameCheck)
162 output +=tempString;
163 }
164 }
165 else {
166// printf("| Name | |\n");
167 tempString.sprintf("| Name | |");
168 if(donameCheck)
169 output +=tempString;
170 }
171
172// printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice);
173 tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice);
174 if(docurrentPriceCheck)
175 output +=tempString;
176
177// printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice);
178 tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice);
179 if(dolastPriceCheck)
180 output +=tempString;
181
182// printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice);
183 tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice);
184 if(doopenPriceCheck)
185 output +=tempString;
186
187// printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice);
188 tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice);
189 if(dominPriceCheck)
190 output +=tempString;
191
192// printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice);
193 tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice);
194 if(domaxPriceCheck)
195 output +=tempString;
196
197// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage);
198 tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage);
199 if(dovariationCheck)
200 output +=tempString;
201
202// printf("| Volume | %-9d |\n", stocks_tmp->Volume);
203 tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume);
204 if(dovolumeCheck)
205 output +=tempString;
206
207// printf("----------------------------------------\n\n");
208 tempString.sprintf("||==++==");
209 output +=tempString;
210
211 /* Simple function which help to browse in the stocks list */
212 stocks_tmp = next_stock(stocks_tmp);
213 }
214
215 /* frees stocks */
216 free_stocks(stocks_quotes);
217
218}
219
220void StockTickerPluginWidget::DefProxy(void) {
221 char *proxy;
222 libstocks_return_code error;
223
224 /* Proxy support */
225 /* Checks for "http_proxy" environment variable */
226 proxy = getenv("http_proxy");
227 if(proxy) {
228 /* printf("proxy set\n"); */
229 error = set_proxy(proxy);
230 if (error) {
231// printf("Proxy error (%d)\n", error);
232 QString tempString;
233 tempString.sprintf("Proxy error (%d)\n", error);
234 output = tempString;
235 return;
236// exit(1);
237 }
238 }
239}
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h
new file mode 100644
index 0000000..6524ae4
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h
@@ -0,0 +1,62 @@
1/*
2 * stocktickerpluginwidget.h
3 *
4 * copyright : (c) 2002 by L.J. Potter
5 * email : lornkcor@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18#ifndef STOCKTICKERL_PLUGIN_WIDGET_H
19#define STOCKTICKERL_PLUGIN_WIDGET_H
20
21#include <qstring.h>
22#include <qwidget.h>
23#include <qlineedit.h>
24
25#include <opie/tododb.h>
26#include <opie/oclickablelabel.h>
27
28#include <sys/types.h>
29#include <sys/uio.h>
30#include <unistd.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include "ticker.h"
36
37/* extern "C" { */
38/* #include "stocks.h" */
39/* } */
40
41class StockTickerPluginWidget : public QWidget {
42
43 Q_OBJECT
44
45public:
46 StockTickerPluginWidget( QWidget *parent, const char *name );
47 ~StockTickerPluginWidget();
48 QString output;
49
50protected slots:
51 void doStocks();
52
53private:
54 Ticker *stocktickerTicker;
55
56 void init();
57 void getStocks( const char *stock_liste);
58 void DefProxy(void);
59
60};
61
62#endif
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktimerpluginwidget.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktimerpluginwidget.h
new file mode 100644
index 0000000..2feef80
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktimerpluginwidget.h
@@ -0,0 +1,45 @@
1/*
2 * mailpluginwidget.h
3 *
4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org
6 *
7 */
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18#ifndef MAIL_PLUGIN_WIDGET_H
19#define MAIL_PLUGIN_WIDGET_H
20
21#include <qstring.h>
22#include <qwidget.h>
23
24#include <opie/tododb.h>
25#include <opie/oclickablelabel.h>
26
27class MailPluginWidget : public QWidget {
28
29 Q_OBJECT
30
31
32public:
33 MailPluginWidget( QWidget *parent, const char *name );
34 ~MailPluginWidget();
35
36protected slots:
37 void startMail();
38
39private:
40 OClickableLabel *mailLabel;
41 void readConfig();
42 void getInfo();
43};
44
45#endif
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/ticker.cpp b/noncore/todayplugins/stockticker/stocktickerlib/ticker.cpp
new file mode 100644
index 0000000..6e6273b
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/ticker.cpp
@@ -0,0 +1,93 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h>
36#include <qpe/config.h>
37
38#include <qwidget.h>
39#include <qpixmap.h>
40#include <qbutton.h>
41#include <qpainter.h>
42#include <qframe.h>
43#include <qlayout.h>
44#include <qdir.h>
45#include <stdlib.h>
46#include <stdio.h>
47
48#include "ticker.h"
49
50Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
51 setFrameStyle( NoFrame/*WinPanel | Sunken */);
52}
53
54Ticker::~Ticker() {
55}
56
57void Ticker::setText( const QString& text ) {
58
59 pos = 0; // reset it everytime the text is changed
60 scrollText = text;
61
62 int pixelLen = fontMetrics().width( text );
63 QPixmap pm( pixelLen, contentsRect().height() );
64 pm.fill( QColor( 167, 212, 167 ) );
65 QPainter pmp( &pm );
66 pmp.setPen( Qt::black );
67 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText );
68 pmp.end();
69 scrollTextPixmap = pm;
70
71 killTimers();
72 if ( pixelLen > contentsRect().width() )
73 startTimer( 50 );
74 update();
75}
76
77
78void Ticker::timerEvent( QTimerEvent * ) {
79 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - 1;
80 repaint( FALSE );
81}
82
83void Ticker::drawContents( QPainter *p ) {
84 int pixelLen = scrollTextPixmap.width();
85 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
86 if ( pixelLen > contentsRect().width() ) // Scrolling
87 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
88}
89
90void Ticker::mouseReleaseEvent( QMouseEvent * e) {
91 qDebug("<<<<<<<>>>>>>>>>");
92 emit mousePressed();
93}
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/ticker.h b/noncore/todayplugins/stockticker/stocktickerlib/ticker.h
new file mode 100644
index 0000000..3b68928
--- a/dev/null
+++ b/noncore/todayplugins/stockticker/stocktickerlib/ticker.h
@@ -0,0 +1,32 @@
1#ifndef TICKER_H
2#define TICKER_H
3
4#include <qwidget.h>
5#include <qpainter.h>
6#include <qdrawutil.h>
7#include <qpixmap.h>
8#include <qstring.h>
9#include <qslider.h>
10#include <qframe.h>
11#include <qlineedit.h>
12
13class Ticker : public QFrame {
14 Q_OBJECT
15
16public:
17 Ticker( QWidget* parent=0 );
18 ~Ticker();
19 void setText( const QString& text ) ;
20signals:
21 void mousePressed();
22protected:
23 void timerEvent( QTimerEvent * );
24 void drawContents( QPainter *p );
25 void mouseReleaseEvent ( QMouseEvent *);
26private:
27 QString scrollText;
28 QPixmap scrollTextPixmap;
29 int pos;//, pixelLen;
30};
31
32#endif