21 #ifndef __KGAMEPROPERTYLIST_H_
22 #define __KGAMEPROPERTYLIST_H_
24 #include <tqvaluelist.h>
28 #include "kgamemessage.h"
29 #include "kgameproperty.h"
30 #include "kgamepropertyhandler.h"
41 typedef TQValueListIterator<type> Iterator;
42 typedef TQValueListConstIterator<type> ConstIterator;
48 KGamePropertyList(
const KGamePropertyList<type> &a ) : TQValueList<type>(a)
52 uint findIterator(Iterator me)
56 for( it = this->begin(); it != this->end(); ++it )
67 Iterator insert( Iterator it,
const type& d )
69 it=TQValueList<type>::insert(it,d);
72 TQDataStream s(b, IO_WriteOnly);
73 KGameMessage::createPropertyCommand(s,KGamePropertyBase::IdCommand,
id(),CmdInsert);
74 int i=findIterator(it);
91 void prepend(
const type& d) { insert(this->begin(),d); }
93 void append(
const type& d )
96 TQDataStream s(b, IO_WriteOnly);
97 KGameMessage::createPropertyCommand(s,KGamePropertyBase::IdCommand,
id(),CmdAppend);
112 Iterator erase( Iterator it )
115 TQDataStream s(b, IO_WriteOnly);
116 KGameMessage::createPropertyCommand(s,KGamePropertyBase::IdCommand,
id(),CmdRemove);
117 int i=findIterator(it);
135 Iterator remove( Iterator it )
140 void remove(
const type& d )
149 TQDataStream s(b, IO_WriteOnly);
150 KGameMessage::createPropertyCommand(s,KGamePropertyBase::IdCommand,
id(),CmdClear);
164 void load(TQDataStream& s)
166 kdDebug(11001) <<
"KGamePropertyList load " <<
id() << endl;
167 TQValueList<type>::clear();
172 for (
unsigned int i=0;i<size;i++)
175 TQValueList<type>::append(data);
180 void save(TQDataStream &s)
182 kdDebug(11001) <<
"KGamePropertyList save "<<
id() << endl;
184 uint size=this->count();
187 for( it = this->begin(); it != this->end(); ++it )
194 void command(TQDataStream &s,
int cmd,
bool)
197 kdDebug(11001) <<
"---> LIST id="<<
id()<<
" got command ("<<cmd<<
") !!!" <<endl;
207 TQValueList<type>::insert(it,data);
216 TQValueList<type>::append(data);
226 TQValueList<type>::remove(it);
227 kdDebug(11001) <<
"CmdRemove:id="<<
id()<<
" i="<<i <<endl;
233 TQValueList<type>::clear();
234 kdDebug(11001) <<
"CmdClear:id="<<
id()<<endl;
239 kdDebug(11001) <<
"Error in KPropertyList::command: Unknown command " << cmd << endl;
244 void extractProperty(
const TQByteArray& b)
248 TQDataStream s(b, IO_ReadOnly);
251 KGameMessage::extractPropertyHeader(s, propId);
252 KGameMessage::extractPropertyCommand(s, propId, cmd);
253 command(s, cmd,
true);
Base class of KGameProperty.
PropertyPolicy policy() const
bool isEmittingSignal() const
See also setEmittingSignal.
virtual void command(TQDataStream &stream, int msgid, bool isSender=false)
send a command to advanced properties like arrays
void emitSignal()
Causes the parent object to emit a signal on value change.
bool sendProperty(TQDataStream &s)
called by a property to send itself into the datastream.