summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-10 23:49:18 (UTC)
committer llornkcor <llornkcor>2002-11-10 23:49:18 (UTC)
commit38b632ddbe065403b84bf29949941c88f8916d41 (patch) (unidiff)
tree143f923544f1d33a4c0a4cab820cf20890b0fadd
parent41c15dff26825ba13233d84583080e6bceee470f (diff)
downloadopie-38b632ddbe065403b84bf29949941c88f8916d41.zip
opie-38b632ddbe065403b84bf29949941c88f8916d41.tar.gz
opie-38b632ddbe065403b84bf29949941c88f8916d41.tar.bz2
added scroll speed options
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp32
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h2
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp11
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h1
4 files changed, 40 insertions, 6 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp
index 11b615b..fdabd5c 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp
@@ -1,181 +1,211 @@
1/* 1/*
2 * stocktickeRconfig.cpp 2 * stocktickeRconfig.cpp
3 * 3 *
4 * copyright : (c) 2002 by ljp 4 * copyright : (c) 2002 by ljp
5 * email : llornkcor@handhelds.org 5 * email : llornkcor@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "stocktickerconfig.h" 17#include "stocktickerconfig.h"
18#include <opie/todayconfigwidget.h> 18#include <opie/todayconfigwidget.h>
19 19
20#include <qpe/config.h> 20#include <qpe/config.h>
21 21
22#include <qapplication.h> 22#include <qapplication.h>
23 23
24#include <qspinbox.h> 24#include <qspinbox.h>
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qvariant.h> 29#include <qvariant.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qmainwindow.h> 35#include <qmainwindow.h>
36 36
37#include <stdlib.h> 37#include <stdlib.h>
38 38
39StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char* name) 39StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char* name)
40 : TodayConfigWidget(parent, name ) { 40 : TodayConfigWidget(parent, name ) {
41 41
42 QGridLayout *layout = new QGridLayout( this ); 42 QGridLayout *layout = new QGridLayout( this );
43 layout->setSpacing(2); 43 layout->setSpacing(2);
44 layout->setMargin( 2); 44 layout->setMargin( 2);
45 45
46 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 46 LineEdit1 = new QLineEdit( this, "LineEdit1" );
47 LineEdit1->setFocus(); 47 LineEdit1->setFocus();
48// QWhatsThis::add( LineEdit1, tr("Enter the stock symbols you want to be shown here.")); 48// QWhatsThis::add( LineEdit1, tr("Enter the stock symbols you want to be shown here."));
49 49
50 layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 4); 50 layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 4);
51 51
52 Config cfg( "stockticker"); 52 Config cfg( "stockticker");
53 cfg.setGroup( "Symbols" ); 53 cfg.setGroup( "Symbols" );
54 QString symbollist; 54 QString symbollist;
55 symbollist = cfg.readEntry("Symbols", ""); 55 symbollist = cfg.readEntry("Symbols", "");
56 LineEdit1->setText(symbollist); 56 LineEdit1->setText(symbollist);
57 57
58 QLabel *label; 58 QLabel *label;
59 label = new QLabel(this); 59 label = new QLabel(this);
60 label->setText( tr("Enter stock symbols seperated\nby a space.")); 60 label->setText( tr("Enter stock symbols seperated\nby a space."));
61 label->setMaximumHeight(60); 61 label->setMaximumHeight(60);
62 layout->addMultiCellWidget( label, 1, 1, 0, 4); 62 layout->addMultiCellWidget( label, 1, 1, 0, 4);
63 63
64 cfg.setGroup( "Fields" ); 64 cfg.setGroup( "Fields" );
65 65
66 timeCheck= new QCheckBox ( "Time",this ); 66 timeCheck= new QCheckBox ( "Time",this );
67 timeCheck->setChecked( cfg.readBoolEntry("timeCheck",1)); 67 timeCheck->setChecked( cfg.readBoolEntry("timeCheck",1));
68 layout->addMultiCellWidget(timeCheck, 2, 2, 0, 0 ); 68 layout->addMultiCellWidget(timeCheck, 2, 2, 0, 0 );
69 QWhatsThis::add( timeCheck, tr("Toggles Time of current price field")); 69 QWhatsThis::add( timeCheck, tr("Toggles Time of current price field"));
70 70
71 dateCheck= new QCheckBox ( "Date", this ); 71 dateCheck= new QCheckBox ( "Date", this );
72 dateCheck->setChecked( cfg.readBoolEntry("dateCheck",1)); 72 dateCheck->setChecked( cfg.readBoolEntry("dateCheck",1));
73 layout->addMultiCellWidget( dateCheck, 2, 2, 1, 1 ); 73 layout->addMultiCellWidget( dateCheck, 2, 2, 1, 1 );
74 QWhatsThis::add(dateCheck, tr("Toggles date field")); 74 QWhatsThis::add(dateCheck, tr("Toggles date field"));
75 75
76 symbolCheck= new QCheckBox ( "Symbol", this ); 76 symbolCheck= new QCheckBox ( "Symbol", this );
77 symbolCheck->setChecked( cfg.readBoolEntry("symbolCheck",1)); 77 symbolCheck->setChecked( cfg.readBoolEntry("symbolCheck",1));
78 layout->addMultiCellWidget( symbolCheck, 2, 2, 2, 2 ); 78 layout->addMultiCellWidget( symbolCheck, 2, 2, 2, 2 );
79 QWhatsThis::add(symbolCheck, tr("Toggles Symbol field")); 79 QWhatsThis::add(symbolCheck, tr("Toggles Symbol field"));
80 80
81 nameCheck= new QCheckBox ( "Name", this ); 81 nameCheck= new QCheckBox ( "Name", this );
82 nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1)); 82 nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1));
83 layout->addMultiCellWidget( nameCheck, 3, 3, 0, 0 ); 83 layout->addMultiCellWidget( nameCheck, 3, 3, 0, 0 );
84 QWhatsThis::add(nameCheck, tr("Toggles Name of symbols owner field")); 84 QWhatsThis::add(nameCheck, tr("Toggles Name of symbols owner field"));
85 85
86 currentPriceCheck= new QCheckBox ( "Price", this ); 86 currentPriceCheck= new QCheckBox ( "Price", this );
87 currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1)); 87 currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1));
88 layout->addMultiCellWidget( currentPriceCheck, 3, 3, 1, 1 ); 88 layout->addMultiCellWidget( currentPriceCheck, 3, 3, 1, 1 );
89 QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field")); 89 QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field"));
90 90
91 lastPriceCheck= new QCheckBox ( "Last Price", this ); 91 lastPriceCheck= new QCheckBox ( "Last Price", this );
92 lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1)); 92 lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1));
93 layout->addMultiCellWidget(lastPriceCheck, 3, 3, 2, 2); 93 layout->addMultiCellWidget(lastPriceCheck, 3, 3, 2, 2);
94 QWhatsThis::add(lastPriceCheck, tr("Toggles last price field")); 94 QWhatsThis::add(lastPriceCheck, tr("Toggles last price field"));
95 95
96 openPriceCheck= new QCheckBox ( "Open Price", this); 96 openPriceCheck= new QCheckBox ( "Open Price", this);
97 openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1)); 97 openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1));
98 layout->addMultiCellWidget( openPriceCheck, 4, 4, 0, 0 ); 98 layout->addMultiCellWidget( openPriceCheck, 4, 4, 0, 0 );
99 QWhatsThis::add(openPriceCheck, tr("Toggles opening price field")); 99 QWhatsThis::add(openPriceCheck, tr("Toggles opening price field"));
100 100
101 minPriceCheck= new QCheckBox ( "Min Price", this ); 101 minPriceCheck= new QCheckBox ( "Min Price", this );
102 minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1)); 102 minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1));
103 layout->addMultiCellWidget( minPriceCheck, 4, 4, 1, 1); 103 layout->addMultiCellWidget( minPriceCheck, 4, 4, 1, 1);
104 QWhatsThis::add(minPriceCheck, tr("Toggles minimum daily price field")); 104 QWhatsThis::add(minPriceCheck, tr("Toggles minimum daily price field"));
105 105
106 maxPriceCheck= new QCheckBox ( "Max Price", this); 106 maxPriceCheck= new QCheckBox ( "Max Price", this);
107 maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1)); 107 maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1));
108 layout->addMultiCellWidget( maxPriceCheck, 4, 4, 2, 2 ); 108 layout->addMultiCellWidget( maxPriceCheck, 4, 4, 2, 2 );
109 QWhatsThis::add(maxPriceCheck, tr("Toggles maximum daily price field")); 109 QWhatsThis::add(maxPriceCheck, tr("Toggles maximum daily price field"));
110 110
111 variationCheck= new QCheckBox ( "Variation", this ); 111 variationCheck= new QCheckBox ( "Variation", this );
112 variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1)); 112 variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1));
113 layout->addMultiCellWidget( variationCheck, 5, 5, 0, 0 ); 113 layout->addMultiCellWidget( variationCheck, 5, 5, 0, 0 );
114 QWhatsThis::add(variationCheck, tr("Toggles daily variation of price field")); 114 QWhatsThis::add(variationCheck, tr("Toggles daily variation of price field"));
115 115
116 volumeCheck= new QCheckBox ( "Volume", this ); 116 volumeCheck= new QCheckBox ( "Volume", this );
117 volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1)); 117 volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1));
118 layout->addMultiCellWidget( volumeCheck , 5, 5, 1, 1); 118 layout->addMultiCellWidget( volumeCheck , 5, 5, 1, 1);
119 QWhatsThis::add(volumeCheck, tr("Toggles volume of trading field")); 119 QWhatsThis::add(volumeCheck, tr("Toggles volume of trading field"));
120 120
121 timerDelaySpin = new QSpinBox( this, "timer spin" ); 121 timerDelaySpin = new QSpinBox( this, "timer spin" );
122 QWhatsThis::add( timerDelaySpin , tr( "How often stocks prices should be looked up. In minutes" ) ); 122 QWhatsThis::add( timerDelaySpin , tr( "How often stocks prices should be looked up. In minutes" ) );
123 timerDelaySpin->setMaxValue( 60); 123 timerDelaySpin->setMaxValue( 60);
124 124
125 cfg.setGroup("Timer"); 125 cfg.setGroup("Timer");
126 timerDelaySpin->setValue( cfg.readNumEntry("Delay",0)); 126 timerDelaySpin->setValue( cfg.readNumEntry("Delay",0));
127 layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0); 127 layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0);
128 128
129 QLabel *label2; 129 QLabel *label2;
130 label2 = new QLabel(this); 130 label2 = new QLabel(this);
131 label2->setText( tr("Minutes between lookups.")); 131 label2->setText( tr("Minutes between lookups."));
132 label2->setMaximumHeight(60); 132 label2->setMaximumHeight(60);
133 layout->addMultiCellWidget( label2, 6, 6, 1, 2); 133 layout->addMultiCellWidget( label2, 6, 6, 1, 2);
134 134
135 scrollSpeed = new QSpinBox( this, "Scrollspin" );
136 QWhatsThis::add( timerDelaySpin , tr( "Speed of scrolling action, in milliseconds" ) );
137 scrollSpeed->setMaxValue( 1000);
138 scrollSpeed->setSteps(50,50);
139 cfg.setGroup("Timer");
140 scrollSpeed->setValue( cfg.readNumEntry("ScrollSpeed",50));
141 layout->addMultiCellWidget( scrollSpeed , 7, 7, 0, 0);
142
143 QLabel *label3;
144 label3 = new QLabel(this);
145 label3->setText( tr("Scroll Speed, in milliseconds"));
146 label3->setMaximumHeight(60);
147 layout->addMultiCellWidget( label3, 7, 7, 1, 2);
148
149 scrollLength = new QSpinBox( this, "ScrollLength" );
150 QWhatsThis::add( timerDelaySpin , tr( "Length of scrolling" ) );
151 scrollLength->setMaxValue( 10);
152// scrollLength->setSteps(5,5);
153 cfg.setGroup("Timer");
154 scrollLength->setValue( cfg.readNumEntry("ScrollLength",1));
155 layout->addMultiCellWidget( scrollLength , 8, 8, 0, 0);
156
157 QLabel *label4;
158 label4 = new QLabel(this);
159 label4->setText( tr("Scroll Length"));
160 label4->setMaximumHeight(60);
161 layout->addMultiCellWidget( label4, 8, 8, 1, 2);
162
135// lookupButton = new QPushButton(this, "LookupButton"); 163// lookupButton = new QPushButton(this, "LookupButton");
136// lookupButton->setText(tr("Symbol Lookup")); 164// lookupButton->setText(tr("Symbol Lookup"));
137// connect(lookupButton,SIGNAL(clicked()),SLOT( doLookup())); 165// connect(lookupButton,SIGNAL(clicked()),SLOT( doLookup()));
138// layout->addMultiCellWidget( lookupButton , 9, 9, 0, 0); 166// layout->addMultiCellWidget( lookupButton , 9, 9, 0, 0);
139 167
140 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); 168 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
141 layout->addItem( spacer, 8, 0 ); 169 layout->addItem( spacer, 9, 0 );
142 170
143} 171}
144 172
145 173
146void StocktickerPluginConfig::writeConfig() { 174void StocktickerPluginConfig::writeConfig() {
147 Config cfg( "stockticker"); 175 Config cfg( "stockticker");
148 cfg.setGroup( "Symbols" ); 176 cfg.setGroup( "Symbols" );
149 QString outText = text().upper(); 177 QString outText = text().upper();
150 outText.stripWhiteSpace(); 178 outText.stripWhiteSpace();
151 cfg.writeEntry("Symbols", outText ); 179 cfg.writeEntry("Symbols", outText );
152 cfg.setGroup( "Fields" ); 180 cfg.setGroup( "Fields" );
153 cfg.writeEntry("timeCheck",timeCheck->isChecked()); 181 cfg.writeEntry("timeCheck",timeCheck->isChecked());
154 cfg.writeEntry("dateCheck",dateCheck->isChecked()); 182 cfg.writeEntry("dateCheck",dateCheck->isChecked());
155 cfg.writeEntry("symbolCheck",symbolCheck->isChecked()); 183 cfg.writeEntry("symbolCheck",symbolCheck->isChecked());
156 cfg.writeEntry("nameCheck",nameCheck->isChecked()); 184 cfg.writeEntry("nameCheck",nameCheck->isChecked());
157 cfg.writeEntry("currentPriceCheck",currentPriceCheck->isChecked()); 185 cfg.writeEntry("currentPriceCheck",currentPriceCheck->isChecked());
158 cfg.writeEntry("lastPriceCheck",lastPriceCheck->isChecked()); 186 cfg.writeEntry("lastPriceCheck",lastPriceCheck->isChecked());
159 cfg.writeEntry("openPriceCheck",openPriceCheck->isChecked()); 187 cfg.writeEntry("openPriceCheck",openPriceCheck->isChecked());
160 cfg.writeEntry("minPriceCheck",minPriceCheck->isChecked()); 188 cfg.writeEntry("minPriceCheck",minPriceCheck->isChecked());
161 cfg.writeEntry("maxPriceCheck",maxPriceCheck->isChecked()); 189 cfg.writeEntry("maxPriceCheck",maxPriceCheck->isChecked());
162 cfg.writeEntry("variationCheck",variationCheck->isChecked()); 190 cfg.writeEntry("variationCheck",variationCheck->isChecked());
163 cfg.writeEntry("volumeCheck",volumeCheck->isChecked()); 191 cfg.writeEntry("volumeCheck",volumeCheck->isChecked());
164 192
165 cfg.setGroup("Timer"); 193 cfg.setGroup("Timer");
166 cfg.writeEntry("Delay",timerDelaySpin->value()); 194 cfg.writeEntry("Delay",timerDelaySpin->value());
195 cfg.writeEntry("ScrollLength",scrollLength->value());
196 cfg.writeEntry("ScrollSpeed",scrollSpeed->value());
167 197
168 cfg.write(); 198 cfg.write();
169} 199}
170 200
171StocktickerPluginConfig::~StocktickerPluginConfig() { 201StocktickerPluginConfig::~StocktickerPluginConfig() {
172} 202}
173 203
174QString StocktickerPluginConfig::text() const { 204QString StocktickerPluginConfig::text() const {
175 return LineEdit1->text(); 205 return LineEdit1->text();
176} 206}
177 207
178void StocktickerPluginConfig::doLookup() { 208void StocktickerPluginConfig::doLookup() {
179 209
180 system("stockticker"); 210 system("stockticker");
181} 211}
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h
index 33aed86..2b67a8b 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h
@@ -1,46 +1,46 @@
1/* 1/*
2 * stocktickerconfig.h 2 * stocktickerconfig.h
3 * 3 *
4 * copyright : (c) 2002 by LJP 4 * copyright : (c) 2002 by LJP
5 * email : llornkcor@handhelds.org 5 * email : llornkcor@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#ifndef STOCKTICKER_PLUGIN_CONFIG_H 17#ifndef STOCKTICKER_PLUGIN_CONFIG_H
18#define STOCKTICKER_PLUGIN_CONFIG_H 18#define STOCKTICKER_PLUGIN_CONFIG_H
19 19
20#include <qwidget.h> 20#include <qwidget.h>
21#include <opie/todayconfigwidget.h> 21#include <opie/todayconfigwidget.h>
22#include <qstring.h> 22#include <qstring.h>
23 23
24class QLineEdit; 24class QLineEdit;
25class QCheckBox; 25class QCheckBox;
26class QPushButton; 26class QPushButton;
27class QCheckBox; 27class QCheckBox;
28class QSpinBox; 28class QSpinBox;
29 29
30class StocktickerPluginConfig : public TodayConfigWidget { 30class StocktickerPluginConfig : public TodayConfigWidget {
31//Q_OBJECT 31//Q_OBJECT
32public: 32public:
33 StocktickerPluginConfig( QWidget *parent, const char *name ); 33 StocktickerPluginConfig( QWidget *parent, const char *name );
34 ~StocktickerPluginConfig(); 34 ~StocktickerPluginConfig();
35 QString text() const; 35 QString text() const;
36 void writeConfig(); 36 void writeConfig();
37private: 37private:
38 QLineEdit* LineEdit1; 38 QLineEdit* LineEdit1;
39 QCheckBox *timeCheck, *dateCheck, *symbolCheck, *nameCheck, *currentPriceCheck, *lastPriceCheck, *openPriceCheck, *minPriceCheck, *maxPriceCheck, *variationCheck, *volumeCheck; 39 QCheckBox *timeCheck, *dateCheck, *symbolCheck, *nameCheck, *currentPriceCheck, *lastPriceCheck, *openPriceCheck, *minPriceCheck, *maxPriceCheck, *variationCheck, *volumeCheck;
40 QPushButton *lookupButton; 40 QPushButton *lookupButton;
41 QSpinBox *timerDelaySpin; 41 QSpinBox *timerDelaySpin, *scrollSpeed, *scrollLength;
42private slots: 42private slots:
43 void doLookup(); 43 void doLookup();
44 44
45}; 45};
46#endif 46#endif
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index 18c9e51..0d90d0f 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -23,286 +23,289 @@
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28 28
29#include <qpe/config.h> 29#include <qpe/config.h>
30#include <qpe/timestring.h> 30#include <qpe/timestring.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32#include <qpe/network.h> 32#include <qpe/network.h>
33 33
34#include <opie/oticker.h> 34#include <opie/oticker.h>
35 35
36extern "C" { 36extern "C" {
37#include "libstocks/stocks.h" 37#include "libstocks/stocks.h"
38} 38}
39 39
40#include <pthread.h> 40#include <pthread.h>
41 41
42#include "stocktickerpluginwidget.h" 42#include "stocktickerpluginwidget.h"
43 43
44QString output; 44QString output;
45OTicker *stocktickerTicker; 45OTicker *stocktickerTicker;
46 46
47void getStocks( const QString *blah) { 47void getStocks( const QString *blah) {
48 48
49// stocktickerTicker->setText( "Downloading stock data."); 49// stocktickerTicker->setText( "Downloading stock data.");
50 stock *stocks_quotes=NULL; 50 stock *stocks_quotes=NULL;
51 stock *stocks_tmp; 51 stock *stocks_tmp;
52 qDebug("%s", blah->latin1()); 52 qDebug("%s", blah->latin1());
53 QString tempString; 53 QString tempString;
54 output = ""; 54 output = "";
55 55
56 libstocks_return_code error; 56 libstocks_return_code error;
57 57
58 Config cfg( "stockticker"); 58 Config cfg( "stockticker");
59 cfg.setGroup( "Fields" ); 59 cfg.setGroup( "Fields" );
60 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; 60 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
61 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; 61 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
62 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; 62 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
63 63
64 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; 64 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
65 65
66 dotimeCheck=cfg.readBoolEntry("timeCheck",1); 66 dotimeCheck=cfg.readBoolEntry("timeCheck",1);
67 dodateCheck=cfg.readBoolEntry("dateCheck",1); 67 dodateCheck=cfg.readBoolEntry("dateCheck",1);
68 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); 68 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1);
69 donameCheck=cfg.readBoolEntry("nameCheck",1); 69 donameCheck=cfg.readBoolEntry("nameCheck",1);
70 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); 70 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1);
71 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); 71 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1);
72 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); 72 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1);
73 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); 73 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1);
74 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); 74 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1);
75 dovariationCheck=cfg.readBoolEntry("variationCheck",1); 75 dovariationCheck=cfg.readBoolEntry("variationCheck",1);
76 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); 76 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1);
77 77
78// DefProxy(); 78// DefProxy();
79 { 79 {
80 char *proxy; 80 char *proxy;
81 libstocks_return_code error; 81 libstocks_return_code error;
82 82
83 /* Proxy support */ 83 /* Proxy support */
84 /* Checks for "http_proxy" environment variable */ 84 /* Checks for "http_proxy" environment variable */
85 proxy = getenv("http_proxy"); 85 proxy = getenv("http_proxy");
86 if(proxy) { 86 if(proxy) {
87 /* printf("proxy set\n"); */ 87 /* printf("proxy set\n"); */
88 error = set_proxy(proxy); 88 error = set_proxy(proxy);
89 if (error) { 89 if (error) {
90 printf("Proxy error (%d)\n", error); 90 printf("Proxy error (%d)\n", error);
91 QString tempString; 91 QString tempString;
92 tempString.sprintf("Proxy error (%d)\n", error); 92 tempString.sprintf("Proxy error (%d)\n", error);
93 output = tempString; 93 output = tempString;
94 return; 94 return;
95// exit(1); 95// exit(1);
96 } 96 }
97 } 97 }
98 } 98 }
99 char *stock_liste = (char *)blah->latin1(); 99 char *stock_liste = (char *)blah->latin1();
100// char *stock_liste = (char *)blah; 100// char *stock_liste = (char *)blah;
101 /* Get the stocks and process errors */ 101 /* Get the stocks and process errors */
102 error = get_stocks( stock_liste, &stocks_quotes); 102 error = get_stocks( stock_liste, &stocks_quotes);
103 103
104 if (error) { 104 if (error) {
105 printf("Error in getting stocks (%d)\n", error); 105 printf("Error in getting stocks (%d)\n", error);
106 tempString.sprintf("Error in getting stocks (%d)\n", error); 106 tempString.sprintf("Error in getting stocks (%d)\n", error);
107 output =tempString; 107 output =tempString;
108 return; 108 return;
109// exit(1); 109// exit(1);
110 } 110 }
111 111
112 stocks_tmp = stocks_quotes; 112 stocks_tmp = stocks_quotes;
113 113
114 /* Displays the stocks */ 114 /* Displays the stocks */
115 while(stocks_tmp!=0){ 115 while(stocks_tmp!=0){
116 116
117 if (stocks_tmp->Time) { 117 if (stocks_tmp->Time) {
118// printf("%s ", stocks_tmp->Time); 118// printf("%s ", stocks_tmp->Time);
119 tempString.sprintf("| %s ", stocks_tmp->Time); 119 tempString.sprintf("| %s ", stocks_tmp->Time);
120 tempString.replace(QRegExp("\""),""); 120 tempString.replace(QRegExp("\""),"");
121 if( dotimeCheck) 121 if( dotimeCheck)
122 output +=tempString; 122 output +=tempString;
123 } 123 }
124 if (stocks_tmp->Date) { 124 if (stocks_tmp->Date) {
125// printf("%s ", stocks_tmp->Date); 125// printf("%s ", stocks_tmp->Date);
126 tempString.sprintf("| %s ", stocks_tmp->Date); 126 tempString.sprintf("| %s ", stocks_tmp->Date);
127 tempString.replace(QRegExp("\""),""); 127 tempString.replace(QRegExp("\""),"");
128 if(dodateCheck) 128 if(dodateCheck)
129 output +=tempString; 129 output +=tempString;
130 } 130 }
131// printf("\n"); 131// printf("\n");
132 132
133// printf("----------------------------------------\n"); 133// printf("----------------------------------------\n");
134 134
135 if ( strlen(stocks_tmp->Symbol) > 20 ) { 135 if ( strlen(stocks_tmp->Symbol) > 20 ) {
136// printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); 136// printf("| Symbol | %.20s |\n",stocks_tmp->Symbol);
137 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); 137 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
138 if(dosymbolCheck) 138 if(dosymbolCheck)
139 output +=tempString; 139 output +=tempString;
140 } 140 }
141 else { 141 else {
142// printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); 142// printf("| Symbol | %-20s |\n",stocks_tmp->Symbol);
143 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); 143 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
144 if(dosymbolCheck) 144 if(dosymbolCheck)
145 output +=tempString; 145 output +=tempString;
146 } 146 }
147 147
148 if (stocks_tmp->Name) { 148 if (stocks_tmp->Name) {
149 if ( strlen(stocks_tmp->Name) > 20 ) { 149 if ( strlen(stocks_tmp->Name) > 20 ) {
150// printf("| Name %.20s |\n",stocks_tmp->Name); 150// printf("| Name %.20s |\n",stocks_tmp->Name);
151 tempString.sprintf("| Name %s ",stocks_tmp->Name); 151 tempString.sprintf("| Name %s ",stocks_tmp->Name);
152 tempString.stripWhiteSpace(); 152 tempString.stripWhiteSpace();
153 if(donameCheck) 153 if(donameCheck)
154 output +=tempString; 154 output +=tempString;
155 } else { 155 } else {
156// printf("| Name | %-20s |\n",stocks_tmp->Name); 156// printf("| Name | %-20s |\n",stocks_tmp->Name);
157 tempString.sprintf("| Name %s ",stocks_tmp->Name); 157 tempString.sprintf("| Name %s ",stocks_tmp->Name);
158 tempString.stripWhiteSpace(); 158 tempString.stripWhiteSpace();
159 if(donameCheck) 159 if(donameCheck)
160 output +=tempString; 160 output +=tempString;
161 } 161 }
162 } 162 }
163 else { 163 else {
164// printf("| Name | |\n"); 164// printf("| Name | |\n");
165 tempString.sprintf("| Name | |"); 165 tempString.sprintf("| Name | |");
166 if(donameCheck) 166 if(donameCheck)
167 output +=tempString; 167 output +=tempString;
168 } 168 }
169 169
170// printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); 170// printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice);
171 tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); 171 tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice);
172 if(docurrentPriceCheck) 172 if(docurrentPriceCheck)
173 output +=tempString; 173 output +=tempString;
174 174
175// printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); 175// printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice);
176 tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); 176 tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice);
177 if(dolastPriceCheck) 177 if(dolastPriceCheck)
178 output +=tempString; 178 output +=tempString;
179 179
180// printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); 180// printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice);
181 tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); 181 tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice);
182 if(doopenPriceCheck) 182 if(doopenPriceCheck)
183 output +=tempString; 183 output +=tempString;
184 184
185// printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); 185// printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice);
186 tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); 186 tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice);
187 if(dominPriceCheck) 187 if(dominPriceCheck)
188 output +=tempString; 188 output +=tempString;
189 189
190// printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); 190// printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice);
191 tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); 191 tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice);
192 if(domaxPriceCheck) 192 if(domaxPriceCheck)
193 output +=tempString; 193 output +=tempString;
194 194
195// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); 195// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage);
196 tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); 196 tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage);
197 if(dovariationCheck) 197 if(dovariationCheck)
198 output +=tempString; 198 output +=tempString;
199 199
200// printf("| Volume | %-9d |\n", stocks_tmp->Volume); 200// printf("| Volume | %-9d |\n", stocks_tmp->Volume);
201 tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); 201 tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume);
202 if(dovolumeCheck) 202 if(dovolumeCheck)
203 output +=tempString; 203 output +=tempString;
204 204
205// printf("----------------------------------------\n\n"); 205// printf("----------------------------------------\n\n");
206 tempString.sprintf("||==++==|"); 206 tempString.sprintf("||==++==|");
207 output +=tempString; 207 output +=tempString;
208 208
209 /* Simple function which help to browse in the stocks list */ 209 /* Simple function which help to browse in the stocks list */
210 stocks_tmp = next_stock(stocks_tmp); 210 stocks_tmp = next_stock(stocks_tmp);
211 } 211 }
212 212
213 /* frees stocks */ 213 /* frees stocks */
214 free_stocks(stocks_quotes); 214 free_stocks(stocks_quotes);
215 stocktickerTicker->setText( output ); 215 stocktickerTicker->setText( output.latin1() );
216 216
217} 217}
218 218
219StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) 219StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name)
220 : QWidget(parent, name ) { 220 : QWidget(parent, name ) {
221 init(); 221 init();
222 startTimer(1000); 222 startTimer(1000);
223
224 stocktickerTicker->setTextFormat(Qt::RichText);
223// checkConnection(); 225// checkConnection();
224} 226}
225 227
226StockTickerPluginWidget::~StockTickerPluginWidget() { 228StockTickerPluginWidget::~StockTickerPluginWidget() {
227} 229}
228 230
229void StockTickerPluginWidget::init() { 231void StockTickerPluginWidget::init() {
230 232
231 QHBoxLayout* layout = new QHBoxLayout( this ); 233 QHBoxLayout* layout = new QHBoxLayout( this );
232 stocktickerTicker = new OTicker(this); 234 stocktickerTicker = new OTicker(this);
233// stocktickerTicker->setMinimumHeight(15); 235// stocktickerTicker->setMinimumHeight(15);
234 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); 236 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() ));
235 layout->addWidget( stocktickerTicker); 237 layout->addWidget( stocktickerTicker);
236 wasError = true; 238 wasError = true;
237} 239}
238 240
239void StockTickerPluginWidget::doStocks() { 241void StockTickerPluginWidget::doStocks() {
240 Config cfg( "stockticker"); 242 Config cfg( "stockticker");
241 cfg.setGroup( "Symbols" ); 243 cfg.setGroup( "Symbols" );
242 symbollist=""; 244 symbollist="";
243 symbollist = cfg.readEntry("Symbols", ""); 245 symbollist = cfg.readEntry("Symbols", "");
244 symbollist.replace(QRegExp(" "),"+");//seperated by + 246 symbollist.replace(QRegExp(" "),"+");//seperated by +
245 247
246// qDebug(symbollist); 248 cfg.setGroup("Timer");
249 stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50));
250 stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10));
251
247 if (!symbollist.isEmpty()) { 252 if (!symbollist.isEmpty()) {
248 pthread_t thread1; 253 pthread_t thread1;
249 pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist); 254 pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist);
250 } 255 }
251// pthread_join(thread1,NULL);
252// getStocks( symbollist.latin1() );
253} 256}
254 257
255void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { 258void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
256 killTimer(e->timerId()); 259 killTimer(e->timerId());
257 checkConnection(); 260 checkConnection();
258} 261}
259 262
260void StockTickerPluginWidget::checkConnection() { 263void StockTickerPluginWidget::checkConnection() {
261// qDebug("checking connection"); 264// qDebug("checking connection");
262// Sock = new QSocket( this ); 265// Sock = new QSocket( this );
263 266
264// if( wasError) 267// if( wasError)
265// stocktickerTicker->setText("Checking connection"); 268// stocktickerTicker->setText("Checking connection");
266 269
267// if(Sock->state() == QSocket::Idle) { 270// if(Sock->state() == QSocket::Idle) {
268// Sock->connectToHost("finance.yahoo.com", 80); 271// Sock->connectToHost("finance.yahoo.com", 80);
269// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); 272// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) );
270// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); 273// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) );
271// } else { 274// } else {
272// qDebug("State is not Idle"); 275// qDebug("State is not Idle");
273 isConnected(); 276 isConnected();
274// } 277// }
275} 278}
276 279
277void StockTickerPluginWidget::isConnected() { 280void StockTickerPluginWidget::isConnected() {
278// qDebug("We connect, so ok to grab stocks"); 281// qDebug("We connect, so ok to grab stocks");
279 doStocks(); 282 doStocks();
280 283
281 Config cfg( "stockticker"); 284 Config cfg( "stockticker");
282 cfg.setGroup("Timer"); 285 cfg.setGroup("Timer");
283 timerDelay= cfg.readNumEntry("Delay",0); 286 timerDelay= cfg.readNumEntry("Delay",0);
284 if(timerDelay > 0) 287 if(timerDelay > 0)
285 startTimer(timerDelay*60000); 288 startTimer(timerDelay*60000);
286 qDebug("timer set for %d",(timerDelay*60000)/60000); 289 qDebug("timer set for %d",(timerDelay*60000)/60000);
287 wasError = false; 290 wasError = false;
288 291
289// Sock->close(); 292// Sock->close();
290} 293}
291 294
292void StockTickerPluginWidget::socketError(int errcode) { 295void StockTickerPluginWidget::socketError(int errcode) {
293 switch(errcode) { 296 switch(errcode) {
294 case QSocket::ErrConnectionRefused: 297 case QSocket::ErrConnectionRefused:
295 output = tr("Connection refused."); 298 output = tr("Connection refused.");
296 break; 299 break;
297 case QSocket::ErrHostNotFound: 300 case QSocket::ErrHostNotFound:
298 output = tr("Could not find server."); 301 output = tr("Could not find server.");
299 break; 302 break;
300 case QSocket::ErrSocketRead : 303 case QSocket::ErrSocketRead :
301 output = tr("Socket read error."); 304 output = tr("Socket read error.");
302 break; 305 break;
303 }; 306 };
304 stocktickerTicker->setText( output ); 307 stocktickerTicker->setText( output );
305 wasError = true; 308 wasError = true;
306// Sock->close(); 309// Sock->close();
307 310
308} 311}
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h
index 8776bff..1189bf5 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h
@@ -1,62 +1,63 @@
1/* 1/*
2 * stocktickerpluginwidget.h 2 * stocktickerpluginwidget.h
3 * 3 *
4 * copyright : (c) 2002 by L.J. Potter 4 * copyright : (c) 2002 by L.J. Potter
5 * email : lornkcor@handhelds.org 5 * email : lornkcor@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17 17
18#ifndef STOCKTICKERL_PLUGIN_WIDGET_H 18#ifndef STOCKTICKERL_PLUGIN_WIDGET_H
19#define STOCKTICKERL_PLUGIN_WIDGET_H 19#define STOCKTICKERL_PLUGIN_WIDGET_H
20 20
21#include <qsocket.h> 21#include <qsocket.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25 25
26#include <opie/tododb.h> 26#include <opie/tododb.h>
27#include <opie/oclickablelabel.h> 27#include <opie/oclickablelabel.h>
28#include <opie/oticker.h> 28#include <opie/oticker.h>
29 29
30#include <sys/types.h> 30#include <sys/types.h>
31#include <sys/uio.h> 31#include <sys/uio.h>
32#include <unistd.h> 32#include <unistd.h>
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include <string.h> 35#include <string.h>
36 36
37class QTimer; 37class QTimer;
38 38
39class StockTickerPluginWidget : public QWidget { 39class StockTickerPluginWidget : public QWidget {
40 40
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 StockTickerPluginWidget( QWidget *parent, const char *name ); 44 StockTickerPluginWidget( QWidget *parent, const char *name );
45 ~StockTickerPluginWidget(); 45 ~StockTickerPluginWidget();
46 46
47protected slots: 47protected slots:
48 void doStocks(); 48 void doStocks();
49 void isConnected(); 49 void isConnected();
50 void socketError(int); 50 void socketError(int);
51 void checkConnection(); 51 void checkConnection();
52private: 52private:
53 int updateSpeed;
53 QString symbollist; 54 QString symbollist;
54 bool wasError; 55 bool wasError;
55 QSocket *Sock; 56 QSocket *Sock;
56 void timerEvent( QTimerEvent * ); 57 void timerEvent( QTimerEvent * );
57 void init(); 58 void init();
58// void DefProxy(void); 59// void DefProxy(void);
59 int timerDelay; 60 int timerDelay;
60}; 61};
61 62
62#endif 63#endif