KDevelop API Documentation

autoform.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 "autoform.h"
00021 #include <kpushbutton.h>
00022 #include <qhbox.h>
00023 #include <qvbox.h>
00024 #include <qlabel.h>
00025 #include <qvariant.h>
00026 #include <kdebug.h>
00027 #include <propeditor/propertywidgetproxy.h>
00028 #include <kdialog.h>
00029 
00030 AutoForm::AutoForm(AutoPropertyMap *map, QWidget *parent, const char *name)
00031  : QScrollView(parent, name)
00032 {
00033     m_dataForm = new DataForm(this, "dataForm");
00034     m_dataForm->setMap( (PropertyMap *)map );
00035     m_dataForm->setForm( this );
00036     m_mainBox = new QVBox( viewport() );
00037     addChild( m_mainBox );
00038     m_mainBox->setSpacing( KDialog::spacingHint() );
00039     m_mainBox->setMargin( KDialog::marginHint() );
00040     
00041     buildGUI( map );
00042 
00043     connect( m_dataForm, SIGNAL( mapChanged() ), this, SLOT( slotMapChanged() ) );
00044     m_dataForm->updateView();
00045 }
00046 
00047 
00048 AutoForm::~AutoForm()
00049 {
00050 }
00051 
00052 void AutoForm::buildGUI( AutoPropertyMap *map )
00053 {
00054     AutoPropertyMap::Iterator idx = map->begin();
00055     for( ; idx != map->end(); ++idx )
00056     {
00057         QHBox *line = new QHBox(m_mainBox);
00058         // Key Name | Property Edit
00059         QString name =  QString("%1 %2").arg( idx.key().widget ).arg( idx.key().property );
00060         new QLabel(idx.key().label, line, name.latin1() );
00061         PropertyLib::PropertyWidgetProxy *prop = new PropertyLib::PropertyWidgetProxy( line, idx.key().widget.latin1() );
00062         line->setSizePolicy( QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed ) );
00063         m_mainBox->setSpacing( KDialog::spacingHint() );
00064     }
00065     QHBox *line = new QHBox(m_mainBox);
00066     m_reset = new KPushButton("Reset", line);
00067     m_submit = new KPushButton("Submit", line);
00068     connect( m_reset, SIGNAL( clicked() ), m_dataForm, SLOT( resetView() ) );
00069     connect( m_submit, SIGNAL( clicked() ), m_dataForm, SLOT( updateData() ) );
00070     line->setSizePolicy( QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed ) );
00071 }
00072 
00073 void AutoForm::slotMapChanged( )
00074 {
00075     emit mapChanged();
00076 }
00077 
00078 void AutoForm::viewportResizeEvent( QResizeEvent * ev )
00079 {
00080     QSize viewSize = ev->size();
00081     QSize newSize = m_mainBox->size();
00082     if( m_mainBox->minimumSizeHint().height() < viewSize.height() )
00083         newSize.setHeight(viewSize.height());
00084     if( m_mainBox->minimumSizeHint().width() < viewSize.width() )
00085         newSize.setWidth(viewSize.width());
00086     m_mainBox->resize(newSize);
00087 }
00088 
00089 
00090 #include "autoform.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