KDevelop API Documentation

childproperty.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Alexander Dymo                                  *
00003  *   cloudtemple@mskat.net                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "childproperty.h"
00021 
00022 #include <qsize.h>
00023 #include <qpoint.h>
00024 #include <qrect.h>
00025 #include <qsizepolicy.h>
00026 
00027 #include "multiproperty.h"
00028 
00029 namespace PropertyLib{
00030  
00031 ChildProperty::ChildProperty(MultiProperty *parent, int type, ChildPropertyType childType, const QString &name,
00032     const QString &description, const QVariant &value, bool save, bool readOnly)
00033     :Property(type, name, description, value, save, readOnly), m_parent(parent), m_childType(childType)
00034 {
00035 }
00036 
00037 ChildProperty::ChildProperty(MultiProperty *parent, const QString & name, ChildPropertyType childType,
00038     const QMap<QString, QVariant> &v_valueList, const QString &description,
00039     const QVariant &value, bool save, bool readOnly)
00040     :Property(name, v_valueList, description, value, save, readOnly), m_parent(parent), m_childType(childType)
00041 {
00042 }
00043 
00044 void ChildProperty::setValue(const QVariant &value, bool rememberOldValue)
00045 {
00046     qWarning("ChildProperty::setValue");
00047     if (!m_parent->valid())
00048         return;
00049     switch (m_parent->type())
00050     {
00051         case Size:
00052         {
00053             qWarning("ChildProperty::setValue for QSize");
00054             QSize v = m_parent->value().toSize();
00055             if (m_childType == Size_Height)
00056                 v.setHeight(value.toInt());
00057             else if (m_childType == Size_Width)
00058                 v.setWidth(value.toInt());
00059             m_parent->setValue(v);
00060             break;
00061         }
00062         case Point:
00063         {
00064             qWarning("ChildProperty::setValue for QPoint");
00065             QPoint v = m_parent->value().toPoint();
00066             if (m_childType == Point_X)
00067                 v.setX(value.toInt());
00068             else if (m_childType == Point_Y)
00069                 v.setY(value.toInt());
00070             m_parent->setValue(v);
00071             break;
00072         }
00073         case Rect:
00074         {
00075             qWarning("ChildProperty::setValue for QRect");
00076             QRect v = m_parent->value().toRect();
00077             if (m_childType == Rect_X)
00078                 v.setX(value.toInt());
00079             else if (m_childType == Rect_Y)
00080                 v.setY(value.toInt());
00081             else if (m_childType == Rect_Width)
00082                 v.setWidth(value.toInt());
00083             else if (m_childType == Rect_Height)
00084                 v.setHeight(value.toInt());
00085             m_parent->setValue(v);
00086             break;
00087         }
00088         case SizePolicy:
00089         {
00090             qWarning("ChildProperty::setValue for QSizePolicy");
00091             QSizePolicy v = m_parent->value().toSizePolicy();
00092             if (m_childType == SizePolicy_HorData)
00093                 v.setHorData(QSizePolicy::SizeType(value.toInt()));
00094             else if (m_childType == SizePolicy_VerData)
00095                 v.setVerData(QSizePolicy::SizeType(value.toInt()));
00096             else if (m_childType == SizePolicy_HorStretch)
00097                 v.setHorStretch(value.toInt());
00098             else if (m_childType == SizePolicy_VerStretch)
00099                 v.setVerStretch(value.toInt());
00100             m_parent->setValue(v);
00101             break;
00102         }
00103     }
00104 }
00105 
00106 QVariant ChildProperty::value( ) const
00107 {
00108     if (!m_parent->valid())
00109         return QVariant();
00110     switch (m_parent->type())
00111     {
00112         case Size:
00113             if (m_childType == Size_Height)
00114                 return m_parent->value().toSize().height();
00115             else if (m_childType == Size_Width)
00116                 return m_parent->value().toSize().width();
00117         case Point:
00118             if (m_childType == Point_X)
00119                 return m_parent->value().toPoint().x();
00120             else if (m_childType == Point_Y)
00121                 return m_parent->value().toPoint().y();
00122         case Rect:
00123             if (m_childType == Rect_X)
00124                 return m_parent->value().toRect().x();
00125             else if (m_childType == Rect_Y)
00126                 return m_parent->value().toRect().y();
00127             else if (m_childType == Rect_Width)
00128                 return m_parent->value().toRect().width();
00129             else if (m_childType == Rect_Height)
00130                 return m_parent->value().toRect().height();
00131         case SizePolicy:
00132             if (m_childType == SizePolicy_HorData)
00133                 return m_parent->value().toSizePolicy().horData();
00134             else if (m_childType == SizePolicy_VerData)
00135                 return m_parent->value().toSizePolicy().verData();
00136             else if (m_childType == SizePolicy_HorStretch)
00137                 return m_parent->value().toSizePolicy().horStretch();
00138             else if (m_childType == SizePolicy_VerStretch)
00139                 return m_parent->value().toSizePolicy().verStretch();
00140     }
00141     return QVariant();
00142 }
00143 
00144 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:36 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003