File indexing completed on 2024-10-06 06:48:46

0001 /* This file is part of KsirK.
0002  *   Copyright (C) 2005-2007 Gael de Chalendar (aka Kleag) <kleag@free.fr>
0003  *
0004  *   KsirK is free software; you can redistribute it and/or
0005  *   modify it under the terms of the GNU General Public
0006  *   License as published by the Free Software Foundation, either version 2
0007    of the License, or (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  *   General Public License for more details.
0013  *
0014  *   You should have received a copy of the GNU General Public License
0015  *   along with this program; if not, write to the Free Software
0016  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017  *   02110-1301, USA
0018  */
0019 #include "eventslistproperty.h"
0020 
0021 namespace Ksirk {
0022 
0023 namespace GameLogic {
0024 
0025 // EventsListProperty::EventsListProperty() : KGamePropertyList< QPair< QString, QPoint > >()
0026 EventsListProperty::EventsListProperty() : QList< QPair< QString, QPointF > >()
0027 {
0028 }
0029 
0030 
0031 EventsListProperty::~EventsListProperty()
0032 {
0033 }
0034 
0035 // void EventsListProperty::load(QDataStream& s)
0036 // {
0037 //   QValueList< QPair< QString, QPoint> > list;
0038 //   while (!s.atEnd())
0039 //   {
0040 //     QString str; QPoint p;
0041 //     s >> str >> p;
0042 //     list.push_back(qMakePair(str,p));
0043 //   }
0044 // //   setValue(list);
0045 // }
0046 
0047   /**
0048     * Write the value into a stream. MUST be overwritten
0049     **/
0050 // void EventsListProperty::save(QDataStream& s)
0051 // {
0052 //   QValueList< QPair< QString, QPoint> >::const_iterator it, it_end;
0053 //   it = value().begin(); it_end = value().end();
0054 //   for (; it != it_end; it++)
0055 //   {
0056 //     s << (*it).first << (*it).second;
0057 //   }
0058 // }
0059 
0060   /**
0061     * send a command to advanced properties like arrays
0062     * @param stream The stream containing the data of the comand
0063     * @param msgid The ID of the command - see PropertyCommandIds
0064     * @param isSender whether this client is also the sender of the command
0065     **/
0066 // void EventsListProperty::command(QDataStream &stream, int msgid, bool isSender)
0067 // {
0068 //   qCDebug(KSIRK_LOG) << "EventsListProperty::command ";
0069 //   
0070 //   QString commandName;
0071 //   stream >> commandName;
0072 //   
0073 //   qCDebug(KSIRK_LOG) << "    command name is " << commandName ;
0074 //   if (commandName == "pop_front")
0075 //   {
0076 //     QValueList< QPair< QString, QPoint> > list = value();
0077 //     list.pop_front();
0078 //     setValue(list);
0079 //   }
0080 //   else if (commandName == "push_back")
0081 //   {
0082 //     QString str; QPoint point;
0083 //     stream >> str >> point;
0084 //     QValueList< QPair< QString, QPoint> > list = value();
0085 //     list.push_back(qMakePair(str,point));
0086 //     setValue(list);
0087 //   }
0088 // }
0089 
0090 void EventsListProperty::pop_front()
0091 {
0092 //   qCDebug(KSIRK_LOG) << "EventsListProperty::pop_front ";
0093 QList< QPair< QString, QPointF > >::pop_front();
0094 /*  if (!isEmpty())
0095   {
0096     EventsListProperty::iterator it = begin();
0097     remove(it);
0098   }*/
0099 //   QByteArray buffer;
0100 /*  QDataStream stream(buffer, QIODevice::ReadWrite);
0101   stream << QString("pop_front");
0102   command(stream, 1,true);*/
0103 }
0104 
0105 void EventsListProperty::push_back(const QPair<QString, QPointF>& pair)
0106 {
0107 //   qCDebug(KSIRK_LOG) << "EventsListProperty::push_back " << pair.first << " / " << pair.second ;
0108 QList< QPair< QString, QPointF > >::push_back(pair);
0109 //   append(pair);
0110 //   QByteArray buffer;
0111 /*  QDataStream stream(buffer, QIODevice::ReadWrite);
0112   qCDebug(KSIRK_LOG) << "1";
0113   stream << QString("push_back");
0114   qCDebug(KSIRK_LOG) << "2";
0115   stream << pair.first;
0116   qCDebug(KSIRK_LOG) << "3";
0117   stream << pair.second;
0118   qCDebug(KSIRK_LOG) << "4";
0119   command(stream, 2, true);*/
0120 }
0121 
0122 }
0123 
0124 }