00001
00002
00003 #include "VisFramework/VisFrameworkBase/interface/VisParamEditor.h"
00004 #include "VisFramework/VisFrameworkBase/interface/VisConfiguration.h"
00005 #include <qvariant.h>
00006 #include <qlabel.h>
00007 #include <qlineedit.h>
00008 #include <qpushbutton.h>
00009 #include <qlayout.h>
00010 #include <qtooltip.h>
00011 #include <qwhatsthis.h>
00012 #include <qmessagebox.h>
00013
00014 #include <string>
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 VisParamEditor::VisParamEditor (IgState *state, QWidget *parent, const char *name, WFlags fl)
00032 : QWidget (parent, name, fl),
00033 m_state (state)
00034 {
00035 if (!name)
00036 setName ("VisParamEditor");
00037 resize (506, 184);
00038 setCaption (trUtf8 ("Edit Configurable Parameter"));
00039 paramEditorLayout = new QVBoxLayout (this, 11, 6, "paramEditorLayout");
00040
00041 peLayout = new QVBoxLayout (0, 0, 6, "peLayout");
00042
00043 peNameLbl = new QLabel (this, "peNameLbl");
00044 peNameLbl->setText (trUtf8 ("Name"));
00045 peLayout->addWidget (peNameLbl);
00046
00047 peNameStr = new QLineEdit (this, "peNameStr");
00048 peLayout->addWidget (peNameStr);
00049
00050 peValueLbl = new QLabel (this, "peValueLbl");
00051 peValueLbl->setText (trUtf8 ("Value"));
00052 peLayout->addWidget (peValueLbl);
00053
00054 peValueStr = new QLineEdit (this, "peValueStr");
00055 peLayout->addWidget (peValueStr);
00056
00057 peBtnLayout = new QHBoxLayout (0, 0, 6, "peBtnLayout");
00058
00059 peHelpBtn = new QPushButton (this, "peHelpBtn");
00060 peHelpBtn->setText (trUtf8 ("Help"));
00061 peBtnLayout->addWidget (peHelpBtn);
00062
00063 peApplyBtn = new QPushButton (this, "peApplyBtn");
00064 peApplyBtn->setEnabled (false);
00065 peApplyBtn->setText (trUtf8 ("Apply"));
00066 peBtnLayout->addWidget (peApplyBtn);
00067
00068 peOkBtn = new QPushButton (this, "peOkBtn");
00069 peOkBtn->setText (trUtf8 ("OK"));
00070 peOkBtn->setOn (false);
00071 peOkBtn->setDefault (true);
00072 peBtnLayout->addWidget (peOkBtn);
00073
00074 peCancelBtn = new QPushButton (this, "peCancelBtn");
00075 peCancelBtn->setText (trUtf8 ("Cancel"));
00076 peBtnLayout->addWidget (peCancelBtn);
00077 peLayout->addLayout (peBtnLayout);
00078 paramEditorLayout->addLayout (peLayout);
00079
00080
00081 connect (peHelpBtn, SIGNAL (clicked ()), this, SLOT (peHelpBtn_clicked ()));
00082 connect (peApplyBtn, SIGNAL (clicked ()), this, SLOT (peApplyBtn_clicked ()));
00083 connect (peOkBtn, SIGNAL (clicked ()), this, SLOT (peOkBtn_clicked ()));
00084 connect (peCancelBtn, SIGNAL (clicked ()), this, SLOT (peCancelBtn_clicked ()));
00085 connect (peNameStr, SIGNAL (textChanged (const QString&)), this, SLOT (peNameStr_textChanged (const QString&)));
00086 connect (peNameStr, SIGNAL (returnPressed ()), this, SLOT (peNameStr_returnPressed ()));
00087 connect (peValueStr, SIGNAL (returnPressed ()), this, SLOT (peValueStr_returnPressed ()));
00088 connect (peValueStr, SIGNAL (textChanged (const QString&)), this, SLOT (peValueStr_textChanged (const QString&)));
00089 }
00090
00091
00092
00093
00094 VisParamEditor::~VisParamEditor()
00095 {
00096
00097 }
00098
00102 void
00103 VisParamEditor::peHelpBtn_clicked ()
00104 {
00105 QMessageBox::about (this, "Configurable Parameter Editor",
00106 "Visualization configurable parameters editor\n"
00107 "Copyright 2007 CMS\n");
00108 }
00109
00113 void
00114 VisParamEditor::peApplyBtn_clicked ()
00115 {
00116 if (peApplyBtn->isEnabled ())
00117 {
00118 std::string name (peNameStr->text ().latin1 ());
00119 std::string value (peValueStr->text ().latin1 ());
00120 if (!name.empty ()) VisConfiguration::get (m_state)->modify (name, value);
00121 else QMessageBox::warning (this, "Warning: Empty name",
00122 "Empty name cannot be set!\n"
00123 "Please, change the name\n"
00124 "to something meaningful.");
00125 peApplyBtn->setEnabled (false);
00126 }
00127 }
00128
00133 void
00134 VisParamEditor::peOkBtn_clicked ()
00135 {
00136 peApplyBtn_clicked ();
00137 this->close ();
00138 }
00139
00144 void
00145 VisParamEditor::peCancelBtn_clicked ()
00146 {
00147 this->close ();
00148 }
00149
00153 void
00154 VisParamEditor::peNameStr_textChanged (const QString &)
00155 {
00156 peApplyBtn->setEnabled (true);
00157 }
00158
00163 void
00164 VisParamEditor::peNameStr_returnPressed ()
00165 {
00166 peApplyBtn->setEnabled (true);
00167 peApplyBtn_clicked ();
00168 }
00169
00174 void
00175 VisParamEditor::peValueStr_returnPressed ()
00176 {
00177 peApplyBtn->setEnabled (true);
00178 peApplyBtn_clicked ();
00179 }
00180
00184 void
00185 VisParamEditor::peValueStr_textChanged (const QString&)
00186 {
00187 peApplyBtn->setEnabled (true);
00188 }