Changeset View
Changeset View
Standalone View
Standalone View
core/backends/devicelinereader.h
Show All 33 Lines | |||||
34 | class DeviceLineReader | 34 | class DeviceLineReader | ||
35 | : public QObject | 35 | : public QObject | ||
36 | { | 36 | { | ||
37 | Q_OBJECT | 37 | Q_OBJECT | ||
38 | 38 | | |||
39 | public: | 39 | public: | ||
40 | DeviceLineReader(QIODevice* device, QObject* parent = 0); | 40 | DeviceLineReader(QIODevice* device, QObject* parent = 0); | ||
41 | 41 | | |||
42 | QByteArray readLine() { return m_packages.dequeue(); } | 42 | QByteArray readLine() { return m_packets.dequeue(); } | ||
43 | qint64 write(const QByteArray& data) { return m_device->write(data); } | 43 | qint64 write(const QByteArray& data) { return m_device->write(data); } | ||
44 | qint64 bytesAvailable() const { return m_packages.size(); } | 44 | qint64 bytesAvailable() const { return m_packets.size(); } | ||
45 | 45 | | |||
46 | Q_SIGNALS: | 46 | Q_SIGNALS: | ||
47 | void readyRead(); | 47 | void readyRead(); | ||
48 | void disconnected(); | 48 | void disconnected(); | ||
49 | 49 | | |||
50 | private Q_SLOTS: | 50 | private Q_SLOTS: | ||
51 | void dataReceived(); | 51 | void dataReceived(); | ||
52 | 52 | | |||
53 | private: | 53 | private: | ||
54 | QByteArray m_lastChunk; | 54 | QByteArray m_lastChunk; | ||
55 | QIODevice* m_device; | 55 | QIODevice* m_device; | ||
56 | QQueue<QByteArray> m_packages; | 56 | QQueue<QByteArray> m_packets; | ||
57 | 57 | | |||
58 | }; | 58 | }; | ||
59 | 59 | | |||
60 | #endif | 60 | #endif |