Diffstat (limited to 'core/apps/helpbrowser/helpbrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.cpp | 103 |
1 files changed, 52 insertions, 51 deletions
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp index 336d9fb..cbb4059 100644 --- a/core/apps/helpbrowser/helpbrowser.cpp +++ b/core/apps/helpbrowser/helpbrowser.cpp | |||
@@ -22,8 +22,13 @@ | |||
22 | 22 | ||
23 | #include "helpbrowser.h" | 23 | #include "helpbrowser.h" |
24 | #include "magictextbrowser.h" | ||
24 | 25 | ||
26 | /* OPIE */ | ||
27 | #include <opie2/odebug.h> | ||
25 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | using namespace Opie::Core; | ||
27 | 31 | ||
32 | /* QT */ | ||
28 | #include <qmenubar.h> | 33 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 34 | #include <qtoolbar.h> |
@@ -32,8 +37,4 @@ | |||
32 | #include <qaction.h> | 37 | #include <qaction.h> |
33 | 38 | ||
34 | #include <cctype> | ||
35 | |||
36 | #include "magictextbrowser.h" | ||
37 | |||
38 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) | 39 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) |
39 | : QMainWindow( parent, name, f ), | 40 | : QMainWindow( parent, name, f ), |
@@ -53,5 +54,5 @@ void HelpBrowser::init( const QString& _home ) | |||
53 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 54 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
54 | connect( browser, SIGNAL( textChanged() ), | 55 | connect( browser, SIGNAL( textChanged() ), |
55 | this, SLOT( textChanged() ) ); | 56 | this, SLOT( textChanged() ) ); |
56 | 57 | ||
57 | setCentralWidget( browser ); | 58 | setCentralWidget( browser ); |
@@ -59,5 +60,5 @@ void HelpBrowser::init( const QString& _home ) | |||
59 | 60 | ||
60 | if ( !_home.isEmpty() ) | 61 | if ( !_home.isEmpty() ) |
61 | browser->setSource( _home ); | 62 | browser->setSource( _home ); |
62 | 63 | ||
63 | QToolBar* toolbar = new QToolBar( this ); | 64 | QToolBar* toolbar = new QToolBar( this ); |
@@ -72,5 +73,5 @@ void HelpBrowser::init( const QString& _home ) | |||
72 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); | 73 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); |
73 | connect( browser, SIGNAL( backwardAvailable(bool) ), | 74 | connect( browser, SIGNAL( backwardAvailable(bool) ), |
74 | backAction, SLOT( setEnabled(bool) ) ); | 75 | backAction, SLOT( setEnabled(bool) ) ); |
75 | backAction->addTo( go ); | 76 | backAction->addTo( go ); |
76 | backAction->addTo( toolbar ); | 77 | backAction->addTo( toolbar ); |
@@ -80,5 +81,5 @@ void HelpBrowser::init( const QString& _home ) | |||
80 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); | 81 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); |
81 | connect( browser, SIGNAL( forwardAvailable(bool) ), | 82 | connect( browser, SIGNAL( forwardAvailable(bool) ), |
82 | forwardAction, SLOT( setEnabled(bool) ) ); | 83 | forwardAction, SLOT( setEnabled(bool) ) ); |
83 | forwardAction->addTo( go ); | 84 | forwardAction->addTo( go ); |
84 | forwardAction->addTo( toolbar ); | 85 | forwardAction->addTo( toolbar ); |
@@ -95,5 +96,5 @@ void HelpBrowser::init( const QString& _home ) | |||
95 | bookm->insertSeparator(); | 96 | bookm->insertSeparator(); |
96 | connect( bookm, SIGNAL( activated(int) ), | 97 | connect( bookm, SIGNAL( activated(int) ), |
97 | this, SLOT( bookmChosen(int) ) ); | 98 | this, SLOT( bookmChosen(int) ) ); |
98 | 99 | ||
99 | readBookmarks(); | 100 | readBookmarks(); |
@@ -113,21 +114,21 @@ void HelpBrowser::init( const QString& _home ) | |||
113 | 114 | ||
114 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 115 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
115 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | 116 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
116 | } | 117 | } |
117 | 118 | ||
118 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | 119 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) |
119 | { | 120 | { |
120 | qDebug("reached appMessage"); | 121 | odebug << "reached appMessage" << oendl; |
121 | if ( msg == "showFile(QString)" ) { | 122 | if ( msg == "showFile(QString)" ) { |
122 | QDataStream ds(data,IO_ReadOnly); | 123 | QDataStream ds(data,IO_ReadOnly); |
123 | QString fn; | 124 | QString fn; |
124 | ds >> fn; | 125 | ds >> fn; |
125 | setDocument( fn ); | 126 | setDocument( fn ); |
126 | 127 | ||
127 | QPEApplication::setKeepRunning(); | 128 | QPEApplication::setKeepRunning(); |
128 | 129 | ||
129 | showMaximized(); | 130 | showMaximized(); |
130 | setActiveWindow(); | 131 | setActiveWindow(); |
131 | raise(); | 132 | raise(); |
132 | } | 133 | } |
133 | } | 134 | } |
@@ -136,5 +137,5 @@ void HelpBrowser::setDocument( const QString &doc ) | |||
136 | { | 137 | { |
137 | if ( !doc.isEmpty() ) | 138 | if ( !doc.isEmpty() ) |
138 | browser->setSource( doc ); | 139 | browser->setSource( doc ); |
139 | raise(); | 140 | raise(); |
140 | } | 141 | } |
@@ -144,7 +145,7 @@ void HelpBrowser::textChanged() | |||
144 | { | 145 | { |
145 | if ( browser->documentTitle().isNull() ) | 146 | if ( browser->documentTitle().isNull() ) |
146 | setCaption( tr("Help Browser") ); | 147 | setCaption( tr("Help Browser") ); |
147 | else | 148 | else |
148 | setCaption( browser->documentTitle() ) ; | 149 | setCaption( browser->documentTitle() ) ; |
149 | 150 | ||
150 | selectedURL = caption(); | 151 | selectedURL = caption(); |
@@ -156,11 +157,11 @@ HelpBrowser::~HelpBrowser() | |||
156 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); | 157 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); |
157 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 158 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
158 | bookmarks.append( (*it2).name + "=" + (*it2).file ); | 159 | bookmarks.append( (*it2).name + "=" + (*it2).file ); |
159 | 160 | ||
160 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); | 161 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); |
161 | if ( f2.open( IO_WriteOnly ) ) { | 162 | if ( f2.open( IO_WriteOnly ) ) { |
162 | QDataStream s2( &f2 ); | 163 | QDataStream s2( &f2 ); |
163 | s2 << bookmarks; | 164 | s2 << bookmarks; |
164 | f2.close(); | 165 | f2.close(); |
165 | } | 166 | } |
166 | } | 167 | } |
@@ -175,22 +176,22 @@ void HelpBrowser::readBookmarks() | |||
175 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); | 176 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); |
176 | if ( QFile::exists( file ) ) { | 177 | if ( QFile::exists( file ) ) { |
177 | QStringList bookmarks; | 178 | QStringList bookmarks; |
178 | QFile f( file ); | 179 | QFile f( file ); |
179 | if ( f.open( IO_ReadOnly ) ) { | 180 | if ( f.open( IO_ReadOnly ) ) { |
180 | QDataStream s( &f ); | 181 | QDataStream s( &f ); |
181 | s >> bookmarks; | 182 | s >> bookmarks; |
182 | f.close(); | 183 | f.close(); |
183 | } | 184 | } |
184 | QStringList::Iterator it = bookmarks.begin(); | 185 | QStringList::Iterator it = bookmarks.begin(); |
185 | for ( ; it != bookmarks.end(); ++it ) { | 186 | for ( ; it != bookmarks.end(); ++it ) { |
186 | Bookmark b; | 187 | Bookmark b; |
187 | QString current = *it; | 188 | QString current = *it; |
188 | int equal = current.find( "=" ); | 189 | int equal = current.find( "=" ); |
189 | if ( equal < 1 || equal == (int)current.length() - 1 ) | 190 | if ( equal < 1 || equal == (int)current.length() - 1 ) |
190 | continue; | 191 | continue; |
191 | b.name = current.left( equal ); | 192 | b.name = current.left( equal ); |
192 | b.file = current.mid( equal + 1 ); | 193 | b.file = current.mid( equal + 1 ); |
193 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 194 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
194 | } | 195 | } |
195 | } | 196 | } |
196 | } | 197 | } |
@@ -199,5 +200,5 @@ void HelpBrowser::bookmChosen( int i ) | |||
199 | { | 200 | { |
200 | if ( mBookmarks.contains( i ) ) | 201 | if ( mBookmarks.contains( i ) ) |
201 | browser->setSource( mBookmarks[ i ].file ); | 202 | browser->setSource( mBookmarks[ i ].file ); |
202 | } | 203 | } |
203 | 204 | ||
@@ -208,9 +209,9 @@ void HelpBrowser::addBookmark() | |||
208 | b.file = browser->source(); | 209 | b.file = browser->source(); |
209 | if (b.name.isEmpty() ) { | 210 | if (b.name.isEmpty() ) { |
210 | b.name = b.file.left( b.file.length() - 5 ); // remove .html | 211 | b.name = b.file.left( b.file.length() - 5 ); // remove .html |
211 | } | 212 | } |
212 | QMap<int, Bookmark>::Iterator it; | 213 | QMap<int, Bookmark>::Iterator it; |
213 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) | 214 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) |
214 | if ( (*it).file == b.file ) return; | 215 | if ( (*it).file == b.file ) return; |
215 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 216 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
216 | } | 217 | } |
@@ -221,8 +222,8 @@ void HelpBrowser::removeBookmark() | |||
221 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); | 222 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); |
222 | for( ; it != mBookmarks.end(); ++it ) | 223 | for( ; it != mBookmarks.end(); ++it ) |
223 | if ( (*it).file == file ) { | 224 | if ( (*it).file == file ) { |
224 | bookm->removeItem( it.key() ); | 225 | bookm->removeItem( it.key() ); |
225 | mBookmarks.remove( it ); | 226 | mBookmarks.remove( it ); |
226 | break; | 227 | break; |
227 | } | 228 | } |
228 | } | 229 | } |