author | mickeyl <mickeyl> | 2004-04-05 13:30:36 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-05 13:30:36 (UTC) |
commit | 743adf3ed3032feb15e71002613a4643d059aa09 (patch) (unidiff) | |
tree | da8c0549515f694775a1cd169cdc5abe615a3847 /core/apps/helpbrowser/helpbrowser.cpp | |
parent | b136b4d55c810c35c54b18b435aa4172b7f6b9fe (diff) | |
download | opie-743adf3ed3032feb15e71002613a4643d059aa09.zip opie-743adf3ed3032feb15e71002613a4643d059aa09.tar.gz opie-743adf3ed3032feb15e71002613a4643d059aa09.tar.bz2 |
convert helpbrowser, taboapp and textedit to Opie debugging framework
qcop and embeddedkonsole needs more work. the diagnostics part uses printf
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 | |||
@@ -21,20 +21,21 @@ | |||
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
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> |
30 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
31 | #include <qfileinfo.h> | 36 | #include <qfileinfo.h> |
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 ), |
40 | selectedURL() | 41 | selectedURL() |
@@ -52,13 +53,13 @@ void HelpBrowser::init( const QString& _home ) | |||
52 | browser = new MagicTextBrowser( this ); | 53 | browser = new MagicTextBrowser( this ); |
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 ); |
58 | setToolBarsMovable( FALSE ); | 59 | setToolBarsMovable( FALSE ); |
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 ); |
64 | toolbar->setHorizontalStretchable( TRUE ); | 65 | toolbar->setHorizontalStretchable( TRUE ); |
@@ -71,7 +72,7 @@ void HelpBrowser::init( const QString& _home ) | |||
71 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); | 72 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); |
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 ); |
77 | backAction->setEnabled( FALSE ); | 78 | backAction->setEnabled( FALSE ); |
@@ -79,7 +80,7 @@ void HelpBrowser::init( const QString& _home ) | |||
79 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); | 80 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); |
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 ); |
85 | forwardAction->setEnabled( FALSE ); | 86 | forwardAction->setEnabled( FALSE ); |
@@ -94,7 +95,7 @@ void HelpBrowser::init( const QString& _home ) | |||
94 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); | 95 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); |
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(); |
100 | 101 | ||
@@ -112,30 +113,30 @@ void HelpBrowser::init( const QString& _home ) | |||
112 | #endif | 113 | #endif |
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 | } |
134 | 135 | ||
135 | void HelpBrowser::setDocument( const QString &doc ) | 136 | 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 | } |
141 | 142 | ||
@@ -143,9 +144,9 @@ void HelpBrowser::setDocument( const QString &doc ) | |||
143 | void HelpBrowser::textChanged() | 144 | 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(); |
151 | } | 152 | } |
@@ -155,13 +156,13 @@ HelpBrowser::~HelpBrowser() | |||
155 | QStringList bookmarks; | 156 | QStringList bookmarks; |
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 | } |
167 | 168 | ||
@@ -174,31 +175,31 @@ void HelpBrowser::readBookmarks() | |||
174 | { | 175 | { |
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 | } |
197 | 198 | ||
198 | void HelpBrowser::bookmChosen( int i ) | 199 | 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 | ||
204 | void HelpBrowser::addBookmark() | 205 | void HelpBrowser::addBookmark() |
@@ -207,11 +208,11 @@ void HelpBrowser::addBookmark() | |||
207 | b.name = browser->documentTitle(); | 208 | b.name = browser->documentTitle(); |
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 | } |
217 | 218 | ||
@@ -220,9 +221,9 @@ void HelpBrowser::removeBookmark() | |||
220 | QString file = browser->source(); | 221 | QString file = browser->source(); |
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 | } |