Rev 4519 | Rev 4905 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
564 | cbradney | 7 | /*************************************************************************** |
8 | * Copyright (C) 2004 by Craig Bradney * |
||
9 | * cbradney@zip.com.au * |
||
2052 | subik | 10 | * Copyright (C) 2005 by Petr Vanek * |
11 | * petr@yarpen.cz * |
||
564 | cbradney | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * |
||
14 | * it under the terms of the GNU General Public License as published by * |
||
15 | * the Free Software Foundation; either version 2 of the License, or * |
||
16 | * (at your option) any later version. * |
||
17 | * * |
||
18 | * This program is distributed in the hope that it will be useful, * |
||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
21 | * GNU General Public License for more details. * |
||
22 | * * |
||
23 | * You should have received a copy of the GNU General Public License * |
||
24 | * along with this program; if not, write to the * |
||
25 | * Free Software Foundation, Inc., * |
||
26 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
27 | ***************************************************************************/ |
||
560 | cbradney | 28 | |
3 | paul | 29 | #include "helpbrowser.h" |
30 | #include "helpbrowser.moc" |
||
560 | cbradney | 31 | |
3 | paul | 32 | #include <qvariant.h> |
2052 | subik | 33 | #include <qstring.h> |
560 | cbradney | 34 | #include <qpushbutton.h> |
35 | #include <qtabwidget.h> |
||
36 | #include <qwidget.h> |
||
37 | #include <qheader.h> |
||
38 | #include <qtextbrowser.h> |
||
39 | #include <qlayout.h> |
||
3 | paul | 40 | #include <qtooltip.h> |
560 | cbradney | 41 | #include <qtoolbutton.h> |
42 | #include <qwhatsthis.h> |
||
3 | paul | 43 | #include <qimage.h> |
44 | #include <qpixmap.h> |
||
560 | cbradney | 45 | #include <qpopupmenu.h> |
46 | #include <qfileinfo.h> |
||
3 | paul | 47 | #include <qtextcodec.h> |
560 | cbradney | 48 | #include <qdom.h> |
1033 | cbradney | 49 | #include <qdir.h> |
786 | cbradney | 50 | #include <qsplitter.h> |
1144 | cbradney | 51 | #include <qmime.h> |
2006 | subik | 52 | #include <qlabel.h> |
53 | #include <qlineedit.h> |
||
54 | #include <qaccel.h> |
||
55 | #include <qinputdialog.h> |
||
2023 | subik | 56 | #include <qmenubar.h> |
57 | #include <qpopupmenu.h> |
||
58 | #include <qprinter.h> |
||
59 | #include <qpainter.h> |
||
60 | #include <qpaintdevicemetrics.h> |
||
61 | #include <qsimplerichtext.h> |
||
2048 | subik | 62 | #include <qxml.h> |
128 | Franz | 63 | |
1693 | craig | 64 | #include "scpaths.h" |
3240 | fschmid | 65 | #include "util.h" |
2688 | craig | 66 | #include "scconfig.h" |
4519 | subik | 67 | #include "prefsmanager.h" |
68 | #include "prefsfile.h" |
||
128 | Franz | 69 | |
4676 | cbradney | 70 | #if defined(_WIN32) |
71 | #include <windows.h> |
||
72 | #include <shellapi.h> |
||
73 | #endif |
||
74 | |||
3 | paul | 75 | extern QPixmap loadIcon(QString nam); |
76 | |||
560 | cbradney | 77 | |
2048 | subik | 78 | /*! \brief Returns the name of the cfg file for bookmarks. |
2052 | subik | 79 | A helper function. |
2048 | subik | 80 | \author Petr Vanek <petr@yarpen.cz> |
81 | */ |
||
82 | QString bookmarkFile() |
||
83 | { |
||
2052 | subik | 84 | QString fname(QDir::convertSeparators(QDir::homeDirPath()+ "/.scribus/doc/bookmarks.xml")); |
2048 | subik | 85 | QFileInfo f(fname); |
86 | if (!f.exists()) |
||
87 | { |
||
2052 | subik | 88 | QDir d(QDir::convertSeparators(QDir::homeDirPath()+ "/.scribus/")); |
2048 | subik | 89 | d.mkdir("doc"); |
90 | } |
||
2052 | subik | 91 | return fname; |
2048 | subik | 92 | } |
93 | |||
94 | |||
2052 | subik | 95 | /*! \brief Returns the name of the cfg file for persistent history. |
96 | A helper function. |
||
97 | \author Petr Vanek <petr@yarpen.cz> |
||
98 | */ |
||
99 | QString historyFile() |
||
100 | { |
||
101 | QString fname(QDir::convertSeparators(QDir::homeDirPath()+ "/.scribus/doc/history.xml")); |
||
102 | QFileInfo f(fname); |
||
103 | if (!f.exists()) |
||
104 | { |
||
105 | QDir d(QDir::convertSeparators(QDir::homeDirPath()+ "/.scribus/")); |
||
106 | d.mkdir("doc"); |
||
107 | } |
||
108 | return fname; |
||
109 | } |
||
110 | |||
111 | |||
2048 | subik | 112 | /*! \brief XML parsef for documantation bookmarks. |
113 | This is small helper class which reads saved bookmarks configuration |
||
114 | from ~/.scribus/doc/bookmarks.xml file. |
||
2052 | subik | 115 | The reference to QListView *view is a reference to the list view with bookmarks |
2048 | subik | 116 | \author Petr Vanek <petr@yarpen.cz> |
117 | */ |
||
118 | class BookmarkParser : public QXmlDefaultHandler |
||
119 | { |
||
120 | public: |
||
121 | QListView* view; |
||
122 | |||
123 | bool startDocument() |
||
124 | { |
||
125 | return true; |
||
126 | } |
||
127 | |||
128 | bool startElement(const QString&, const QString&, const QString& qName, const QXmlAttributes& attrs) |
||
129 | { |
||
130 | if (qName == "item") |
||
131 | { |
||
132 | QListViewItem *item = new QListViewItem(view, attrs.value(0), attrs.value(1)); |
||
133 | view->insertItem(item); |
||
134 | } |
||
135 | return true; |
||
136 | } |
||
137 | |||
138 | bool endElement(const QString&, const QString&, const QString&) |
||
139 | { |
||
140 | return true; |
||
141 | } |
||
142 | }; |
||
143 | |||
2052 | subik | 144 | /*! \brief XML parsef for documantation history. |
145 | This is small helper class which reads saved bookmarks configuration |
||
146 | from ~/.scribus/doc/history.xml file. |
||
147 | The reference to historyBrowser is a reference to the dialog. |
||
148 | \author Petr Vanek <petr@yarpen.cz> |
||
149 | */ |
||
150 | class HistoryParser : public QXmlDefaultHandler |
||
151 | { |
||
152 | public: |
||
153 | HelpBrowser *helpBrowser; |
||
2048 | subik | 154 | |
2052 | subik | 155 | bool startDocument() |
156 | { |
||
157 | return true; |
||
158 | } |
||
159 | |||
160 | bool startElement(const QString&, const QString&, const QString& qName, const QXmlAttributes& attrs) |
||
161 | { |
||
162 | if (qName == "item") |
||
163 | { |
||
164 | struct histd his; |
||
165 | his.title = attrs.value(0); |
||
166 | his.url = attrs.value(1); |
||
167 | helpBrowser->mHistory[helpBrowser->histMenu->insertItem(his.title)] = his; |
||
168 | } |
||
169 | return true; |
||
170 | } |
||
171 | |||
172 | bool endElement(const QString&, const QString&, const QString&) |
||
173 | { |
||
174 | return true; |
||
175 | } |
||
176 | }; |
||
177 | |||
4519 | subik | 178 | int HelpListItem::compare(QListViewItem *i, int col, bool asc) const |
179 | { |
||
180 | if (col == 1) |
||
181 | { |
||
182 | int d = text(col).toInt() - i->text(col).toInt(); |
||
183 | if (d > 0) |
||
184 | return 1; |
||
185 | return -1; |
||
186 | } |
||
187 | else |
||
188 | return QListViewItem::compare(i, col, asc); |
||
189 | } |
||
2052 | subik | 190 | |
4676 | cbradney | 191 | TextBrowser::TextBrowser(QWidget * parent, const char * name) : QTextBrowser(parent, name) |
192 | { |
||
193 | } |
||
194 | |||
195 | void TextBrowser::setSource(const QString &name) |
||
196 | { |
||
197 | #if defined(_WIN32) |
||
198 | int index = name.find( "http:/" ); |
||
199 | if ( index >=0 ) |
||
200 | { |
||
201 | QString url = name.right(name.length() - index); |
||
202 | //textBrowser->setSource( textBrowser->source() ); |
||
203 | QT_WA( { |
||
204 | ShellExecute( winId(), 0, (TCHAR*)url.ucs2(), 0, 0, SW_SHOWNORMAL ); |
||
205 | } , { |
||
206 | ShellExecuteA( winId(), 0, url.local8Bit(), 0, 0, SW_SHOWNORMAL ); |
||
207 | } ); |
||
208 | return; |
||
209 | } |
||
210 | #endif |
||
211 | QTextBrowser::setSource(name); |
||
212 | } |
||
213 | |||
2006 | subik | 214 | HelpBrowser::HelpBrowser( QWidget* parent, QString /*caption*/, QString guiLanguage, QString jumpToSection, QString jumpToFile) |
3804 | cbradney | 215 | : QWidget( parent, "Help", WType_TopLevel | WDestructiveClose | WGroupLeader ) |
3 | paul | 216 | { |
560 | cbradney | 217 | QString fileName; |
564 | cbradney | 218 | mHistory.clear(); |
219 | struct histd his; |
||
2877 | cbradney | 220 | language = guiLanguage.isEmpty() ? QString("en") : guiLanguage.left(2); |
2006 | subik | 221 | helpBrowsermainLayout = new QVBoxLayout( this); |
564 | cbradney | 222 | buttonLayout = new QHBoxLayout; |
223 | buttonLayout->setSpacing( 6 ); |
||
224 | buttonLayout->setMargin( 2 ); |
||
3 | paul | 225 | |
564 | cbradney | 226 | homeButton = new QToolButton( this, "homeButton" ); |
227 | homeButton->setText( "" ); |
||
228 | homeButton->setPixmap(loadIcon("gohome.png")); |
||
786 | cbradney | 229 | homeButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed, homeButton->sizePolicy().hasHeightForWidth() ) ); |
564 | cbradney | 230 | buttonLayout->addWidget( homeButton ); |
3 | paul | 231 | |
564 | cbradney | 232 | histMenu = new QPopupMenu( this ); |
233 | backButton = new QToolButton( this, "backButton" ); |
||
234 | backButton->setPixmap(loadIcon("back.png")); |
||
786 | cbradney | 235 | backButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed, backButton->sizePolicy().hasHeightForWidth() ) ); |
564 | cbradney | 236 | backButton->setPopup(histMenu); |
237 | backButton->setPopupDelay(0); |
||
238 | buttonLayout->addWidget( backButton ); |
||
3 | paul | 239 | |
564 | cbradney | 240 | forwButton = new QToolButton( this, "forwButton" ); |
241 | forwButton->setPixmap(loadIcon("forward.png")); |
||
786 | cbradney | 242 | forwButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed, forwButton->sizePolicy().hasHeightForWidth() ) ); |
564 | cbradney | 243 | buttonLayout->addWidget( forwButton ); |
244 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
||
245 | buttonLayout->addItem( spacer ); |
||
560 | cbradney | 246 | helpBrowsermainLayout->addLayout( buttonLayout ); |
247 | |||
2006 | subik | 248 | helpBrowserLayout = new QHBoxLayout; |
786 | cbradney | 249 | splitter = new QSplitter(this, "splitter"); |
250 | splitter->setChildrenCollapsible( false ); |
||
251 | helpBrowserLayout->addWidget( splitter ); |
||
560 | cbradney | 252 | |
786 | cbradney | 253 | tabWidget = new QTabWidget( splitter, "tabWidget" ); |
564 | cbradney | 254 | tabContents = new QWidget( tabWidget, "tabContents" ); |
2006 | subik | 255 | tabLayout = new QHBoxLayout( tabContents, 11, 6, "tabLayout"); |
560 | cbradney | 256 | |
564 | cbradney | 257 | listView = new QListView( tabContents, "listView" ); |
258 | listView->addColumn( tr( "Contents" ) ); |
||
1097 | cbradney | 259 | listView->addColumn( tr( "Link" ) , 0 ); |
260 | listView->setColumnWidthMode( 0, QListView::Maximum ); |
||
261 | listView->setColumnWidthMode( 1, QListView::Manual ); |
||
560 | cbradney | 262 | listView->setSorting(-1,-1); |
263 | listView->setRootIsDecorated( true ); |
||
264 | listView->setSelectionMode(QListView::Single); |
||
265 | listView->setDefaultRenameAction(QListView::Reject); |
||
266 | listView->clear(); |
||
564 | cbradney | 267 | tabLayout->addWidget( listView ); |
2006 | subik | 268 | |
269 | tabWidget->insertTab( tabContents, tr("&Contents") ); |
||
560 | cbradney | 270 | |
2006 | subik | 271 | // searching |
272 | tabSearching = new QWidget(tabWidget, "tabSearching"); |
||
273 | searchingMainLayout = new QVBoxLayout(tabSearching, 11, 6, "searchingMainLayout"); |
||
274 | searchingButtonLayout = new QHBoxLayout; |
||
275 | searchingEdit = new QLineEdit(tabSearching, "searchingEdit"); |
||
2397 | cbradney | 276 | searchingButton = new QPushButton( tr("&Search"), tabSearching, "searchingButton"); |
2006 | subik | 277 | searchingButtonLayout->addWidget(searchingEdit); |
278 | searchingButtonLayout->addWidget(searchingButton); |
||
279 | searchingMainLayout->addLayout(searchingButtonLayout); |
||
280 | searchingView = new QListView(tabSearching, "searchingView"); |
||
4519 | subik | 281 | searchingView->addColumn(tr("Contents")); |
282 | searchingView->addColumn(tr("Relevance")); |
||
283 | searchingView->addColumn(tr("Link" ) ,0); |
||
2006 | subik | 284 | searchingView->setColumnWidthMode( 0, QListView::Maximum ); |
285 | searchingView->setColumnWidthMode( 1, QListView::Manual ); |
||
4519 | subik | 286 | searchingView->setSorting(1, false); |
2006 | subik | 287 | searchingView->setRootIsDecorated( true ); |
288 | searchingView->setSelectionMode(QListView::Single); |
||
289 | searchingView->setDefaultRenameAction(QListView::Reject); |
||
4519 | subik | 290 | searchingView->setAllColumnsShowFocus(true); |
2006 | subik | 291 | searchingView->clear(); |
292 | searchingMainLayout->addWidget(searchingView); |
||
2062 | subik | 293 | tabWidget->insertTab(tabSearching, tr("Se&arch")); |
2006 | subik | 294 | |
2048 | subik | 295 | // bookmarks |
296 | tabBookmarks = new QWidget(tabWidget, "tabBookmarks"); |
||
297 | bookmarksMainLayout = new QVBoxLayout(tabBookmarks, 11, 6, "bookmarksMainLayout"); |
||
298 | bookmarksView = new QListView(tabBookmarks, "bookmarksView"); |
||
299 | bookmarksView->addColumn( tr( "Contents" ) ); |
||
300 | bookmarksView->addColumn( tr( "Link" ) , 0 ); |
||
301 | bookmarksView->setColumnWidthMode( 0, QListView::Maximum ); |
||
302 | bookmarksView->setColumnWidthMode( 1, QListView::Manual ); |
||
4519 | subik | 303 | bookmarksView->setSorting(1, -1); |
2048 | subik | 304 | bookmarksView->setRootIsDecorated( true ); |
305 | bookmarksView->setSelectionMode(QListView::Single); |
||
306 | bookmarksView->setDefaultRenameAction(QListView::Reject); |
||
307 | bookmarksView->clear(); |
||
308 | bookmarksMainLayout->addWidget(bookmarksView); |
||
309 | bookmarksButtonLayout = new QHBoxLayout; |
||
2397 | cbradney | 310 | bookmarkButton = new QPushButton( tr("&New"), tabBookmarks, "bookmarkButton"); |
311 | deleteBookmarkButton = new QPushButton( tr("&Delete"), tabBookmarks, "deleteBookmarkButton"); |
||
312 | deleteAllBookmarkButton = new QPushButton( tr("De&lete All"), tabBookmarks, "deleteAllBookmarkButton"); |
||
2048 | subik | 313 | bookmarksButtonLayout->addWidget(bookmarkButton); |
314 | bookmarksButtonLayout->addWidget(deleteBookmarkButton); |
||
315 | bookmarksButtonLayout->addWidget(deleteAllBookmarkButton); |
||
316 | bookmarksMainLayout->addLayout(bookmarksButtonLayout); |
||
2062 | subik | 317 | tabWidget->insertTab(tabBookmarks, tr("Book&marks")); |
2048 | subik | 318 | |
4676 | cbradney | 319 | textBrowser = new TextBrowser( splitter, "textBrowser" ); |
2238 | subik | 320 | textBrowser->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum, false ) ); |
564 | cbradney | 321 | textBrowser->setFrameShape( QTextBrowser::StyledPanel ); |
1144 | cbradney | 322 | QMimeSourceFactory *textBrowserMSF=textBrowser->mimeSourceFactory(); |
323 | textBrowserMSF->setExtensionType("html", "text/html;charset=UTF-8"); |
||
564 | cbradney | 324 | helpBrowsermainLayout->addLayout( helpBrowserLayout ); |
560 | cbradney | 325 | |
2023 | subik | 326 | // menus |
327 | menuBar = new QMenuBar(this); |
||
328 | QPopupMenu *fileMenu = new QPopupMenu(this); |
||
329 | fileMenu->insertItem(loadIcon("DateiPrint.xpm"), tr("&Print..."), this, SLOT(print()), CTRL+Key_P); |
||
330 | fileMenu->insertSeparator(); |
||
331 | fileMenu->insertItem(loadIcon("exit.png"), tr("E&xit"), this, SLOT(close())); |
||
3360 | cbradney | 332 | menuBar->insertItem( tr("&File"), fileMenu); |
2023 | subik | 333 | QPopupMenu *editMenu = new QPopupMenu(this); |
3360 | cbradney | 334 | editMenu->insertItem(loadIcon("find.png"), tr("&Find..."), this, SLOT(find()), CTRL+Key_F); |
335 | editMenu->insertItem( tr("Find &Next"), this, SLOT(findNext()), Key_F3); |
||
336 | editMenu->insertItem( tr("Find &Previous"), this, SLOT(findPrevious()), SHIFT+Key_F3); |
||
337 | menuBar->insertItem( tr("&Edit"), editMenu); |
||
2048 | subik | 338 | QPopupMenu *bookmarkMenu = new QPopupMenu(this); |
3360 | cbradney | 339 | bookmarkMenu->insertItem( tr("&Add Bookmark"), this, SLOT(bookmarkButton_clicked()), CTRL+Key_D); |
340 | bookmarkMenu->insertItem( tr("&Delete"), this, SLOT(deleteBookmarkButton_clicked())); |
||
341 | bookmarkMenu->insertItem( tr("D&elete All"), this, SLOT(deleteAllBookmarkButton_clicked())); |
||
2023 | subik | 342 | helpBrowsermainLayout->setMenuBar(menuBar); |
3360 | cbradney | 343 | menuBar->insertItem( tr("&Bookmarks"), bookmarkMenu); |
564 | cbradney | 344 | languageChange(); |
1092 | cbradney | 345 | loadMenu(); |
560 | cbradney | 346 | listView->header()->hide(); |
2006 | subik | 347 | searchingView->header()->hide(); |
2048 | subik | 348 | bookmarksView->header()->hide(); |
1092 | cbradney | 349 | jumpToHelpSection(jumpToSection, jumpToFile ); |
2048 | subik | 350 | readBookmarks(); |
2052 | subik | 351 | readHistory(); |
3472 | fschmid | 352 | splitter->setResizeMode( tabWidget, QSplitter::KeepSize ); |
353 | splitter->setResizeMode( textBrowser, QSplitter::Stretch ); |
||
4519 | subik | 354 | // reset previous size |
355 | prefs = PrefsManager::instance()->prefsFile->getPluginContext("helpbrowser"); |
||
356 | int xsize = prefs->getUInt("xsize", 640); |
||
357 | int ysize = prefs->getUInt("ysize", 480); |
||
358 | resize(QSize(xsize, ysize).expandedTo(minimumSizeHint()) ); |
||
3472 | fschmid | 359 | clearWState( WState_Polished ); |
560 | cbradney | 360 | |
361 | connect( homeButton, SIGNAL( clicked() ), textBrowser, SLOT( home() ) ); |
||
362 | connect( forwButton, SIGNAL( clicked() ), textBrowser, SLOT( forward() ) ); |
||
363 | connect( backButton, SIGNAL( clicked() ), textBrowser, SLOT( backward() ) ); |
||
564 | cbradney | 364 | connect( histMenu, SIGNAL(activated(int)), this, SLOT(histChosen(int))); |
365 | connect( listView, SIGNAL(clicked( QListViewItem *)), this, SLOT(itemSelected( QListViewItem *))); |
||
2006 | subik | 366 | // searching |
2048 | subik | 367 | connect(searchingEdit, SIGNAL(returnPressed()), this, SLOT(searchingButton_clicked())); |
368 | connect(searchingView, SIGNAL(clicked( QListViewItem *)), this, SLOT(itemSearchSelected(QListViewItem *))); |
||
369 | connect(searchingButton, SIGNAL(clicked()), this, SLOT(searchingButton_clicked())); |
||
370 | // bookmarks |
||
371 | connect(bookmarkButton, SIGNAL(clicked()), this, SLOT(bookmarkButton_clicked())); |
||
372 | connect(deleteBookmarkButton, SIGNAL(clicked()), this, SLOT(deleteBookmarkButton_clicked())); |
||
373 | connect(deleteAllBookmarkButton, SIGNAL(clicked()), this, SLOT(deleteAllBookmarkButton_clicked())); |
||
374 | connect(bookmarksView, SIGNAL(clicked(QListViewItem *)), this, SLOT(itemSearchSelected(QListViewItem *))); |
||
560 | cbradney | 375 | } |
376 | |||
377 | HelpBrowser::~HelpBrowser() |
||
378 | { |
||
564 | cbradney | 379 | // no need to delete child widgets, Qt does it all for us |
2048 | subik | 380 | // bookmarks |
381 | QFile bookFile(bookmarkFile()); |
||
382 | if (bookFile.open(IO_WriteOnly)) |
||
383 | { |
||
384 | QTextStream stream(&bookFile); |
||
385 | stream.setEncoding(QTextStream::UnicodeUTF8); |
||
386 | stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
||
387 | stream << "<bookmarks>\n"; |
||
388 | QListViewItemIterator it(bookmarksView); |
||
389 | for ( ; it.current(); ++it) |
||
390 | stream << "\t<item title=\"" << it.current()->text(0) << "\" url=\"" << it.current()->text(1) << "\" />\n"; |
||
391 | stream << "</bookmarks>\n"; |
||
392 | bookFile.close(); |
||
393 | } |
||
2052 | subik | 394 | // history |
395 | QFile histFile(historyFile()); |
||
396 | if (histFile.open(IO_WriteOnly)) |
||
397 | { |
||
398 | QTextStream stream(&histFile); |
||
399 | stream.setEncoding(QTextStream::UnicodeUTF8); |
||
400 | stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
||
401 | stream << "<history>\n"; |
||
402 | for (QMap<int,histd>::Iterator it = mHistory.begin() ; it != mHistory.end(); ++it) |
||
403 | stream << "\t<item title=\"" << it.data().title << "\" url=\"" << it.data().url << "\" />\n"; |
||
404 | stream << "</history>\n"; |
||
405 | histFile.close(); |
||
406 | } |
||
4519 | subik | 407 | // size |
408 | prefs->set("xsize", width()); |
||
409 | prefs->set("ysize", height()); |
||
560 | cbradney | 410 | } |
411 | |||
412 | void HelpBrowser::languageChange() |
||
413 | { |
||
564 | cbradney | 414 | setCaption( tr( "Scribus Online Help" ) ); |
415 | listView->header()->setLabel( 0, tr( "Contents" ) ); |
||
416 | listView->clear(); |
||
560 | cbradney | 417 | |
2006 | subik | 418 | tabWidget->changeTab( tabContents, tr( "&Contents" ) ); |
2052 | subik | 419 | QToolTip::add(searchingEdit, tr("Searching is case unsensitive")); |
560 | cbradney | 420 | } |
421 | |||
422 | void HelpBrowser::histChosen(int i) |
||
423 | { |
||
564 | cbradney | 424 | if (mHistory.contains(i)) |
2052 | subik | 425 | textBrowser->setSource(mHistory[i].url); |
560 | cbradney | 426 | } |
427 | |||
1092 | cbradney | 428 | void HelpBrowser::jumpToHelpSection(QString jumpToSection, QString jumpToFile) |
560 | cbradney | 429 | { |
430 | QString toLoad; |
||
1141 | cbradney | 431 | bool noDocs=false; |
560 | cbradney | 432 | |
2877 | cbradney | 433 | if (jumpToFile.isEmpty()) |
564 | cbradney | 434 | { |
2008 | cbradney | 435 | toLoad = ScPaths::instance().docDir() + language + "/"; //clean this later to handle 5 char locales |
2877 | cbradney | 436 | if (jumpToSection.isEmpty()) |
564 | cbradney | 437 | { |
1141 | cbradney | 438 | if (listView->firstChild()) |
439 | { |
||
440 | toLoad+=listView->firstChild()->text(1); |
||
441 | listView->setSelected( listView->firstChild(), true ); |
||
442 | } |
||
443 | else |
||
444 | noDocs=true; |
||
205 | Franz | 445 | } |
2006 | subik | 446 | else if (jumpToSection=="scripter") |
564 | cbradney | 447 | { |
560 | cbradney | 448 | toLoad+="scripter1.html"; |
449 | QListViewItemIterator it(listView); |
||
2006 | subik | 450 | while (it.current()) |
564 | cbradney | 451 | { |
560 | cbradney | 452 | if (it.current()->text(1)=="scripter1.html") |
453 | listView->setSelected( it.current(), true ); |
||
454 | if (it.current()->text(1)=="developers.html") |
||
455 | it.current()->setOpen( true ); |
||
456 | ++it; |
||
457 | } |
||
458 | } |
||
205 | Franz | 459 | } |
560 | cbradney | 460 | else |
564 | cbradney | 461 | toLoad=jumpToFile; |
3 | paul | 462 | |
1141 | cbradney | 463 | if (!noDocs) |
464 | loadHelp(toLoad); |
||
465 | else |
||
466 | textBrowser->setText("<h2>"+ tr("Sorry, no manual available! Please see: http://docs.scribus.net for updated docs\nand www.scribus.net for downloads.")+"</h2>"); |
||
3 | paul | 467 | } |
468 | |||
560 | cbradney | 469 | void HelpBrowser::loadHelp(QString filename) |
68 | Franz | 470 | { |
75 | Franz | 471 | struct histd his; |
564 | cbradney | 472 | bool Avail = true; |
560 | cbradney | 473 | QString toLoad; |
564 | cbradney | 474 | QFileInfo fi; |
475 | fi = QFileInfo(filename); |
||
1100 | cbradney | 476 | if (fi.fileName().length()>0) |
564 | cbradney | 477 | { |
1100 | cbradney | 478 | if (fi.exists()) |
479 | toLoad=filename; |
||
2006 | subik | 480 | else |
564 | cbradney | 481 | { |
2008 | cbradney | 482 | toLoad = QDir::convertSeparators(ScPaths::instance().docDir() + "en/index.html"); |
1100 | cbradney | 483 | language="en"; |
484 | fi = QFileInfo(toLoad); |
||
485 | if (!fi.exists()) |
||
486 | { |
||
487 | textBrowser->setText("<h2>"+ tr("Sorry, no manual available! Please see: http://docs.scribus.net for updated docs\nand www.scribus.net for downloads.")+"</h2>"); |
||
488 | Avail = false; |
||
489 | } |
||
564 | cbradney | 490 | } |
491 | } |
||
2006 | subik | 492 | else |
1100 | cbradney | 493 | Avail=false; |
2006 | subik | 494 | if (Avail) |
564 | cbradney | 495 | { |
496 | textBrowser->setSource(toLoad); |
||
2052 | subik | 497 | his.title = textBrowser->documentTitle(); |
2877 | cbradney | 498 | if (his.title.isEmpty()) |
2052 | subik | 499 | his.title = toLoad; |
500 | his.url = toLoad; |
||
501 | mHistory[histMenu->insertItem(his.title)] = his; |
||
564 | cbradney | 502 | } |
2052 | subik | 503 | if (mHistory.count() > 15) |
504 | { |
||
505 | int itk = histMenu->idAt(0); |
||
506 | mHistory.remove(itk); |
||
507 | histMenu->removeItem(itk); |
||
508 | } |
||
560 | cbradney | 509 | } |
510 | |||
1092 | cbradney | 511 | void HelpBrowser::loadMenu() |
560 | cbradney | 512 | { |
1693 | craig | 513 | QString pfad = ScPaths::instance().docDir(); |
786 | cbradney | 514 | QString toLoad; |
2008 | cbradney | 515 | QString pfad2 = QDir::convertSeparators(pfad + language + "/menu.xml"); |
564 | cbradney | 516 | QFileInfo fi = QFileInfo(pfad2); |
786 | cbradney | 517 | |
793 | cbradney | 518 | if (fi.exists()) |
519 | toLoad=pfad2; |
||
520 | else |
||
521 | { |
||
2008 | cbradney | 522 | toLoad = QDir::convertSeparators(pfad + "en/menu.xml"); |
1092 | cbradney | 523 | language="en"; |
786 | cbradney | 524 | fi = QFileInfo(toLoad); |
3240 | fschmid | 525 | sDebug("Scribus help in your selected language does not exist, trying English. Otherwise, please visit http://docs.scribus.net."); |
786 | cbradney | 526 | } |
527 | |||
560 | cbradney | 528 | if (fi.exists()) |
564 | cbradney | 529 | { |
560 | cbradney | 530 | QDomDocument doc( "menuentries" ); |
786 | cbradney | 531 | QFile file( toLoad ); |
560 | cbradney | 532 | if ( !file.open( IO_ReadOnly ) ) |
533 | return; |
||
2006 | subik | 534 | if ( !doc.setContent( &file ) ) |
564 | cbradney | 535 | { |
560 | cbradney | 536 | file.close(); |
537 | return; |
||
538 | } |
||
539 | file.close(); |
||
540 | |||
541 | QDomElement docElem = doc.documentElement(); |
||
542 | QDomNode n = docElem.firstChild(); |
||
543 | QListViewItem *qlvi=NULL, *qlvi2=NULL, *qlvi3=NULL, *qlvi4=NULL, *qlvi5=NULL, *qlvi6=NULL; |
||
1033 | cbradney | 544 | QListViewItem *tutorialsMenuItem; |
545 | bool haveTutorials=false; |
||
560 | cbradney | 546 | |
2006 | subik | 547 | while( !n.isNull() ) |
564 | cbradney | 548 | { |
560 | cbradney | 549 | QDomElement e = n.toElement(); // try to convert the node to an element. |
2006 | subik | 550 | if( !e.isNull() ) |
564 | cbradney | 551 | { |
2006 | subik | 552 | if (e.hasAttribute( "text" ) && e.hasAttribute( "file" )) |
564 | cbradney | 553 | { |
560 | cbradney | 554 | QDomAttr textAttr = e.attributeNode( "text" ); |
555 | QDomAttr fileAttr = e.attributeNode( "file" ); |
||
556 | if (qlvi2==NULL) |
||
557 | qlvi=new QListViewItem(listView, textAttr.value(), fileAttr.value()); |
||
2006 | subik | 558 | else |
1033 | cbradney | 559 | qlvi=new QListViewItem(listView, qlvi2, textAttr.value(), fileAttr.value()); |
1103 | cbradney | 560 | if (qlvi!=NULL && e.hasAttribute( "section" )) |
564 | cbradney | 561 | { |
1103 | cbradney | 562 | QDomAttr sectionAttr = e.attributeNode( "section" ); |
2006 | subik | 563 | if (sectionAttr.value()=="tutorials" && !haveTutorials) |
1103 | cbradney | 564 | { |
565 | haveTutorials=true; |
||
566 | tutorialsMenuItem=qlvi; |
||
567 | } |
||
560 | cbradney | 568 | } |
1033 | cbradney | 569 | |
560 | cbradney | 570 | if (qlvi!=NULL) |
571 | qlvi2=qlvi; |
||
572 | } |
||
573 | |||
574 | QDomNodeList nl=n.childNodes(); |
||
2006 | subik | 575 | for(uint i=0 ; i<= nl.count() ; i++) |
564 | cbradney | 576 | { |
560 | cbradney | 577 | QDomNode child=nl.item(i); |
2006 | subik | 578 | if (child.isElement()) |
564 | cbradney | 579 | { |
2006 | subik | 580 | QDomElement ec = child.toElement(); |
581 | if (!ec.isNull()) |
||
564 | cbradney | 582 | { |
2006 | subik | 583 | if (ec.hasAttribute( "text" ) && ec.hasAttribute( "file" )) |
564 | cbradney | 584 | { |
560 | cbradney | 585 | QDomAttr textAttr = ec.attributeNode( "text" ); |
586 | QDomAttr fileAttr = ec.attributeNode( "file" ); |
||
587 | if (qlvi4==NULL) |
||
588 | qlvi3=new QListViewItem(qlvi, textAttr.value(), fileAttr.value()); |
||
2006 | subik | 589 | else |
1033 | cbradney | 590 | qlvi3=new QListViewItem(qlvi, qlvi4, textAttr.value(), fileAttr.value()); |
1103 | cbradney | 591 | if (qlvi3!=NULL && ec.hasAttribute( "section" )) |
564 | cbradney | 592 | { |
1103 | cbradney | 593 | QDomAttr sectionAttr = e.attributeNode( "section" ); |
1105 | cbradney | 594 | if (sectionAttr.value()=="tutorials" && !haveTutorials) |
1103 | cbradney | 595 | { |
596 | haveTutorials=true; |
||
597 | tutorialsMenuItem=qlvi3; |
||
598 | } |
||
560 | cbradney | 599 | } |
600 | if (qlvi3!=NULL) |
||
601 | qlvi4=qlvi3; |
||
602 | } |
||
603 | //3rd level |
||
604 | QDomNodeList nl2=child.childNodes(); |
||
2006 | subik | 605 | for(uint i=0 ; i<= nl2.count() ; i++) |
564 | cbradney | 606 | { |
560 | cbradney | 607 | QDomNode childchild=nl2.item(i); |
2006 | subik | 608 | if (childchild.isElement()) |
564 | cbradney | 609 | { |
2006 | subik | 610 | QDomElement ecc = childchild.toElement(); |
611 | if (!ecc.isNull()) |
||
564 | cbradney | 612 | { |
2006 | subik | 613 | if (ecc.hasAttribute( "text" ) && ecc.hasAttribute( "file" )) |
564 | cbradney | 614 | { |
560 | cbradney | 615 | QDomAttr textAttr = ecc.attributeNode( "text" ); |
616 | QDomAttr fileAttr = ecc.attributeNode( "file" ); |
||
617 | if (qlvi6==NULL) |
||
618 | qlvi5=new QListViewItem(qlvi3, textAttr.value(), fileAttr.value()); |
||
2006 | subik | 619 | else |
1033 | cbradney | 620 | qlvi5=new QListViewItem(qlvi3, qlvi6, textAttr.value(), fileAttr.value()); |
1103 | cbradney | 621 | if (qlvi5!=NULL && ecc.hasAttribute( "section" )) |
564 | cbradney | 622 | { |
1103 | cbradney | 623 | QDomAttr sectionAttr = e.attributeNode( "section" ); |
1105 | cbradney | 624 | if (sectionAttr.value()=="tutorials" && !haveTutorials) |
1103 | cbradney | 625 | { |
626 | haveTutorials=true; |
||
627 | tutorialsMenuItem=qlvi5; |
||
628 | } |
||
560 | cbradney | 629 | } |
630 | } |
||
631 | if (qlvi5!=NULL) |
||
632 | qlvi6=qlvi5; |
||
633 | } |
||
634 | } |
||
635 | } |
||
636 | } |
||
637 | } |
||
638 | } |
||
639 | } |
||
640 | n = n.nextSibling(); |
||
641 | } |
||
1033 | cbradney | 642 | //scan for installed tutorials |
2006 | subik | 643 | if (haveTutorials) |
1033 | cbradney | 644 | { |
1693 | craig | 645 | QString path = ScPaths::instance().docDir(); |
1092 | cbradney | 646 | path += language + "/tutorials/"; |
1033 | cbradney | 647 | QDir dir(path, "*", QDir::Name, QDir::Dirs | QDir::NoSymLinks); |
648 | |||
2006 | subik | 649 | if (dir.exists() && (dir.count() != 0)) |
1033 | cbradney | 650 | { |
2006 | subik | 651 | for (uint i = 0; i < dir.count(); ++i) |
1033 | cbradney | 652 | { |
653 | if (dir[i]!="." && dir[i]!="..") |
||
654 | { |
||
2008 | cbradney | 655 | QString tutorialdir = QDir::convertSeparators("tutorials/" + dir[i] + "/"); |
656 | QFileInfo file(QDir::convertSeparators(path + dir[i] + "/menu.xml")); |
||
1033 | cbradney | 657 | if (file.exists()) // menu.xml exists for tutorial |
658 | { |
||
659 | QDomDocument docTutorial( "tutorialmenuentries" ); |
||
660 | QFile fileTutorialMenu( file.filePath() ); |
||
661 | if ( !fileTutorialMenu.open( IO_ReadOnly ) ) |
||
662 | break; |
||
2006 | subik | 663 | if ( !docTutorial.setContent( &fileTutorialMenu ) ) |
1033 | cbradney | 664 | { |
665 | fileTutorialMenu.close(); |
||
666 | break; |
||
667 | } |
||
668 | fileTutorialMenu.close(); |
||
669 | |||
670 | QDomElement docElemTutorial = docTutorial.documentElement(); |
||
671 | QDomNode nTutorial = docElemTutorial.firstChild(); |
||
672 | QListViewItem *tutorialQLVI=NULL; |
||
673 | |||
2006 | subik | 674 | while( !nTutorial.isNull() ) |
1033 | cbradney | 675 | { |
676 | QDomElement eTutorial = nTutorial.toElement(); // try to convert the node to an element. |
||
2006 | subik | 677 | if( !eTutorial.isNull() ) |
1033 | cbradney | 678 | { |
2006 | subik | 679 | if (tutorialsMenuItem!=NULL && eTutorial.hasAttribute( "text" ) && eTutorial.hasAttribute( "file" )) |
1033 | cbradney | 680 | { |
681 | QDomAttr textAttr = eTutorial.attributeNode( "text" ); |
||
682 | QDomAttr fileAttr = eTutorial.attributeNode( "file" ); |
||
1092 | cbradney | 683 | tutorialQLVI=new QListViewItem(tutorialsMenuItem, textAttr.value(), tutorialdir + fileAttr.value()); |
1033 | cbradney | 684 | } |
685 | QDomNodeList nl=nTutorial.childNodes(); |
||
686 | QListViewItem *tutorialSubMenuItem, *tutorialSubMenuItemLast=NULL; |
||
1092 | cbradney | 687 | for(uint j=0 ; j<= nl.count() ; j++) |
1033 | cbradney | 688 | { |
1092 | cbradney | 689 | QDomNode child=nl.item(j); |
1033 | cbradney | 690 | if (child.isElement()) |
691 | { |
||
692 | QDomElement ec = child.toElement(); |
||
693 | if (!ec.isNull()) |
||
694 | { |
||
695 | if (ec.hasAttribute( "text" ) && ec.hasAttribute( "file" )) |
||
696 | { |
||
697 | QDomAttr textAttr = ec.attributeNode( "text" ); |
||
698 | QDomAttr fileAttr = ec.attributeNode( "file" ); |
||
699 | if (tutorialSubMenuItemLast==NULL) |
||
1092 | cbradney | 700 | tutorialSubMenuItem=new QListViewItem(tutorialQLVI, textAttr.value(), tutorialdir + fileAttr.value()); |
2006 | subik | 701 | else |
1092 | cbradney | 702 | tutorialSubMenuItem=new QListViewItem(tutorialQLVI, tutorialSubMenuItemLast, textAttr.value(), tutorialdir + fileAttr.value()); |
1033 | cbradney | 703 | if (tutorialSubMenuItem!=NULL) |
704 | tutorialSubMenuItemLast=tutorialSubMenuItem; |
||
705 | } |
||
706 | } |
||
707 | } |
||
708 | } |
||
709 | } |
||
710 | nTutorial = nTutorial.nextSibling(); |
||
711 | } |
||
712 | } |
||
713 | } |
||
714 | } |
||
715 | } |
||
716 | |||
717 | } |
||
205 | Franz | 718 | } |
68 | Franz | 719 | } |
720 | |||
560 | cbradney | 721 | void HelpBrowser::itemSelected(QListViewItem *item) |
68 | Franz | 722 | { |
560 | cbradney | 723 | if ( !item ) |
724 | return; |
||
2878 | cbradney | 725 | if (!item->text(1).isNull()) |
1033 | cbradney | 726 | { |
1693 | craig | 727 | QString pfad = ScPaths::instance().docDir(); |
2008 | cbradney | 728 | loadHelp(QDir::convertSeparators(pfad + language + "/" + item->text(1))); |
1033 | cbradney | 729 | } |
68 | Franz | 730 | } |
2006 | subik | 731 | |
732 | void HelpBrowser::itemSearchSelected(QListViewItem *item) |
||
733 | { |
||
4519 | subik | 734 | if (item && !item->text(2).isNull()) |
2006 | subik | 735 | { |
4519 | subik | 736 | loadHelp(item->text(2)); |
2006 | subik | 737 | findText = searchingEdit->text(); |
738 | findNext(); |
||
739 | } |
||
740 | } |
||
741 | |||
742 | void HelpBrowser::searchingInDirectory(QString aDir) |
||
743 | { |
||
4519 | subik | 744 | QDir dir(QDir::convertSeparators(aDir + "/")); |
2006 | subik | 745 | QStringList lst = dir.entryList("*.html"); |
746 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it) |
||
747 | { |
||
748 | QString fname(aDir + (*it)); |
||
749 | QFile f(fname); |
||
750 | if (f.open(IO_ReadOnly)) |
||
751 | { |
||
752 | QTextStream stream(&f); |
||
753 | QString str = stream.read().lower(); |
||
754 | int cnt = str.contains(searchingEdit->text().lower()); |
||
755 | if (cnt > 0) |
||
756 | { |
||
757 | // the remove() hack is here for itemSelected() handling |
||
758 | QString fullname = fname; |
||
759 | QString title; |
||
2008 | cbradney | 760 | QListViewItem *refItem = listView->findItem(fname.remove(QDir::convertSeparators(ScPaths::instance().docDir()+language + "/")), 1); |
4519 | subik | 761 | title = refItem ? refItem->text(0) : fname; |
762 | HelpListItem *item = new HelpListItem(searchingView, QString("%2").arg(title), QString("%1").arg(cnt), fullname); |
||
2006 | subik | 763 | searchingView->insertItem(item); |
764 | } |
||
765 | f.close(); |
||
766 | } |
||
767 | } |
||
768 | // get dirs - ugly recursion |
||
769 | QStringList dst = dir.entryList("*", QDir::Dirs); |
||
770 | for (QStringList::Iterator it = dst.begin(); it != dst.end(); ++it) |
||
771 | if ((*it)!="." && (*it)!="..") |
||
2008 | cbradney | 772 | searchingInDirectory(QDir::convertSeparators(aDir + QString((*it)) + "/")); |
2006 | subik | 773 | } |
774 | |||
775 | void HelpBrowser::searchingButton_clicked() |
||
776 | { |
||
777 | searchingView->clear(); |
||
778 | // root files |
||
779 | QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
||
4519 | subik | 780 | searchingInDirectory(QDir::convertSeparators(ScPaths::instance().docDir() + language + "/")); |
2006 | subik | 781 | QApplication::restoreOverrideCursor(); |
782 | } |
||
783 | |||
784 | void HelpBrowser::find() |
||
785 | { |
||
2397 | cbradney | 786 | findText = QInputDialog::getText( tr("Find"), tr("Search Term:"), QLineEdit::Normal, findText, 0, this); |
2878 | cbradney | 787 | if (findText.isNull()) |
2006 | subik | 788 | return; |
789 | findNext(); |
||
790 | } |
||
791 | |||
792 | void HelpBrowser::findNext() |
||
793 | { |
||
2878 | cbradney | 794 | if (findText.isNull()) |
2006 | subik | 795 | { |
796 | find(); |
||
797 | return; |
||
798 | } |
||
799 | // find it. finally |
||
800 | textBrowser->find(findText, false, false, true, 0, 0); |
||
801 | } |
||
2023 | subik | 802 | |
803 | void HelpBrowser::findPrevious() |
||
804 | { |
||
2878 | cbradney | 805 | if (findText.isNull()) |
2023 | subik | 806 | { |
807 | find(); |
||
808 | return; |
||
809 | } |
||
810 | // find it. finally |
||
811 | textBrowser->find(findText, false, false, false, 0, 0); |
||
812 | } |
||
813 | |||
814 | void HelpBrowser::print() |
||
815 | { |
||
816 | QPrinter printer; |
||
817 | printer.setFullPage(true); |
||
818 | if (!printer.setup(this)) |
||
819 | return; |
||
820 | |||
821 | QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
||
822 | QPainter p(&printer); |
||
823 | QPaintDeviceMetrics metrics(p.device()); |
||
824 | int dpix = metrics.logicalDpiX(); |
||
825 | int dpiy = metrics.logicalDpiY(); |
||
826 | const int margin = 72; // pt |
||
827 | QRect body(margin*dpix/72, margin*dpiy/72, metrics.width()-margin*dpix/72*2, metrics.height()-margin*dpiy/72*2); |
||
828 | QFont font("Helvetica"); |
||
829 | QSimpleRichText richText( textBrowser->text(), font, textBrowser->context(), textBrowser->styleSheet(), textBrowser->mimeSourceFactory(), body.height()); |
||
830 | richText.setWidth( &p, body.width()); |
||
831 | QRect view(body); |
||
832 | int page = 1; |
||
833 | do { |
||
834 | richText.draw(&p, body.left(), body.top(), view, colorGroup()); |
||
835 | view.moveBy(0, body.height()); |
||
836 | p.translate(0 , -body.height()); |
||
837 | p.setFont(font); |
||
838 | p.drawText(view.right() - p.fontMetrics().width(QString::number(page)), view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page)); |
||
839 | if (view.top() >= body.top() + richText.height()) |
||
840 | break; |
||
841 | printer.newPage(); |
||
842 | page++; |
||
843 | } while (true); |
||
844 | QApplication::restoreOverrideCursor(); |
||
845 | } |
||
846 | |||
2048 | subik | 847 | void HelpBrowser::bookmarkButton_clicked() |
848 | { |
||
2052 | subik | 849 | QString title = textBrowser->documentTitle(); |
2048 | subik | 850 | QString fname(QDir::cleanDirPath(textBrowser->source())); |
2397 | cbradney | 851 | title = QInputDialog::getText( tr("New Bookmark"), tr("New Bookmark's Title:"), QLineEdit::Normal, title, 0, this); |
2048 | subik | 852 | // user cancel |
2878 | cbradney | 853 | if (title.isNull()) |
2048 | subik | 854 | return; |
2052 | subik | 855 | QListViewItem *item = new QListViewItem(bookmarksView, title, fname); |
2048 | subik | 856 | bookmarksView->insertItem(item); |
857 | } |
||
858 | |||
859 | void HelpBrowser::deleteBookmarkButton_clicked() |
||
860 | { |
||
861 | delete(bookmarksView->currentItem()); |
||
862 | } |
||
863 | |||
864 | void HelpBrowser::deleteAllBookmarkButton_clicked() |
||
865 | { |
||
866 | bookmarksView->clear(); |
||
867 | } |
||
868 | |||
869 | void HelpBrowser::readBookmarks() |
||
870 | { |
||
871 | BookmarkParser handler; |
||
872 | handler.view = bookmarksView; |
||
873 | QFile xmlFile(bookmarkFile()); |
||
874 | QXmlInputSource source(xmlFile); |
||
875 | QXmlSimpleReader reader; |
||
876 | reader.setContentHandler(&handler); |
||
2052 | subik | 877 | reader.parse(source); |
2048 | subik | 878 | } |
2052 | subik | 879 | |
880 | void HelpBrowser::readHistory() |
||
881 | { |
||
882 | HistoryParser handler; |
||
883 | handler.helpBrowser = this; |
||
884 | QFile xmlFile(historyFile()); |
||
885 | QXmlInputSource source(xmlFile); |
||
886 | QXmlSimpleReader reader; |
||
887 | reader.setContentHandler(&handler); |
||
888 | reader.parse(source); |
||
889 | } |
||
890 | |||
4458 | subik | 891 | void HelpBrowser::setText(QString str) |
892 | { |
||
893 | textBrowser->setText(str); |
||
894 | } |