TipDialog.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2007 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_TIP_DIALOG_H
17 #define SV_TIP_DIALOG_H
18 
19 #include <QDialog>
20 #include <QString>
21 #include <QXmlDefaultHandler>
22 
23 #include <vector>
24 
25 #include "base/Debug.h"
26 
27 class QLabel;
28 class QXmlInputSource;
29 
30 class TipDialog : public QDialog
31 {
32  Q_OBJECT
33 
34 public:
35  TipDialog(QWidget *parent = 0);
36  virtual ~TipDialog();
37 
38  bool isOK() { return !m_tips.empty(); }
39 
40 protected slots:
41  void previous();
42  void next();
43 
44 protected:
46  QLabel *m_label;
47  QString m_caption;
48 
49  std::vector<QString> m_tips;
50 
51  void readTips();
52  void showTip();
53 
54  class TipFileParser : public QXmlDefaultHandler
55  {
56  public:
57  TipFileParser(TipDialog *dialog);
58  virtual ~TipFileParser();
59 
60  void parse(QXmlInputSource &source);
61 
62  bool startElement(const QString &namespaceURI,
63  const QString &localName,
64  const QString &qName,
65  const QXmlAttributes& atts) override;
66 
67  bool characters(const QString &) override;
68 
69  bool endElement(const QString &namespaceURI,
70  const QString &localName,
71  const QString &qName) override;
72 
73  bool error(const QXmlParseException &exception) override;
74  bool fatalError(const QXmlParseException &exception) override;
75 
76  protected:
78 
79  bool m_inTip;
80  bool m_inText;
81  bool m_inHtml;
82  };
83 };
84 
85 #endif
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) override
Definition: TipDialog.cpp:232
void readTips()
Definition: TipDialog.cpp:115
int m_tipNumber
Definition: TipDialog.h:45
TipFileParser(TipDialog *dialog)
Definition: TipDialog.cpp:163
bool error(const QXmlParseException &exception) override
Definition: TipDialog.cpp:276
std::vector< QString > m_tips
Definition: TipDialog.h:49
void showTip()
Definition: TipDialog.cpp:146
void parse(QXmlInputSource &source)
Definition: TipDialog.cpp:176
TipDialog(QWidget *parent=0)
Definition: TipDialog.cpp:31
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) override
Definition: TipDialog.cpp:185
bool isOK()
Definition: TipDialog.h:38
TipDialog * m_dialog
Definition: TipDialog.h:77
virtual ~TipDialog()
Definition: TipDialog.cpp:88
QString m_caption
Definition: TipDialog.h:47
bool fatalError(const QXmlParseException &exception) override
Definition: TipDialog.cpp:288
void next()
Definition: TipDialog.cpp:93
bool characters(const QString &) override
Definition: TipDialog.cpp:264
QLabel * m_label
Definition: TipDialog.h:46
void previous()
Definition: TipDialog.cpp:105