autoform.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 AUTOFORM_H 00021 #define AUTOFORM_H 00022 00023 #include <qscrollview.h> 00024 #include <dataform.h> 00025 class KPushButton; 00026 class QVBox; 00027 00028 class autoKey : public key 00029 { 00030 public: 00031 autoKey( const QString &w="", const QString &l = "") : key(w,"value") , label(l) 00032 { if( label.isEmpty() ) label = QString( "Value for %1" ).arg(w);} 00033 QString label; 00034 }; 00035 00036 typedef QMap<autoKey,QVariant> AutoPropertyMap; 00037 00043 class AutoForm : public QScrollView 00044 { 00045 Q_OBJECT 00046 public: 00047 AutoForm(AutoPropertyMap *map, QWidget *parent = 0, const char *name = 0); 00048 ~AutoForm(); 00049 00053 DataForm *dataForm() const { return m_dataForm; } 00054 00055 signals: 00056 void mapChanged(); 00057 00058 private slots: 00059 void slotMapChanged(); 00060 protected: 00061 void viewportResizeEvent( QResizeEvent *ev ); 00062 private: 00063 void buildGUI( AutoPropertyMap *map ); 00064 KPushButton *m_reset; 00065 KPushButton *m_submit; 00066 DataForm *m_dataForm; 00067 QVBox *m_mainBox; 00068 00069 }; 00070 00071 #endif