Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 AQSAbstractMemArray_p.h 00003 ------------------- 00004 begin : 27/02/2011 00005 copyright : (C) 2003-2011 by InfoSiAL S.L. 00006 email : mail@infosial.com 00007 ***************************************************************************/ 00008 /*************************************************************************** 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; version 2 of the License. * 00012 ***************************************************************************/ 00013 /*************************************************************************** 00014 Este programa es software libre. Puede redistribuirlo y/o modificarlo 00015 bajo los términos de la Licencia Pública General de GNU en su 00016 versión 2, publicada por la Free Software Foundation. 00017 ***************************************************************************/ 00018 00019 #ifndef AQSABSTRACTMEMARRAY_P_H_ 00020 #define AQSABSTRACTMEMARRAY_P_H_ 00021 00022 #include "AQSVoidPtr_p.h" 00023 00024 // @AQ_PTR_INDIRECTION@ 00025 00026 class AQSAbstractMemArray : public AQSVoidPtr 00027 { 00028 Q_OBJECT 00029 00030 Q_PROPERTY(uint size READ size WRITE resize) 00031 Q_PROPERTY(uint length READ size WRITE resize) 00032 Q_PROPERTY(QValueList data READ data WRITE setData) 00033 00034 AQ_SKIP_DECLARE(AbstractMemArray, VoidPtr); 00035 00036 public: 00037 virtual void setter(uint index, const QVariant &v) = 0; 00038 virtual QVariant getter(uint index) const = 0; 00039 virtual uint size() const = 0; 00040 virtual bool resize(uint size) = 0; 00041 00042 QValueList<QVariant> data() const { 00043 QValueList<QVariant> dt; 00044 if (!isValid()) 00045 return dt; 00046 for (uint i = 0; i < this->size(); ++i) 00047 dt.append(this->getter(i)); 00048 return dt; 00049 } 00050 00051 public slots: 00052 void set(uint index, const QVariant &v) { 00053 this->setter(index, v); 00054 } 00055 00056 QVariant get(uint index) const { 00057 return getter(index); 00058 } 00059 00060 void setData(const QValueList<QVariant> &dt) { 00061 if (!isValid()) 00062 return; 00063 this->resize(dt.size()); 00064 uint idx = 0; 00065 QValueList<QVariant>::const_iterator it; 00066 for (it = dt.begin(); it != dt.end(); ++it, ++idx) 00067 this->setter(idx, *it); 00068 } 00069 00070 //@AQ_BEGIN_DEF_PUB_SLOTS@ 00071 //@AQ_END_DEF_PUB_SLOTS@ 00072 }; 00073 00074 //@AQ_BEGIN_IMP_PUB_SLOTS@ 00075 //@AQ_END_IMP_PUB_SLOTS@ 00076 00077 #endif /* AQSABSTRACTMEMARRAY_P_H_ */ 00078 // @AQSVOIDPTR@