summaryrefslogtreecommitdiff
authormouse <mouse>2004-03-31 13:33:34 (UTC)
committer mouse <mouse>2004-03-31 13:33:34 (UTC)
commit38e313e5b9d2339580614264a428a84f70f4f4c0 (patch) (unidiff)
tree36db27452496be76a6cc54d50d203f8721b1bbb7
parent2a9adba9bf421aa8bddecfe3f1c1b8a7f8343c4f (diff)
downloadopie-38e313e5b9d2339580614264a428a84f70f4f4c0.zip
opie-38e313e5b9d2339580614264a428a84f70f4f4c0.tar.gz
opie-38e313e5b9d2339580614264a428a84f70f4f4c0.tar.bz2
added missed include file for QFileDialog
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stockticker/helpwindow.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
index db662e8..410d642 100644
--- a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
+++ b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
@@ -1,267 +1,271 @@
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#ifndef QT_NO_FILEDIALOG
19#include <qfiledialog.h>
20#endif
21
18#include <ctype.h> 22#include <ctype.h>
19 23
20HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) 24HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name )
21 : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() 25 : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL()
22{ 26{
23 readHistory(); 27 readHistory();
24 readBookmarks(); 28 readBookmarks();
25 29
26 browser = new QTextBrowser( this ); 30 browser = new QTextBrowser( this );
27 QStringList Strlist; 31 QStringList Strlist;
28 Strlist.append( home_); 32 Strlist.append( home_);
29 33
30 browser->mimeSourceFactory()->setFilePath( Strlist ); 34 browser->mimeSourceFactory()->setFilePath( Strlist );
31 35
32 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 36 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
33 37
34 connect( browser, SIGNAL( textChanged() ), 38 connect( browser, SIGNAL( textChanged() ),
35 39
36 this, SLOT( textChanged() ) ); 40 this, SLOT( textChanged() ) );
37 41
38 setCentralWidget( browser ); 42 setCentralWidget( browser );
39 43
40 if ( !home_.isEmpty() ) 44 if ( !home_.isEmpty() )
41 45
42//////////////////////////////// 46////////////////////////////////
43 browser->setSource( home_ ); 47 browser->setSource( home_ );
44 48
45//////////////////////////////// 49////////////////////////////////
46 connect( browser, SIGNAL( highlighted(const QString&) ), 50 connect( browser, SIGNAL( highlighted(const QString&) ),
47 statusBar(), SLOT( message(const QString&)) ); 51 statusBar(), SLOT( message(const QString&)) );
48 52
49 setGeometry( 0,0,236,280); 53 setGeometry( 0,0,236,280);
50 54
51 QPopupMenu* file = new QPopupMenu( this ); 55 QPopupMenu* file = new QPopupMenu( this );
52// file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); 56// file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N );
53 file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); 57 file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O );
54// file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); 58// file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P );
55 file->insertSeparator(); 59 file->insertSeparator();
56 file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); 60 file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q );
57// file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); 61// file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X );
58 62
59 // The same three icons are used twice each. 63 // The same three icons are used twice each.
60////F FIXME 64////F FIXME
61 QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; 65 QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/";
62 QIconSet icon_back( QPixmap(pixs+"back.png") ); 66 QIconSet icon_back( QPixmap(pixs+"back.png") );
63 QIconSet icon_forward( QPixmap(pixs+"forward.png") ); 67 QIconSet icon_forward( QPixmap(pixs+"forward.png") );
64 QIconSet icon_home( QPixmap(pixs+"home.png") ); 68 QIconSet icon_home( QPixmap(pixs+"home.png") );
65 69
66 QPopupMenu* go = new QPopupMenu( this ); 70 QPopupMenu* go = new QPopupMenu( this );
67 backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); 71 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 ); 72 forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right );
69 go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); 73 go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) );
70 74
71 75
72 hist = new QPopupMenu( this ); 76 hist = new QPopupMenu( this );
73 QStringList::Iterator it = history.begin(); 77 QStringList::Iterator it = history.begin();
74 for ( ; it != history.end(); ++it ) 78 for ( ; it != history.end(); ++it )
75 mHistory[ hist->insertItem( *it ) ] = *it; 79 mHistory[ hist->insertItem( *it ) ] = *it;
76 connect( hist, SIGNAL( activated(int) ), this, SLOT( histChosen(int) ) ); 80 connect( hist, SIGNAL( activated(int) ), this, SLOT( histChosen(int) ) );
77 81
78 bookm = new QPopupMenu( this ); 82 bookm = new QPopupMenu( this );
79 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); 83 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
80 bookm->insertSeparator(); 84 bookm->insertSeparator();
81 85
82 QStringList::Iterator it2 = bookmarks.begin(); 86 QStringList::Iterator it2 = bookmarks.begin();
83 for ( ; it2 != bookmarks.end(); ++it2 ) 87 for ( ; it2 != bookmarks.end(); ++it2 )
84 mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; 88 mBookmarks[ bookm->insertItem( *it2 ) ] = *it2;
85 connect( bookm, SIGNAL( activated(int) ), 89 connect( bookm, SIGNAL( activated(int) ),
86 this, SLOT( bookmChosen(int) ) ); 90 this, SLOT( bookmChosen(int) ) );
87 91
88 menuBar()->insertItem( tr("&File"), file ); 92 menuBar()->insertItem( tr("&File"), file );
89 menuBar()->insertItem( tr("&Go"), go ); 93 menuBar()->insertItem( tr("&Go"), go );
90 menuBar()->insertItem( tr( "History" ), hist ); 94 menuBar()->insertItem( tr( "History" ), hist );
91 menuBar()->insertItem( tr( "Bookmarks" ), bookm ); 95 menuBar()->insertItem( tr( "Bookmarks" ), bookm );
92// menuBar()->insertSeparator(); 96// menuBar()->insertSeparator();
93// menuBar()->insertItem( tr("&Help"), help ); 97// menuBar()->insertItem( tr("&Help"), help );
94 98
95 menuBar()->setItemEnabled( forwardId, FALSE); 99 menuBar()->setItemEnabled( forwardId, FALSE);
96 menuBar()->setItemEnabled( backwardId, FALSE); 100 menuBar()->setItemEnabled( backwardId, FALSE);
97 connect( browser, SIGNAL( backwardAvailable(bool) ), this, SLOT( setBackwardAvailable(bool) ) ); 101 connect( browser, SIGNAL( backwardAvailable(bool) ), this, SLOT( setBackwardAvailable(bool) ) );
98 connect( browser, SIGNAL( forwardAvailable(bool) ), this, SLOT( setForwardAvailable(bool) ) ); 102 connect( browser, SIGNAL( forwardAvailable(bool) ), this, SLOT( setForwardAvailable(bool) ) );
99 103
100 104
101 QToolBar* toolbar = new QToolBar( this ); 105 QToolBar* toolbar = new QToolBar( this );
102 addToolBar( toolbar, "Toolbar"); 106 addToolBar( toolbar, "Toolbar");
103 QToolButton* button; 107 QToolButton* button;
104 108
105 button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); 109 button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar );
106 connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); 110 connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
107 button->setEnabled( FALSE ); 111 button->setEnabled( FALSE );
108 button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); 112 button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar );
109 connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); 113 connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
110 button->setEnabled( FALSE ); 114 button->setEnabled( FALSE );
111 button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); 115 button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar );
112 116
113 toolbar->addSeparator(); 117 toolbar->addSeparator();
114 118
115 pathCombo = new QComboBox( TRUE, toolbar ); 119 pathCombo = new QComboBox( TRUE, toolbar );
116 connect( pathCombo, SIGNAL( activated(const QString&) ), this, SLOT( pathSelected(const QString&) ) ); 120 connect( pathCombo, SIGNAL( activated(const QString&) ), this, SLOT( pathSelected(const QString&) ) );
117 toolbar->setStretchableWidget( pathCombo ); 121 toolbar->setStretchableWidget( pathCombo );
118 122
119// pathCombo->setMaximumWidth(190); 123// pathCombo->setMaximumWidth(190);
120// setRightJustification( TRUE ); 124// setRightJustification( TRUE );
121// setDockEnabled( Left, FALSE ); 125// setDockEnabled( Left, FALSE );
122// setDockEnabled( Right, FALSE ); 126// setDockEnabled( Right, FALSE );
123 127
124 pathCombo->insertItem( home_ ); 128 pathCombo->insertItem( home_ );
125 129
126 browser->setFocus(); 130 browser->setFocus();
127 131
128 132
129} 133}
130 134
131 135
132void HelpWindow::setBackwardAvailable( bool b) 136void HelpWindow::setBackwardAvailable( bool b)
133{ 137{
134 menuBar()->setItemEnabled( backwardId, b); 138 menuBar()->setItemEnabled( backwardId, b);
135} 139}
136 140
137void HelpWindow::setForwardAvailable( bool b) 141void HelpWindow::setForwardAvailable( bool b)
138{ 142{
139 menuBar()->setItemEnabled( forwardId, b); 143 menuBar()->setItemEnabled( forwardId, b);
140} 144}
141 145
142 146
143void HelpWindow::textChanged() 147void HelpWindow::textChanged()
144{ 148{
145 if ( browser->documentTitle().isNull() ) { 149 if ( browser->documentTitle().isNull() ) {
146 setCaption( "Stockticker Lookup - " + browser->context() ); 150 setCaption( "Stockticker Lookup - " + browser->context() );
147 selectedURL = browser->context(); 151 selectedURL = browser->context();
148 } 152 }
149 else { 153 else {
150 setCaption( "Stockticker Lookup - " + browser->documentTitle() ) ; 154 setCaption( "Stockticker Lookup - " + browser->documentTitle() ) ;
151 selectedURL = browser->documentTitle(); 155 selectedURL = browser->documentTitle();
152 } 156 }
153 157
154 if ( !selectedURL.isEmpty() && pathCombo ) { 158 if ( !selectedURL.isEmpty() && pathCombo ) {
155 bool exists = FALSE; 159 bool exists = FALSE;
156 int i; 160 int i;
157 for ( i = 0; i < pathCombo->count(); ++i ) { 161 for ( i = 0; i < pathCombo->count(); ++i ) {
158 if ( pathCombo->text( i ) == selectedURL ) { 162 if ( pathCombo->text( i ) == selectedURL ) {
159 exists = TRUE; 163 exists = TRUE;
160 break; 164 break;
161 } 165 }
162 } 166 }
163 if ( !exists ) { 167 if ( !exists ) {
164 pathCombo->insertItem( selectedURL, 0 ); 168 pathCombo->insertItem( selectedURL, 0 );
165 pathCombo->setCurrentItem( 0 ); 169 pathCombo->setCurrentItem( 0 );
166 mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; 170 mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
167 } else 171 } else
168 pathCombo->setCurrentItem( i ); 172 pathCombo->setCurrentItem( i );
169 selectedURL = QString::null; 173 selectedURL = QString::null;
170 } 174 }
171} 175}
172 176
173HelpWindow::~HelpWindow() 177HelpWindow::~HelpWindow()
174{ 178{
175 history.clear(); 179 history.clear();
176 QMap<int, QString>::Iterator it = mHistory.begin(); 180 QMap<int, QString>::Iterator it = mHistory.begin();
177 for ( ; it != mHistory.end(); ++it ) 181 for ( ; it != mHistory.end(); ++it )
178 history.append( *it ); 182 history.append( *it );
179 183
180 QFile f( QDir::currentDirPath() + "/.history" ); 184 QFile f( QDir::currentDirPath() + "/.history" );
181 f.open( IO_WriteOnly ); 185 f.open( IO_WriteOnly );
182 QDataStream s( &f ); 186 QDataStream s( &f );
183 s << history; 187 s << history;
184 f.close(); 188 f.close();
185 189
186 bookmarks.clear(); 190 bookmarks.clear();
187 QMap<int, QString>::Iterator it2 = mBookmarks.begin(); 191 QMap<int, QString>::Iterator it2 = mBookmarks.begin();
188 for ( ; it2 != mBookmarks.end(); ++it2 ) 192 for ( ; it2 != mBookmarks.end(); ++it2 )
189 bookmarks.append( *it2 ); 193 bookmarks.append( *it2 );
190 194
191 QFile f2( QDir::currentDirPath() + "/.bookmarks" ); 195 QFile f2( QDir::currentDirPath() + "/.bookmarks" );
192 f2.open( IO_WriteOnly ); 196 f2.open( IO_WriteOnly );
193 QDataStream s2( &f2 ); 197 QDataStream s2( &f2 );
194 s2 << bookmarks; 198 s2 << bookmarks;
195 f2.close(); 199 f2.close();
196} 200}
197 201
198void HelpWindow::openFile() 202void HelpWindow::openFile()
199{ 203{
200#ifndef QT_NO_FILEDIALOG 204#ifndef QT_NO_FILEDIALOG
201 QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); 205 QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );
202 if ( !fn.isEmpty() ) 206 if ( !fn.isEmpty() )
203 browser->setSource( fn ); 207 browser->setSource( fn );
204#endif 208#endif
205} 209}
206 210
207void HelpWindow::newWindow() 211void HelpWindow::newWindow()
208{ 212{
209 ( new HelpWindow(browser->source(), "qbrowser") )->show(); 213 ( new HelpWindow(browser->source(), "qbrowser") )->show();
210} 214}
211 215
212void HelpWindow::pathSelected( const QString &_path ) 216void HelpWindow::pathSelected( const QString &_path )
213{ 217{
214 browser->setSource( _path ); 218 browser->setSource( _path );
215 QMap<int, QString>::Iterator it = mHistory.begin(); 219 QMap<int, QString>::Iterator it = mHistory.begin();
216 bool exists = FALSE; 220 bool exists = FALSE;
217 for ( ; it != mHistory.end(); ++it ) { 221 for ( ; it != mHistory.end(); ++it ) {
218 if ( *it == _path ) { 222 if ( *it == _path ) {
219 exists = TRUE; 223 exists = TRUE;
220 break; 224 break;
221 } 225 }
222 } 226 }
223 if ( !exists ) 227 if ( !exists )
224 mHistory[ hist->insertItem( _path ) ] = _path; 228 mHistory[ hist->insertItem( _path ) ] = _path;
225} 229}
226 230
227void HelpWindow::readHistory() 231void HelpWindow::readHistory()
228{ 232{
229 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { 233 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) {
230 QFile f( QDir::currentDirPath() + "/.history" ); 234 QFile f( QDir::currentDirPath() + "/.history" );
231 f.open( IO_ReadOnly ); 235 f.open( IO_ReadOnly );
232 QDataStream s( &f ); 236 QDataStream s( &f );
233 s >> history; 237 s >> history;
234 f.close(); 238 f.close();
235 while ( history.count() > 20 ) 239 while ( history.count() > 20 )
236 history.remove( history.begin() ); 240 history.remove( history.begin() );
237 } 241 }
238} 242}
239 243
240void HelpWindow::readBookmarks() 244void HelpWindow::readBookmarks()
241{ 245{
242 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { 246 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) {
243 QFile f( QDir::currentDirPath() + "/.bookmarks" ); 247 QFile f( QDir::currentDirPath() + "/.bookmarks" );
244 f.open( IO_ReadOnly ); 248 f.open( IO_ReadOnly );
245 QDataStream s( &f ); 249 QDataStream s( &f );
246 s >> bookmarks; 250 s >> bookmarks;
247 f.close(); 251 f.close();
248 } 252 }
249} 253}
250 254
251void HelpWindow::histChosen( int i ) 255void HelpWindow::histChosen( int i )
252{ 256{
253 if ( mHistory.contains( i ) ) 257 if ( mHistory.contains( i ) )
254 browser->setSource( mHistory[ i ] ); 258 browser->setSource( mHistory[ i ] );
255} 259}
256 260
257void HelpWindow::bookmChosen( int i ) 261void HelpWindow::bookmChosen( int i )
258{ 262{
259 if ( mBookmarks.contains( i ) ) 263 if ( mBookmarks.contains( i ) )
260 browser->setSource( mBookmarks[ i ] ); 264 browser->setSource( mBookmarks[ i ] );
261} 265}
262 266
263void HelpWindow::addBookmark() 267void HelpWindow::addBookmark()
264{ 268{
265 mBookmarks[ bookm->insertItem( caption() ) ] = caption(); 269 mBookmarks[ bookm->insertItem( caption() ) ] = caption();
266} 270}
267 271