-rw-r--r-- | core/apps/helpbrowser/.cvsignore | 2 | ||||
-rw-r--r-- | core/apps/helpbrowser/Makefile.in | 119 | ||||
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.cpp | 227 | ||||
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.h | 69 | ||||
-rw-r--r-- | core/apps/helpbrowser/helpbrowser.pro | 12 | ||||
-rw-r--r-- | core/apps/helpbrowser/main.cpp | 34 | ||||
-rw-r--r-- | core/apps/helpbrowser/qpe-helpbrowser.control | 10 |
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 @@ | |||
1 | moc_* | ||
2 | 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 @@ | |||
1 | ############################################################################# | ||
2 | |||
3 | ####### Compiler, tools and options | ||
4 | |||
5 | CXX =$(SYSCONF_CXX) $(QT_CXX_MT) | ||
6 | CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) | ||
7 | CC =$(SYSCONF_CC) $(QT_C_MT) | ||
8 | CFLAGS =$(SYSCONF_CFLAGS) | ||
9 | INCPATH =-I$(QPEDIR)/include | ||
10 | LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) | ||
11 | LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) | ||
12 | MOC =$(SYSCONF_MOC) | ||
13 | UIC =$(SYSCONF_UIC) | ||
14 | |||
15 | ####### Target | ||
16 | |||
17 | DESTDIR = $(QPEDIR)/bin/ | ||
18 | VER_MAJ = 1 | ||
19 | VER_MIN = 0 | ||
20 | VER_PATCH = 0 | ||
21 | TARGET= helpbrowser | ||
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =helpbrowser.h | ||
27 | SOURCES =helpbrowser.cpp \ | ||
28 | main.cpp | ||
29 | OBJECTS =helpbrowser.o \ | ||
30 | main.o | ||
31 | INTERFACES = | ||
32 | UICDECLS = | ||
33 | UICIMPLS = | ||
34 | SRCMOC =moc_helpbrowser.cpp | ||
35 | OBJMOC =moc_helpbrowser.o | ||
36 | |||
37 | |||
38 | ####### Implicit rules | ||
39 | |||
40 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
41 | |||
42 | .cpp.o: | ||
43 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
44 | |||
45 | .cxx.o: | ||
46 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
47 | |||
48 | .cc.o: | ||
49 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
50 | |||
51 | .C.o: | ||
52 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
53 | |||
54 | .c.o: | ||
55 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
56 | |||
57 | ####### Build rules | ||
58 | |||
59 | |||
60 | all: $(DESTDIR)$(TARGET) | ||
61 | |||
62 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
63 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
64 | |||
65 | moc: $(SRCMOC) | ||
66 | |||
67 | tmake: | ||
68 | tmake helpbrowser.pro | ||
69 | |||
70 | clean: | ||
71 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
72 | -rm -f *~ core | ||
73 | -rm -f allmoc.cpp | ||
74 | |||
75 | ####### Extension Modules | ||
76 | |||
77 | listpromodules: | ||
78 | @echo | ||
79 | |||
80 | listallmodules: | ||
81 | @echo | ||
82 | |||
83 | listaddonpromodules: | ||
84 | @echo | ||
85 | |||
86 | listaddonentmodules: | ||
87 | @echo | ||
88 | |||
89 | |||
90 | REQUIRES= | ||
91 | |||
92 | ####### Sub-libraries | ||
93 | |||
94 | |||
95 | ###### Combined headers | ||
96 | |||
97 | |||
98 | |||
99 | ####### Compile | ||
100 | |||
101 | helpbrowser.o: helpbrowser.cpp \ | ||
102 | helpbrowser.h \ | ||
103 | $(QPEDIR)/include/qpe/qpeapplication.h \ | ||
104 | $(QPEDIR)/include/qpe/resource.h \ | ||
105 | $(QPEDIR)/include/qpe/global.h \ | ||
106 | $(QPEDIR)/include/qpe/qpemenubar.h \ | ||
107 | $(QPEDIR)/include/qpe/qpetoolbar.h | ||
108 | |||
109 | main.o: main.cpp \ | ||
110 | helpbrowser.h \ | ||
111 | $(QPEDIR)/include/qpe/qpeapplication.h | ||
112 | |||
113 | moc_helpbrowser.o: moc_helpbrowser.cpp \ | ||
114 | helpbrowser.h | ||
115 | |||
116 | moc_helpbrowser.cpp: helpbrowser.h | ||
117 | $(MOC) helpbrowser.h -o moc_helpbrowser.cpp | ||
118 | |||
119 | |||
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 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "helpbrowser.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpe/resource.h> | ||
25 | #include <qpe/global.h> | ||
26 | |||
27 | #include <qstatusbar.h> | ||
28 | #include <qdragobject.h> | ||
29 | #include <qpixmap.h> | ||
30 | #include <qpopupmenu.h> | ||
31 | #include <qpe/qpemenubar.h> | ||
32 | #include <qpe/qpetoolbar.h> | ||
33 | #include <qtoolbutton.h> | ||
34 | #include <qiconset.h> | ||
35 | #include <qfile.h> | ||
36 | #include <qtextstream.h> | ||
37 | #include <qstylesheet.h> | ||
38 | #include <qmessagebox.h> | ||
39 | #include <qfiledialog.h> | ||
40 | #include <qevent.h> | ||
41 | #include <qlineedit.h> | ||
42 | #include <qobjectlist.h> | ||
43 | #include <qfileinfo.h> | ||
44 | #include <qfile.h> | ||
45 | #include <qdatastream.h> | ||
46 | #include <qprinter.h> | ||
47 | #include <qsimplerichtext.h> | ||
48 | #include <qpaintdevicemetrics.h> | ||
49 | #include <qaction.h> | ||
50 | |||
51 | #include <ctype.h> | ||
52 | |||
53 | |||
54 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) | ||
55 | : QMainWindow( parent, name, f ), | ||
56 | selectedURL() | ||
57 | { | ||
58 | init( "index.html" ); | ||
59 | } | ||
60 | |||
61 | void HelpBrowser::init( const QString& _home ) | ||
62 | { | ||
63 | setIcon( Resource::loadPixmap( "help_icon" ) ); | ||
64 | |||
65 | browser = new QTextBrowser( this ); | ||
66 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | ||
67 | connect( browser, SIGNAL( textChanged() ), | ||
68 | this, SLOT( textChanged() ) ); | ||
69 | |||
70 | setCentralWidget( browser ); | ||
71 | setToolBarsMovable( FALSE ); | ||
72 | |||
73 | if ( !_home.isEmpty() ) | ||
74 | browser->setSource( _home ); | ||
75 | |||
76 | QPEToolBar* toolbar = new QPEToolBar( this ); | ||
77 | toolbar->setHorizontalStretchable( TRUE ); | ||
78 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | ||
79 | |||
80 | toolbar = new QPEToolBar( this ); | ||
81 | // addToolBar( toolbar, "Toolbar"); | ||
82 | |||
83 | //QPopupMenu* go = new QPopupMenu( this ); | ||
84 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); | ||
85 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); | ||
86 | connect( browser, SIGNAL( backwardAvailable( bool ) ), | ||
87 | backAction, SLOT( setEnabled( bool ) ) ); | ||
88 | //backAction->addTo( go ); | ||
89 | backAction->addTo( toolbar ); | ||
90 | backAction->setEnabled( FALSE ); | ||
91 | |||
92 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); | ||
93 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); | ||
94 | connect( browser, SIGNAL( forwardAvailable( bool ) ), | ||
95 | forwardAction, SLOT( setEnabled( bool ) ) ); | ||
96 | //forwardAction->addTo( go ); | ||
97 | forwardAction->addTo( toolbar ); | ||
98 | forwardAction->setEnabled( FALSE ); | ||
99 | |||
100 | QAction *a = new QAction( tr( "Home" ), Resource::loadPixmap( "home" ), QString::null, 0, this, 0 ); | ||
101 | connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); | ||
102 | //a->addTo( go ); | ||
103 | a->addTo( toolbar ); | ||
104 | |||
105 | bookm = new QPopupMenu( this ); | ||
106 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | ||
107 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); | ||
108 | bookm->insertSeparator(); | ||
109 | connect( bookm, SIGNAL( activated( int ) ), | ||
110 | this, SLOT( bookmChosen( int ) ) ); | ||
111 | |||
112 | readBookmarks(); | ||
113 | |||
114 | //menu->insertItem( tr("Go"), go ); | ||
115 | menu->insertItem( tr( "Bookmarks" ), bookm ); | ||
116 | |||
117 | resize( 240, 300 ); | ||
118 | browser->setFocus(); | ||
119 | |||
120 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | ||
121 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | ||
122 | } | ||
123 | |||
124 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | ||
125 | { | ||
126 | if ( msg == "showFile(QString)" ) { | ||
127 | QDataStream ds(data,IO_ReadOnly); | ||
128 | QString fn; | ||
129 | ds >> fn; | ||
130 | setDocument( fn ); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | void HelpBrowser::setDocument( const QString &doc ) | ||
135 | { | ||
136 | if ( !doc.isEmpty() ) | ||
137 | browser->setSource( doc ); | ||
138 | raise(); | ||
139 | } | ||
140 | |||
141 | |||
142 | void HelpBrowser::textChanged() | ||
143 | { | ||
144 | if ( browser->documentTitle().isNull() ) | ||
145 | setCaption( tr("Help Browser") ); | ||
146 | else | ||
147 | setCaption( browser->documentTitle() ) ; | ||
148 | |||
149 | selectedURL = caption(); | ||
150 | } | ||
151 | |||
152 | HelpBrowser::~HelpBrowser() | ||
153 | { | ||
154 | QStringList bookmarks; | ||
155 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); | ||
156 | for ( ; it2 != mBookmarks.end(); ++it2 ) | ||
157 | bookmarks.append( (*it2).name + "=" + (*it2).file ); | ||
158 | |||
159 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); | ||
160 | if ( f2.open( IO_WriteOnly ) ) { | ||
161 | QDataStream s2( &f2 ); | ||
162 | s2 << bookmarks; | ||
163 | f2.close(); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | void HelpBrowser::pathSelected( const QString &_path ) | ||
168 | { | ||
169 | browser->setSource( _path ); | ||
170 | } | ||
171 | |||
172 | void HelpBrowser::readBookmarks() | ||
173 | { | ||
174 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); | ||
175 | if ( QFile::exists( file ) ) { | ||
176 | QStringList bookmarks; | ||
177 | QFile f( file ); | ||
178 | if ( f.open( IO_ReadOnly ) ) { | ||
179 | QDataStream s( &f ); | ||
180 | s >> bookmarks; | ||
181 | f.close(); | ||
182 | } | ||
183 | QStringList::Iterator it = bookmarks.begin(); | ||
184 | for ( ; it != bookmarks.end(); ++it ) { | ||
185 | Bookmark b; | ||
186 | QString current = *it; | ||
187 | int equal = current.find( "=" ); | ||
188 | if ( equal < 1 || equal == (int)current.length() - 1 ) | ||
189 | continue; | ||
190 | b.name = current.left( equal ); | ||
191 | b.file = current.mid( equal + 1 ); | ||
192 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | |||
197 | void HelpBrowser::bookmChosen( int i ) | ||
198 | { | ||
199 | if ( mBookmarks.contains( i ) ) | ||
200 | browser->setSource( mBookmarks[ i ].file ); | ||
201 | } | ||
202 | |||
203 | void HelpBrowser::addBookmark() | ||
204 | { | ||
205 | Bookmark b; | ||
206 | b.name = browser->documentTitle(); | ||
207 | b.file = browser->source(); | ||
208 | if (b.name.isEmpty() ) { | ||
209 | b.name = b.file.left( b.file.length() - 5 ); // remove .html | ||
210 | } | ||
211 | QMap<int, Bookmark>::Iterator it; | ||
212 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) | ||
213 | if ( (*it).file == b.file ) return; | ||
214 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | ||
215 | } | ||
216 | |||
217 | void HelpBrowser::removeBookmark() | ||
218 | { | ||
219 | QString file = browser->source(); | ||
220 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); | ||
221 | for( ; it != mBookmarks.end(); ++it ) | ||
222 | if ( (*it).file == file ) { | ||
223 | bookm->removeItem( it.key() ); | ||
224 | mBookmarks.remove( it ); | ||
225 | break; | ||
226 | } | ||
227 | } | ||
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 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef HELPWINDOW_H | ||
22 | #define HELPWINDOW_H | ||
23 | |||
24 | #include <qmainwindow.h> | ||
25 | #include <qtextbrowser.h> | ||
26 | #include <qstringlist.h> | ||
27 | #include <qmap.h> | ||
28 | |||
29 | class QPopupMenu; | ||
30 | class QAction; | ||
31 | |||
32 | class HelpBrowser : public QMainWindow | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | HelpBrowser( QWidget* parent = 0, const char *name=0, WFlags f=0 ); | ||
37 | ~HelpBrowser(); | ||
38 | |||
39 | public slots: | ||
40 | void setDocument( const QString &doc ); | ||
41 | |||
42 | private slots: | ||
43 | void appMessage(const QCString& msg, const QByteArray& data); | ||
44 | void textChanged(); | ||
45 | |||
46 | void pathSelected( const QString & ); | ||
47 | void bookmChosen( int ); | ||
48 | void addBookmark(); | ||
49 | void removeBookmark(); | ||
50 | |||
51 | private: | ||
52 | void init( const QString & ); | ||
53 | void readBookmarks(); | ||
54 | |||
55 | QTextBrowser* browser; | ||
56 | QAction *backAction; | ||
57 | QAction *forwardAction; | ||
58 | QString selectedURL; | ||
59 | struct Bookmark { | ||
60 | QString name; | ||
61 | QString file; | ||
62 | }; | ||
63 | QMap<int, Bookmark> mBookmarks; | ||
64 | QMenuBar *menu; | ||
65 | QPopupMenu *bookm; | ||
66 | }; | ||
67 | |||
68 | #endif | ||
69 | |||
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 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on release | ||
3 | DESTDIR = $(QPEDIR)/bin | ||
4 | HEADERS = helpbrowser.h | ||
5 | SOURCES = helpbrowser.cpp \ | ||
6 | main.cpp | ||
7 | INCLUDEPATH += $(QPEDIR)/include | ||
8 | DEPENDPATH+= $(QPEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | INTERFACES= | ||
11 | |||
12 | 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 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "helpbrowser.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | int main( int argc, char ** argv ) | ||
26 | { | ||
27 | QPEApplication a( argc, argv ); | ||
28 | |||
29 | HelpBrowser mw; | ||
30 | mw.setCaption( HelpBrowser::tr("HelpBrowser") ); | ||
31 | a.showMainDocumentWidget( &mw ); | ||
32 | |||
33 | return a.exec(); | ||
34 | } | ||
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 @@ | |||
1 | Files: bin/helpbrowser apps/Applications/helpbrowser.desktop docs | ||
2 | Priority: optional | ||
3 | Section: qpe/applications | ||
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | ||
5 | Architecture: arm | ||
6 | Arch: iPAQ | ||
7 | Version: $QPE_VERSION-3 | ||
8 | Depends: qpe-base ($QPE_VERSION) | ||
9 | Description: Browse HTML help documents | ||
10 | The HTML help browser for the Qtopia environment. | ||