29 #include "invocationdialog.h"
30 #include <QVBoxLayout>
31 #include <QHBoxLayout>
34 #include <QRadioButton>
35 #include <QButtonGroup>
36 #include <QPushButton>
40 #include <arcs/arcsfactory.h>
41 #include "stringlistvalidator.h"
42 #include <QMessageBox>
44 InvocationDialog::InvocationDialog(QString portName, QWidget *parent) :
49 QString paramLiteralType = portName.section(
'(',1,1).section(
')',0,0).section(
',',0,0);
54 if (actualType.isEmpty())
55 cbType->setCurrentIndex(cbType->findText(
"void"));
57 cbType->setCurrentIndex(cbType->findText(actualType));
63 void InvocationDialog::prepareDialog()
66 setLayout(vlayout =
new QVBoxLayout(
this));
68 layout()->addWidget(
new QLabel(
"Select an invocation type"));
69 layout()->addWidget(cbType =
new QComboBox(
this));
70 layout()->addWidget(
new QLabel(
"Invoke at:"));
74 QRadioButton* rbCleanup;
76 bgType =
new QButtonGroup(
this);
77 layout()->addWidget(rbPre =
new QRadioButton(
"Pre-connection",
this));
78 layout()->addWidget(rbPost =
new QRadioButton(
"Post-connection",
this));
79 layout()->addWidget(rbCleanup =
new QRadioButton(
"Cleanup stage",
this));
81 bgType->addButton(rbPre,GraphicsInvocationItem::Pre);
82 bgType->addButton(rbPost,GraphicsInvocationItem::Post);
83 bgType->addButton(rbCleanup,GraphicsInvocationItem::Cleanup);
84 rbPre->setChecked(
true);
86 layout()->addWidget(
new QLabel(
"Invocation value:"));
87 layout()->addWidget(teValue =
new QTextEdit(
this));
90 QHBoxLayout* hlayout =
new QHBoxLayout(
this);
91 vlayout->addLayout(hlayout);
93 QPushButton* ok =
new QPushButton(
"Ok",
this);
94 QPushButton* cancel =
new QPushButton(
"Cancel",
this);
96 connect(ok,SIGNAL(clicked()),SLOT(accept()));
97 connect(cancel,SIGNAL(clicked()),SLOT(reject()));
100 hlayout->addWidget(ok);
101 hlayout->addWidget(cancel);
106 cbType->addItems(arcsTypes);
107 cbType->setEditable(
true);
113 void InvocationDialog::accept()
120 if (cbType->currentText() !=
"void")
125 QMessageBox::critical(
this,
"Type parsing error",
126 "Parsing the text \""+teValue->toPlainText()+
"\" to perform an invocation of type \""+
127 cbType->currentText()+
"\" has failed.",QMessageBox::Ok,QMessageBox::NoButton);
QString getVariantType(QVariant var)
Returns the type of a QVariant.
QString getInternalType(QString s)
static ARCSFactory * getInstance()
Returns the instance of the singleton ARCSFactory.
QVariant dataDeserialize(QString type, QString representation)
Deserialize data from their string representation.
QStringList getTypeNames()
Returns the names of the types currently stored.