KDevelop API Documentation

dataform.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Ian Reinhart Geiser                             *
00003  *   geiseri@kde.org                                                       *
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 "dataform.h"
00021 #include <qvariant.h> 
00022 
00023 DataForm::DataForm(QWidget *parent, const char *name)
00024         : QObject(parent, name), m_form(0L), m_dataMap(0L)
00025 {
00026 
00027 }
00028 
00029 
00030 DataForm::~DataForm()
00031 {}
00032 
00033 void DataForm::updateView( )
00034 {
00035     //Check if Map or Widget is null.
00036     if( m_form == 0L || m_dataMap == 0L ) return;
00037     //Walk the map looking for map names that match up with widget children.
00038     PropertyMap::Iterator idx = m_dataMap->begin();
00039     for( ; idx != m_dataMap->end(); ++idx )
00040     {
00041         QWidget *wid = dynamic_cast<QWidget *>( m_form->child( idx.key().widget.latin1() ) );
00042         if ( wid )
00043             wid->setProperty( idx.key().property.latin1() , idx.data() );
00044     }
00045 }
00046 
00047 void DataForm::resetView( )
00048 {
00049 }
00050 
00051 void DataForm::updateData( )
00052 {
00053     //Check if Map or Widget is null.
00054     if( m_form == 0L || m_dataMap == 0L ) return;
00055     //Walk the map looking for map names that match up with widget children.
00056     PropertyMap::Iterator idx = m_dataMap->begin();
00057     for( ; idx != m_dataMap->end(); ++idx )
00058     {
00059         QWidget *wid = dynamic_cast<QWidget *>( m_form->child( idx.key().widget.latin1() ) );
00060         if ( wid )
00061         {
00062             QVariant value = wid->property( idx.key().property.latin1() );
00063             if( value.isValid() ) idx.data() = value;
00064         }
00065     }
00066     emit mapChanged();
00067 }
00068 
00069 QMap<QString,QString> DataForm::createPropertyMap( bool fullKey  ) const
00070 {
00071     QMap<QString,QString> propMap;
00072     fillPropertyMap( &propMap, fullKey );
00073     return propMap;
00074 }
00075 
00076 void DataForm::fillPropertyMap( QMap< QString, QString > * map, bool fullKey ) const
00077 {
00078     PropertyMap::Iterator idx = m_dataMap->begin();
00079     for( ; idx != m_dataMap->end(); ++idx )
00080     {
00081         QString key = idx.key().widget;
00082         if( fullKey ) key = key + "." + idx.key().property;
00083         QString value = idx.data().toString();
00084         map->insert( key,value );
00085     }
00086 }
00087 
00088 
00089 #include "dataform.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:53 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003