PageRenderTime 39ms CodeModel.GetById 21ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

/vp_plugins/print_acpu/message.cpp

http://cupsfilter.googlecode.com/
C++ | 64 lines | 50 code | 14 blank | 0 comment | 1 complexity | 5e615b5c78c16f97a7cbf31999da3983 MD5 | raw file
 1#include "message.h"
 2#include <QtCore/QDebug>
 3#include <QtCore/QMetaType>
 4#include <QtCore/QDataStream>
 5
 6Message::Message(QObject *parent)
 7    : QObject(parent)
 8    , messageType( VPrn::NoMsgType )
 9    , msgData()
10    , m_valid(false)
11{
12   clear();
13
14}
15
16
17
18void Message::setType( MessageType tp )
19{
20    messageType =  tp ;
21}
22
23MessageType Message::getType() const
24{
25    return messageType;
26}
27
28void Message::setMessageData( const QByteArray &m_data )
29{
30    msgData = m_data;
31}
32
33void Message::setMessageData( QStringList &m_list )
34{
35    if (!m_list.isEmpty()) {        
36        QDataStream out(&msgData, QIODevice::WriteOnly );
37        out.setVersion(QDataStream::Qt_3_0);
38        out << m_list;
39    }
40}
41
42QByteArray Message::getMessageData() const
43{
44    return msgData;
45}
46
47
48QStringList Message::getMessageDataList() const
49{
50    QStringList list;
51    QDataStream in( msgData );
52    in.setVersion(QDataStream::Qt_3_0);
53    in >> list;
54    return list;
55}
56
57void Message::clear()
58{
59    setType(VPrn::NoMsgType);
60    msgData.clear();
61    m_valid = true;
62}
63
64