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 @@ #include "helpbrowser.h" +#include "magictextbrowser.h" +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> +using namespace Opie::Core; +/* QT */ #include <qmenubar.h> #include <qtoolbar.h> @@ -32,8 +37,4 @@ #include <qaction.h> -#include <cctype> - -#include "magictextbrowser.h" - HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ), @@ -53,5 +54,5 @@ void HelpBrowser::init( const QString& _home ) browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); connect( browser, SIGNAL( textChanged() ), - this, SLOT( textChanged() ) ); + this, SLOT( textChanged() ) ); setCentralWidget( browser ); @@ -59,5 +60,5 @@ void HelpBrowser::init( const QString& _home ) if ( !_home.isEmpty() ) - browser->setSource( _home ); + browser->setSource( _home ); QToolBar* toolbar = new QToolBar( this ); @@ -72,5 +73,5 @@ void HelpBrowser::init( const QString& _home ) connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); connect( browser, SIGNAL( backwardAvailable(bool) ), - backAction, SLOT( setEnabled(bool) ) ); + backAction, SLOT( setEnabled(bool) ) ); backAction->addTo( go ); backAction->addTo( toolbar ); @@ -80,5 +81,5 @@ void HelpBrowser::init( const QString& _home ) connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); connect( browser, SIGNAL( forwardAvailable(bool) ), - forwardAction, SLOT( setEnabled(bool) ) ); + forwardAction, SLOT( setEnabled(bool) ) ); forwardAction->addTo( go ); forwardAction->addTo( toolbar ); @@ -95,5 +96,5 @@ void HelpBrowser::init( const QString& _home ) bookm->insertSeparator(); connect( bookm, SIGNAL( activated(int) ), - this, SLOT( bookmChosen(int) ) ); + this, SLOT( bookmChosen(int) ) ); readBookmarks(); @@ -113,21 +114,21 @@ void HelpBrowser::init( const QString& _home ) connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), - this, SLOT(appMessage(const QCString&,const QByteArray&)) ); + this, SLOT(appMessage(const QCString&,const QByteArray&)) ); } void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) { - qDebug("reached appMessage"); + odebug << "reached appMessage" << oendl; if ( msg == "showFile(QString)" ) { - QDataStream ds(data,IO_ReadOnly); - QString fn; - ds >> fn; - setDocument( fn ); + QDataStream ds(data,IO_ReadOnly); + QString fn; + ds >> fn; + setDocument( fn ); QPEApplication::setKeepRunning(); - showMaximized(); - setActiveWindow(); - raise(); + showMaximized(); + setActiveWindow(); + raise(); } } @@ -136,5 +137,5 @@ void HelpBrowser::setDocument( const QString &doc ) { if ( !doc.isEmpty() ) - browser->setSource( doc ); + browser->setSource( doc ); raise(); } @@ -144,7 +145,7 @@ void HelpBrowser::textChanged() { if ( browser->documentTitle().isNull() ) - setCaption( tr("Help Browser") ); + setCaption( tr("Help Browser") ); else - setCaption( browser->documentTitle() ) ; + setCaption( browser->documentTitle() ) ; selectedURL = caption(); @@ -156,11 +157,11 @@ HelpBrowser::~HelpBrowser() QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); for ( ; it2 != mBookmarks.end(); ++it2 ) - bookmarks.append( (*it2).name + "=" + (*it2).file ); + bookmarks.append( (*it2).name + "=" + (*it2).file ); QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); if ( f2.open( IO_WriteOnly ) ) { - QDataStream s2( &f2 ); - s2 << bookmarks; - f2.close(); + QDataStream s2( &f2 ); + s2 << bookmarks; + f2.close(); } } @@ -175,22 +176,22 @@ void HelpBrowser::readBookmarks() QString file = Global::applicationFileName("helpbrowser", "bookmarks"); if ( QFile::exists( file ) ) { - QStringList bookmarks; - QFile f( file ); - if ( f.open( IO_ReadOnly ) ) { - QDataStream s( &f ); - s >> bookmarks; - f.close(); - } - QStringList::Iterator it = bookmarks.begin(); - for ( ; it != bookmarks.end(); ++it ) { - Bookmark b; - QString current = *it; - int equal = current.find( "=" ); - if ( equal < 1 || equal == (int)current.length() - 1 ) - continue; - b.name = current.left( equal ); - b.file = current.mid( equal + 1 ); - mBookmarks[ bookm->insertItem( b.name ) ] = b; - } + QStringList bookmarks; + QFile f( file ); + if ( f.open( IO_ReadOnly ) ) { + QDataStream s( &f ); + s >> bookmarks; + f.close(); + } + QStringList::Iterator it = bookmarks.begin(); + for ( ; it != bookmarks.end(); ++it ) { + Bookmark b; + QString current = *it; + int equal = current.find( "=" ); + if ( equal < 1 || equal == (int)current.length() - 1 ) + continue; + b.name = current.left( equal ); + b.file = current.mid( equal + 1 ); + mBookmarks[ bookm->insertItem( b.name ) ] = b; + } } } @@ -199,5 +200,5 @@ void HelpBrowser::bookmChosen( int i ) { if ( mBookmarks.contains( i ) ) - browser->setSource( mBookmarks[ i ].file ); + browser->setSource( mBookmarks[ i ].file ); } @@ -208,9 +209,9 @@ void HelpBrowser::addBookmark() b.file = browser->source(); if (b.name.isEmpty() ) { - b.name = b.file.left( b.file.length() - 5 ); // remove .html + b.name = b.file.left( b.file.length() - 5 ); // remove .html } QMap<int, Bookmark>::Iterator it; for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) - if ( (*it).file == b.file ) return; + if ( (*it).file == b.file ) return; mBookmarks[ bookm->insertItem( b.name ) ] = b; } @@ -221,8 +222,8 @@ void HelpBrowser::removeBookmark() QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); for( ; it != mBookmarks.end(); ++it ) - if ( (*it).file == file ) { - bookm->removeItem( it.key() ); - mBookmarks.remove( it ); - break; - } + if ( (*it).file == file ) { + bookm->removeItem( it.key() ); + mBookmarks.remove( it ); + break; + } } |