29 #include "atcommand.h"
31 #include "commanditem.h"
33 CommandItem::CommandItem(TQListView *listView, ATCommand *command)
34 : TQListViewItem(listView)
41 CommandItem::~CommandItem()
50 void CommandItem::load(TQDomElement *c)
52 mCommand->setCmdName(c->attribute( "name", "unknown"));
53 mCommand->setCmdString(c->attribute( "string", "at"));
54 mCommand->setHexOutput(c->attribute( "hexoutput", "n") == "y");
56 TQDomNode n = c->firstChild();
58 TQDomElement e = n.toElement();
60 ATParameter *p = new ATParameter;
61 p->setName(e.attribute( "name", "unnamed"));
62 p->setValue(e.attribute( "value", "0"));
63 p->setUserInput(e.attribute( "userinput", "n") == "y");
65 mCommand->addParameter(p);
73 void CommandItem::save(TQDomDocument *doc,TQDomElement *parent)
75 TQDomElement c = doc->createElement( "command");
76 c.setAttribute( "name",mCommand->cmdName());
77 c.setAttribute( "string",mCommand->cmdString());
78 c.setAttribute( "hexoutput",mCommand->hexOutput() ? "y" : "n");
79 parent->appendChild(c);
81 TQPtrList<ATParameter> paras = mCommand->parameters();
82 for(uint i=0;i<paras.count();++i) {
83 saveParameter(paras.at(i),doc,&c);
87 void CommandItem::saveParameter(ATParameter *p, TQDomDocument *doc,
90 TQDomElement e = doc->createElement( "parameter");
91 e.setAttribute( "name",p->name());
92 e.setAttribute( "value",p->value());
93 e.setAttribute( "userinput",p->userInput() ? "y" : "n");
94 parent->appendChild(e);
97 void CommandItem::setItemText()
99 setText(0,mCommand->cmdName());
100 setText(1,mCommand->cmdString());
101 setText(2,mCommand->hexOutput() ? "y" : "n");
This class provides an abstraction of an AT command.
|