annotate widgets/TipDialog.h @ 854:c17719e488c9

Fix some potential null-pointer derefs, and simplify some logic where loops were used with an unconditional "break" that meant they could only happen once (from coverity scan)
author Chris Cannam
date Wed, 03 Sep 2014 12:04:22 +0100
parents d632a1e87018
children a18e78b9c78b
rev   line source
Chris@225 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@225 2
Chris@225 3 /*
Chris@225 4 Sonic Visualiser
Chris@225 5 An audio file viewer and annotation editor.
Chris@225 6 Centre for Digital Music, Queen Mary, University of London.
Chris@225 7 This file copyright 2007 QMUL.
Chris@225 8
Chris@225 9 This program is free software; you can redistribute it and/or
Chris@225 10 modify it under the terms of the GNU General Public License as
Chris@225 11 published by the Free Software Foundation; either version 2 of the
Chris@225 12 License, or (at your option) any later version. See the file
Chris@225 13 COPYING included with this distribution for more information.
Chris@225 14 */
Chris@225 15
Chris@225 16 #ifndef _TIP_DIALOG_H_
Chris@225 17 #define _TIP_DIALOG_H_
Chris@225 18
Chris@225 19 #include <QDialog>
Chris@225 20 #include <QString>
Chris@225 21 #include <QXmlDefaultHandler>
Chris@225 22
Chris@225 23 #include <vector>
Chris@225 24
Chris@584 25 #include "base/Debug.h"
Chris@584 26
Chris@225 27 class QLabel;
Chris@225 28 class QXmlInputSource;
Chris@225 29
Chris@225 30 class TipDialog : public QDialog
Chris@225 31 {
Chris@225 32 Q_OBJECT
Chris@225 33
Chris@225 34 public:
Chris@616 35 TipDialog(QWidget *parent = 0);
Chris@225 36 virtual ~TipDialog();
Chris@225 37
Chris@225 38 bool isOK() { return !m_tips.empty(); }
Chris@225 39
Chris@225 40 protected slots:
Chris@225 41 void previous();
Chris@225 42 void next();
Chris@225 43
Chris@225 44 protected:
Chris@225 45 int m_tipNumber;
Chris@225 46 QLabel *m_label;
Chris@225 47 QString m_caption;
Chris@225 48
Chris@225 49 std::vector<QString> m_tips;
Chris@225 50
Chris@225 51 void readTips();
Chris@225 52 void showTip();
Chris@225 53
Chris@225 54 class TipFileParser : public QXmlDefaultHandler
Chris@225 55 {
Chris@225 56 public:
Chris@225 57 TipFileParser(TipDialog *dialog);
Chris@225 58 virtual ~TipFileParser();
Chris@225 59
Chris@225 60 void parse(QXmlInputSource &source);
Chris@225 61
Chris@225 62 virtual bool startElement(const QString &namespaceURI,
Chris@225 63 const QString &localName,
Chris@225 64 const QString &qName,
Chris@225 65 const QXmlAttributes& atts);
Chris@225 66
Chris@225 67 virtual bool characters(const QString &);
Chris@225 68
Chris@225 69 virtual bool endElement(const QString &namespaceURI,
Chris@225 70 const QString &localName,
Chris@225 71 const QString &qName);
Chris@225 72
Chris@225 73 bool error(const QXmlParseException &exception);
Chris@225 74 bool fatalError(const QXmlParseException &exception);
Chris@225 75
Chris@225 76 protected:
Chris@225 77 TipDialog *m_dialog;
Chris@225 78
Chris@225 79 bool m_inTip;
Chris@225 80 bool m_inText;
Chris@228 81 bool m_inHtml;
Chris@225 82 };
Chris@225 83 };
Chris@225 84
Chris@225 85 #endif