summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
Unidiff
Diffstat (limited to 'noncore/todayplugins/stockticker/stockticker/inputDialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stockticker/inputDialog.cpp136
1 files changed, 41 insertions, 95 deletions
diff --git a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
index ad841f2..18021c2 100644
--- a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
+++ b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
@@ -10,134 +10,80 @@
10#include <qpushbutton.h> 10#include <qpushbutton.h>
11#include <qwhatsthis.h> 11#include <qwhatsthis.h>
12#include <qlabel.h> 12#include <qlabel.h>
13#include <qpe/config.h> 13#include <qpe/config.h>
14#include <qstringlist.h> 14#include <qstringlist.h>
15#include <qmainwindow.h> 15#include <qmainwindow.h>
16#include "helpwindow.h"
16 17
18#include <opie/oprocess.h>
19
20#include <stdlib.h>
21// #include <sys/stat.h>
22// #include <unistd.h>
17 23
18InputDialog::InputDialog( ) 24InputDialog::InputDialog( )
19 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { 25 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) {
20 setCaption( tr("Enter Stock Symbols")); 26 setCaption( tr("Symbol Lookup"));
21
22 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
23 27
24 QGridLayout *layout = new QGridLayout( this ); 28 QGridLayout *layout = new QGridLayout( this );
25 layout->setSpacing(6); 29 layout->setSpacing(6);
26 layout->setMargin( 2); 30 layout->setMargin( 2);
27 31
28 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 32 LineEdit1 = new QLineEdit( this, "LineEdit1" );
29 LineEdit1->setFocus(); 33 LineEdit1->setFocus();
30 QWhatsThis::add( LineEdit1, tr("Enter the stock symbols you want to be shown here."));
31 34
32 layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); 35 layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3);
33 36
34 Config cfg( "stockticker");
35 cfg.setGroup( "Symbols" );
36 QString symbollist;
37 symbollist = cfg.readEntry("Symbols", "");
38 LineEdit1->setText(symbollist);
39
40 QLabel *label; 37 QLabel *label;
41 label = new QLabel(this); 38 label = new QLabel(this);
42 label->setText( tr("Enter stock symbols seperated\nby a space.")); 39 label->setText( tr("Enter something to lookup / search."));
43 label->setMaximumHeight(60); 40 label->setMaximumHeight(60);
44 layout->addMultiCellWidget( label, 1, 1, 0, 3); 41 layout->addMultiCellWidget( label, 1, 1, 0, 3);
45 42
46 cfg.setGroup( "Fields" ); 43 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup()));
47 44 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
48 timeCheck= new QCheckBox ( "Time",this ); 45 layout->addItem( spacer, 8, 0 );
49 timeCheck->setChecked( cfg.readBoolEntry("timeCheck",1));
50 layout->addMultiCellWidget(timeCheck, 2, 2, 0, 0 );
51 QWhatsThis::add( timeCheck, tr("Toggles Time Field"));
52
53 dateCheck= new QCheckBox ( "Date", this );
54 dateCheck->setChecked( cfg.readBoolEntry("dateCheck",1));
55 layout->addMultiCellWidget( dateCheck, 2, 2, 1, 1 );
56 QWhatsThis::add(dateCheck, tr("Toggles date field"));
57
58 symbolCheck= new QCheckBox ( "Symbol", this );
59 symbolCheck->setChecked( cfg.readBoolEntry("symbolCheck",1));
60 layout->addMultiCellWidget( symbolCheck, 3, 3, 0, 0 );
61 QWhatsThis::add(symbolCheck, tr("Toggles Symbol field"));
62
63 nameCheck= new QCheckBox ( "Name", this );
64 nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1));
65 layout->addMultiCellWidget( nameCheck, 3, 3, 1, 1 );
66 QWhatsThis::add(nameCheck, tr("Toggles Name field"));
67
68 currentPriceCheck= new QCheckBox ( "Current Price", this );
69 currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1));
70 layout->addMultiCellWidget( currentPriceCheck, 4, 4, 0, 0 );
71 QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field"));
72
73 46
74 lastPriceCheck= new QCheckBox ( "Last Price", this ); 47}
75 lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1));
76 layout->addMultiCellWidget(lastPriceCheck, 4, 4, 1, 1);
77 QWhatsThis::add(lastPriceCheck, tr("Toggles last price field"));
78 48
79 openPriceCheck= new QCheckBox ( "Open Price", this); 49InputDialog::~InputDialog() {
80 openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1)); 50}
81 layout->addMultiCellWidget( openPriceCheck, 5, 5, 0, 0 );
82 QWhatsThis::add(openPriceCheck, tr("Toggles opening price field"));
83 51
84 minPriceCheck= new QCheckBox ( "Min Price", this ); 52void InputDialog::doLookup() {
85 minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1)); 53// http://finance.yahoo.com/l?m=&s=siemens&t=
86 layout->addMultiCellWidget( minPriceCheck, 5, 5, 1, 1);
87 QWhatsThis::add(minPriceCheck, tr("Toggles minamum price field"));
88 54
89 maxPriceCheck= new QCheckBox ( "Max Price", this); 55 QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\"";
90 maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1)); 56 QString tempHtml = "/tmp/stockticker.html";
91 layout->addMultiCellWidget( maxPriceCheck, 6, 6, 0, 0 ); 57 QString cmd = "wget -O "+tempHtml+" "+url;
92 QWhatsThis::add(maxPriceCheck, tr("Toggles maximum price field")); 58 qDebug(cmd);
93 59
94 variationCheck= new QCheckBox ( "Variation", this );
95 variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1));
96 layout->addMultiCellWidget( variationCheck, 6, 6, 1, 1 );
97 QWhatsThis::add(variationCheck, tr("Toggles daily variation field"));
98 60
99 volumeCheck= new QCheckBox ( "Volume", this ); 61/*
100 volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1)); 62 OProcess proc;
101 layout->addMultiCellWidget( volumeCheck , 7, 7, 0, 0); 63 proc << "/usr/bin/wget";
102 QWhatsThis::add(volumeCheck, tr("Toggles volume field")); 64 proc<<"-O"<< tempHtml<< url;
103 65
66 connect( &proc, SIGNAL( processExited( OProcess *)),this, SLOT( showBrowser(OProcess *)));
67 proc.start( OProcess::NotifyOnExit);
68*/
69 system(cmd.latin1());
70 HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup");
71 StockLookup->setCaption("Symbol");
72 StockLookup->showMaximized();
73 StockLookup->show();
74 LineEdit1->text();
104 75
105 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
106 layout->addItem( spacer, 8, 0 );
107 76
108} 77}
109 78
110QString InputDialog::text() const { 79void InputDialog::showBrowser(OProcess*) {
111 return LineEdit1->text(); 80 qDebug("BLAH");
112} 81 QString tempHtml = "/tmp/stockticker.html";
113 82
114InputDialog::~InputDialog() { 83 HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup");
115} 84 StockLookup->setCaption("Symbol");
85 StockLookup->showMaximized();
86 StockLookup->show();
87 LineEdit1->text();
116 88
117void InputDialog::cleanUp(){
118 Config cfg( "stockticker");
119 cfg.setGroup( "Symbols" );
120 QString outText = text().upper();
121 outText.stripWhiteSpace();
122 cfg.writeEntry("Symbols", outText );
123 qDebug( "<<<<<<<<<<<>>>>>>>>>>>>"+text());
124
125 cfg.setGroup( "Fields" );
126
127 cfg.writeEntry("timeCheck",timeCheck->isChecked());
128 cfg.writeEntry("dateCheck",dateCheck->isChecked());
129 cfg.writeEntry("symbolCheck",symbolCheck->isChecked());
130 cfg.writeEntry("nameCheck",nameCheck->isChecked());
131 cfg.writeEntry("currentPriceCheck",currentPriceCheck->isChecked());
132 cfg.writeEntry("lastPriceCheck",lastPriceCheck->isChecked());
133 cfg.writeEntry("openPriceCheck",openPriceCheck->isChecked());
134 cfg.writeEntry("minPriceCheck",minPriceCheck->isChecked());
135 cfg.writeEntry("maxPriceCheck",maxPriceCheck->isChecked());
136 cfg.writeEntry("variationCheck",variationCheck->isChecked());
137 cfg.writeEntry("volumeCheck",volumeCheck->isChecked());
138
139
140 cfg.write();
141} 89}
142
143