4 files changed, 12 insertions, 12 deletions
diff --git a/noncore/todayplugins/fortune/fortunepluginwidget.cpp b/noncore/todayplugins/fortune/fortunepluginwidget.cpp index b210fa9..e6a0d09 100644 --- a/noncore/todayplugins/fortune/fortunepluginwidget.cpp +++ b/noncore/todayplugins/fortune/fortunepluginwidget.cpp | |||
@@ -1,84 +1,84 @@ | |||
1 | /* | 1 | /* |
2 | * fortunepluginwidget.cpp | 2 | * fortunepluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@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 "fortunepluginwidget.h" | 17 | #include "fortunepluginwidget.h" |
18 | 18 | ||
19 | #include <qvaluelist.h> | 19 | #include <qvaluelist.h> |
20 | #include <qtl.h> | 20 | #include <qtl.h> |
21 | #include <qstring.h> | 21 | #include <qstring.h> |
22 | #include <qscrollview.h> | 22 | #include <qscrollview.h> |
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | 25 | ||
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
28 | 28 | ||
29 | #include <opie/oprocess.h> | 29 | #include <opie/oprocess.h> |
30 | #include <opie/oticker.h> | 30 | #include <opie/oticker.h> |
31 | 31 | ||
32 | FortunePluginWidget::FortunePluginWidget( QWidget *parent, const char* name ) | 32 | FortunePluginWidget::FortunePluginWidget( QWidget *parent, const char* name ) |
33 | : QWidget( parent, name ) | 33 | : QWidget( parent, name ) |
34 | { | 34 | { |
35 | 35 | ||
36 | fortune = NULL; | 36 | fortune = NULL; |
37 | getFortune(); | 37 | getFortune(); |
38 | } | 38 | } |
39 | 39 | ||
40 | FortunePluginWidget::~FortunePluginWidget() { | 40 | FortunePluginWidget::~FortunePluginWidget() { |
41 | if( fortuneProcess ){ | 41 | if( fortuneProcess ){ |
42 | delete fortuneProcess; | 42 | delete fortuneProcess; |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Get the fortunes | 47 | * Get the fortunes |
48 | */ | 48 | */ |
49 | void FortunePluginWidget::getFortune() { | 49 | void FortunePluginWidget::getFortune() { |
50 | 50 | ||
51 | QVBoxLayout* layoutFortune = new QVBoxLayout( this ); | 51 | QVBoxLayout* layoutFortune = new QVBoxLayout( this ); |
52 | 52 | ||
53 | if ( fortune ) { | 53 | if ( fortune ) { |
54 | delete fortune; | 54 | delete fortune; |
55 | } | 55 | } |
56 | 56 | ||
57 | fortune = new OTicker( this ); | 57 | fortune = new OTicker( this ); |
58 | //fortune->setReadOnly( TRUE ); | 58 | //fortune->setReadOnly( TRUE ); |
59 | //fortune->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); | 59 | //fortune->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); |
60 | 60 | ||
61 | fortune->setText( QString("Obtaining fortune...") ); | 61 | fortune->setText( QString("Obtaining fortune...") ); |
62 | layoutFortune->addWidget( fortune ); | 62 | layoutFortune->addWidget( fortune ); |
63 | 63 | ||
64 | fortuneProcess = new OProcess(); | 64 | fortuneProcess = new OProcess(); |
65 | *fortuneProcess << "fortune"; | 65 | *fortuneProcess << "fortune"; |
66 | 66 | ||
67 | connect(fortuneProcess, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 67 | connect(fortuneProcess, SIGNAL(receivedStdout(OProcess*,char*,int) ), |
68 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 68 | this, SLOT(slotStdOut(OProcess*,char*,int) ) ); |
69 | 69 | ||
70 | if(!fortuneProcess->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 70 | if(!fortuneProcess->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
71 | qWarning("could not start :("); | 71 | qWarning("could not start :("); |
72 | fortune->setText( QString("Failed to obtain fortune.") ); | 72 | fortune->setText( QString("Failed to obtain fortune.") ); |
73 | delete fortuneProcess; | 73 | delete fortuneProcess; |
74 | fortuneProcess = 0; | 74 | fortuneProcess = 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | void FortunePluginWidget::slotStdOut( OProcess* proc, char* buf, int len ) | 79 | void FortunePluginWidget::slotStdOut( OProcess* proc, char* buf, int len ) |
80 | { | 80 | { |
81 | QCString s( buf, len ); | 81 | QCString s( buf, len ); |
82 | s.replace( QRegExp("\n"), "" ); | 82 | s.replace( QRegExp("\n"), "" ); |
83 | fortune->setText( s ); | 83 | fortune->setText( s ); |
84 | } | 84 | } |
diff --git a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp index 2274402..db662e8 100644 --- a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp +++ b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp | |||
@@ -1,212 +1,212 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of an example program for Qt. This example | 5 | ** This file is part of an example program for Qt. This example |
6 | ** program may be used, distributed and modified without limitation. | 6 | ** program may be used, distributed and modified without limitation. |
7 | ** | 7 | ** |
8 | *****************************************************************************/ | 8 | *****************************************************************************/ |
9 | 9 | ||
10 | #include "helpwindow.h" | 10 | #include "helpwindow.h" |
11 | #include <qstatusbar.h> | 11 | #include <qstatusbar.h> |
12 | 12 | ||
13 | #include <qmenubar.h> | 13 | #include <qmenubar.h> |
14 | #include <qtoolbar.h> | 14 | #include <qtoolbar.h> |
15 | #include <qtoolbutton.h> | 15 | #include <qtoolbutton.h> |
16 | #include <qcombobox.h> | 16 | #include <qcombobox.h> |
17 | 17 | ||
18 | #include <ctype.h> | 18 | #include <ctype.h> |
19 | 19 | ||
20 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) | 20 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) |
21 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() | 21 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() |
22 | { | 22 | { |
23 | readHistory(); | 23 | readHistory(); |
24 | readBookmarks(); | 24 | readBookmarks(); |
25 | 25 | ||
26 | browser = new QTextBrowser( this ); | 26 | browser = new QTextBrowser( this ); |
27 | QStringList Strlist; | 27 | QStringList Strlist; |
28 | Strlist.append( home_); | 28 | Strlist.append( home_); |
29 | 29 | ||
30 | browser->mimeSourceFactory()->setFilePath( Strlist ); | 30 | browser->mimeSourceFactory()->setFilePath( Strlist ); |
31 | 31 | ||
32 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 32 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
33 | 33 | ||
34 | connect( browser, SIGNAL( textChanged() ), | 34 | connect( browser, SIGNAL( textChanged() ), |
35 | 35 | ||
36 | this, SLOT( textChanged() ) ); | 36 | this, SLOT( textChanged() ) ); |
37 | 37 | ||
38 | setCentralWidget( browser ); | 38 | setCentralWidget( browser ); |
39 | 39 | ||
40 | if ( !home_.isEmpty() ) | 40 | if ( !home_.isEmpty() ) |
41 | 41 | ||
42 | //////////////////////////////// | 42 | //////////////////////////////// |
43 | browser->setSource( home_ ); | 43 | browser->setSource( home_ ); |
44 | 44 | ||
45 | //////////////////////////////// | 45 | //////////////////////////////// |
46 | connect( browser, SIGNAL( highlighted( const QString&) ), | 46 | connect( browser, SIGNAL( highlighted(const QString&) ), |
47 | statusBar(), SLOT( message( const QString&)) ); | 47 | statusBar(), SLOT( message(const QString&)) ); |
48 | 48 | ||
49 | setGeometry( 0,0,236,280); | 49 | setGeometry( 0,0,236,280); |
50 | 50 | ||
51 | QPopupMenu* file = new QPopupMenu( this ); | 51 | QPopupMenu* file = new QPopupMenu( this ); |
52 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); | 52 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); |
53 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); | 53 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); |
54 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); | 54 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); |
55 | file->insertSeparator(); | 55 | file->insertSeparator(); |
56 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); | 56 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); |
57 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); | 57 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); |
58 | 58 | ||
59 | // The same three icons are used twice each. | 59 | // The same three icons are used twice each. |
60 | ////F FIXME | 60 | ////F FIXME |
61 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; | 61 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; |
62 | QIconSet icon_back( QPixmap(pixs+"back.png") ); | 62 | QIconSet icon_back( QPixmap(pixs+"back.png") ); |
63 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); | 63 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); |
64 | QIconSet icon_home( QPixmap(pixs+"home.png") ); | 64 | QIconSet icon_home( QPixmap(pixs+"home.png") ); |
65 | 65 | ||
66 | QPopupMenu* go = new QPopupMenu( this ); | 66 | QPopupMenu* go = new QPopupMenu( this ); |
67 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); | 67 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); |
68 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); | 68 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); |
69 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); | 69 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); |
70 | 70 | ||
71 | 71 | ||
72 | hist = new QPopupMenu( this ); | 72 | hist = new QPopupMenu( this ); |
73 | QStringList::Iterator it = history.begin(); | 73 | QStringList::Iterator it = history.begin(); |
74 | for ( ; it != history.end(); ++it ) | 74 | for ( ; it != history.end(); ++it ) |
75 | mHistory[ hist->insertItem( *it ) ] = *it; | 75 | mHistory[ hist->insertItem( *it ) ] = *it; |
76 | connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); | 76 | connect( hist, SIGNAL( activated(int) ), this, SLOT( histChosen(int) ) ); |
77 | 77 | ||
78 | bookm = new QPopupMenu( this ); | 78 | bookm = new QPopupMenu( this ); |
79 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | 79 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); |
80 | bookm->insertSeparator(); | 80 | bookm->insertSeparator(); |
81 | 81 | ||
82 | QStringList::Iterator it2 = bookmarks.begin(); | 82 | QStringList::Iterator it2 = bookmarks.begin(); |
83 | for ( ; it2 != bookmarks.end(); ++it2 ) | 83 | for ( ; it2 != bookmarks.end(); ++it2 ) |
84 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; | 84 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; |
85 | connect( bookm, SIGNAL( activated( int ) ), | 85 | connect( bookm, SIGNAL( activated(int) ), |
86 | this, SLOT( bookmChosen( int ) ) ); | 86 | this, SLOT( bookmChosen(int) ) ); |
87 | 87 | ||
88 | menuBar()->insertItem( tr("&File"), file ); | 88 | menuBar()->insertItem( tr("&File"), file ); |
89 | menuBar()->insertItem( tr("&Go"), go ); | 89 | menuBar()->insertItem( tr("&Go"), go ); |
90 | menuBar()->insertItem( tr( "History" ), hist ); | 90 | menuBar()->insertItem( tr( "History" ), hist ); |
91 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); | 91 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); |
92 | // menuBar()->insertSeparator(); | 92 | // menuBar()->insertSeparator(); |
93 | // menuBar()->insertItem( tr("&Help"), help ); | 93 | // menuBar()->insertItem( tr("&Help"), help ); |
94 | 94 | ||
95 | menuBar()->setItemEnabled( forwardId, FALSE); | 95 | menuBar()->setItemEnabled( forwardId, FALSE); |
96 | menuBar()->setItemEnabled( backwardId, FALSE); | 96 | menuBar()->setItemEnabled( backwardId, FALSE); |
97 | connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); | 97 | connect( browser, SIGNAL( backwardAvailable(bool) ), this, SLOT( setBackwardAvailable(bool) ) ); |
98 | connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); | 98 | connect( browser, SIGNAL( forwardAvailable(bool) ), this, SLOT( setForwardAvailable(bool) ) ); |
99 | 99 | ||
100 | 100 | ||
101 | QToolBar* toolbar = new QToolBar( this ); | 101 | QToolBar* toolbar = new QToolBar( this ); |
102 | addToolBar( toolbar, "Toolbar"); | 102 | addToolBar( toolbar, "Toolbar"); |
103 | QToolButton* button; | 103 | QToolButton* button; |
104 | 104 | ||
105 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); | 105 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); |
106 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 106 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
107 | button->setEnabled( FALSE ); | 107 | button->setEnabled( FALSE ); |
108 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); | 108 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); |
109 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 109 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
110 | button->setEnabled( FALSE ); | 110 | button->setEnabled( FALSE ); |
111 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); | 111 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); |
112 | 112 | ||
113 | toolbar->addSeparator(); | 113 | toolbar->addSeparator(); |
114 | 114 | ||
115 | pathCombo = new QComboBox( TRUE, toolbar ); | 115 | pathCombo = new QComboBox( TRUE, toolbar ); |
116 | connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); | 116 | connect( pathCombo, SIGNAL( activated(const QString&) ), this, SLOT( pathSelected(const QString&) ) ); |
117 | toolbar->setStretchableWidget( pathCombo ); | 117 | toolbar->setStretchableWidget( pathCombo ); |
118 | 118 | ||
119 | // pathCombo->setMaximumWidth(190); | 119 | // pathCombo->setMaximumWidth(190); |
120 | // setRightJustification( TRUE ); | 120 | // setRightJustification( TRUE ); |
121 | // setDockEnabled( Left, FALSE ); | 121 | // setDockEnabled( Left, FALSE ); |
122 | // setDockEnabled( Right, FALSE ); | 122 | // setDockEnabled( Right, FALSE ); |
123 | 123 | ||
124 | pathCombo->insertItem( home_ ); | 124 | pathCombo->insertItem( home_ ); |
125 | 125 | ||
126 | browser->setFocus(); | 126 | browser->setFocus(); |
127 | 127 | ||
128 | 128 | ||
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | void HelpWindow::setBackwardAvailable( bool b) | 132 | void HelpWindow::setBackwardAvailable( bool b) |
133 | { | 133 | { |
134 | menuBar()->setItemEnabled( backwardId, b); | 134 | menuBar()->setItemEnabled( backwardId, b); |
135 | } | 135 | } |
136 | 136 | ||
137 | void HelpWindow::setForwardAvailable( bool b) | 137 | void HelpWindow::setForwardAvailable( bool b) |
138 | { | 138 | { |
139 | menuBar()->setItemEnabled( forwardId, b); | 139 | menuBar()->setItemEnabled( forwardId, b); |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | void HelpWindow::textChanged() | 143 | void HelpWindow::textChanged() |
144 | { | 144 | { |
145 | if ( browser->documentTitle().isNull() ) { | 145 | if ( browser->documentTitle().isNull() ) { |
146 | setCaption( "Stockticker Lookup - " + browser->context() ); | 146 | setCaption( "Stockticker Lookup - " + browser->context() ); |
147 | selectedURL = browser->context(); | 147 | selectedURL = browser->context(); |
148 | } | 148 | } |
149 | else { | 149 | else { |
150 | setCaption( "Stockticker Lookup - " + browser->documentTitle() ) ; | 150 | setCaption( "Stockticker Lookup - " + browser->documentTitle() ) ; |
151 | selectedURL = browser->documentTitle(); | 151 | selectedURL = browser->documentTitle(); |
152 | } | 152 | } |
153 | 153 | ||
154 | if ( !selectedURL.isEmpty() && pathCombo ) { | 154 | if ( !selectedURL.isEmpty() && pathCombo ) { |
155 | bool exists = FALSE; | 155 | bool exists = FALSE; |
156 | int i; | 156 | int i; |
157 | for ( i = 0; i < pathCombo->count(); ++i ) { | 157 | for ( i = 0; i < pathCombo->count(); ++i ) { |
158 | if ( pathCombo->text( i ) == selectedURL ) { | 158 | if ( pathCombo->text( i ) == selectedURL ) { |
159 | exists = TRUE; | 159 | exists = TRUE; |
160 | break; | 160 | break; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | if ( !exists ) { | 163 | if ( !exists ) { |
164 | pathCombo->insertItem( selectedURL, 0 ); | 164 | pathCombo->insertItem( selectedURL, 0 ); |
165 | pathCombo->setCurrentItem( 0 ); | 165 | pathCombo->setCurrentItem( 0 ); |
166 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 166 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
167 | } else | 167 | } else |
168 | pathCombo->setCurrentItem( i ); | 168 | pathCombo->setCurrentItem( i ); |
169 | selectedURL = QString::null; | 169 | selectedURL = QString::null; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | HelpWindow::~HelpWindow() | 173 | HelpWindow::~HelpWindow() |
174 | { | 174 | { |
175 | history.clear(); | 175 | history.clear(); |
176 | QMap<int, QString>::Iterator it = mHistory.begin(); | 176 | QMap<int, QString>::Iterator it = mHistory.begin(); |
177 | for ( ; it != mHistory.end(); ++it ) | 177 | for ( ; it != mHistory.end(); ++it ) |
178 | history.append( *it ); | 178 | history.append( *it ); |
179 | 179 | ||
180 | QFile f( QDir::currentDirPath() + "/.history" ); | 180 | QFile f( QDir::currentDirPath() + "/.history" ); |
181 | f.open( IO_WriteOnly ); | 181 | f.open( IO_WriteOnly ); |
182 | QDataStream s( &f ); | 182 | QDataStream s( &f ); |
183 | s << history; | 183 | s << history; |
184 | f.close(); | 184 | f.close(); |
185 | 185 | ||
186 | bookmarks.clear(); | 186 | bookmarks.clear(); |
187 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 187 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
188 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 188 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
189 | bookmarks.append( *it2 ); | 189 | bookmarks.append( *it2 ); |
190 | 190 | ||
191 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 191 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
192 | f2.open( IO_WriteOnly ); | 192 | f2.open( IO_WriteOnly ); |
193 | QDataStream s2( &f2 ); | 193 | QDataStream s2( &f2 ); |
194 | s2 << bookmarks; | 194 | s2 << bookmarks; |
195 | f2.close(); | 195 | f2.close(); |
196 | } | 196 | } |
197 | 197 | ||
198 | void HelpWindow::openFile() | 198 | void HelpWindow::openFile() |
199 | { | 199 | { |
200 | #ifndef QT_NO_FILEDIALOG | 200 | #ifndef QT_NO_FILEDIALOG |
201 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); | 201 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); |
202 | if ( !fn.isEmpty() ) | 202 | if ( !fn.isEmpty() ) |
203 | browser->setSource( fn ); | 203 | browser->setSource( fn ); |
204 | #endif | 204 | #endif |
205 | } | 205 | } |
206 | 206 | ||
207 | void HelpWindow::newWindow() | 207 | void HelpWindow::newWindow() |
208 | { | 208 | { |
209 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 209 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
210 | } | 210 | } |
211 | 211 | ||
212 | void HelpWindow::pathSelected( const QString &_path ) | 212 | void HelpWindow::pathSelected( const QString &_path ) |
diff --git a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp index 73f8bb3..64798f4 100644 --- a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp +++ b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp | |||
@@ -1,89 +1,89 @@ | |||
1 | #include "inputDialog.h" | 1 | #include "inputDialog.h" |
2 | 2 | ||
3 | #include <qapplication.h> | 3 | #include <qapplication.h> |
4 | 4 | ||
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | #include <qcheckbox.h> | 6 | #include <qcheckbox.h> |
7 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
8 | #include <qvariant.h> | 8 | #include <qvariant.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | #include <qlayout.h> | 12 | #include <qlayout.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 | #include "helpwindow.h" |
17 | 17 | ||
18 | #include <opie/oprocess.h> | 18 | #include <opie/oprocess.h> |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | // #include <sys/stat.h> | 21 | // #include <sys/stat.h> |
22 | // #include <unistd.h> | 22 | // #include <unistd.h> |
23 | 23 | ||
24 | InputDialog::InputDialog( ) | 24 | InputDialog::InputDialog( ) |
25 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { | 25 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { |
26 | setCaption( tr("Symbol Lookup")); | 26 | setCaption( tr("Symbol Lookup")); |
27 | 27 | ||
28 | QGridLayout *layout = new QGridLayout( this ); | 28 | QGridLayout *layout = new QGridLayout( this ); |
29 | layout->setSpacing(6); | 29 | layout->setSpacing(6); |
30 | layout->setMargin( 2); | 30 | layout->setMargin( 2); |
31 | 31 | ||
32 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 32 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
33 | LineEdit1->setFocus(); | 33 | LineEdit1->setFocus(); |
34 | 34 | ||
35 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); | 35 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); |
36 | 36 | ||
37 | QLabel *label; | 37 | QLabel *label; |
38 | label = new QLabel(this); | 38 | label = new QLabel(this); |
39 | label->setText( tr("Enter something to lookup / search.")); | 39 | label->setText( tr("Enter something to lookup / search.")); |
40 | label->setMaximumHeight(60); | 40 | label->setMaximumHeight(60); |
41 | layout->addMultiCellWidget( label, 1, 1, 0, 3); | 41 | layout->addMultiCellWidget( label, 1, 1, 0, 3); |
42 | 42 | ||
43 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup())); | 43 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup())); |
44 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); | 44 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); |
45 | layout->addItem( spacer, 8, 0 ); | 45 | layout->addItem( spacer, 8, 0 ); |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | InputDialog::~InputDialog() { | 49 | InputDialog::~InputDialog() { |
50 | } | 50 | } |
51 | 51 | ||
52 | void InputDialog::doLookup() { | 52 | void InputDialog::doLookup() { |
53 | // http://finance.yahoo.com/l?m=&s=siemens&t= | 53 | // http://finance.yahoo.com/l?m=&s=siemens&t= |
54 | 54 | ||
55 | QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\""; | 55 | QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\""; |
56 | QString tempHtml = "/tmp/stockticker.html"; | 56 | QString tempHtml = "/tmp/stockticker.html"; |
57 | QString cmd = "wget -O "+tempHtml+" "+url; | 57 | QString cmd = "wget -O "+tempHtml+" "+url; |
58 | qDebug(cmd); | 58 | qDebug(cmd); |
59 | 59 | ||
60 | 60 | ||
61 | /* | 61 | /* |
62 | OProcess proc; | 62 | OProcess proc; |
63 | proc << "/usr/bin/wget"; | 63 | proc << "/usr/bin/wget"; |
64 | proc<<"-O"<< tempHtml<< url; | 64 | proc<<"-O"<< tempHtml<< url; |
65 | 65 | ||
66 | connect( &proc, SIGNAL( processExited( OProcess *)),this, SLOT( showBrowser(OProcess *))); | 66 | connect( &proc, SIGNAL( processExited(OProcess*)),this, SLOT( showBrowser(OProcess*))); |
67 | proc.start( OProcess::NotifyOnExit); | 67 | proc.start( OProcess::NotifyOnExit); |
68 | */ | 68 | */ |
69 | system(cmd.latin1()); | 69 | system(cmd.latin1()); |
70 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); | 70 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); |
71 | StockLookup->setCaption("Symbol"); | 71 | StockLookup->setCaption("Symbol"); |
72 | StockLookup->showMaximized(); | 72 | StockLookup->showMaximized(); |
73 | StockLookup->show(); | 73 | StockLookup->show(); |
74 | LineEdit1->text(); | 74 | LineEdit1->text(); |
75 | 75 | ||
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | void InputDialog::showBrowser(OProcess*) { | 79 | void InputDialog::showBrowser(OProcess*) { |
80 | qDebug("BLAH"); | 80 | qDebug("BLAH"); |
81 | QString tempHtml = "/tmp/stockticker.html"; | 81 | QString tempHtml = "/tmp/stockticker.html"; |
82 | 82 | ||
83 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); | 83 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); |
84 | StockLookup->setCaption("Symbol"); | 84 | StockLookup->setCaption("Symbol"); |
85 | StockLookup->showMaximized(); | 85 | StockLookup->showMaximized(); |
86 | StockLookup->show(); | 86 | StockLookup->show(); |
87 | LineEdit1->text(); | 87 | LineEdit1->text(); |
88 | 88 | ||
89 | } | 89 | } |
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.cpp b/noncore/todayplugins/weather/weatherpluginwidget.cpp index 4491b91..15d1c6e 100644 --- a/noncore/todayplugins/weather/weatherpluginwidget.cpp +++ b/noncore/todayplugins/weather/weatherpluginwidget.cpp | |||
@@ -12,193 +12,193 @@ | |||
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qimage.h> | 30 | #include <qimage.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | 35 | ||
36 | #include <opie/oprocess.h> | 36 | #include <opie/oprocess.h> |
37 | 37 | ||
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include "weatherpluginwidget.h" | 41 | #include "weatherpluginwidget.h" |
42 | 42 | ||
43 | WeatherPluginWidget::WeatherPluginWidget( QWidget *parent, const char* name ) | 43 | WeatherPluginWidget::WeatherPluginWidget( QWidget *parent, const char* name ) |
44 | : QWidget( parent, name ) | 44 | : QWidget( parent, name ) |
45 | { | 45 | { |
46 | QHBoxLayout *layout = new QHBoxLayout( this ); | 46 | QHBoxLayout *layout = new QHBoxLayout( this ); |
47 | layout->setAutoAdd( TRUE ); | 47 | layout->setAutoAdd( TRUE ); |
48 | layout->setSpacing( 2 ); | 48 | layout->setSpacing( 2 ); |
49 | 49 | ||
50 | weatherIcon = new QLabel( this ); | 50 | weatherIcon = new QLabel( this ); |
51 | weatherIcon->setMaximumWidth( 32 ); | 51 | weatherIcon->setMaximumWidth( 32 ); |
52 | QImage logo1 = Resource::loadImage( "Clock" ); | 52 | QImage logo1 = Resource::loadImage( "Clock" ); |
53 | QPixmap pic; | 53 | QPixmap pic; |
54 | pic.convertFromImage( logo1 ); | 54 | pic.convertFromImage( logo1 ); |
55 | weatherIcon->setPixmap( pic ); | 55 | weatherIcon->setPixmap( pic ); |
56 | 56 | ||
57 | weatherLabel = new QLabel( tr( "Retreiving current weather information." ), this ); | 57 | weatherLabel = new QLabel( tr( "Retreiving current weather information." ), this ); |
58 | weatherLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) ); | 58 | weatherLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) ); |
59 | 59 | ||
60 | startTimer(1000); | 60 | startTimer(1000); |
61 | } | 61 | } |
62 | 62 | ||
63 | WeatherPluginWidget::~WeatherPluginWidget() | 63 | WeatherPluginWidget::~WeatherPluginWidget() |
64 | { | 64 | { |
65 | QFile file( localFile ); | 65 | QFile file( localFile ); |
66 | if ( file.exists() ) | 66 | if ( file.exists() ) |
67 | { | 67 | { |
68 | file.remove(); | 68 | file.remove(); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void WeatherPluginWidget::timerEvent( QTimerEvent *e ) | 72 | void WeatherPluginWidget::timerEvent( QTimerEvent *e ) |
73 | { | 73 | { |
74 | killTimer( e->timerId() ); | 74 | killTimer( e->timerId() ); |
75 | retreiveData(); | 75 | retreiveData(); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | 79 | ||
80 | void WeatherPluginWidget::retreiveData() | 80 | void WeatherPluginWidget::retreiveData() |
81 | { | 81 | { |
82 | Config config( "todayweatherplugin"); | 82 | Config config( "todayweatherplugin"); |
83 | config.setGroup( "Config" ); | 83 | config.setGroup( "Config" ); |
84 | 84 | ||
85 | location = config.readEntry( "Location", "" ); | 85 | location = config.readEntry( "Location", "" ); |
86 | useMetric = config.readBoolEntry( "Metric", TRUE ); | 86 | useMetric = config.readBoolEntry( "Metric", TRUE ); |
87 | frequency = config.readNumEntry( "Frequency", 5 ); | 87 | frequency = config.readNumEntry( "Frequency", 5 ); |
88 | 88 | ||
89 | startTimer( frequency * 60000 ); | 89 | startTimer( frequency * 60000 ); |
90 | 90 | ||
91 | localFile = "/tmp/"; | 91 | localFile = "/tmp/"; |
92 | localFile.append( location ); | 92 | localFile.append( location ); |
93 | localFile.append( ".TXT" ); | 93 | localFile.append( ".TXT" ); |
94 | 94 | ||
95 | remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/"; | 95 | remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/"; |
96 | remoteFile.append( location ); | 96 | remoteFile.append( location ); |
97 | remoteFile.append( ".TXT" ); | 97 | remoteFile.append( ".TXT" ); |
98 | 98 | ||
99 | QFile file( localFile ); | 99 | QFile file( localFile ); |
100 | if ( file.exists() ) | 100 | if ( file.exists() ) |
101 | { | 101 | { |
102 | file.remove(); | 102 | file.remove(); |
103 | } | 103 | } |
104 | 104 | ||
105 | OProcess *proc = new OProcess; | 105 | OProcess *proc = new OProcess; |
106 | 106 | ||
107 | *proc << "wget" << "-q" << remoteFile << "-O" << localFile; | 107 | *proc << "wget" << "-q" << remoteFile << "-O" << localFile; |
108 | connect( proc, SIGNAL( processExited( OProcess * ) ), this, SLOT( dataRetrieved( OProcess * ) ) ); | 108 | connect( proc, SIGNAL( processExited(OProcess*) ), this, SLOT( dataRetrieved(OProcess*) ) ); |
109 | proc->start(); | 109 | proc->start(); |
110 | } | 110 | } |
111 | 111 | ||
112 | void WeatherPluginWidget::displayWeather() | 112 | void WeatherPluginWidget::displayWeather() |
113 | { | 113 | { |
114 | weatherData = QString::null; | 114 | weatherData = QString::null; |
115 | 115 | ||
116 | QFile file( localFile ); | 116 | QFile file( localFile ); |
117 | 117 | ||
118 | if ( file.size() > 0 && file.open( IO_ReadOnly ) ) | 118 | if ( file.size() > 0 && file.open( IO_ReadOnly ) ) |
119 | { | 119 | { |
120 | QTextStream data( &file ); | 120 | QTextStream data( &file ); |
121 | while ( !data.eof() ) | 121 | while ( !data.eof() ) |
122 | { | 122 | { |
123 | weatherData.append( data.readLine() ); | 123 | weatherData.append( data.readLine() ); |
124 | } | 124 | } |
125 | file.close(); | 125 | file.close(); |
126 | weatherData = weatherData.simplifyWhiteSpace(); | 126 | weatherData = weatherData.simplifyWhiteSpace(); |
127 | 127 | ||
128 | QString tmpstr; | 128 | QString tmpstr; |
129 | 129 | ||
130 | tmpstr.append( tr( "Temp: " ) ); | 130 | tmpstr.append( tr( "Temp: " ) ); |
131 | getTemp( weatherData ); | 131 | getTemp( weatherData ); |
132 | tmpstr.append( dataStr ); | 132 | tmpstr.append( dataStr ); |
133 | 133 | ||
134 | tmpstr.append( tr( " Wind: " ) ); | 134 | tmpstr.append( tr( " Wind: " ) ); |
135 | getWind( weatherData ); | 135 | getWind( weatherData ); |
136 | tmpstr.append( dataStr ); | 136 | tmpstr.append( dataStr ); |
137 | 137 | ||
138 | tmpstr.append( tr( "\nPres: " ) ); | 138 | tmpstr.append( tr( "\nPres: " ) ); |
139 | getPressure( weatherData ); | 139 | getPressure( weatherData ); |
140 | tmpstr.append( dataStr ); | 140 | tmpstr.append( dataStr ); |
141 | 141 | ||
142 | weatherLabel->setText( tmpstr ); | 142 | weatherLabel->setText( tmpstr ); |
143 | 143 | ||
144 | tmpstr = "todayweatherplugin/"; | 144 | tmpstr = "todayweatherplugin/"; |
145 | getIcon( weatherData ); | 145 | getIcon( weatherData ); |
146 | tmpstr.append( dataStr ); | 146 | tmpstr.append( dataStr ); |
147 | QImage logo1 = Resource::loadImage( tmpstr ); | 147 | QImage logo1 = Resource::loadImage( tmpstr ); |
148 | QPixmap pic; | 148 | QPixmap pic; |
149 | pic.convertFromImage( logo1 ); | 149 | pic.convertFromImage( logo1 ); |
150 | weatherIcon->setPixmap( pic ); | 150 | weatherIcon->setPixmap( pic ); |
151 | } | 151 | } |
152 | else | 152 | else |
153 | { | 153 | { |
154 | weatherLabel->setText( tr( "Current weather data not available." ) ); | 154 | weatherLabel->setText( tr( "Current weather data not available." ) ); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void WeatherPluginWidget::getTemp( const QString &data ) | 158 | void WeatherPluginWidget::getTemp( const QString &data ) |
159 | { | 159 | { |
160 | int value; | 160 | int value; |
161 | bool ok; | 161 | bool ok; |
162 | 162 | ||
163 | int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 ); | 163 | int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 ); |
164 | if ( pos > -1 ) | 164 | if ( pos > -1 ) |
165 | { | 165 | { |
166 | if ( data.at( pos ) == 'M' ) | 166 | if ( data.at( pos ) == 'M' ) |
167 | { | 167 | { |
168 | value = -1 * data.mid( pos + 1, 2 ).toInt( &ok ); | 168 | value = -1 * data.mid( pos + 1, 2 ).toInt( &ok ); |
169 | } | 169 | } |
170 | else | 170 | else |
171 | { | 171 | { |
172 | value = data.mid( pos, 2 ).toInt( &ok ); | 172 | value = data.mid( pos, 2 ).toInt( &ok ); |
173 | } | 173 | } |
174 | if ( useMetric ) | 174 | if ( useMetric ) |
175 | { | 175 | { |
176 | dataStr = QString::number( value ); | 176 | dataStr = QString::number( value ); |
177 | dataStr.append( 'C' ); | 177 | dataStr.append( 'C' ); |
178 | } | 178 | } |
179 | else | 179 | else |
180 | { | 180 | { |
181 | dataStr = QString::number( ( value * 9 / 5 ) + 32 ); | 181 | dataStr = QString::number( ( value * 9 / 5 ) + 32 ); |
182 | dataStr.append( 'F' ); | 182 | dataStr.append( 'F' ); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | else | 185 | else |
186 | { | 186 | { |
187 | dataStr = tr( "n/a" ); | 187 | dataStr = tr( "n/a" ); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | void WeatherPluginWidget::getWind( const QString &data ) | 191 | void WeatherPluginWidget::getWind( const QString &data ) |
192 | { | 192 | { |
193 | int value; | 193 | int value; |
194 | bool ok; | 194 | bool ok; |
195 | 195 | ||
196 | int pos = data.find( QRegExp( "[0-9]*G*[0-9]*KT" ), 20 ); | 196 | int pos = data.find( QRegExp( "[0-9]*G*[0-9]*KT" ), 20 ); |
197 | if ( pos > -1 ) | 197 | if ( pos > -1 ) |
198 | { | 198 | { |
199 | if ( data.mid( pos, 3 ) != "VRB" ) | 199 | if ( data.mid( pos, 3 ) != "VRB" ) |
200 | { | 200 | { |
201 | value = data.mid( pos, 3 ).toInt( &ok ); | 201 | value = data.mid( pos, 3 ).toInt( &ok ); |
202 | if ( ( value >= 0 && value < 23 ) || ( value >= 239 && value <= 360 ) ) | 202 | if ( ( value >= 0 && value < 23 ) || ( value >= 239 && value <= 360 ) ) |
203 | dataStr = tr("E " ); | 203 | dataStr = tr("E " ); |
204 | else if ( value >= 23 && value < 69 ) | 204 | else if ( value >= 23 && value < 69 ) |