dataform.h
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 #ifndef DATAFORM_H 00021 #define DATAFORM_H 00022 00023 #include <qwidget.h> 00024 #include <qmap.h> 00025 #include <kdebug.h> 00026 #include <qvariant.h> 00027 00028 00029 class key 00030 { 00031 public: 00032 key( const QString &w="", const QString &p="text") : widget(w),property(p){;} 00033 virtual ~key(){;} 00034 QString widget; 00035 QString property; 00036 bool operator<( const key &right) const 00037 { 00038 if( widget == right.widget ) return (property < right.property); 00039 return ( widget < right.widget ); 00040 } 00041 }; 00042 00043 typedef QMap<key,QVariant> PropertyMap; 00044 00051 class DataForm : public QObject 00052 { 00053 Q_OBJECT 00054 public: 00055 DataForm(QWidget *parent = 0, const char *name = 0); 00056 ~DataForm(); 00057 00061 void setMap( PropertyMap *map ) { m_dataMap = map; } 00062 00066 void setForm( QWidget *form ) { m_form = form; } 00067 00074 QMap<QString,QString> createPropertyMap(bool fullKey = false) const; 00075 00084 void fillPropertyMap(QMap<QString,QString> *map, bool fullKey = false) const; 00085 00086 public slots: 00087 void updateView(); 00088 void resetView(); 00089 void updateData(); 00090 00091 signals: 00092 void mapChanged(); 00093 00094 private: 00095 00096 QWidget *m_form; 00097 PropertyMap *m_dataMap; 00098 }; 00099 00100 #endif