arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

FieldProperties.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     6-20-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 /// FieldProperties.cpp
00019 ///  simianUI
00020 
00021 
00022 #include "FieldProperties.h"
00023 #include <qlabel.h>
00024 #include <string>
00025 #include <qlayout.h>
00026 #include <qlineedit.h>
00027 #include <qcheckbox.h>
00028 #include <qpushbutton.h>
00029 #include <iostream>
00030 
00031 using namespace std;
00032 
00033 FieldProperties::FieldProperties(VolFieldSP vf, QWidget *parent, const char *name, WFlags wf)
00034 : QWidget(parent,name,wf), _vf(vf)
00035 {
00036    confFieldProps();
00037 }
00038 
00039 //////////////////////////////////////////////////////////////////////////
00040 //////////////////////////////////////////////////////////////////////////
00041 /// Public Slots
00042 //////////////////////////////////////////////////////////////////////////
00043 //////////////////////////////////////////////////////////////////////////
00044 
00045 //////////////////////////////////////////////////////////////////////////
00046 /// set name
00047 //////////////////////////////////////////////////////////////////////////
00048 void FieldProperties::setName(const QString &name)
00049 {
00050    if(_vf.isNull()) return;
00051    if(name.isEmpty())
00052    {
00053       _vf->setName("");
00054       return;
00055    }
00056 
00057    _vf->setName(name.ascii());
00058    _vf->setChanged();
00059 }
00060 
00061 //////////////////////////////////////////////////////////////////////////
00062 /// set Active
00063 //////////////////////////////////////////////////////////////////////////
00064 void FieldProperties::setActive(bool onoff)
00065 {
00066    if(_vf.isNull()) return;
00067    _vf->setActive(onoff);
00068    _vf->setChanged();
00069    _vf->setUpdate(true);
00070 }
00071 
00072 void FieldProperties::showProperties(void)
00073 {
00074    cerr << "show properties not implemented" << endl;
00075 }
00076 
00077 
00078 //////////////////////////////////////////////////////////////////////////
00079 //////////////////////////////////////////////////////////////////////////
00080 /// Protected Members
00081 //////////////////////////////////////////////////////////////////////////
00082 //////////////////////////////////////////////////////////////////////////
00083 
00084 //////////////////////////////////////////////////////////////////////////
00085 /// configure
00086 //////////////////////////////////////////////////////////////////////////
00087 void FieldProperties::confFieldProps()
00088 {
00089    if(_vf.isNull())
00090    {  
00091       return;
00092    }
00093    
00094    NrroSP n = _vf->getNrro(0);
00095    if(n.isNull()) return;
00096 
00097    // Create a layout to position the widgets
00098    QHBoxLayout *topLayout = new QHBoxLayout( this, 5 );
00099    topLayout->setAlignment(Qt::AlignTop);
00100 
00101    // Create a grid layout for all the info
00102    // 2 rows, 1 column
00103    QGridLayout *grid = new QGridLayout(topLayout, 2,1);
00104 
00105    /// name
00106    QGridLayout *nameg = new QGridLayout(grid,1,2);
00107 
00108    /// label the name field
00109    nameg->addWidget( new QLabel("Field", this), 0, 0 );
00110    /// find a suitable name
00111    string name = _vf->getName();
00112    if(name.empty())
00113    {
00114       name = n->getName();
00115       if(name.empty())
00116       {
00117          name = "Un-named";
00118       }
00119    }
00120    /// let the user change the name of the field, needed for saving etc...
00121    QLineEdit *le = new QLineEdit( name.c_str(), this, "Field name");
00122    nameg->addWidget(le, 0, 1);
00123    connect(le, SIGNAL(textChanged(const QString &)), SLOT(setName(const QString &)));
00124 
00125    /// 1 row 2 columns
00126    QGridLayout *propg = new QGridLayout(grid,1,2);
00127 
00128    QCheckBox * abox = new QCheckBox(QString("Active"),this);
00129    abox->setChecked(_vf->isActive());
00130    propg->addWidget(abox,0,0);
00131    connect(abox,SIGNAL(toggel(bool)),SLOT(setActive(bool)));
00132    
00133    QPushButton *proppage = new QPushButton("Properties", this, "property button");
00134    propg->addWidget(proppage,0,1);
00135    connect(proppage,SIGNAL(pressed()),SLOT(showProperties()));
00136 
00137 }
00138 
00139 

Send questions, comments, and bug reports to:
jmk