summaryrefslogtreecommitdiff
path: root/core/apps/helpbrowser
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (side-by-side diff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /core/apps/helpbrowser
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'core/apps/helpbrowser') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/helpbrowser/.cvsignore2
-rw-r--r--core/apps/helpbrowser/Makefile.in119
-rw-r--r--core/apps/helpbrowser/helpbrowser.cpp227
-rw-r--r--core/apps/helpbrowser/helpbrowser.h69
-rw-r--r--core/apps/helpbrowser/helpbrowser.pro12
-rw-r--r--core/apps/helpbrowser/main.cpp34
-rw-r--r--core/apps/helpbrowser/qpe-helpbrowser.control10
7 files changed, 473 insertions, 0 deletions
diff --git a/core/apps/helpbrowser/.cvsignore b/core/apps/helpbrowser/.cvsignore
new file mode 100644
index 0000000..6fe2396
--- a/dev/null
+++ b/core/apps/helpbrowser/.cvsignore
@@ -0,0 +1,2 @@
+moc_*
+Makefile
diff --git a/core/apps/helpbrowser/Makefile.in b/core/apps/helpbrowser/Makefile.in
new file mode 100644
index 0000000..8f0ce0e
--- a/dev/null
+++ b/core/apps/helpbrowser/Makefile.in
@@ -0,0 +1,119 @@
+#############################################################################
+
+####### Compiler, tools and options
+
+CXX = $(SYSCONF_CXX) $(QT_CXX_MT)
+CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
+CC = $(SYSCONF_CC) $(QT_C_MT)
+CFLAGS = $(SYSCONF_CFLAGS)
+INCPATH = -I$(QPEDIR)/include
+LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
+LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
+MOC = $(SYSCONF_MOC)
+UIC = $(SYSCONF_UIC)
+
+####### Target
+
+DESTDIR = $(QPEDIR)/bin/
+VER_MAJ = 1
+VER_MIN = 0
+VER_PATCH = 0
+TARGET = helpbrowser
+TARGET1 = lib$(TARGET).so.$(VER_MAJ)
+
+####### Files
+
+HEADERS = helpbrowser.h
+SOURCES = helpbrowser.cpp \
+ main.cpp
+OBJECTS = helpbrowser.o \
+ main.o
+INTERFACES =
+UICDECLS =
+UICIMPLS =
+SRCMOC = moc_helpbrowser.cpp
+OBJMOC = moc_helpbrowser.o
+
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cxx .cc .C .c
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+
+all: $(DESTDIR)$(TARGET)
+
+$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
+ $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
+
+moc: $(SRCMOC)
+
+tmake:
+ tmake helpbrowser.pro
+
+clean:
+ -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
+ -rm -f *~ core
+ -rm -f allmoc.cpp
+
+####### Extension Modules
+
+listpromodules:
+ @echo
+
+listallmodules:
+ @echo
+
+listaddonpromodules:
+ @echo
+
+listaddonentmodules:
+ @echo
+
+
+REQUIRES=
+
+####### Sub-libraries
+
+
+###### Combined headers
+
+
+
+####### Compile
+
+helpbrowser.o: helpbrowser.cpp \
+ helpbrowser.h \
+ $(QPEDIR)/include/qpe/qpeapplication.h \
+ $(QPEDIR)/include/qpe/resource.h \
+ $(QPEDIR)/include/qpe/global.h \
+ $(QPEDIR)/include/qpe/qpemenubar.h \
+ $(QPEDIR)/include/qpe/qpetoolbar.h
+
+main.o: main.cpp \
+ helpbrowser.h \
+ $(QPEDIR)/include/qpe/qpeapplication.h
+
+moc_helpbrowser.o: moc_helpbrowser.cpp \
+ helpbrowser.h
+
+moc_helpbrowser.cpp: helpbrowser.h
+ $(MOC) helpbrowser.h -o moc_helpbrowser.cpp
+
+
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp
new file mode 100644
index 0000000..d32fc0b
--- a/dev/null
+++ b/core/apps/helpbrowser/helpbrowser.cpp
@@ -0,0 +1,227 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "helpbrowser.h"
+
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+#include <qpe/global.h>
+
+#include <qstatusbar.h>
+#include <qdragobject.h>
+#include <qpixmap.h>
+#include <qpopupmenu.h>
+#include <qpe/qpemenubar.h>
+#include <qpe/qpetoolbar.h>
+#include <qtoolbutton.h>
+#include <qiconset.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qstylesheet.h>
+#include <qmessagebox.h>
+#include <qfiledialog.h>
+#include <qevent.h>
+#include <qlineedit.h>
+#include <qobjectlist.h>
+#include <qfileinfo.h>
+#include <qfile.h>
+#include <qdatastream.h>
+#include <qprinter.h>
+#include <qsimplerichtext.h>
+#include <qpaintdevicemetrics.h>
+#include <qaction.h>
+
+#include <ctype.h>
+
+
+HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f )
+ : QMainWindow( parent, name, f ),
+ selectedURL()
+{
+ init( "index.html" );
+}
+
+void HelpBrowser::init( const QString& _home )
+{
+ setIcon( Resource::loadPixmap( "help_icon" ) );
+
+ browser = new QTextBrowser( this );
+ browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ connect( browser, SIGNAL( textChanged() ),
+ this, SLOT( textChanged() ) );
+
+ setCentralWidget( browser );
+ setToolBarsMovable( FALSE );
+
+ if ( !_home.isEmpty() )
+ browser->setSource( _home );
+
+ QPEToolBar* toolbar = new QPEToolBar( this );
+ toolbar->setHorizontalStretchable( TRUE );
+ QPEMenuBar *menu = new QPEMenuBar( toolbar );
+
+ toolbar = new QPEToolBar( this );
+ // addToolBar( toolbar, "Toolbar");
+
+ //QPopupMenu* go = new QPopupMenu( this );
+ backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 );
+ connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) );
+ connect( browser, SIGNAL( backwardAvailable( bool ) ),
+ backAction, SLOT( setEnabled( bool ) ) );
+ //backAction->addTo( go );
+ backAction->addTo( toolbar );
+ backAction->setEnabled( FALSE );
+
+ forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 );
+ connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) );
+ connect( browser, SIGNAL( forwardAvailable( bool ) ),
+ forwardAction, SLOT( setEnabled( bool ) ) );
+ //forwardAction->addTo( go );
+ forwardAction->addTo( toolbar );
+ forwardAction->setEnabled( FALSE );
+
+ QAction *a = new QAction( tr( "Home" ), Resource::loadPixmap( "home" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), browser, SLOT( home() ) );
+ //a->addTo( go );
+ a->addTo( toolbar );
+
+ bookm = new QPopupMenu( this );
+ bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
+ bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) );
+ bookm->insertSeparator();
+ connect( bookm, SIGNAL( activated( int ) ),
+ this, SLOT( bookmChosen( int ) ) );
+
+ readBookmarks();
+
+ //menu->insertItem( tr("Go"), go );
+ menu->insertItem( tr( "Bookmarks" ), bookm );
+
+ resize( 240, 300 );
+ browser->setFocus();
+
+ connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
+ this, SLOT(appMessage(const QCString&, const QByteArray&)) );
+}
+
+void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data)
+{
+ if ( msg == "showFile(QString)" ) {
+ QDataStream ds(data,IO_ReadOnly);
+ QString fn;
+ ds >> fn;
+ setDocument( fn );
+ }
+}
+
+void HelpBrowser::setDocument( const QString &doc )
+{
+ if ( !doc.isEmpty() )
+ browser->setSource( doc );
+ raise();
+}
+
+
+void HelpBrowser::textChanged()
+{
+ if ( browser->documentTitle().isNull() )
+ setCaption( tr("Help Browser") );
+ else
+ setCaption( browser->documentTitle() ) ;
+
+ selectedURL = caption();
+}
+
+HelpBrowser::~HelpBrowser()
+{
+ QStringList bookmarks;
+ QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin();
+ for ( ; it2 != mBookmarks.end(); ++it2 )
+ bookmarks.append( (*it2).name + "=" + (*it2).file );
+
+ QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") );
+ if ( f2.open( IO_WriteOnly ) ) {
+ QDataStream s2( &f2 );
+ s2 << bookmarks;
+ f2.close();
+ }
+}
+
+void HelpBrowser::pathSelected( const QString &_path )
+{
+ browser->setSource( _path );
+}
+
+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;
+ }
+ }
+}
+
+void HelpBrowser::bookmChosen( int i )
+{
+ if ( mBookmarks.contains( i ) )
+ browser->setSource( mBookmarks[ i ].file );
+}
+
+void HelpBrowser::addBookmark()
+{
+ Bookmark b;
+ b.name = browser->documentTitle();
+ b.file = browser->source();
+ if (b.name.isEmpty() ) {
+ 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;
+ mBookmarks[ bookm->insertItem( b.name ) ] = b;
+}
+
+void HelpBrowser::removeBookmark()
+{
+ QString file = browser->source();
+ QMap<int, Bookmark>::Iterator it = mBookmarks.begin();
+ for( ; it != mBookmarks.end(); ++it )
+ if ( (*it).file == file ) {
+ bookm->removeItem( it.key() );
+ mBookmarks.remove( it );
+ break;
+ }
+}
diff --git a/core/apps/helpbrowser/helpbrowser.h b/core/apps/helpbrowser/helpbrowser.h
new file mode 100644
index 0000000..2f7153a
--- a/dev/null
+++ b/core/apps/helpbrowser/helpbrowser.h
@@ -0,0 +1,69 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef HELPWINDOW_H
+#define HELPWINDOW_H
+
+#include <qmainwindow.h>
+#include <qtextbrowser.h>
+#include <qstringlist.h>
+#include <qmap.h>
+
+class QPopupMenu;
+class QAction;
+
+class HelpBrowser : public QMainWindow
+{
+ Q_OBJECT
+public:
+ HelpBrowser( QWidget* parent = 0, const char *name=0, WFlags f=0 );
+ ~HelpBrowser();
+
+public slots:
+ void setDocument( const QString &doc );
+
+private slots:
+ void appMessage(const QCString& msg, const QByteArray& data);
+ void textChanged();
+
+ void pathSelected( const QString & );
+ void bookmChosen( int );
+ void addBookmark();
+ void removeBookmark();
+
+private:
+ void init( const QString & );
+ void readBookmarks();
+
+ QTextBrowser* browser;
+ QAction *backAction;
+ QAction *forwardAction;
+ QString selectedURL;
+ struct Bookmark {
+ QString name;
+ QString file;
+ };
+ QMap<int, Bookmark> mBookmarks;
+ QMenuBar *menu;
+ QPopupMenu *bookm;
+};
+
+#endif
+
diff --git a/core/apps/helpbrowser/helpbrowser.pro b/core/apps/helpbrowser/helpbrowser.pro
new file mode 100644
index 0000000..43230f1
--- a/dev/null
+++ b/core/apps/helpbrowser/helpbrowser.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+CONFIG = qt warn_on release
+DESTDIR = $(QPEDIR)/bin
+HEADERS = helpbrowser.h
+SOURCES = helpbrowser.cpp \
+ main.cpp
+INCLUDEPATH += $(QPEDIR)/include
+DEPENDPATH += $(QPEDIR)/include
+LIBS += -lqpe
+INTERFACES =
+
+TRANSLATIONS = ../i18n/de/helpbrowser.ts
diff --git a/core/apps/helpbrowser/main.cpp b/core/apps/helpbrowser/main.cpp
new file mode 100644
index 0000000..1cb10b7
--- a/dev/null
+++ b/core/apps/helpbrowser/main.cpp
@@ -0,0 +1,34 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "helpbrowser.h"
+
+#include <qpe/qpeapplication.h>
+
+int main( int argc, char ** argv )
+{
+ QPEApplication a( argc, argv );
+
+ HelpBrowser mw;
+ mw.setCaption( HelpBrowser::tr("HelpBrowser") );
+ a.showMainDocumentWidget( &mw );
+
+ return a.exec();
+}
diff --git a/core/apps/helpbrowser/qpe-helpbrowser.control b/core/apps/helpbrowser/qpe-helpbrowser.control
new file mode 100644
index 0000000..b6e3404
--- a/dev/null
+++ b/core/apps/helpbrowser/qpe-helpbrowser.control
@@ -0,0 +1,10 @@
+Files: bin/helpbrowser apps/Applications/helpbrowser.desktop docs
+Priority: optional
+Section: qpe/applications
+Maintainer: Warwick Allison <warwick@trolltech.com>
+Architecture: arm
+Arch: iPAQ
+Version: $QPE_VERSION-3
+Depends: qpe-base ($QPE_VERSION)
+Description: Browse HTML help documents
+ The HTML help browser for the Qtopia environment.