PARP Research Group University of Murcia, Spain


src/qvgui/qvdesigner/facade/itemproperties.cpp

00001 /*
00002  *      Copyright (C) 2008, 2009. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 
00022 #include "itemproperties.h"
00023 #include "qvcore/qvpropertycontainer.h"
00024 
00025 
00026 // genera un item properties vacio
00027 ItemProperties::ItemProperties(QString type): containerType(type)
00028 {
00029 }
00030 
00031 // genera un item properties a partir de un qvpropertycontainer
00032 ItemProperties::ItemProperties(QString type, QVPropertyContainer *container): containerType(type)
00033 {
00034         QList<QString> prop( container->getPropertyList() );
00035 
00036         for (int i = 0; i < prop.size(); i++)
00037         { // para cada propiedad
00038                 QVPropertyContainer::PropertyFlags flags = container->getPropertyFlags(prop[i]);
00039                 if ( !(flags & (QVPropertyContainer::guiInvisible | QVPropertyContainer::internalProp)) )
00040                 { // solo la incluyo si no es ni guiinvisible ni internalprop
00041                         properties.append( prop[i] );
00042                         types.append( container->getPropertyType(prop[i]) );
00043                         inputs.append( container->isInput(prop[i]) );
00044                         outputs.append( container->isOutput(prop[i]) );
00045                         infos.append( container->getPropertyInfo(prop[i]) );
00046                 }
00047         }
00048 }
00049 
00050 QString ItemProperties::getType() const
00051 {
00052         return containerType;
00053 }
00054 
00055 QList<QString> ItemProperties::getProperties() const
00056 {
00057         return properties;
00058 }
00059 
00060 int ItemProperties::propertyType(const uint i) const
00061 {
00062         if (i >= (uint)types.size()) return 0;
00063         return types[i];
00064 }
00065 
00066 bool ItemProperties::isInput(const uint i) const
00067 {
00068         if (i >= (uint)inputs.size()) return false;
00069         return inputs[i];
00070 }
00071 
00072 bool ItemProperties::isOutput(const uint i) const
00073 {
00074         if (i >= (uint)outputs.size()) return false;
00075         return outputs[i];
00076 }
00077 
00078 QString ItemProperties::info(const uint i) const
00079 {
00080         if (i >= (uint)outputs.size()) return QString();
00081         return infos[i];
00082 }
00083 
00084 void ItemProperties::insertProperty(int pos, QString name, int type, bool input, bool output)
00085 {
00086         if ( (pos >= 0) && (pos <= properties.size()) )
00087         {
00088                 properties.insert(pos, name);
00089                 types.insert(pos, type);
00090                 inputs.insert(pos, input);
00091                 outputs.insert(pos, output);
00092         }
00093 }
00094 
00095 void ItemProperties::deleteProperty(int pos)
00096 {
00097         if ( (pos >= 0) && (pos <= properties.size()) )
00098         {
00099                 properties.removeAt(pos);
00100                 types.removeAt(pos);
00101                 inputs.removeAt(pos);
00102                 outputs.removeAt(pos);
00103         }
00104 }
00105 
00106 void ItemProperties::deleteProperty(QString name)
00107 {
00108         deleteProperty(properties.indexOf(name));
00109 }
00110 



QVision framework. PARP research group, copyright 2007, 2008.