Documentation


MFEditor.cpp

Go to the documentation of this file.
00001 #include "MFEditor.h"
00002 
00003 #include <qpushbutton.h>
00004 #include <qtextedit.h>
00005 #include <qlayout.h>
00006 #include <qobjectlist.h>
00007 
00008 #include "Fields.h"
00009 
00010 namespace X3DTK {
00011 namespace Qt{
00012 
00013 MFEditor::MFEditor( AbstractMField * multiField,
00014                     QPushButton * editButton,
00015                     QWidget* parent,
00016                     const char* name, bool modal, WFlags fl )
00017 : QDialog( parent, name, modal, fl )
00018 , multiField(multiField)
00019 {
00020     if ( !name )
00021       setName( "MFEditor" );
00022       
00023     QGridLayout * layout = new QGridLayout( this ); 
00024 
00025     textEdit = new QTextEdit( this );
00026     textEdit->setWrapPolicy( QTextEdit::AtWhiteSpace );
00027     layout->addMultiCellWidget( textEdit, 0, 0, 0, 1 );
00028 
00029     QPushButton * CancelButton = new QPushButton( this, "Cancel" );
00030     layout->addWidget( CancelButton, 1, 0 );
00031 
00032     QPushButton * OKButton = new QPushButton( this, "OK" );
00033     layout->addWidget( OKButton, 1, 1 );
00034     
00035     setCaption(multiField->name+" editor");
00036     CancelButton->setText("Cancel");
00037     OKButton->setText("OK");
00038     resize( QSize(195, 124).expandedTo(minimumSizeHint()) );
00039 
00040     // signals and slots connections
00041     connect( CancelButton, SIGNAL( released() ), this, SLOT( close() ) );
00042     connect( OKButton, SIGNAL( released() ), this, SLOT( ok() ) );
00043     connect( editButton, SIGNAL( released() ), this, SLOT( load()));
00044 }
00045 
00046 /*
00047  *  Destroys the object and frees any allocated resources
00048  */
00049 MFEditor::~MFEditor()
00050 {
00051     // no need to delete child widgets, Qt does it all for us
00052 }
00053 void MFEditor::load()
00054 {
00055     textEdit->setText(multiField->read());
00056     show();
00057 }
00058 void MFEditor::ok()
00059 {
00060     multiField->write(textEdit->text());
00061     close();
00062 }
00063 } // Qt
00064 } // X3DTK

Generated on Thu Dec 23 13:52:26 2004 by doxygen 1.3.6