author | zecke <zecke> | 2005-02-19 17:24:39 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-19 17:24:39 (UTC) |
commit | b02c537198dad1e53f8c4004a4c08578e431b411 (patch) (unidiff) | |
tree | e68be3ed8bb7d27c1716e7df22dc2ba0f5f3091c | |
parent | be32e0c045814142954ac37c89715313633d6aa2 (diff) | |
download | opie-b02c537198dad1e53f8c4004a4c08578e431b411.zip opie-b02c537198dad1e53f8c4004a4c08578e431b411.tar.gz opie-b02c537198dad1e53f8c4004a4c08578e431b411.tar.bz2 |
-QFileDialog is not used in opentext.cpp so remove it from its header file
-Help Window eventually uses QFileDialog, better include it then as well...
-rw-r--r-- | noncore/apps/opie-gutenbrowser/helpwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/openetext.h | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.cpp b/noncore/apps/opie-gutenbrowser/helpwindow.cpp index ffdc9f0..57b1e74 100644 --- a/noncore/apps/opie-gutenbrowser/helpwindow.cpp +++ b/noncore/apps/opie-gutenbrowser/helpwindow.cpp | |||
@@ -1,326 +1,330 @@ | |||
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 | copyright : (C) 2000 -2004 by llornkcor | 9 | copyright : (C) 2000 -2004 by llornkcor |
10 | email : ljp@llornkcor.com | 10 | email : ljp@llornkcor.com |
11 | *****************************************************************************/ | 11 | *****************************************************************************/ |
12 | 12 | ||
13 | #include "helpwindow.h" | 13 | #include "helpwindow.h" |
14 | #include <qstatusbar.h> | 14 | #include <qstatusbar.h> |
15 | 15 | ||
16 | #include <qmenubar.h> | 16 | #include <qmenubar.h> |
17 | #include <qtoolbar.h> | 17 | #include <qtoolbar.h> |
18 | #include <qtoolbutton.h> | 18 | #include <qtoolbutton.h> |
19 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
20 | 20 | ||
21 | #ifndef QT_NO_FILEDIALOG | ||
22 | #include <qfiledialog.h> | ||
23 | #endif | ||
24 | |||
21 | #include <ctype.h> | 25 | #include <ctype.h> |
22 | 26 | ||
23 | HelpWindow::HelpWindow( const QString& home_, const QString&, QWidget* parent, const char *name ) | 27 | HelpWindow::HelpWindow( const QString& home_, const QString&, QWidget* parent, const char *name ) |
24 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() | 28 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() |
25 | { | 29 | { |
26 | QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 30 | QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
27 | // readHistory(); | 31 | // readHistory(); |
28 | // readBookmarks(); | 32 | // readBookmarks(); |
29 | 33 | ||
30 | browser = new QTextBrowser( this ); | 34 | browser = new QTextBrowser( this ); |
31 | QStringList Strlist; | 35 | QStringList Strlist; |
32 | Strlist.append( home_); | 36 | Strlist.append( home_); |
33 | browser->mimeSourceFactory()->setFilePath( Strlist ); | 37 | browser->mimeSourceFactory()->setFilePath( Strlist ); |
34 | 38 | ||
35 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 39 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
36 | 40 | ||
37 | connect(browser,SIGNAL(textChanged()),this,SLOT(textChanged())); | 41 | connect(browser,SIGNAL(textChanged()),this,SLOT(textChanged())); |
38 | 42 | ||
39 | setCentralWidget( browser ); | 43 | setCentralWidget( browser ); |
40 | 44 | ||
41 | if ( !home_.isEmpty() ) | 45 | if ( !home_.isEmpty() ) |
42 | 46 | ||
43 | //////////////////////////////// | 47 | //////////////////////////////// |
44 | browser->setSource( home_ ); | 48 | browser->setSource( home_ ); |
45 | 49 | ||
46 | //////////////////////////////// | 50 | //////////////////////////////// |
47 | connect( browser, SIGNAL( highlighted( const QString&) ), | 51 | connect( browser, SIGNAL( highlighted( const QString&) ), |
48 | statusBar(), SLOT( message( const QString&)) ); | 52 | statusBar(), SLOT( message( const QString&)) ); |
49 | 53 | ||
50 | // resize( 640,600 ); | 54 | // resize( 640,600 ); |
51 | #ifdef Q_WS_QWS | 55 | #ifdef Q_WS_QWS |
52 | setGeometry( 0,0,236,280); | 56 | setGeometry( 0,0,236,280); |
53 | #else | 57 | #else |
54 | setGeometry( 10,30,520,420 ); | 58 | setGeometry( 10,30,520,420 ); |
55 | // resize(520,420); | 59 | // resize(520,420); |
56 | #endif | 60 | #endif |
57 | 61 | ||
58 | QPopupMenu* file = new QPopupMenu( this ); | 62 | QPopupMenu* file = new QPopupMenu( this ); |
59 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); | 63 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); |
60 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); | 64 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); |
61 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); | 65 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); |
62 | file->insertSeparator(); | 66 | file->insertSeparator(); |
63 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); | 67 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); |
64 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); | 68 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); |
65 | 69 | ||
66 | // The same three icons are used twice each. | 70 | // The same three icons are used twice each. |
67 | ////F FIXME | 71 | ////F FIXME |
68 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; | 72 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; |
69 | QIconSet icon_back( QPixmap(pixs+"back.png") ); | 73 | QIconSet icon_back( QPixmap(pixs+"back.png") ); |
70 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); | 74 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); |
71 | QIconSet icon_home( QPixmap(pixs+"home.png") ); | 75 | QIconSet icon_home( QPixmap(pixs+"home.png") ); |
72 | 76 | ||
73 | QPopupMenu* go = new QPopupMenu( this ); | 77 | QPopupMenu* go = new QPopupMenu( this ); |
74 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); | 78 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); |
75 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); | 79 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); |
76 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); | 80 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); |
77 | 81 | ||
78 | // QPopupMenu* help = new QPopupMenu( this ); | 82 | // QPopupMenu* help = new QPopupMenu( this ); |
79 | // help->insertItem( tr("&About ..."), this, SLOT( about() ) ); | 83 | // help->insertItem( tr("&About ..."), this, SLOT( about() ) ); |
80 | // help->insertItem( tr("About &Qt ..."), this, SLOT( aboutQt() ) ); | 84 | // help->insertItem( tr("About &Qt ..."), this, SLOT( aboutQt() ) ); |
81 | 85 | ||
82 | 86 | ||
83 | hist = new QPopupMenu( this ); | 87 | hist = new QPopupMenu( this ); |
84 | QStringList::Iterator it = history.begin(); | 88 | QStringList::Iterator it = history.begin(); |
85 | for ( ; it != history.end(); ++it ) | 89 | for ( ; it != history.end(); ++it ) |
86 | mHistory[ hist->insertItem( *it ) ] = *it; | 90 | mHistory[ hist->insertItem( *it ) ] = *it; |
87 | connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); | 91 | connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); |
88 | 92 | ||
89 | bookm = new QPopupMenu( this ); | 93 | bookm = new QPopupMenu( this ); |
90 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | 94 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); |
91 | bookm->insertSeparator(); | 95 | bookm->insertSeparator(); |
92 | 96 | ||
93 | QStringList::Iterator it2 = bookmarks.begin(); | 97 | QStringList::Iterator it2 = bookmarks.begin(); |
94 | for ( ; it2 != bookmarks.end(); ++it2 ) | 98 | for ( ; it2 != bookmarks.end(); ++it2 ) |
95 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; | 99 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; |
96 | connect( bookm, SIGNAL( activated( int ) ), | 100 | connect( bookm, SIGNAL( activated( int ) ), |
97 | this, SLOT( bookmChosen( int ) ) ); | 101 | this, SLOT( bookmChosen( int ) ) ); |
98 | 102 | ||
99 | menuBar()->insertItem( tr("&File"), file ); | 103 | menuBar()->insertItem( tr("&File"), file ); |
100 | menuBar()->insertItem( tr("&Go"), go ); | 104 | menuBar()->insertItem( tr("&Go"), go ); |
101 | menuBar()->insertItem( tr( "History" ), hist ); | 105 | menuBar()->insertItem( tr( "History" ), hist ); |
102 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); | 106 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); |
103 | // menuBar()->insertSeparator(); | 107 | // menuBar()->insertSeparator(); |
104 | // menuBar()->insertItem( tr("&Help"), help ); | 108 | // menuBar()->insertItem( tr("&Help"), help ); |
105 | 109 | ||
106 | menuBar()->setItemEnabled( forwardId, FALSE); | 110 | menuBar()->setItemEnabled( forwardId, FALSE); |
107 | menuBar()->setItemEnabled( backwardId, FALSE); | 111 | menuBar()->setItemEnabled( backwardId, FALSE); |
108 | connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); | 112 | connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); |
109 | connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); | 113 | connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); |
110 | 114 | ||
111 | 115 | ||
112 | QToolBar* toolbar = new QToolBar( this ); | 116 | QToolBar* toolbar = new QToolBar( this ); |
113 | addToolBar( toolbar, "Toolbar"); | 117 | addToolBar( toolbar, "Toolbar"); |
114 | QToolButton* button; | 118 | QToolButton* button; |
115 | 119 | ||
116 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); | 120 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); |
117 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 121 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
118 | button->setEnabled( FALSE ); | 122 | button->setEnabled( FALSE ); |
119 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); | 123 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); |
120 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 124 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
121 | button->setEnabled( FALSE ); | 125 | button->setEnabled( FALSE ); |
122 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); | 126 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); |
123 | 127 | ||
124 | toolbar->addSeparator(); | 128 | toolbar->addSeparator(); |
125 | 129 | ||
126 | pathCombo = new QComboBox( TRUE, toolbar ); | 130 | pathCombo = new QComboBox( TRUE, toolbar ); |
127 | connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); | 131 | connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); |
128 | toolbar->setStretchableWidget( pathCombo ); | 132 | toolbar->setStretchableWidget( pathCombo ); |
129 | 133 | ||
130 | // pathCombo->setMaximumWidth(190); | 134 | // pathCombo->setMaximumWidth(190); |
131 | // setRightJustification( TRUE ); | 135 | // setRightJustification( TRUE ); |
132 | // setDockEnabled( Left, FALSE ); | 136 | // setDockEnabled( Left, FALSE ); |
133 | // setDockEnabled( Right, FALSE ); | 137 | // setDockEnabled( Right, FALSE ); |
134 | 138 | ||
135 | pathCombo->insertItem( home_ ); | 139 | pathCombo->insertItem( home_ ); |
136 | 140 | ||
137 | browser->setFocus(); | 141 | browser->setFocus(); |
138 | 142 | ||
139 | 143 | ||
140 | } | 144 | } |
141 | 145 | ||
142 | 146 | ||
143 | void HelpWindow::setBackwardAvailable( bool b) | 147 | void HelpWindow::setBackwardAvailable( bool b) |
144 | { | 148 | { |
145 | menuBar()->setItemEnabled( backwardId, b); | 149 | menuBar()->setItemEnabled( backwardId, b); |
146 | } | 150 | } |
147 | 151 | ||
148 | void HelpWindow::setForwardAvailable( bool b) | 152 | void HelpWindow::setForwardAvailable( bool b) |
149 | { | 153 | { |
150 | menuBar()->setItemEnabled( forwardId, b); | 154 | menuBar()->setItemEnabled( forwardId, b); |
151 | } | 155 | } |
152 | 156 | ||
153 | 157 | ||
154 | void HelpWindow::textChanged() | 158 | void HelpWindow::textChanged() |
155 | { | 159 | { |
156 | if ( browser->documentTitle().isNull() ) { | 160 | if ( browser->documentTitle().isNull() ) { |
157 | setCaption( "Gutenbrowser - Helpviewer - " + browser->context() ); | 161 | setCaption( "Gutenbrowser - Helpviewer - " + browser->context() ); |
158 | selectedURL = browser->context(); | 162 | selectedURL = browser->context(); |
159 | } | 163 | } |
160 | else { | 164 | else { |
161 | setCaption( "Gutenbrowser - Helpviewer - " + browser->documentTitle() ) ; | 165 | setCaption( "Gutenbrowser - Helpviewer - " + browser->documentTitle() ) ; |
162 | selectedURL = browser->documentTitle(); | 166 | selectedURL = browser->documentTitle(); |
163 | } | 167 | } |
164 | 168 | ||
165 | if ( !selectedURL.isEmpty() && pathCombo ) { | 169 | if ( !selectedURL.isEmpty() && pathCombo ) { |
166 | bool exists = FALSE; | 170 | bool exists = FALSE; |
167 | int i; | 171 | int i; |
168 | for ( i = 0; i < pathCombo->count(); ++i ) { | 172 | for ( i = 0; i < pathCombo->count(); ++i ) { |
169 | if ( pathCombo->text( i ) == selectedURL ) { | 173 | if ( pathCombo->text( i ) == selectedURL ) { |
170 | exists = TRUE; | 174 | exists = TRUE; |
171 | break; | 175 | break; |
172 | } | 176 | } |
173 | } | 177 | } |
174 | if ( !exists ) { | 178 | if ( !exists ) { |
175 | pathCombo->insertItem( selectedURL, 0 ); | 179 | pathCombo->insertItem( selectedURL, 0 ); |
176 | pathCombo->setCurrentItem( 0 ); | 180 | pathCombo->setCurrentItem( 0 ); |
177 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 181 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
178 | } else | 182 | } else |
179 | pathCombo->setCurrentItem( i ); | 183 | pathCombo->setCurrentItem( i ); |
180 | selectedURL = QString::null; | 184 | selectedURL = QString::null; |
181 | } | 185 | } |
182 | } | 186 | } |
183 | 187 | ||
184 | HelpWindow::~HelpWindow() | 188 | HelpWindow::~HelpWindow() |
185 | { | 189 | { |
186 | history.clear(); | 190 | history.clear(); |
187 | QMap<int, QString>::Iterator it = mHistory.begin(); | 191 | QMap<int, QString>::Iterator it = mHistory.begin(); |
188 | for ( ; it != mHistory.end(); ++it ) | 192 | for ( ; it != mHistory.end(); ++it ) |
189 | history.append( *it ); | 193 | history.append( *it ); |
190 | 194 | ||
191 | QFile f( QDir::currentDirPath() + "/.history" ); | 195 | QFile f( QDir::currentDirPath() + "/.history" ); |
192 | f.open( IO_WriteOnly ); | 196 | f.open( IO_WriteOnly ); |
193 | QDataStream s( &f ); | 197 | QDataStream s( &f ); |
194 | s << history; | 198 | s << history; |
195 | f.close(); | 199 | f.close(); |
196 | 200 | ||
197 | bookmarks.clear(); | 201 | bookmarks.clear(); |
198 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 202 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
199 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 203 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
200 | bookmarks.append( *it2 ); | 204 | bookmarks.append( *it2 ); |
201 | 205 | ||
202 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 206 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
203 | f2.open( IO_WriteOnly ); | 207 | f2.open( IO_WriteOnly ); |
204 | QDataStream s2( &f2 ); | 208 | QDataStream s2( &f2 ); |
205 | s2 << bookmarks; | 209 | s2 << bookmarks; |
206 | f2.close(); | 210 | f2.close(); |
207 | } | 211 | } |
208 | 212 | ||
209 | // void HelpWindow::about() | 213 | // void HelpWindow::about() |
210 | // { | 214 | // { |
211 | // QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" ); | 215 | // QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" ); |
212 | // } | 216 | // } |
213 | 217 | ||
214 | // void HelpWindow::aboutQt() | 218 | // void HelpWindow::aboutQt() |
215 | // { | 219 | // { |
216 | // QMessageBox::aboutQt( this, "QBrowser" ); | 220 | // QMessageBox::aboutQt( this, "QBrowser" ); |
217 | // } | 221 | // } |
218 | 222 | ||
219 | void HelpWindow::openFile() | 223 | void HelpWindow::openFile() |
220 | { | 224 | { |
221 | #ifndef QT_NO_FILEDIALOG | 225 | #ifndef QT_NO_FILEDIALOG |
222 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); | 226 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); |
223 | if ( !fn.isEmpty() ) | 227 | if ( !fn.isEmpty() ) |
224 | browser->setSource( fn ); | 228 | browser->setSource( fn ); |
225 | #endif | 229 | #endif |
226 | } | 230 | } |
227 | 231 | ||
228 | void HelpWindow::newWindow() | 232 | void HelpWindow::newWindow() |
229 | { | 233 | { |
230 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 234 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
231 | } | 235 | } |
232 | 236 | ||
233 | void HelpWindow::print() | 237 | void HelpWindow::print() |
234 | { | 238 | { |
235 | #ifndef QT_NO_PRINTER | 239 | #ifndef QT_NO_PRINTER |
236 | QPrinter printer; | 240 | QPrinter printer; |
237 | printer.setFullPage(TRUE); | 241 | printer.setFullPage(TRUE); |
238 | if ( printer.setup() ) { | 242 | if ( printer.setup() ) { |
239 | QPainter p( &printer ); | 243 | QPainter p( &printer ); |
240 | QPaintDeviceMetrics metrics(p.device()); | 244 | QPaintDeviceMetrics metrics(p.device()); |
241 | int dpix = metrics.logicalDpiX(); | 245 | int dpix = metrics.logicalDpiX(); |
242 | int dpiy = metrics.logicalDpiY(); | 246 | int dpiy = metrics.logicalDpiY(); |
243 | const int margin = 72; // pt | 247 | const int margin = 72; // pt |
244 | QRect body(margin*dpix/72, margin*dpiy/72, | 248 | QRect body(margin*dpix/72, margin*dpiy/72, |
245 | metrics.width()-margin*dpix/72*2, | 249 | metrics.width()-margin*dpix/72*2, |
246 | metrics.height()-margin*dpiy/72*2 ); | 250 | metrics.height()-margin*dpiy/72*2 ); |
247 | QFont font("times", 10); | 251 | QFont font("times", 10); |
248 | QSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(), | 252 | QSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(), |
249 | browser->mimeSourceFactory(), body.height() ); | 253 | browser->mimeSourceFactory(), body.height() ); |
250 | richText.setWidth( &p, body.width() ); | 254 | richText.setWidth( &p, body.width() ); |
251 | QRect view( body ); | 255 | QRect view( body ); |
252 | int page = 1; | 256 | int page = 1; |
253 | do { | 257 | do { |
254 | p.setClipRect( body ); | 258 | p.setClipRect( body ); |
255 | richText.draw( &p, body.left(), body.top(), view, colorGroup() ); | 259 | richText.draw( &p, body.left(), body.top(), view, colorGroup() ); |
256 | p.setClipping( FALSE ); | 260 | p.setClipping( FALSE ); |
257 | view.moveBy( 0, body.height() ); | 261 | view.moveBy( 0, body.height() ); |
258 | p.translate( 0 , -body.height() ); | 262 | p.translate( 0 , -body.height() ); |
259 | p.setFont( font ); | 263 | p.setFont( font ); |
260 | p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ), | 264 | p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ), |
261 | view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) ); | 265 | view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) ); |
262 | if ( view.top() >= richText.height() ) | 266 | if ( view.top() >= richText.height() ) |
263 | break; | 267 | break; |
264 | printer.newPage(); | 268 | printer.newPage(); |
265 | page++; | 269 | page++; |
266 | } while (TRUE); | 270 | } while (TRUE); |
267 | } | 271 | } |
268 | #endif | 272 | #endif |
269 | } | 273 | } |
270 | 274 | ||
271 | void HelpWindow::pathSelected( const QString &_path ) | 275 | void HelpWindow::pathSelected( const QString &_path ) |
272 | { | 276 | { |
273 | browser->setSource( _path ); | 277 | browser->setSource( _path ); |
274 | QMap<int, QString>::Iterator it = mHistory.begin(); | 278 | QMap<int, QString>::Iterator it = mHistory.begin(); |
275 | bool exists = FALSE; | 279 | bool exists = FALSE; |
276 | for ( ; it != mHistory.end(); ++it ) { | 280 | for ( ; it != mHistory.end(); ++it ) { |
277 | if ( *it == _path ) { | 281 | if ( *it == _path ) { |
278 | exists = TRUE; | 282 | exists = TRUE; |
279 | break; | 283 | break; |
280 | } | 284 | } |
281 | } | 285 | } |
282 | if ( !exists ) | 286 | if ( !exists ) |
283 | mHistory[ hist->insertItem( _path ) ] = _path; | 287 | mHistory[ hist->insertItem( _path ) ] = _path; |
284 | } | 288 | } |
285 | 289 | ||
286 | void HelpWindow::readHistory() | 290 | void HelpWindow::readHistory() |
287 | { | 291 | { |
288 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 292 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { |
289 | QFile f( QDir::currentDirPath() + "/.history" ); | 293 | QFile f( QDir::currentDirPath() + "/.history" ); |
290 | f.open( IO_ReadOnly ); | 294 | f.open( IO_ReadOnly ); |
291 | QDataStream s( &f ); | 295 | QDataStream s( &f ); |
292 | s >> history; | 296 | s >> history; |
293 | f.close(); | 297 | f.close(); |
294 | while ( history.count() > 20 ) | 298 | while ( history.count() > 20 ) |
295 | history.remove( history.begin() ); | 299 | history.remove( history.begin() ); |
296 | } | 300 | } |
297 | } | 301 | } |
298 | 302 | ||
299 | void HelpWindow::readBookmarks() | 303 | void HelpWindow::readBookmarks() |
300 | { | 304 | { |
301 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 305 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { |
302 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 306 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
303 | f.open( IO_ReadOnly ); | 307 | f.open( IO_ReadOnly ); |
304 | QDataStream s( &f ); | 308 | QDataStream s( &f ); |
305 | s >> bookmarks; | 309 | s >> bookmarks; |
306 | f.close(); | 310 | f.close(); |
307 | } | 311 | } |
308 | } | 312 | } |
309 | 313 | ||
310 | void HelpWindow::histChosen( int i ) | 314 | void HelpWindow::histChosen( int i ) |
311 | { | 315 | { |
312 | if ( mHistory.contains( i ) ) | 316 | if ( mHistory.contains( i ) ) |
313 | browser->setSource( mHistory[ i ] ); | 317 | browser->setSource( mHistory[ i ] ); |
314 | } | 318 | } |
315 | 319 | ||
316 | void HelpWindow::bookmChosen( int i ) | 320 | void HelpWindow::bookmChosen( int i ) |
317 | { | 321 | { |
318 | if ( mBookmarks.contains( i ) ) | 322 | if ( mBookmarks.contains( i ) ) |
319 | browser->setSource( mBookmarks[ i ] ); | 323 | browser->setSource( mBookmarks[ i ] ); |
320 | } | 324 | } |
321 | 325 | ||
322 | void HelpWindow::addBookmark() | 326 | void HelpWindow::addBookmark() |
323 | { | 327 | { |
324 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 328 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
325 | } | 329 | } |
326 | 330 | ||
diff --git a/noncore/apps/opie-gutenbrowser/openetext.h b/noncore/apps/opie-gutenbrowser/openetext.h index 6db71c4..ecc0bbd 100644 --- a/noncore/apps/opie-gutenbrowser/openetext.h +++ b/noncore/apps/opie-gutenbrowser/openetext.h | |||
@@ -1,82 +1,79 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | openetext.h - description | 2 | openetext.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Tue Jul 25 2000 | 4 | begin : Tue Jul 25 2000 |
5 | copyright : (C) 2000 -2004 by llornkcor | 5 | copyright : (C) 2000 -2004 by llornkcor |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #ifndef OPENETEXT_H | 17 | #ifndef OPENETEXT_H |
18 | #define OPENETEXT_H | 18 | #define OPENETEXT_H |
19 | #include "gutenbrowser.h" | 19 | #include "gutenbrowser.h" |
20 | #include <qdialog.h> | 20 | #include <qdialog.h> |
21 | #include <qstringlist.h> | 21 | #include <qstringlist.h> |
22 | #ifndef Q_WS_QWS | ||
23 | #include <qfiledialog.h> | ||
24 | #endif | ||
25 | //#include <fileselector.h> | 22 | //#include <fileselector.h> |
26 | #include <qlabel.h> | 23 | #include <qlabel.h> |
27 | #include <qlistbox.h> | 24 | #include <qlistbox.h> |
28 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
29 | #include <qstrlist.h> | 26 | #include <qstrlist.h> |
30 | #include <qwidget.h> | 27 | #include <qwidget.h> |
31 | //#include "CConfigFile.h" | 28 | //#include "CConfigFile.h" |
32 | 29 | ||
33 | /** | 30 | /** |
34 | *@author llornkcor | 31 | *@author llornkcor |
35 | */ | 32 | */ |
36 | 33 | ||
37 | class OpenEtext : public QDialog { | 34 | class OpenEtext : public QDialog { |
38 | Q_OBJECT | 35 | Q_OBJECT |
39 | public: | 36 | public: |
40 | OpenEtext(QWidget *parent, QString name); | 37 | OpenEtext(QWidget *parent, QString name); |
41 | ~OpenEtext(); | 38 | ~OpenEtext(); |
42 | 39 | ||
43 | QPushButton* RemoveButton, * OpenFileButton, * OpenButton, *scanButton, *editButton; | 40 | QPushButton* RemoveButton, * OpenFileButton, * OpenButton, *scanButton, *editButton; |
44 | void getTitles(); | 41 | void getTitles(); |
45 | QString title; | 42 | QString title; |
46 | QString file; | 43 | QString file; |
47 | QString selFile; | 44 | QString selFile; |
48 | QString s_numofFiles; | 45 | QString s_numofFiles; |
49 | QString fileName; | 46 | QString fileName; |
50 | QString name; | 47 | QString name; |
51 | QString openFileTitle; | 48 | QString openFileTitle; |
52 | QStringList fileList; | 49 | QStringList fileList; |
53 | QString local_library; | 50 | QString local_library; |
54 | QString local_index; | 51 | QString local_index; |
55 | QString title_text; | 52 | QString title_text; |
56 | void remFile(); | 53 | void remFile(); |
57 | void removeSelection(); | 54 | void removeSelection(); |
58 | QString titleFromLibrary( const QString fileName); | 55 | QString titleFromLibrary( const QString fileName); |
59 | bool FindTitle( const QString filename); | 56 | bool FindTitle( const QString filename); |
60 | bool checkConf(); | 57 | bool checkConf(); |
61 | // CConfigFile *config; | 58 | // CConfigFile *config; |
62 | 59 | ||
63 | protected: | 60 | protected: |
64 | 61 | ||
65 | void initDialog(); | 62 | void initDialog(); |
66 | QListBox *QListBox_1; | 63 | QListBox *QListBox_1; |
67 | QPushButton *QPushButton_OK; | 64 | QPushButton *QPushButton_OK; |
68 | QPushButton *QPushButton_Cancel; | 65 | QPushButton *QPushButton_Cancel; |
69 | QLabel *QLabel_1; | 66 | QLabel *QLabel_1; |
70 | 67 | ||
71 | private: | 68 | private: |
72 | private slots: | 69 | private slots: |
73 | 70 | ||
74 | virtual void select_title(int index ); | 71 | virtual void select_title(int index ); |
75 | virtual void remove(); | 72 | virtual void remove(); |
76 | virtual void scan(); | 73 | virtual void scan(); |
77 | virtual void open(); | 74 | virtual void open(); |
78 | virtual void OpenTitle(); | 75 | virtual void OpenTitle(); |
79 | virtual void editTitle(); | 76 | virtual void editTitle(); |
80 | }; | 77 | }; |
81 | 78 | ||
82 | #endif | 79 | #endif |