helpbrowser.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /** 
00023  * \file helpbrowser.h
00024  * \version $Id: helpbrowser.h 1238 2006-09-25 17:50:57Z edmanm $ 
00025  * \brief Displays a list of help topics and content
00026  */
00027 
00028 #ifndef _HELPBROWSER_H
00029 #define _HELPBROWSER_H
00030 
00031 #include <QMainWindow>
00032 #include <QCloseEvent>
00033 #include <QDomDocument>
00034 #include <QDomElement>
00035 #include <QDomNodeList>
00036 #include <QTreeWidgetItem>
00037 #include <QTextBrowser>
00038 #include <QTextCursor>
00039 #include <gui/common/vidaliawindow.h>
00040 
00041 #include "ui_helpbrowser.h"
00042 
00043 class HelpBrowser : public VidaliaWindow
00044 {
00045   Q_OBJECT
00046 
00047 public:
00048   /** Default constructor **/
00049   HelpBrowser(QWidget *parent = 0);
00050  
00051 public slots:
00052   /** Overrides the default QWidget::show() */
00053   void show(QString topic = QString());
00054   
00055 private slots:
00056   /** Called when the user clicks "Find Next" */
00057   void findNext();
00058   /** Called when the user clicks "Find Previous" */
00059   void findPrev();
00060   /** Called when the user starts a search */
00061   void search();
00062   /** Called when the user selects a different item in the contents tree */
00063   void contentsItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev);
00064   /** Called when the user selects a different item in the search tree */
00065   void searchItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev);
00066    
00067 private:
00068   /** Load the contents of the help topics tree from the specified XML file. */
00069   void loadContentsFromXml(QString xmlFile);
00070   /** Load the contents of the help topics tree from the given DOM document. */
00071   bool loadContents(const QDomDocument *document, QString &errorString);
00072   /** Parse a Topic element and handle all its children. */
00073   void parseHelpTopic(const QDomElement &element, QTreeWidgetItem *parent);
00074   /** Returns true if the given Topic element has the necessary attributes. */
00075   bool isValidTopicElement(const QDomElement &topicElement);
00076   /** Builds a resource path to an html file associated with a help topic. */
00077   QString getResourcePath(const QDomElement &topicElement);
00078   /** Searches the current page for the phrase in the Find box */
00079   void find(bool forward);
00080   /** Creates a new item to be placed in the topic tree. */
00081   QTreeWidgetItem* createTopicTreeItem(const QDomElement &topicElement,
00082                                        QTreeWidgetItem *parent);
00083   /** Called when the user selects a different item in the tree. */
00084   void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev);
00085   /** Finds a topic in the topic tree. */
00086   QTreeWidgetItem* findTopicItem(QTreeWidgetItem *startItem, QString topic);
00087   /** Shows the help browser and finds a specific a topic in the browser. */
00088   void showTopic(QString topic);
00089 
00090   /** List of DOM elements representing topics. */
00091   QList<QDomElement> _elementList;
00092   /** Last phrase used for 'Find' */
00093   QString _lastFind;
00094   /** Last phrase searched on */
00095   QString _lastSearch;
00096   /** Indicates if phrase was previously found on current page */
00097   bool _foundBefore;
00098 
00099   /** Qt Designer generated QObject */
00100   Ui::HelpBrowser ui;
00101 };
00102 
00103 #endif
00104   

Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0