38 QObject::connect(
this,SIGNAL(textChanged(
const QString &)),
this,SLOT(
redden(
void)));
47 palette.setBrush(this->foregroundRole(), QApplication::palette().color(QPalette::WindowText));
56 palette.setBrush(this->foregroundRole(), Qt::red);
62 QWidget(
MainWindow::getInstance()->centralWidget()),
Workspace::Instance(name, var, size), myname(name)
64 setWindowTitle(QString::number(
getID()) +
" " + QString::fromStdString(name));
66 QTimer *timer =
new QTimer(
this);
67 timer->setTimerType(Qt::PreciseTimer);
69 QObject::connect(timer,SIGNAL(timeout(
void)),
this,SLOT(
refresh(
void)));
79 for (std::map<QString, param_t>::iterator i =
parameter.begin(); i
82 delete i->second.str_value;
89 subWindow =
new QMdiSubWindow;
90 subWindow->setAttribute(Qt::WA_DeleteOnClose);
91 subWindow->setWindowIcon(QIcon(
"/usr/local/share/rtxi/RTXI-widget-icon.png"));
92 subWindow->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
93 subWindow->setOption(QMdiSubWindow::RubberBandResize,
true);
94 subWindow->setOption(QMdiSubWindow::RubberBandMove,
true);
101 QScrollArea *gridArea =
new QScrollArea;
102 gridBox =
new QWidget;
103 gridArea->setWidget(gridBox);
104 gridArea->ensureWidgetVisible(gridBox, 0, 0);
105 gridArea->setWidgetResizable(
true);
106 QGridLayout *gridLayout =
new QGridLayout;
108 size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
109 for (
int i = 0; i < size; i++)
115 param.
label =
new QLabel(QString::fromStdString(var[i].name), gridBox);
120 param.
label->setToolTip(QString::fromStdString(var[i].description));
121 param.
edit->setToolTip(QString::fromStdString(var[i].description));
125 if (var[i].flags &
DOUBLE)
127 param.
edit->setValidator(
new QDoubleValidator(param.
edit));
132 QIntValidator *validator =
new QIntValidator(param.
edit);
133 param.
edit->setValidator(validator);
134 validator->setBottom(0);
137 else if (var[i].flags &
INTEGER)
139 param.
edit->setValidator(
new QIntValidator(param.
edit));
144 param.
index = nparam++;
147 else if (var[i].flags &
STATE)
149 param.
edit->setReadOnly(
true);
150 palette.setBrush(param.
edit->foregroundRole(), Qt::darkGray);
153 param.
index = nstate++;
155 else if (var[i].flags &
EVENT)
157 param.
edit->setReadOnly(
true);
159 param.
index = nevent++;
161 else if (var[i].flags &
COMMENT)
164 param.
index = ncomment++;
166 parameter[QString::fromStdString(var[i].name)] = param;
171 buttonGroup =
new QGroupBox;
172 QHBoxLayout *buttonLayout =
new QHBoxLayout;
189 gridBox->setLayout(gridLayout);
190 buttonGroup->setLayout(buttonLayout);
193 layout->addWidget(gridArea, 1, 0);
196 layout->addWidget(buttonGroup, 10, 0);
200 subWindow->setWidget(
this);
210 subWindow->adjustSize();
227 for (std::map<QString, param_t>::iterator i =
parameter.begin(); i!=
parameter.end(); ++i)
231 i->second.edit->setText(QString::number(
getValue(i->second.type, i->second.index)));
232 palette.setBrush(i->second.edit->foregroundRole(), Qt::darkGray);
233 i->second.edit->setPalette(
palette);
235 else if ((i->second.type &
PARAMETER) && !i->second.edit->isModified()
236 && i->second.edit->text() != *i->second.str_value)
238 i->second.edit->setText(*i->second.str_value);
240 else if ((i->second.type &
COMMENT) && !i->second.edit->isModified()
257 for (std::map<QString, param_t>::iterator i =
parameter.begin(); i !=
parameter.end(); ++i)
260 QByteArray textData = i->second.edit->text().toLatin1();
261 const char *text = textData.constData();
268 for (std::map<QString, param_t>::iterator i =
parameter.begin(); i !=
parameter.end(); ++i)
269 i->second.edit->blacken();
274 std::map<QString, param_t>::iterator n =
parameter.find(name);
282 std::map<QString, param_t>::iterator n =
parameter.find(name);
285 n->second.edit->setText(comment);
286 QByteArray textData = comment.toLatin1();
287 const char *text = textData.constData();
294 std::map<QString, param_t>::iterator n =
parameter.find(name);
297 *n->second.str_value = n->second.edit->text();
298 setValue(n->second.index, n->second.edit->text().toDouble());
299 return n->second.edit->text();
306 std::map<QString, param_t>::iterator n =
parameter.find(name);
309 n->second.edit->setText(QString::number(value));
310 *n->second.str_value = n->second.edit->text();
311 setValue(n->second.index, n->second.edit->text().toDouble());
317 std::map<QString, param_t>::iterator n =
parameter.find(name);
320 n->second.edit->setText(value);
321 *n->second.str_value = n->second.edit->text();
322 setValue(n->second.index, n->second.edit->text().toDouble());
328 std::map<QString, param_t>::iterator n =
parameter.find(name);
331 setData(Workspace::STATE, n->second.index, &ref);
332 n->second.edit->setText(QString::number(ref));
338 std::map<QString, param_t>::iterator n =
parameter.find(name);
341 setData(Workspace::EVENT, n->second.index, &ref);
342 n->second.edit->setText(QString::number(ref));
360 setWindowTitle(QString::number(
getID()) +
" " + QString::fromStdString(myname));
365 for (std::map<QString, param_t>::iterator i =
parameter.begin(); i
367 i->second.edit->setText(QString::fromStdString(s.
loadString((i->first).toStdString())));
388 else if (isMinimized())
391 QPoint pos = parentWidget()->pos();
397 for (std::map<QString, param_t>::const_iterator i =
parameter.begin(); i
399 s.
saveString((i->first).toStdString(), (i->second.edit->text()).toStdString());
402 void DefaultGUIModel::receiveEvent(
const Event::Object *event)
413 ERROR_MSG(
"DefaultGUIModel::receiveEvent : model unpaused during a period update\n");