svgui  1.9
TipDialog.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2007 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _TIP_DIALOG_H_
00017 #define _TIP_DIALOG_H_
00018 
00019 #include <QDialog>
00020 #include <QString>
00021 #include <QXmlDefaultHandler>
00022 
00023 #include <vector>
00024 
00025 #include "base/Debug.h"
00026 
00027 class QLabel;
00028 class QXmlInputSource;
00029 
00030 class TipDialog : public QDialog
00031 {
00032     Q_OBJECT
00033 
00034 public:
00035     TipDialog(QWidget *parent = 0);
00036     virtual ~TipDialog();
00037 
00038     bool isOK() { return !m_tips.empty(); }
00039 
00040 protected slots:
00041     void previous();
00042     void next();
00043 
00044 protected:
00045     int m_tipNumber;
00046     QLabel *m_label;
00047     QString m_caption;
00048 
00049     std::vector<QString> m_tips;
00050 
00051     void readTips();
00052     void showTip();
00053 
00054     class TipFileParser : public QXmlDefaultHandler
00055     {
00056     public:
00057         TipFileParser(TipDialog *dialog);
00058         virtual ~TipFileParser();
00059         
00060         void parse(QXmlInputSource &source);
00061 
00062         virtual bool startElement(const QString &namespaceURI,
00063                                   const QString &localName,
00064                                   const QString &qName,
00065                                   const QXmlAttributes& atts);
00066         
00067         virtual bool characters(const QString &);
00068         
00069         virtual bool endElement(const QString &namespaceURI,
00070                                 const QString &localName,
00071                                 const QString &qName);
00072         
00073         bool error(const QXmlParseException &exception);
00074         bool fatalError(const QXmlParseException &exception);
00075 
00076     protected:
00077         TipDialog *m_dialog;
00078 
00079         bool m_inTip;
00080         bool m_inText;
00081         bool m_inHtml;
00082     };
00083 };
00084 
00085 #endif