author | llornkcor <llornkcor> | 2003-05-26 03:43:09 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-05-26 03:43:09 (UTC) |
commit | 4a9831b570a60075650863b571b0875e96ca8ad6 (patch) (unidiff) | |
tree | c4c76096f954067301609d1a89d00276d418ea49 | |
parent | 830bab619ea396c018ccd29b20ce81cb47e113e1 (diff) | |
download | opie-4a9831b570a60075650863b571b0875e96ca8ad6.zip opie-4a9831b570a60075650863b571b0875e96ca8ad6.tar.gz opie-4a9831b570a60075650863b571b0875e96ca8ad6.tar.bz2 |
remove extra includes
4 files changed, 0 insertions, 38 deletions
diff --git a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp index 33dcac0..23e78f2 100644 --- a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp +++ b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp | |||
@@ -1,287 +1,268 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | #include "helpwindow.h" | 11 | #include "helpwindow.h" |
12 | #include <qstatusbar.h> | 12 | #include <qstatusbar.h> |
13 | #include <qstringlist.h> | ||
14 | 13 | ||
15 | #include <qpixmap.h> | ||
16 | #include <qpopupmenu.h> | ||
17 | #include <qmenubar.h> | 14 | #include <qmenubar.h> |
18 | #include <qtoolbar.h> | 15 | #include <qtoolbar.h> |
19 | #include <qtoolbutton.h> | 16 | #include <qtoolbutton.h> |
20 | #include <qiconset.h> | ||
21 | #include <qfile.h> | ||
22 | #include <qtextstream.h> | ||
23 | #include <qstylesheet.h> | ||
24 | #include <qmessagebox.h> | ||
25 | #include <qfiledialog.h> | ||
26 | #include <qapplication.h> | ||
27 | #include <qcombobox.h> | 17 | #include <qcombobox.h> |
28 | #include <qevent.h> | ||
29 | #include <qlineedit.h> | ||
30 | #include <qobjectlist.h> | ||
31 | #include <qfileinfo.h> | ||
32 | #include <qfile.h> | ||
33 | #include <qdatastream.h> | ||
34 | #include <qprinter.h> | ||
35 | #include <qsimplerichtext.h> | ||
36 | #include <qpaintdevicemetrics.h> | ||
37 | 18 | ||
38 | #include <ctype.h> | 19 | #include <ctype.h> |
39 | 20 | ||
40 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) | 21 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) |
41 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() | 22 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() |
42 | { | 23 | { |
43 | readHistory(); | 24 | readHistory(); |
44 | readBookmarks(); | 25 | readBookmarks(); |
45 | 26 | ||
46 | browser = new QTextBrowser( this ); | 27 | browser = new QTextBrowser( this ); |
47 | QStringList Strlist; | 28 | QStringList Strlist; |
48 | Strlist.append( home_); | 29 | Strlist.append( home_); |
49 | 30 | ||
50 | browser->mimeSourceFactory()->setFilePath( Strlist ); | 31 | browser->mimeSourceFactory()->setFilePath( Strlist ); |
51 | 32 | ||
52 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 33 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
53 | 34 | ||
54 | connect( browser, SIGNAL( textChanged() ), | 35 | connect( browser, SIGNAL( textChanged() ), |
55 | 36 | ||
56 | this, SLOT( textChanged() ) ); | 37 | this, SLOT( textChanged() ) ); |
57 | 38 | ||
58 | setCentralWidget( browser ); | 39 | setCentralWidget( browser ); |
59 | 40 | ||
60 | if ( !home_.isEmpty() ) | 41 | if ( !home_.isEmpty() ) |
61 | 42 | ||
62 | //////////////////////////////// | 43 | //////////////////////////////// |
63 | browser->setSource( home_ ); | 44 | browser->setSource( home_ ); |
64 | 45 | ||
65 | //////////////////////////////// | 46 | //////////////////////////////// |
66 | connect( browser, SIGNAL( highlighted( const QString&) ), | 47 | connect( browser, SIGNAL( highlighted( const QString&) ), |
67 | statusBar(), SLOT( message( const QString&)) ); | 48 | statusBar(), SLOT( message( const QString&)) ); |
68 | 49 | ||
69 | setGeometry( 0,0,236,280); | 50 | setGeometry( 0,0,236,280); |
70 | 51 | ||
71 | QPopupMenu* file = new QPopupMenu( this ); | 52 | QPopupMenu* file = new QPopupMenu( this ); |
72 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); | 53 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); |
73 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); | 54 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); |
74 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); | 55 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); |
75 | file->insertSeparator(); | 56 | file->insertSeparator(); |
76 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); | 57 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); |
77 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); | 58 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); |
78 | 59 | ||
79 | // The same three icons are used twice each. | 60 | // The same three icons are used twice each. |
80 | ////F FIXME | 61 | ////F FIXME |
81 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; | 62 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; |
82 | QIconSet icon_back( QPixmap(pixs+"back.png") ); | 63 | QIconSet icon_back( QPixmap(pixs+"back.png") ); |
83 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); | 64 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); |
84 | QIconSet icon_home( QPixmap(pixs+"home.png") ); | 65 | QIconSet icon_home( QPixmap(pixs+"home.png") ); |
85 | 66 | ||
86 | QPopupMenu* go = new QPopupMenu( this ); | 67 | QPopupMenu* go = new QPopupMenu( this ); |
87 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); | 68 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); |
88 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); | 69 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); |
89 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); | 70 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); |
90 | 71 | ||
91 | 72 | ||
92 | hist = new QPopupMenu( this ); | 73 | hist = new QPopupMenu( this ); |
93 | QStringList::Iterator it = history.begin(); | 74 | QStringList::Iterator it = history.begin(); |
94 | for ( ; it != history.end(); ++it ) | 75 | for ( ; it != history.end(); ++it ) |
95 | mHistory[ hist->insertItem( *it ) ] = *it; | 76 | mHistory[ hist->insertItem( *it ) ] = *it; |
96 | connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); | 77 | connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); |
97 | 78 | ||
98 | bookm = new QPopupMenu( this ); | 79 | bookm = new QPopupMenu( this ); |
99 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | 80 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); |
100 | bookm->insertSeparator(); | 81 | bookm->insertSeparator(); |
101 | 82 | ||
102 | QStringList::Iterator it2 = bookmarks.begin(); | 83 | QStringList::Iterator it2 = bookmarks.begin(); |
103 | for ( ; it2 != bookmarks.end(); ++it2 ) | 84 | for ( ; it2 != bookmarks.end(); ++it2 ) |
104 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; | 85 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; |
105 | connect( bookm, SIGNAL( activated( int ) ), | 86 | connect( bookm, SIGNAL( activated( int ) ), |
106 | this, SLOT( bookmChosen( int ) ) ); | 87 | this, SLOT( bookmChosen( int ) ) ); |
107 | 88 | ||
108 | menuBar()->insertItem( tr("&File"), file ); | 89 | menuBar()->insertItem( tr("&File"), file ); |
109 | menuBar()->insertItem( tr("&Go"), go ); | 90 | menuBar()->insertItem( tr("&Go"), go ); |
110 | menuBar()->insertItem( tr( "History" ), hist ); | 91 | menuBar()->insertItem( tr( "History" ), hist ); |
111 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); | 92 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); |
112 | // menuBar()->insertSeparator(); | 93 | // menuBar()->insertSeparator(); |
113 | // menuBar()->insertItem( tr("&Help"), help ); | 94 | // menuBar()->insertItem( tr("&Help"), help ); |
114 | 95 | ||
115 | menuBar()->setItemEnabled( forwardId, FALSE); | 96 | menuBar()->setItemEnabled( forwardId, FALSE); |
116 | menuBar()->setItemEnabled( backwardId, FALSE); | 97 | menuBar()->setItemEnabled( backwardId, FALSE); |
117 | connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); | 98 | connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); |
118 | connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); | 99 | connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); |
119 | 100 | ||
120 | 101 | ||
121 | QToolBar* toolbar = new QToolBar( this ); | 102 | QToolBar* toolbar = new QToolBar( this ); |
122 | addToolBar( toolbar, "Toolbar"); | 103 | addToolBar( toolbar, "Toolbar"); |
123 | QToolButton* button; | 104 | QToolButton* button; |
124 | 105 | ||
125 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); | 106 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); |
126 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 107 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
127 | button->setEnabled( FALSE ); | 108 | button->setEnabled( FALSE ); |
128 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); | 109 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); |
129 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 110 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
130 | button->setEnabled( FALSE ); | 111 | button->setEnabled( FALSE ); |
131 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); | 112 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); |
132 | 113 | ||
133 | toolbar->addSeparator(); | 114 | toolbar->addSeparator(); |
134 | 115 | ||
135 | pathCombo = new QComboBox( TRUE, toolbar ); | 116 | pathCombo = new QComboBox( TRUE, toolbar ); |
136 | connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); | 117 | connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); |
137 | toolbar->setStretchableWidget( pathCombo ); | 118 | toolbar->setStretchableWidget( pathCombo ); |
138 | 119 | ||
139 | // pathCombo->setMaximumWidth(190); | 120 | // pathCombo->setMaximumWidth(190); |
140 | // setRightJustification( TRUE ); | 121 | // setRightJustification( TRUE ); |
141 | // setDockEnabled( Left, FALSE ); | 122 | // setDockEnabled( Left, FALSE ); |
142 | // setDockEnabled( Right, FALSE ); | 123 | // setDockEnabled( Right, FALSE ); |
143 | 124 | ||
144 | pathCombo->insertItem( home_ ); | 125 | pathCombo->insertItem( home_ ); |
145 | 126 | ||
146 | browser->setFocus(); | 127 | browser->setFocus(); |
147 | 128 | ||
148 | 129 | ||
149 | } | 130 | } |
150 | 131 | ||
151 | 132 | ||
152 | void HelpWindow::setBackwardAvailable( bool b) | 133 | void HelpWindow::setBackwardAvailable( bool b) |
153 | { | 134 | { |
154 | menuBar()->setItemEnabled( backwardId, b); | 135 | menuBar()->setItemEnabled( backwardId, b); |
155 | } | 136 | } |
156 | 137 | ||
157 | void HelpWindow::setForwardAvailable( bool b) | 138 | void HelpWindow::setForwardAvailable( bool b) |
158 | { | 139 | { |
159 | menuBar()->setItemEnabled( forwardId, b); | 140 | menuBar()->setItemEnabled( forwardId, b); |
160 | } | 141 | } |
161 | 142 | ||
162 | 143 | ||
163 | void HelpWindow::textChanged() | 144 | void HelpWindow::textChanged() |
164 | { | 145 | { |
165 | if ( browser->documentTitle().isNull() ) { | 146 | if ( browser->documentTitle().isNull() ) { |
166 | setCaption( "Stockticker Lookup - " + browser->context() ); | 147 | setCaption( "Stockticker Lookup - " + browser->context() ); |
167 | selectedURL = browser->context(); | 148 | selectedURL = browser->context(); |
168 | } | 149 | } |
169 | else { | 150 | else { |
170 | setCaption( "Stockticker Lookup - " + browser->documentTitle() ) ; | 151 | setCaption( "Stockticker Lookup - " + browser->documentTitle() ) ; |
171 | selectedURL = browser->documentTitle(); | 152 | selectedURL = browser->documentTitle(); |
172 | } | 153 | } |
173 | 154 | ||
174 | if ( !selectedURL.isEmpty() && pathCombo ) { | 155 | if ( !selectedURL.isEmpty() && pathCombo ) { |
175 | bool exists = FALSE; | 156 | bool exists = FALSE; |
176 | int i; | 157 | int i; |
177 | for ( i = 0; i < pathCombo->count(); ++i ) { | 158 | for ( i = 0; i < pathCombo->count(); ++i ) { |
178 | if ( pathCombo->text( i ) == selectedURL ) { | 159 | if ( pathCombo->text( i ) == selectedURL ) { |
179 | exists = TRUE; | 160 | exists = TRUE; |
180 | break; | 161 | break; |
181 | } | 162 | } |
182 | } | 163 | } |
183 | if ( !exists ) { | 164 | if ( !exists ) { |
184 | pathCombo->insertItem( selectedURL, 0 ); | 165 | pathCombo->insertItem( selectedURL, 0 ); |
185 | pathCombo->setCurrentItem( 0 ); | 166 | pathCombo->setCurrentItem( 0 ); |
186 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 167 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
187 | } else | 168 | } else |
188 | pathCombo->setCurrentItem( i ); | 169 | pathCombo->setCurrentItem( i ); |
189 | selectedURL = QString::null; | 170 | selectedURL = QString::null; |
190 | } | 171 | } |
191 | } | 172 | } |
192 | 173 | ||
193 | HelpWindow::~HelpWindow() | 174 | HelpWindow::~HelpWindow() |
194 | { | 175 | { |
195 | history.clear(); | 176 | history.clear(); |
196 | QMap<int, QString>::Iterator it = mHistory.begin(); | 177 | QMap<int, QString>::Iterator it = mHistory.begin(); |
197 | for ( ; it != mHistory.end(); ++it ) | 178 | for ( ; it != mHistory.end(); ++it ) |
198 | history.append( *it ); | 179 | history.append( *it ); |
199 | 180 | ||
200 | QFile f( QDir::currentDirPath() + "/.history" ); | 181 | QFile f( QDir::currentDirPath() + "/.history" ); |
201 | f.open( IO_WriteOnly ); | 182 | f.open( IO_WriteOnly ); |
202 | QDataStream s( &f ); | 183 | QDataStream s( &f ); |
203 | s << history; | 184 | s << history; |
204 | f.close(); | 185 | f.close(); |
205 | 186 | ||
206 | bookmarks.clear(); | 187 | bookmarks.clear(); |
207 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 188 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
208 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 189 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
209 | bookmarks.append( *it2 ); | 190 | bookmarks.append( *it2 ); |
210 | 191 | ||
211 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 192 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
212 | f2.open( IO_WriteOnly ); | 193 | f2.open( IO_WriteOnly ); |
213 | QDataStream s2( &f2 ); | 194 | QDataStream s2( &f2 ); |
214 | s2 << bookmarks; | 195 | s2 << bookmarks; |
215 | f2.close(); | 196 | f2.close(); |
216 | } | 197 | } |
217 | 198 | ||
218 | void HelpWindow::openFile() | 199 | void HelpWindow::openFile() |
219 | { | 200 | { |
220 | #ifndef QT_NO_FILEDIALOG | 201 | #ifndef QT_NO_FILEDIALOG |
221 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); | 202 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); |
222 | if ( !fn.isEmpty() ) | 203 | if ( !fn.isEmpty() ) |
223 | browser->setSource( fn ); | 204 | browser->setSource( fn ); |
224 | #endif | 205 | #endif |
225 | } | 206 | } |
226 | 207 | ||
227 | void HelpWindow::newWindow() | 208 | void HelpWindow::newWindow() |
228 | { | 209 | { |
229 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 210 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
230 | } | 211 | } |
231 | 212 | ||
232 | void HelpWindow::pathSelected( const QString &_path ) | 213 | void HelpWindow::pathSelected( const QString &_path ) |
233 | { | 214 | { |
234 | browser->setSource( _path ); | 215 | browser->setSource( _path ); |
235 | QMap<int, QString>::Iterator it = mHistory.begin(); | 216 | QMap<int, QString>::Iterator it = mHistory.begin(); |
236 | bool exists = FALSE; | 217 | bool exists = FALSE; |
237 | for ( ; it != mHistory.end(); ++it ) { | 218 | for ( ; it != mHistory.end(); ++it ) { |
238 | if ( *it == _path ) { | 219 | if ( *it == _path ) { |
239 | exists = TRUE; | 220 | exists = TRUE; |
240 | break; | 221 | break; |
241 | } | 222 | } |
242 | } | 223 | } |
243 | if ( !exists ) | 224 | if ( !exists ) |
244 | mHistory[ hist->insertItem( _path ) ] = _path; | 225 | mHistory[ hist->insertItem( _path ) ] = _path; |
245 | } | 226 | } |
246 | 227 | ||
247 | void HelpWindow::readHistory() | 228 | void HelpWindow::readHistory() |
248 | { | 229 | { |
249 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 230 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { |
250 | QFile f( QDir::currentDirPath() + "/.history" ); | 231 | QFile f( QDir::currentDirPath() + "/.history" ); |
251 | f.open( IO_ReadOnly ); | 232 | f.open( IO_ReadOnly ); |
252 | QDataStream s( &f ); | 233 | QDataStream s( &f ); |
253 | s >> history; | 234 | s >> history; |
254 | f.close(); | 235 | f.close(); |
255 | while ( history.count() > 20 ) | 236 | while ( history.count() > 20 ) |
256 | history.remove( history.begin() ); | 237 | history.remove( history.begin() ); |
257 | } | 238 | } |
258 | } | 239 | } |
259 | 240 | ||
260 | void HelpWindow::readBookmarks() | 241 | void HelpWindow::readBookmarks() |
261 | { | 242 | { |
262 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 243 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { |
263 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 244 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
264 | f.open( IO_ReadOnly ); | 245 | f.open( IO_ReadOnly ); |
265 | QDataStream s( &f ); | 246 | QDataStream s( &f ); |
266 | s >> bookmarks; | 247 | s >> bookmarks; |
267 | f.close(); | 248 | f.close(); |
268 | } | 249 | } |
269 | } | 250 | } |
270 | 251 | ||
271 | void HelpWindow::histChosen( int i ) | 252 | void HelpWindow::histChosen( int i ) |
272 | { | 253 | { |
273 | if ( mHistory.contains( i ) ) | 254 | if ( mHistory.contains( i ) ) |
274 | browser->setSource( mHistory[ i ] ); | 255 | browser->setSource( mHistory[ i ] ); |
275 | } | 256 | } |
276 | 257 | ||
277 | void HelpWindow::bookmChosen( int i ) | 258 | void HelpWindow::bookmChosen( int i ) |
278 | { | 259 | { |
279 | if ( mBookmarks.contains( i ) ) | 260 | if ( mBookmarks.contains( i ) ) |
280 | browser->setSource( mBookmarks[ i ] ); | 261 | browser->setSource( mBookmarks[ i ] ); |
281 | } | 262 | } |
282 | 263 | ||
283 | void HelpWindow::addBookmark() | 264 | void HelpWindow::addBookmark() |
284 | { | 265 | { |
285 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 266 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
286 | } | 267 | } |
287 | 268 | ||
diff --git a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp index 18021c2..42a3885 100644 --- a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp +++ b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp | |||
@@ -1,89 +1,87 @@ | |||
1 | #include "inputDialog.h" | 1 | #include "inputDialog.h" |
2 | 2 | ||
3 | #include <qapplication.h> | 3 | #include <qapplication.h> |
4 | 4 | ||
5 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
6 | #include <qlayout.h> | ||
7 | #include <qlineedit.h> | 6 | #include <qlineedit.h> |
8 | #include <qlayout.h> | ||
9 | #include <qvariant.h> | 7 | #include <qvariant.h> |
10 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
11 | #include <qwhatsthis.h> | 9 | #include <qwhatsthis.h> |
12 | #include <qlabel.h> | 10 | #include <qlabel.h> |
13 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
14 | #include <qstringlist.h> | 12 | #include <qstringlist.h> |
15 | #include <qmainwindow.h> | 13 | #include <qmainwindow.h> |
16 | #include "helpwindow.h" | 14 | #include "helpwindow.h" |
17 | 15 | ||
18 | #include <opie/oprocess.h> | 16 | #include <opie/oprocess.h> |
19 | 17 | ||
20 | #include <stdlib.h> | 18 | #include <stdlib.h> |
21 | // #include <sys/stat.h> | 19 | // #include <sys/stat.h> |
22 | // #include <unistd.h> | 20 | // #include <unistd.h> |
23 | 21 | ||
24 | InputDialog::InputDialog( ) | 22 | InputDialog::InputDialog( ) |
25 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { | 23 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { |
26 | setCaption( tr("Symbol Lookup")); | 24 | setCaption( tr("Symbol Lookup")); |
27 | 25 | ||
28 | QGridLayout *layout = new QGridLayout( this ); | 26 | QGridLayout *layout = new QGridLayout( this ); |
29 | layout->setSpacing(6); | 27 | layout->setSpacing(6); |
30 | layout->setMargin( 2); | 28 | layout->setMargin( 2); |
31 | 29 | ||
32 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 30 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
33 | LineEdit1->setFocus(); | 31 | LineEdit1->setFocus(); |
34 | 32 | ||
35 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); | 33 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); |
36 | 34 | ||
37 | QLabel *label; | 35 | QLabel *label; |
38 | label = new QLabel(this); | 36 | label = new QLabel(this); |
39 | label->setText( tr("Enter something to lookup / search.")); | 37 | label->setText( tr("Enter something to lookup / search.")); |
40 | label->setMaximumHeight(60); | 38 | label->setMaximumHeight(60); |
41 | layout->addMultiCellWidget( label, 1, 1, 0, 3); | 39 | layout->addMultiCellWidget( label, 1, 1, 0, 3); |
42 | 40 | ||
43 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup())); | 41 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup())); |
44 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); | 42 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); |
45 | layout->addItem( spacer, 8, 0 ); | 43 | layout->addItem( spacer, 8, 0 ); |
46 | 44 | ||
47 | } | 45 | } |
48 | 46 | ||
49 | InputDialog::~InputDialog() { | 47 | InputDialog::~InputDialog() { |
50 | } | 48 | } |
51 | 49 | ||
52 | void InputDialog::doLookup() { | 50 | void InputDialog::doLookup() { |
53 | // http://finance.yahoo.com/l?m=&s=siemens&t= | 51 | // http://finance.yahoo.com/l?m=&s=siemens&t= |
54 | 52 | ||
55 | QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\""; | 53 | QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\""; |
56 | QString tempHtml = "/tmp/stockticker.html"; | 54 | QString tempHtml = "/tmp/stockticker.html"; |
57 | QString cmd = "wget -O "+tempHtml+" "+url; | 55 | QString cmd = "wget -O "+tempHtml+" "+url; |
58 | qDebug(cmd); | 56 | qDebug(cmd); |
59 | 57 | ||
60 | 58 | ||
61 | /* | 59 | /* |
62 | OProcess proc; | 60 | OProcess proc; |
63 | proc << "/usr/bin/wget"; | 61 | proc << "/usr/bin/wget"; |
64 | proc<<"-O"<< tempHtml<< url; | 62 | proc<<"-O"<< tempHtml<< url; |
65 | 63 | ||
66 | connect( &proc, SIGNAL( processExited( OProcess *)),this, SLOT( showBrowser(OProcess *))); | 64 | connect( &proc, SIGNAL( processExited( OProcess *)),this, SLOT( showBrowser(OProcess *))); |
67 | proc.start( OProcess::NotifyOnExit); | 65 | proc.start( OProcess::NotifyOnExit); |
68 | */ | 66 | */ |
69 | system(cmd.latin1()); | 67 | system(cmd.latin1()); |
70 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); | 68 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); |
71 | StockLookup->setCaption("Symbol"); | 69 | StockLookup->setCaption("Symbol"); |
72 | StockLookup->showMaximized(); | 70 | StockLookup->showMaximized(); |
73 | StockLookup->show(); | 71 | StockLookup->show(); |
74 | LineEdit1->text(); | 72 | LineEdit1->text(); |
75 | 73 | ||
76 | 74 | ||
77 | } | 75 | } |
78 | 76 | ||
79 | void InputDialog::showBrowser(OProcess*) { | 77 | void InputDialog::showBrowser(OProcess*) { |
80 | qDebug("BLAH"); | 78 | qDebug("BLAH"); |
81 | QString tempHtml = "/tmp/stockticker.html"; | 79 | QString tempHtml = "/tmp/stockticker.html"; |
82 | 80 | ||
83 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); | 81 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); |
84 | StockLookup->setCaption("Symbol"); | 82 | StockLookup->setCaption("Symbol"); |
85 | StockLookup->showMaximized(); | 83 | StockLookup->showMaximized(); |
86 | StockLookup->show(); | 84 | StockLookup->show(); |
87 | LineEdit1->text(); | 85 | LineEdit1->text(); |
88 | 86 | ||
89 | } | 87 | } |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp index fdabd5c..e3d378b 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp | |||
@@ -1,211 +1,207 @@ | |||
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> | ||
21 | 20 | ||
22 | #include <qapplication.h> | 21 | #include <qapplication.h> |
23 | 22 | ||
24 | #include <qspinbox.h> | 23 | #include <qspinbox.h> |
25 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
26 | #include <qlayout.h> | ||
27 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
28 | #include <qlayout.h> | ||
29 | #include <qvariant.h> | 26 | #include <qvariant.h> |
30 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
31 | #include <qwhatsthis.h> | 28 | #include <qwhatsthis.h> |
32 | #include <qlabel.h> | 29 | #include <qlabel.h> |
33 | #include <qpe/config.h> | ||
34 | #include <qstringlist.h> | 30 | #include <qstringlist.h> |
35 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
36 | 32 | ||
37 | #include <stdlib.h> | 33 | #include <stdlib.h> |
38 | 34 | ||
39 | StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char* name) | 35 | StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char* name) |
40 | : TodayConfigWidget(parent, name ) { | 36 | : TodayConfigWidget(parent, name ) { |
41 | 37 | ||
42 | QGridLayout *layout = new QGridLayout( this ); | 38 | QGridLayout *layout = new QGridLayout( this ); |
43 | layout->setSpacing(2); | 39 | layout->setSpacing(2); |
44 | layout->setMargin( 2); | 40 | layout->setMargin( 2); |
45 | 41 | ||
46 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 42 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
47 | LineEdit1->setFocus(); | 43 | LineEdit1->setFocus(); |
48 | // QWhatsThis::add( LineEdit1, tr("Enter the stock symbols you want to be shown here.")); | 44 | // QWhatsThis::add( LineEdit1, tr("Enter the stock symbols you want to be shown here.")); |
49 | 45 | ||
50 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 4); | 46 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 4); |
51 | 47 | ||
52 | Config cfg( "stockticker"); | 48 | Config cfg( "stockticker"); |
53 | cfg.setGroup( "Symbols" ); | 49 | cfg.setGroup( "Symbols" ); |
54 | QString symbollist; | 50 | QString symbollist; |
55 | symbollist = cfg.readEntry("Symbols", ""); | 51 | symbollist = cfg.readEntry("Symbols", ""); |
56 | LineEdit1->setText(symbollist); | 52 | LineEdit1->setText(symbollist); |
57 | 53 | ||
58 | QLabel *label; | 54 | QLabel *label; |
59 | label = new QLabel(this); | 55 | label = new QLabel(this); |
60 | label->setText( tr("Enter stock symbols seperated\nby a space.")); | 56 | label->setText( tr("Enter stock symbols seperated\nby a space.")); |
61 | label->setMaximumHeight(60); | 57 | label->setMaximumHeight(60); |
62 | layout->addMultiCellWidget( label, 1, 1, 0, 4); | 58 | layout->addMultiCellWidget( label, 1, 1, 0, 4); |
63 | 59 | ||
64 | cfg.setGroup( "Fields" ); | 60 | cfg.setGroup( "Fields" ); |
65 | 61 | ||
66 | timeCheck= new QCheckBox ( "Time",this ); | 62 | timeCheck= new QCheckBox ( "Time",this ); |
67 | timeCheck->setChecked( cfg.readBoolEntry("timeCheck",1)); | 63 | timeCheck->setChecked( cfg.readBoolEntry("timeCheck",1)); |
68 | layout->addMultiCellWidget(timeCheck, 2, 2, 0, 0 ); | 64 | layout->addMultiCellWidget(timeCheck, 2, 2, 0, 0 ); |
69 | QWhatsThis::add( timeCheck, tr("Toggles Time of current price field")); | 65 | QWhatsThis::add( timeCheck, tr("Toggles Time of current price field")); |
70 | 66 | ||
71 | dateCheck= new QCheckBox ( "Date", this ); | 67 | dateCheck= new QCheckBox ( "Date", this ); |
72 | dateCheck->setChecked( cfg.readBoolEntry("dateCheck",1)); | 68 | dateCheck->setChecked( cfg.readBoolEntry("dateCheck",1)); |
73 | layout->addMultiCellWidget( dateCheck, 2, 2, 1, 1 ); | 69 | layout->addMultiCellWidget( dateCheck, 2, 2, 1, 1 ); |
74 | QWhatsThis::add(dateCheck, tr("Toggles date field")); | 70 | QWhatsThis::add(dateCheck, tr("Toggles date field")); |
75 | 71 | ||
76 | symbolCheck= new QCheckBox ( "Symbol", this ); | 72 | symbolCheck= new QCheckBox ( "Symbol", this ); |
77 | symbolCheck->setChecked( cfg.readBoolEntry("symbolCheck",1)); | 73 | symbolCheck->setChecked( cfg.readBoolEntry("symbolCheck",1)); |
78 | layout->addMultiCellWidget( symbolCheck, 2, 2, 2, 2 ); | 74 | layout->addMultiCellWidget( symbolCheck, 2, 2, 2, 2 ); |
79 | QWhatsThis::add(symbolCheck, tr("Toggles Symbol field")); | 75 | QWhatsThis::add(symbolCheck, tr("Toggles Symbol field")); |
80 | 76 | ||
81 | nameCheck= new QCheckBox ( "Name", this ); | 77 | nameCheck= new QCheckBox ( "Name", this ); |
82 | nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1)); | 78 | nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1)); |
83 | layout->addMultiCellWidget( nameCheck, 3, 3, 0, 0 ); | 79 | layout->addMultiCellWidget( nameCheck, 3, 3, 0, 0 ); |
84 | QWhatsThis::add(nameCheck, tr("Toggles Name of symbols owner field")); | 80 | QWhatsThis::add(nameCheck, tr("Toggles Name of symbols owner field")); |
85 | 81 | ||
86 | currentPriceCheck= new QCheckBox ( "Price", this ); | 82 | currentPriceCheck= new QCheckBox ( "Price", this ); |
87 | currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1)); | 83 | currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1)); |
88 | layout->addMultiCellWidget( currentPriceCheck, 3, 3, 1, 1 ); | 84 | layout->addMultiCellWidget( currentPriceCheck, 3, 3, 1, 1 ); |
89 | QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field")); | 85 | QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field")); |
90 | 86 | ||
91 | lastPriceCheck= new QCheckBox ( "Last Price", this ); | 87 | lastPriceCheck= new QCheckBox ( "Last Price", this ); |
92 | lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1)); | 88 | lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1)); |
93 | layout->addMultiCellWidget(lastPriceCheck, 3, 3, 2, 2); | 89 | layout->addMultiCellWidget(lastPriceCheck, 3, 3, 2, 2); |
94 | QWhatsThis::add(lastPriceCheck, tr("Toggles last price field")); | 90 | QWhatsThis::add(lastPriceCheck, tr("Toggles last price field")); |
95 | 91 | ||
96 | openPriceCheck= new QCheckBox ( "Open Price", this); | 92 | openPriceCheck= new QCheckBox ( "Open Price", this); |
97 | openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1)); | 93 | openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1)); |
98 | layout->addMultiCellWidget( openPriceCheck, 4, 4, 0, 0 ); | 94 | layout->addMultiCellWidget( openPriceCheck, 4, 4, 0, 0 ); |
99 | QWhatsThis::add(openPriceCheck, tr("Toggles opening price field")); | 95 | QWhatsThis::add(openPriceCheck, tr("Toggles opening price field")); |
100 | 96 | ||
101 | minPriceCheck= new QCheckBox ( "Min Price", this ); | 97 | minPriceCheck= new QCheckBox ( "Min Price", this ); |
102 | minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1)); | 98 | minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1)); |
103 | layout->addMultiCellWidget( minPriceCheck, 4, 4, 1, 1); | 99 | layout->addMultiCellWidget( minPriceCheck, 4, 4, 1, 1); |
104 | QWhatsThis::add(minPriceCheck, tr("Toggles minimum daily price field")); | 100 | QWhatsThis::add(minPriceCheck, tr("Toggles minimum daily price field")); |
105 | 101 | ||
106 | maxPriceCheck= new QCheckBox ( "Max Price", this); | 102 | maxPriceCheck= new QCheckBox ( "Max Price", this); |
107 | maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1)); | 103 | maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1)); |
108 | layout->addMultiCellWidget( maxPriceCheck, 4, 4, 2, 2 ); | 104 | layout->addMultiCellWidget( maxPriceCheck, 4, 4, 2, 2 ); |
109 | QWhatsThis::add(maxPriceCheck, tr("Toggles maximum daily price field")); | 105 | QWhatsThis::add(maxPriceCheck, tr("Toggles maximum daily price field")); |
110 | 106 | ||
111 | variationCheck= new QCheckBox ( "Variation", this ); | 107 | variationCheck= new QCheckBox ( "Variation", this ); |
112 | variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1)); | 108 | variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1)); |
113 | layout->addMultiCellWidget( variationCheck, 5, 5, 0, 0 ); | 109 | layout->addMultiCellWidget( variationCheck, 5, 5, 0, 0 ); |
114 | QWhatsThis::add(variationCheck, tr("Toggles daily variation of price field")); | 110 | QWhatsThis::add(variationCheck, tr("Toggles daily variation of price field")); |
115 | 111 | ||
116 | volumeCheck= new QCheckBox ( "Volume", this ); | 112 | volumeCheck= new QCheckBox ( "Volume", this ); |
117 | volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1)); | 113 | volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1)); |
118 | layout->addMultiCellWidget( volumeCheck , 5, 5, 1, 1); | 114 | layout->addMultiCellWidget( volumeCheck , 5, 5, 1, 1); |
119 | QWhatsThis::add(volumeCheck, tr("Toggles volume of trading field")); | 115 | QWhatsThis::add(volumeCheck, tr("Toggles volume of trading field")); |
120 | 116 | ||
121 | timerDelaySpin = new QSpinBox( this, "timer spin" ); | 117 | timerDelaySpin = new QSpinBox( this, "timer spin" ); |
122 | QWhatsThis::add( timerDelaySpin , tr( "How often stocks prices should be looked up. In minutes" ) ); | 118 | QWhatsThis::add( timerDelaySpin , tr( "How often stocks prices should be looked up. In minutes" ) ); |
123 | timerDelaySpin->setMaxValue( 60); | 119 | timerDelaySpin->setMaxValue( 60); |
124 | 120 | ||
125 | cfg.setGroup("Timer"); | 121 | cfg.setGroup("Timer"); |
126 | timerDelaySpin->setValue( cfg.readNumEntry("Delay",0)); | 122 | timerDelaySpin->setValue( cfg.readNumEntry("Delay",0)); |
127 | layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0); | 123 | layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0); |
128 | 124 | ||
129 | QLabel *label2; | 125 | QLabel *label2; |
130 | label2 = new QLabel(this); | 126 | label2 = new QLabel(this); |
131 | label2->setText( tr("Minutes between lookups.")); | 127 | label2->setText( tr("Minutes between lookups.")); |
132 | label2->setMaximumHeight(60); | 128 | label2->setMaximumHeight(60); |
133 | layout->addMultiCellWidget( label2, 6, 6, 1, 2); | 129 | layout->addMultiCellWidget( label2, 6, 6, 1, 2); |
134 | 130 | ||
135 | scrollSpeed = new QSpinBox( this, "Scrollspin" ); | 131 | scrollSpeed = new QSpinBox( this, "Scrollspin" ); |
136 | QWhatsThis::add( timerDelaySpin , tr( "Speed of scrolling action, in milliseconds" ) ); | 132 | QWhatsThis::add( timerDelaySpin , tr( "Speed of scrolling action, in milliseconds" ) ); |
137 | scrollSpeed->setMaxValue( 1000); | 133 | scrollSpeed->setMaxValue( 1000); |
138 | scrollSpeed->setSteps(50,50); | 134 | scrollSpeed->setSteps(50,50); |
139 | cfg.setGroup("Timer"); | 135 | cfg.setGroup("Timer"); |
140 | scrollSpeed->setValue( cfg.readNumEntry("ScrollSpeed",50)); | 136 | scrollSpeed->setValue( cfg.readNumEntry("ScrollSpeed",50)); |
141 | layout->addMultiCellWidget( scrollSpeed , 7, 7, 0, 0); | 137 | layout->addMultiCellWidget( scrollSpeed , 7, 7, 0, 0); |
142 | 138 | ||
143 | QLabel *label3; | 139 | QLabel *label3; |
144 | label3 = new QLabel(this); | 140 | label3 = new QLabel(this); |
145 | label3->setText( tr("Scroll Speed, in milliseconds")); | 141 | label3->setText( tr("Scroll Speed, in milliseconds")); |
146 | label3->setMaximumHeight(60); | 142 | label3->setMaximumHeight(60); |
147 | layout->addMultiCellWidget( label3, 7, 7, 1, 2); | 143 | layout->addMultiCellWidget( label3, 7, 7, 1, 2); |
148 | 144 | ||
149 | scrollLength = new QSpinBox( this, "ScrollLength" ); | 145 | scrollLength = new QSpinBox( this, "ScrollLength" ); |
150 | QWhatsThis::add( timerDelaySpin , tr( "Length of scrolling" ) ); | 146 | QWhatsThis::add( timerDelaySpin , tr( "Length of scrolling" ) ); |
151 | scrollLength->setMaxValue( 10); | 147 | scrollLength->setMaxValue( 10); |
152 | // scrollLength->setSteps(5,5); | 148 | // scrollLength->setSteps(5,5); |
153 | cfg.setGroup("Timer"); | 149 | cfg.setGroup("Timer"); |
154 | scrollLength->setValue( cfg.readNumEntry("ScrollLength",1)); | 150 | scrollLength->setValue( cfg.readNumEntry("ScrollLength",1)); |
155 | layout->addMultiCellWidget( scrollLength , 8, 8, 0, 0); | 151 | layout->addMultiCellWidget( scrollLength , 8, 8, 0, 0); |
156 | 152 | ||
157 | QLabel *label4; | 153 | QLabel *label4; |
158 | label4 = new QLabel(this); | 154 | label4 = new QLabel(this); |
159 | label4->setText( tr("Scroll Length")); | 155 | label4->setText( tr("Scroll Length")); |
160 | label4->setMaximumHeight(60); | 156 | label4->setMaximumHeight(60); |
161 | layout->addMultiCellWidget( label4, 8, 8, 1, 2); | 157 | layout->addMultiCellWidget( label4, 8, 8, 1, 2); |
162 | 158 | ||
163 | // lookupButton = new QPushButton(this, "LookupButton"); | 159 | // lookupButton = new QPushButton(this, "LookupButton"); |
164 | // lookupButton->setText(tr("Symbol Lookup")); | 160 | // lookupButton->setText(tr("Symbol Lookup")); |
165 | // connect(lookupButton,SIGNAL(clicked()),SLOT( doLookup())); | 161 | // connect(lookupButton,SIGNAL(clicked()),SLOT( doLookup())); |
166 | // layout->addMultiCellWidget( lookupButton , 9, 9, 0, 0); | 162 | // layout->addMultiCellWidget( lookupButton , 9, 9, 0, 0); |
167 | 163 | ||
168 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); | 164 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); |
169 | layout->addItem( spacer, 9, 0 ); | 165 | layout->addItem( spacer, 9, 0 ); |
170 | 166 | ||
171 | } | 167 | } |
172 | 168 | ||
173 | 169 | ||
174 | void StocktickerPluginConfig::writeConfig() { | 170 | void StocktickerPluginConfig::writeConfig() { |
175 | Config cfg( "stockticker"); | 171 | Config cfg( "stockticker"); |
176 | cfg.setGroup( "Symbols" ); | 172 | cfg.setGroup( "Symbols" ); |
177 | QString outText = text().upper(); | 173 | QString outText = text().upper(); |
178 | outText.stripWhiteSpace(); | 174 | outText.stripWhiteSpace(); |
179 | cfg.writeEntry("Symbols", outText ); | 175 | cfg.writeEntry("Symbols", outText ); |
180 | cfg.setGroup( "Fields" ); | 176 | cfg.setGroup( "Fields" ); |
181 | cfg.writeEntry("timeCheck",timeCheck->isChecked()); | 177 | cfg.writeEntry("timeCheck",timeCheck->isChecked()); |
182 | cfg.writeEntry("dateCheck",dateCheck->isChecked()); | 178 | cfg.writeEntry("dateCheck",dateCheck->isChecked()); |
183 | cfg.writeEntry("symbolCheck",symbolCheck->isChecked()); | 179 | cfg.writeEntry("symbolCheck",symbolCheck->isChecked()); |
184 | cfg.writeEntry("nameCheck",nameCheck->isChecked()); | 180 | cfg.writeEntry("nameCheck",nameCheck->isChecked()); |
185 | cfg.writeEntry("currentPriceCheck",currentPriceCheck->isChecked()); | 181 | cfg.writeEntry("currentPriceCheck",currentPriceCheck->isChecked()); |
186 | cfg.writeEntry("lastPriceCheck",lastPriceCheck->isChecked()); | 182 | cfg.writeEntry("lastPriceCheck",lastPriceCheck->isChecked()); |
187 | cfg.writeEntry("openPriceCheck",openPriceCheck->isChecked()); | 183 | cfg.writeEntry("openPriceCheck",openPriceCheck->isChecked()); |
188 | cfg.writeEntry("minPriceCheck",minPriceCheck->isChecked()); | 184 | cfg.writeEntry("minPriceCheck",minPriceCheck->isChecked()); |
189 | cfg.writeEntry("maxPriceCheck",maxPriceCheck->isChecked()); | 185 | cfg.writeEntry("maxPriceCheck",maxPriceCheck->isChecked()); |
190 | cfg.writeEntry("variationCheck",variationCheck->isChecked()); | 186 | cfg.writeEntry("variationCheck",variationCheck->isChecked()); |
191 | cfg.writeEntry("volumeCheck",volumeCheck->isChecked()); | 187 | cfg.writeEntry("volumeCheck",volumeCheck->isChecked()); |
192 | 188 | ||
193 | cfg.setGroup("Timer"); | 189 | cfg.setGroup("Timer"); |
194 | cfg.writeEntry("Delay",timerDelaySpin->value()); | 190 | cfg.writeEntry("Delay",timerDelaySpin->value()); |
195 | cfg.writeEntry("ScrollLength",scrollLength->value()); | 191 | cfg.writeEntry("ScrollLength",scrollLength->value()); |
196 | cfg.writeEntry("ScrollSpeed",scrollSpeed->value()); | 192 | cfg.writeEntry("ScrollSpeed",scrollSpeed->value()); |
197 | 193 | ||
198 | cfg.write(); | 194 | cfg.write(); |
199 | } | 195 | } |
200 | 196 | ||
201 | StocktickerPluginConfig::~StocktickerPluginConfig() { | 197 | StocktickerPluginConfig::~StocktickerPluginConfig() { |
202 | } | 198 | } |
203 | 199 | ||
204 | QString StocktickerPluginConfig::text() const { | 200 | QString StocktickerPluginConfig::text() const { |
205 | return LineEdit1->text(); | 201 | return LineEdit1->text(); |
206 | } | 202 | } |
207 | 203 | ||
208 | void StocktickerPluginConfig::doLookup() { | 204 | void StocktickerPluginConfig::doLookup() { |
209 | 205 | ||
210 | system("stockticker"); | 206 | system("stockticker"); |
211 | } | 207 | } |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp index a740b58..c3ca52d 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | |||
@@ -1,314 +1,301 @@ | |||
1 | /* | 1 | /* |
2 | * stocktickerpluginwidget.cpp | 2 | * stocktickerpluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by L.J. Potter | 4 | * copyright : (c) 2002 by L.J. Potter |
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 <qsocket.h> | ||
18 | #include <qvaluelist.h> | ||
19 | #include <qtl.h> | ||
20 | #include <qstring.h> | ||
21 | #include <qstringlist.h> | ||
22 | #include <qobject.h> | ||
23 | #include <qlayout.h> | 17 | #include <qlayout.h> |
24 | #include <qlineedit.h> | ||
25 | #include <qregexp.h> | ||
26 | #include <qtimer.h> | ||
27 | #include <qmessagebox.h> | ||
28 | 18 | ||
29 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
30 | #include <qpe/timestring.h> | ||
31 | #include <qpe/qcopenvelope_qws.h> | ||
32 | #include <qpe/network.h> | ||
33 | 20 | ||
34 | #include <opie/oticker.h> | 21 | #include <opie/oticker.h> |
35 | 22 | ||
36 | extern "C" { | 23 | extern "C" { |
37 | #include "libstocks/stocks.h" | 24 | #include "libstocks/stocks.h" |
38 | } | 25 | } |
39 | 26 | ||
40 | #include <pthread.h> | 27 | #include <pthread.h> |
41 | 28 | ||
42 | #include "stocktickerpluginwidget.h" | 29 | #include "stocktickerpluginwidget.h" |
43 | 30 | ||
44 | QString output; | 31 | QString output; |
45 | OTicker *stocktickerTicker; | 32 | OTicker *stocktickerTicker; |
46 | 33 | ||
47 | void getStocks(char *blah) { | 34 | void getStocks(char *blah) { |
48 | 35 | ||
49 | // stocktickerTicker->setText( "Downloading stock data."); | 36 | // stocktickerTicker->setText( "Downloading stock data."); |
50 | stock *stocks_quotes=NULL; | 37 | stock *stocks_quotes=NULL; |
51 | stock *stocks_tmp; | 38 | stock *stocks_tmp; |
52 | QCString stock_liste = blah; | 39 | QCString stock_liste = blah; |
53 | ::free ( blah ); | 40 | ::free ( blah ); |
54 | // char *stock_liste = (char *)blah->latin1(); | 41 | // char *stock_liste = (char *)blah->latin1(); |
55 | qDebug("%s", stock_liste.data() ); | 42 | qDebug("%s", stock_liste.data() ); |
56 | QString tempString; | 43 | QString tempString; |
57 | output = ""; | 44 | output = ""; |
58 | 45 | ||
59 | libstocks_return_code error; | 46 | libstocks_return_code error; |
60 | 47 | ||
61 | Config cfg( "stockticker"); | 48 | Config cfg( "stockticker"); |
62 | cfg.setGroup( "Fields" ); | 49 | cfg.setGroup( "Fields" ); |
63 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | 50 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; |
64 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | 51 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; |
65 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | 52 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; |
66 | 53 | ||
67 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; | 54 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; |
68 | 55 | ||
69 | dotimeCheck=cfg.readBoolEntry("timeCheck",1); | 56 | dotimeCheck=cfg.readBoolEntry("timeCheck",1); |
70 | dodateCheck=cfg.readBoolEntry("dateCheck",1); | 57 | dodateCheck=cfg.readBoolEntry("dateCheck",1); |
71 | dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); | 58 | dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); |
72 | donameCheck=cfg.readBoolEntry("nameCheck",1); | 59 | donameCheck=cfg.readBoolEntry("nameCheck",1); |
73 | docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); | 60 | docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); |
74 | dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); | 61 | dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); |
75 | doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); | 62 | doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); |
76 | dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); | 63 | dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); |
77 | domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); | 64 | domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); |
78 | dovariationCheck=cfg.readBoolEntry("variationCheck",1); | 65 | dovariationCheck=cfg.readBoolEntry("variationCheck",1); |
79 | dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); | 66 | dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); |
80 | 67 | ||
81 | // DefProxy(); | 68 | // DefProxy(); |
82 | { | 69 | { |
83 | char *proxy; | 70 | char *proxy; |
84 | libstocks_return_code error; | 71 | libstocks_return_code error; |
85 | 72 | ||
86 | /* Proxy support */ | 73 | /* Proxy support */ |
87 | /* Checks for "http_proxy" environment variable */ | 74 | /* Checks for "http_proxy" environment variable */ |
88 | proxy = getenv("http_proxy"); | 75 | proxy = getenv("http_proxy"); |
89 | if(proxy) { | 76 | if(proxy) { |
90 | /* printf("proxy set\n"); */ | 77 | /* printf("proxy set\n"); */ |
91 | error = set_proxy(proxy); | 78 | error = set_proxy(proxy); |
92 | if (error) { | 79 | if (error) { |
93 | printf("Proxy error (%d)\n", error); | 80 | printf("Proxy error (%d)\n", error); |
94 | QString tempString; | 81 | QString tempString; |
95 | tempString.sprintf("Proxy error (%d)\n", error); | 82 | tempString.sprintf("Proxy error (%d)\n", error); |
96 | output = tempString; | 83 | output = tempString; |
97 | return; | 84 | return; |
98 | // exit(1); | 85 | // exit(1); |
99 | } | 86 | } |
100 | } | 87 | } |
101 | } | 88 | } |
102 | // char *stock_liste = (char *)blah; | 89 | // char *stock_liste = (char *)blah; |
103 | /* Get the stocks and process errors */ | 90 | /* Get the stocks and process errors */ |
104 | error = get_stocks( stock_liste.data(), &stocks_quotes); | 91 | error = get_stocks( stock_liste.data(), &stocks_quotes); |
105 | 92 | ||
106 | if (error) { | 93 | if (error) { |
107 | printf("Error in getting stocks (%d)\n", error); | 94 | printf("Error in getting stocks (%d)\n", error); |
108 | tempString.sprintf("Error in getting stocks (%d)\n", error); | 95 | tempString.sprintf("Error in getting stocks (%d)\n", error); |
109 | output =tempString; | 96 | output =tempString; |
110 | return; | 97 | return; |
111 | // exit(1); | 98 | // exit(1); |
112 | } | 99 | } |
113 | 100 | ||
114 | stocks_tmp = stocks_quotes; | 101 | stocks_tmp = stocks_quotes; |
115 | 102 | ||
116 | /* Displays the stocks */ | 103 | /* Displays the stocks */ |
117 | while(stocks_tmp!=0){ | 104 | while(stocks_tmp!=0){ |
118 | 105 | ||
119 | if (stocks_tmp->Time) { | 106 | if (stocks_tmp->Time) { |
120 | // printf("%s ", stocks_tmp->Time); | 107 | // printf("%s ", stocks_tmp->Time); |
121 | tempString.sprintf("| %s ", stocks_tmp->Time); | 108 | tempString.sprintf("| %s ", stocks_tmp->Time); |
122 | tempString.replace(QRegExp("\""),""); | 109 | tempString.replace(QRegExp("\""),""); |
123 | if( dotimeCheck) | 110 | if( dotimeCheck) |
124 | output +=tempString; | 111 | output +=tempString; |
125 | } | 112 | } |
126 | if (stocks_tmp->Date) { | 113 | if (stocks_tmp->Date) { |
127 | // printf("%s ", stocks_tmp->Date); | 114 | // printf("%s ", stocks_tmp->Date); |
128 | tempString.sprintf("| %s ", stocks_tmp->Date); | 115 | tempString.sprintf("| %s ", stocks_tmp->Date); |
129 | tempString.replace(QRegExp("\""),""); | 116 | tempString.replace(QRegExp("\""),""); |
130 | if(dodateCheck) | 117 | if(dodateCheck) |
131 | output +=tempString; | 118 | output +=tempString; |
132 | } | 119 | } |
133 | // printf("\n"); | 120 | // printf("\n"); |
134 | 121 | ||
135 | // printf("----------------------------------------\n"); | 122 | // printf("----------------------------------------\n"); |
136 | 123 | ||
137 | if ( strlen(stocks_tmp->Symbol) > 20 ) { | 124 | if ( strlen(stocks_tmp->Symbol) > 20 ) { |
138 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); | 125 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); |
139 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 126 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
140 | if(dosymbolCheck) | 127 | if(dosymbolCheck) |
141 | output +=tempString; | 128 | output +=tempString; |
142 | } | 129 | } |
143 | else { | 130 | else { |
144 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); | 131 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); |
145 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 132 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
146 | if(dosymbolCheck) | 133 | if(dosymbolCheck) |
147 | output +=tempString; | 134 | output +=tempString; |
148 | } | 135 | } |
149 | 136 | ||
150 | if (stocks_tmp->Name) { | 137 | if (stocks_tmp->Name) { |
151 | if ( strlen(stocks_tmp->Name) > 20 ) { | 138 | if ( strlen(stocks_tmp->Name) > 20 ) { |
152 | // printf("| Name %.20s |\n",stocks_tmp->Name); | 139 | // printf("| Name %.20s |\n",stocks_tmp->Name); |
153 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 140 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
154 | tempString.stripWhiteSpace(); | 141 | tempString.stripWhiteSpace(); |
155 | if(donameCheck) | 142 | if(donameCheck) |
156 | output +=tempString; | 143 | output +=tempString; |
157 | } else { | 144 | } else { |
158 | // printf("| Name | %-20s |\n",stocks_tmp->Name); | 145 | // printf("| Name | %-20s |\n",stocks_tmp->Name); |
159 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 146 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
160 | tempString.stripWhiteSpace(); | 147 | tempString.stripWhiteSpace(); |
161 | if(donameCheck) | 148 | if(donameCheck) |
162 | output +=tempString; | 149 | output +=tempString; |
163 | } | 150 | } |
164 | } | 151 | } |
165 | else { | 152 | else { |
166 | // printf("| Name | |\n"); | 153 | // printf("| Name | |\n"); |
167 | tempString.sprintf("| Name | |"); | 154 | tempString.sprintf("| Name | |"); |
168 | if(donameCheck) | 155 | if(donameCheck) |
169 | output +=tempString; | 156 | output +=tempString; |
170 | } | 157 | } |
171 | 158 | ||
172 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); | 159 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); |
173 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); | 160 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); |
174 | if(docurrentPriceCheck) | 161 | if(docurrentPriceCheck) |
175 | output +=tempString; | 162 | output +=tempString; |
176 | 163 | ||
177 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); | 164 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); |
178 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); | 165 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); |
179 | if(dolastPriceCheck) | 166 | if(dolastPriceCheck) |
180 | output +=tempString; | 167 | output +=tempString; |
181 | 168 | ||
182 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); | 169 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); |
183 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); | 170 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); |
184 | if(doopenPriceCheck) | 171 | if(doopenPriceCheck) |
185 | output +=tempString; | 172 | output +=tempString; |
186 | 173 | ||
187 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); | 174 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); |
188 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); | 175 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); |
189 | if(dominPriceCheck) | 176 | if(dominPriceCheck) |
190 | output +=tempString; | 177 | output +=tempString; |
191 | 178 | ||
192 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); | 179 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); |
193 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); | 180 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); |
194 | if(domaxPriceCheck) | 181 | if(domaxPriceCheck) |
195 | output +=tempString; | 182 | output +=tempString; |
196 | 183 | ||
197 | // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); | 184 | // 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); | 185 | tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); |
199 | if(dovariationCheck) | 186 | if(dovariationCheck) |
200 | output +=tempString; | 187 | output +=tempString; |
201 | 188 | ||
202 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); | 189 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); |
203 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); | 190 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); |
204 | if(dovolumeCheck) | 191 | if(dovolumeCheck) |
205 | output +=tempString; | 192 | output +=tempString; |
206 | 193 | ||
207 | // printf("----------------------------------------\n\n"); | 194 | // printf("----------------------------------------\n\n"); |
208 | tempString.sprintf("||==++==|"); | 195 | tempString.sprintf("||==++==|"); |
209 | output +=tempString; | 196 | output +=tempString; |
210 | 197 | ||
211 | /* Simple function which help to browse in the stocks list */ | 198 | /* Simple function which help to browse in the stocks list */ |
212 | stocks_tmp = next_stock(stocks_tmp); | 199 | stocks_tmp = next_stock(stocks_tmp); |
213 | } | 200 | } |
214 | 201 | ||
215 | /* frees stocks */ | 202 | /* frees stocks */ |
216 | free_stocks(stocks_quotes); | 203 | free_stocks(stocks_quotes); |
217 | stocktickerTicker->setText( output.latin1() ); | 204 | stocktickerTicker->setText( output.latin1() ); |
218 | 205 | ||
219 | } | 206 | } |
220 | 207 | ||
221 | StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) | 208 | StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) |
222 | : QWidget(parent, name ) { | 209 | : QWidget(parent, name ) { |
223 | init(); | 210 | init(); |
224 | startTimer(1000); | 211 | startTimer(1000); |
225 | 212 | ||
226 | stocktickerTicker->setTextFormat(Qt::RichText); | 213 | stocktickerTicker->setTextFormat(Qt::RichText); |
227 | // checkConnection(); | 214 | // checkConnection(); |
228 | } | 215 | } |
229 | 216 | ||
230 | StockTickerPluginWidget::~StockTickerPluginWidget() { | 217 | StockTickerPluginWidget::~StockTickerPluginWidget() { |
231 | } | 218 | } |
232 | 219 | ||
233 | void StockTickerPluginWidget::init() { | 220 | void StockTickerPluginWidget::init() { |
234 | 221 | ||
235 | QHBoxLayout* layout = new QHBoxLayout( this ); | 222 | QHBoxLayout* layout = new QHBoxLayout( this ); |
236 | stocktickerTicker = new OTicker(this); | 223 | stocktickerTicker = new OTicker(this); |
237 | // stocktickerTicker->setMinimumHeight(15); | 224 | // stocktickerTicker->setMinimumHeight(15); |
238 | connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); | 225 | connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); |
239 | layout->addWidget( stocktickerTicker); | 226 | layout->addWidget( stocktickerTicker); |
240 | wasError = true; | 227 | wasError = true; |
241 | } | 228 | } |
242 | 229 | ||
243 | void StockTickerPluginWidget::doStocks() { | 230 | void StockTickerPluginWidget::doStocks() { |
244 | Config cfg( "stockticker"); | 231 | Config cfg( "stockticker"); |
245 | cfg.setGroup( "Symbols" ); | 232 | cfg.setGroup( "Symbols" ); |
246 | symbollist=""; | 233 | symbollist=""; |
247 | symbollist = cfg.readEntry("Symbols", ""); | 234 | symbollist = cfg.readEntry("Symbols", ""); |
248 | symbollist.replace(QRegExp(" "),"+");//seperated by + | 235 | symbollist.replace(QRegExp(" "),"+");//seperated by + |
249 | 236 | ||
250 | cfg.setGroup("Timer"); | 237 | cfg.setGroup("Timer"); |
251 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); | 238 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); |
252 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); | 239 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); |
253 | 240 | ||
254 | if (!symbollist.isEmpty()) { | 241 | if (!symbollist.isEmpty()) { |
255 | pthread_t thread1; | 242 | pthread_t thread1; |
256 | char *blah = ::strdup(symbollist.latin1()); | 243 | char *blah = ::strdup(symbollist.latin1()); |
257 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, (void *) blah); | 244 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, (void *) blah); |
258 | } | 245 | } |
259 | } | 246 | } |
260 | 247 | ||
261 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | 248 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { |
262 | killTimer(e->timerId()); | 249 | killTimer(e->timerId()); |
263 | checkConnection(); | 250 | checkConnection(); |
264 | } | 251 | } |
265 | 252 | ||
266 | void StockTickerPluginWidget::checkConnection() { | 253 | void StockTickerPluginWidget::checkConnection() { |
267 | // qDebug("checking connection"); | 254 | // qDebug("checking connection"); |
268 | // Sock = new QSocket( this ); | 255 | // Sock = new QSocket( this ); |
269 | 256 | ||
270 | // if( wasError) | 257 | // if( wasError) |
271 | // stocktickerTicker->setText("Checking connection"); | 258 | // stocktickerTicker->setText("Checking connection"); |
272 | 259 | ||
273 | // if(Sock->state() == QSocket::Idle) { | 260 | // if(Sock->state() == QSocket::Idle) { |
274 | // Sock->connectToHost("finance.yahoo.com", 80); | 261 | // Sock->connectToHost("finance.yahoo.com", 80); |
275 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); | 262 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); |
276 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | 263 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); |
277 | // } else { | 264 | // } else { |
278 | // qDebug("State is not Idle"); | 265 | // qDebug("State is not Idle"); |
279 | isConnected(); | 266 | isConnected(); |
280 | // } | 267 | // } |
281 | } | 268 | } |
282 | 269 | ||
283 | void StockTickerPluginWidget::isConnected() { | 270 | void StockTickerPluginWidget::isConnected() { |
284 | // qDebug("We connect, so ok to grab stocks"); | 271 | // qDebug("We connect, so ok to grab stocks"); |
285 | doStocks(); | 272 | doStocks(); |
286 | 273 | ||
287 | Config cfg( "stockticker"); | 274 | Config cfg( "stockticker"); |
288 | cfg.setGroup("Timer"); | 275 | cfg.setGroup("Timer"); |
289 | timerDelay= cfg.readNumEntry("Delay",0); | 276 | timerDelay= cfg.readNumEntry("Delay",0); |
290 | if(timerDelay > 0) | 277 | if(timerDelay > 0) |
291 | startTimer(timerDelay*60000); | 278 | startTimer(timerDelay*60000); |
292 | qDebug("timer set for %d",(timerDelay*60000)/60000); | 279 | qDebug("timer set for %d",(timerDelay*60000)/60000); |
293 | wasError = false; | 280 | wasError = false; |
294 | 281 | ||
295 | // Sock->close(); | 282 | // Sock->close(); |
296 | } | 283 | } |
297 | 284 | ||
298 | void StockTickerPluginWidget::socketError(int errcode) { | 285 | void StockTickerPluginWidget::socketError(int errcode) { |
299 | switch(errcode) { | 286 | switch(errcode) { |
300 | case QSocket::ErrConnectionRefused: | 287 | case QSocket::ErrConnectionRefused: |
301 | output = tr("Connection refused."); | 288 | output = tr("Connection refused."); |
302 | break; | 289 | break; |
303 | case QSocket::ErrHostNotFound: | 290 | case QSocket::ErrHostNotFound: |
304 | output = tr("Could not find server."); | 291 | output = tr("Could not find server."); |
305 | break; | 292 | break; |
306 | case QSocket::ErrSocketRead : | 293 | case QSocket::ErrSocketRead : |
307 | output = tr("Socket read error."); | 294 | output = tr("Socket read error."); |
308 | break; | 295 | break; |
309 | }; | 296 | }; |
310 | stocktickerTicker->setText( output ); | 297 | stocktickerTicker->setText( output ); |
311 | wasError = true; | 298 | wasError = true; |
312 | // Sock->close(); | 299 | // Sock->close(); |
313 | 300 | ||
314 | } | 301 | } |