almost ready to merge into master
[avrdudequi:avrdudequi.git] / programmer.h
1 /***************************************************************************
2  *   Copyright (C) 2011 by Maurilio                                        *
3  *   mau_ri_tec@yahoo.it                                                   *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21
22 #ifndef PROGRAMMER_H
23 #define PROGRAMMER_H
24
25 #include <QComboBox>
26 #include <QObject>
27 #include <QXmlStreamReader>
28 #include <QDomDocument>
29 #include <QMap>
30
31 #include "sysdevices.h"
32
33
34
35 class Programmer : public QObject
36 {
37     Q_OBJECT
38 public:
39     ~Programmer();
40     static Programmer *instance() {
41         if (!m_instance)
42             m_instance = new Programmer;
43         return m_instance;
44     }
45     const UdevQt::Device &currentDevice() {
46         return _currentDevice;
47     }
48
49     void setCurrentDevice(const UdevQt::Device &dev) {
50         _currentDevice = dev;
51     }
52
53     void fillProgrammer(QComboBox *);
54     void fillMcu(QComboBox *);
55     QMap<QString, QString> *dataMap();
56     UdevQt::DeviceList getDevices();
57     bool isValid();
58     void settingDialog();
59
60
61 private:
62     static Programmer *m_instance;
63     Programmer();
64     SysDevice *sysDevice;
65     UdevQt::Device _currentDevice;
66     QComboBox *_cBoxProg;
67     bool programmerIsValid;
68     void streamParser(const QStringList &);
69     void parseDeviceNode(QDomElement &child);
70     UdevQt::DeviceList devListMatch;
71     void readVersion();
72     void skipUnknownElement();
73     void readId();
74     void readName();
75     QString idProgrammer;
76     QString name;
77     QString version;
78     QString currentFile;
79     QXmlStreamReader reader;
80     QDomDocument currentDoc;
81     QDomElement currentProgrammer;
82     QMap<QString, QString> m_prog;
83
84
85 signals:
86     void programmerChanged(const QString &id);
87
88 public slots:
89     void change(int);
90
91 private slots:
92     void deviceRemoved(const UdevQt::Device &dev);
93
94
95 };
96
97 #endif // PROGRAMMER_H