helpbrowser.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file helpbrowser.h
00013 ** \version $Id: helpbrowser.h 2362 2008-02-29 04:30:11Z edmanm $ 
00014 ** \brief Displays a list of help topics and content
00015 */
00016 
00017 #ifndef _HELPBROWSER_H
00018 #define _HELPBROWSER_H
00019 
00020 #include <QMainWindow>
00021 #include <QCloseEvent>
00022 #include <QDomDocument>
00023 #include <QDomElement>
00024 #include <QDomNodeList>
00025 #include <QTreeWidgetItem>
00026 #include <QTextBrowser>
00027 #include <QTextCursor>
00028 #include <vidaliawindow.h>
00029 
00030 #include "ui_helpbrowser.h"
00031 
00032 class HelpBrowser : public VidaliaWindow
00033 {
00034   Q_OBJECT
00035 
00036 public:
00037   /** Default constructor **/
00038   HelpBrowser(QWidget *parent = 0);
00039  
00040 public slots:
00041   /** Overrides the default QWidget::show() */
00042   void showWindow(QString topic = QString());
00043   
00044 private slots:
00045   /** Called when the user clicks "Find Next" */
00046   void findNext();
00047   /** Called when the user clicks "Find Previous" */
00048   void findPrev();
00049   /** Called when the user starts a search */
00050   void search();
00051   /** Called when the user selects a different item in the contents tree */
00052   void contentsItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev);
00053   /** Called when the user selects a different item in the search tree */
00054   void searchItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev);
00055    
00056 private:
00057   /** Returns the language in which help topics should appear, or English
00058    * ("en") if no translated help files exist for the current GUI language. */
00059   QString language();
00060   /** Load the contents of the help topics tree from the specified XML file. */
00061   void loadContentsFromXml(QString xmlFile);
00062   /** Load the contents of the help topics tree from the given DOM document. */
00063   bool loadContents(const QDomDocument *document, QString &errorString);
00064   /** Parse a Topic element and handle all its children. */
00065   void parseHelpTopic(const QDomElement &element, QTreeWidgetItem *parent);
00066   /** Returns true if the given Topic element has the necessary attributes. */
00067   bool isValidTopicElement(const QDomElement &topicElement);
00068   /** Builds a resource path to an html file associated with a help topic. */
00069   QString getResourcePath(const QDomElement &topicElement);
00070   /** Searches the current page for the phrase in the Find box */
00071   void find(bool forward);
00072   /** Creates a new item to be placed in the topic tree. */
00073   QTreeWidgetItem* createTopicTreeItem(const QDomElement &topicElement,
00074                                        QTreeWidgetItem *parent);
00075   /** Called when the user selects a different item in the tree. */
00076   void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev);
00077   /** Finds a topic in the topic tree. */
00078   QTreeWidgetItem* findTopicItem(QTreeWidgetItem *startItem, QString topic);
00079   /** Shows the help browser and finds a specific a topic in the browser. */
00080   void showTopic(QString topic);
00081 
00082   /** List of DOM elements representing topics. */
00083   QList<QDomElement> _elementList;
00084   /** Last phrase used for 'Find' */
00085   QString _lastFind;
00086   /** Last phrase searched on */
00087   QString _lastSearch;
00088   /** Indicates if phrase was previously found on current page */
00089   bool _foundBefore;
00090 
00091   /** Qt Designer generated QObject */
00092   Ui::HelpBrowser ui;
00093 };
00094 
00095 #endif
00096   

Generated on Tue Jul 7 16:58:26 2009 for Vidalia by  doxygen 1.4.7