Exemplo n.º 1
0
void KeyOptionView::_createItem() {
	myWidget = new QWidget(myTab);
	QGridLayout *layout = new QGridLayout(myWidget, 2, 2, 0, 10);
	myKeyButton = new KeyButton(*this);
	layout->addMultiCellWidget(myKeyButton, 0, 0, 0, 1);
	myLabel = new QLabel(myWidget);
	myLabel->setTextFormat(QObject::PlainText);
	QFont f = qApp->font();
	f.setPointSize(14);
	myLabel->setFont(f);
#if 0
    QSizePolicy pol = myLabel->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myLabel->setSizePolicy(pol);
    myLabel->setLineWidth(40);
#endif
	layout->addWidget(myLabel, 1, 0);
	myComboBox = new ZComboBox(myWidget, "ZComboBox", true);
#if 0
    pol = myComboBox->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myComboBox->setSizePolicy(pol);
#endif
	const std::vector<std::string> &actions = ((ZLKeyOptionEntry*)myOption)->actionNames();
	int index = 0;
	for (std::vector<std::string>::const_iterator it = actions.begin(); it != actions.end(); ++it, ++index) {
	    myComboBox->insertItem(it->c_str(), index);
	}
	connect(myComboBox, SIGNAL(activated(int)), this, SLOT(onValueChange(int)));
	layout->addWidget(myComboBox, 1, 1);
	myTab->addItem(myWidget, myRow, myFromColumn, myToColumn, AlignLeft);
}
Exemplo n.º 2
0
void KeyButton::keyPressEvent(QKeyEvent *keyEvent) {
	std::string keyText = QKeyUtil::keyName(keyEvent);
	if (keyEvent->key() == Key_Return) {
	    grabKeyboard();
	    return;
	}
	if (keyEvent->key() == Key_Up ||
	    keyEvent->key() == Key_Down) {
	    clearFocus();
	    releaseKeyboard();
	    return;
	}

	if (!keyText.empty()) {
		myKeyView.myCurrentKey = keyText;
		myKeyView.myLabel->setText("Action For " + QString::fromUtf8(keyText.c_str()));
		myKeyView.myLabel->show();
#if 0
    QSizePolicy pol = myKeyView.myLabel->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myKeyView.myLabel->setSizePolicy(pol);
    myKeyView.myLabel->setLineWidth(80);
    pol = myKeyView.myComboBox->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myKeyView.myComboBox->setSizePolicy(pol);
#endif
		myKeyView.myComboBox->setCurrentItem(((ZLKeyOptionEntry*)myKeyView.myOption)->actionIndex(keyText));
		myKeyView.myComboBox->show();
	}
}
Exemplo n.º 3
0
void SpinOptionView::_createItem() {
	myLabel = new QLabel(myOption->name().c_str(), myTab);
	char tmp[64];
	snprintf(tmp, sizeof(tmp)-1, "%d", ((ZLSpinOptionEntry*)myOption)->maxValue()); 
	myNumPick = new ZNumPicker(strlen(tmp), myTab, NULL, 0, (ZSkinService::WidgetClsID)4);
	myNumPick->setMinValue(((ZLSpinOptionEntry*)myOption)->minValue());
	myNumPick->setMaxValue(((ZLSpinOptionEntry*)myOption)->maxValue());
	myNumPick->setLineStep(((ZLSpinOptionEntry*)myOption)->step());
	myNumPick->setValue(((ZLSpinOptionEntry*)myOption)->initialValue());

	QFont f = qApp->font();
	f.setPointSize(14);
	myLabel->setFont(f);
#if 0
    QSizePolicy pol = myNumPick->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    pol.setVerData(QSizePolicy::Fixed);
    myNumPick->setSizePolicy(pol);
    pol = myLabel->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myLabel->setSizePolicy(pol);
    myLabel->setLineWidth(80);
#endif
	int width = myToColumn - myFromColumn + 1;
	myTab->addItem(myLabel, myRow, myFromColumn, myFromColumn + (width * 2) / 3 - 1, Qt::AlignLeft);
	myTab->addItem(myNumPick, myRow, myFromColumn + (width * 2) / 3, myToColumn-1, Qt::AlignLeft);
}
Exemplo n.º 4
0
/*!
  \return MinimumExpanding/Fixed for a horizontal orientation;
          Fixed/MinimumExpanding for a vertical orientation.
*/
QSizePolicy QwtSlider::sizePolicy() const
{
    QSizePolicy sp;
    if ( orientation() == Qt::Horizontal )
    {
        sp.setHorData( QSizePolicy::MinimumExpanding );
        sp.setVerData( QSizePolicy::Fixed );
    }
    else
    {
        sp.setHorData( QSizePolicy::Fixed );
        sp.setVerData( QSizePolicy::MinimumExpanding );
    }
    return sp;
}
Exemplo n.º 5
0
void
SizePolicyCustomProperty::setValue(const QVariant &value, bool rememberOldValue)
{
	if(!m_property)
		return;

	if(m_property->parent()) {
		QSizePolicy v = m_property->parent()->value().toSizePolicy();

		if(m_property->type() == SizePolicy_HorData)
			v.setHorData(QSizePolicy::SizeType(value.toInt()));
		else if(m_property->type() == SizePolicy_VerData)
			v.setVerData(QSizePolicy::SizeType(value.toInt()));
		else if(m_property->type() == SizePolicy_HorStretch)
			v.setHorStretch(value.toInt());
		else if(m_property->type() == SizePolicy_VerStretch)
			v.setVerStretch(value.toInt());

		m_property->parent()->setValue(v, true, false);
	}
	else {
		QSizePolicy v = value.toSizePolicy();
		m_property->child("hSizeType")->setValue(v.horData(), rememberOldValue, false);
		m_property->child("vSizeType")->setValue(v.verData(), rememberOldValue, false);
		m_property->child("hStretch")->setValue(v.horStretch(), rememberOldValue, false);
		m_property->child("vStretch")->setValue(v.verStretch(), rememberOldValue, false);
	}
}
Exemplo n.º 6
0
ZLDialogContent &QOptionsDialog::createTab(const std::string &name) {
//    QScrollView *sv = new QScrollView(myTabWidget, "QScrollView", 0);
    ZScrollView *sv = new ZScrollView(myTabWidget, NULL, 0/*, (ZSkinService::WidgetClsID)4*/);
	sv->setResizePolicy(QScrollView::AutoOneFit );
	sv->setFrameStyle( QFrame::NoFrame );
#if 0
	QSizePolicy pol = sv->sizePolicy();
	pol.setHorData(QSizePolicy::Fixed);
	sv->setSizePolicy(pol);
	QRect rect = sv->contentsRect();
	rect.setWidth(240);
	sv->setFrameRect(rect);
	sv->setLineWidth(240);
#endif
	sv->setVScrollBarMode(QScrollView::AlwaysOff);
	sv->setHScrollBarMode(QScrollView::AlwaysOff);

	QOptionsDialogTab *tab = new QOptionsDialogTab(sv->viewport());
	sv->addChild(tab, 0, 0);
	myTabWidget->insertTab(sv, name.c_str());
	menu->insertItem(QString(name.c_str()), NULL, NULL, true, tabno, tabno);
	myTabs.append(tab);
	myTabNames.push_back(name);
	tabno++;
	return *tab;
}
Exemplo n.º 7
0
//! \return MinimumExpanding/MinimumExpanding
QSizePolicy QwtPlot::sizePolicy() const
{
    QSizePolicy sp;
    sp.setHorData( QSizePolicy::MinimumExpanding );
    sp.setVerData( QSizePolicy::MinimumExpanding );
    return sp;
}
Exemplo n.º 8
0
void StringOptionView::_createItem() {
	myLabel = new QLabel(myOption->name().c_str(), myTab);
	myLineEdit = new ZLineEdit(myTab, "ZLineEdit", ZSkinService::NONE);
	QFont f = qApp->font();
	f.setPointSize(14);
	myLineEdit->setFont(f);
	myLineEdit->setText(QString::fromUtf8(((ZLStringOptionEntry*)myOption)->initialValue().c_str()));
	myLineEdit->cursorLeft(false);
	f = qApp->font();
	f.setPointSize(14);
	myLabel->setFont(f);
#if 0
    QRect rect;
    rect = myLineEdit->getContentRect();
    rect.setWidth(160);
    myLineEdit->setGeometry(rect);
    QSizePolicy pol = myLineEdit->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myLineEdit->setSizePolicy(pol);
    myLabel->setLineWidth(80);
#endif
	int width = myToColumn - myFromColumn + 1;
	myTab->addItem(myLabel, myRow, myFromColumn, myFromColumn + width / 4 - 1, Qt::AlignLeft);
	myTab->addItem(myLineEdit, myRow, myFromColumn + width / 4, myToColumn, Qt::AlignLeft);
}
Exemplo n.º 9
0
QSizePolicy PictButton::sizePolicy() const
{
    QSizePolicy p = QToolButton::sizePolicy();
    QToolBar *bar = static_cast<QToolBar*>(parent());
    if (bar->orientation() == Vertical){
        p.setVerData(QSizePolicy::Expanding);
    }else{
        p.setHorData(QSizePolicy::Expanding);
    }
    return p;
}
Exemplo n.º 10
0
void ParameterSetDialog::init_uml_tab()
{
    bool visit = !hasOkButton();

    BrowserParameterSet * bn =
        (BrowserParameterSet *) data->get_browser_node();
    Q3VBox * vbox;
    Q3Grid * grid = new Q3Grid(2, this);

    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);

    new QLabel(TR("stereotype : "), grid);
    edstereotype = new Q3ComboBox(TRUE, grid);
    edstereotype->insertItem(toUnicode(data->get_stereotype()));

    if (! visit) {
        edstereotype->insertStringList(BrowserParameterSet::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlParameterSet));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    vbox = new Q3VBox(grid);
    new QLabel(TR("description :"), vbox);

    if (! visit) {
        connect(new SmallPushButton(TR("Editor"), vbox), SIGNAL(clicked()),
                this, SLOT(edit_description()));
    }

    comment = new MultiLineEdit(grid);
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    QFont font = comment->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    comment->setFont(font);

    addTab(grid, "Uml");
}
Exemplo n.º 11
0
void ComponentDialog::init_l_tab(Q3VBox *& page, Q3ComboBox *& stereotypefilter,
                                 void (ComponentDialog::* filteractivated)(const QString & st),
                                 const char * slt,
                                 const char * add_slt, const char * remove_slt,
                                 Q3ListBox *& lb_available, Q3ListBox *& lb,
                                 const Q3ValueList<BrowserClass *> & cls,
                                 const char * lbl)
{
    bool visit = !hasOkButton();
    Q3HBox * hbox;
    Q3VBox * vbox;
    QPushButton * button;

    page = new Q3VBox(this);

    if (!visit) {
        hbox = new Q3HBox(page);
        hbox->setMargin(5);
        new QLabel(TR("Stereotype filtering  "), hbox);
        stereotypefilter = new Q3ComboBox(TRUE, hbox);
        stereotypefilter->setAutoCompletion(completion());
        stereotypefilter->insertItem("");
        stereotypefilter->insertStringList(BrowserClass::default_stereotypes());
        stereotypefilter->insertStringList(ProfiledStereotypes::defaults(UmlComponent));
        stereotypefilter->setCurrentItem(0);
        QSizePolicy sp = stereotypefilter->sizePolicy();
        sp.setHorData(QSizePolicy::Expanding);
        stereotypefilter->setSizePolicy(sp);
        connect(stereotypefilter, SIGNAL(activated(const QString &)),
                this, slt);

        hbox = new Q3HBox(page);
        vbox = new Q3VBox(hbox);
        vbox->setMargin(5);
        (new QLabel(TR("Available classes"), vbox))->setAlignment(Qt::AlignCenter);
        lb_available = new Q3ListBox(vbox);
        lb_available->setSelectionMode(Q3ListBox::Multi);

        vbox = new Q3VBox(hbox);
        vbox->setMargin(5);
        (new QLabel("", vbox))->setScaledContents(TRUE);
        button = new QPushButton(vbox);
        button->setPixmap(*rightPixmap);
        connect(button, SIGNAL(clicked()), this, add_slt);
        (new QLabel("", vbox))->setScaledContents(TRUE);
        button = new QPushButton(vbox);
        button->setPixmap(*leftPixmap);
        connect(button, SIGNAL(clicked()), this, remove_slt);
        (new QLabel("", vbox))->setScaledContents(TRUE);
        vbox = new Q3VBox(hbox);
    }
Exemplo n.º 12
0
/*!
  \brief Initializes a QwtPlot instance
  \param title Title text
 */
void QwtPlot::initPlot(const QString &title)
{
    d_layout = new QwtPlotLayout;

    d_curves = new QwtCurveDict;
    d_markers = new QwtMarkerDict;

    d_autoReplot = FALSE;

    d_lblTitle = new QLabel(title, this);
    d_lblTitle->setFont(QFont(fontInfo().family(), 14, QFont::Bold));
    d_lblTitle->setAlignment(Qt::AlignCenter|Qt::WordBreak|Qt::ExpandTabs);

    d_legend = new QwtLegend(this);
    d_autoLegend = FALSE;

    d_scale[yLeft] = new QwtScale(QwtScale::Left, this, "yLeft");
    d_scale[yRight] = new QwtScale(QwtScale::Right, this, "yRight");
    d_scale[xTop] = new QwtScale(QwtScale::Top, this, "xTop");
    d_scale[xBottom] = new QwtScale(QwtScale::Bottom, this, "xBottom");

    initAxes();

    d_grid = new QwtPlotGrid(this);
    d_grid->setPen(QPen(Qt::black, 0, Qt::DotLine));
    d_grid->enableXMin(FALSE);
    d_grid->enableYMin(FALSE);
    d_grid->setAxis(xBottom, yLeft);

    d_canvas = new QwtPlotCanvas(this);
    d_canvas->setFrameStyle(QFrame::Panel|QFrame::Sunken);
    d_canvas->setLineWidth(2);
    d_canvas->setMidLineWidth(0);

#ifndef QWT_NO_COMPAT
    connect(d_canvas, SIGNAL(mousePressed(const QMouseEvent &)),
        this, SIGNAL(plotMousePressed(const QMouseEvent &)));
    connect(d_canvas, SIGNAL(mouseMoved(const QMouseEvent &)),
        this, SIGNAL(plotMouseMoved(const QMouseEvent &)));
    connect(d_canvas, SIGNAL(mouseReleased(const QMouseEvent &)),
        this, SIGNAL(plotMouseReleased(const QMouseEvent &)));
#endif

    updateTabOrder();

    QSizePolicy sp;
    sp.setHorData( QSizePolicy::MinimumExpanding );
    sp.setVerData( QSizePolicy::MinimumExpanding );
    setSizePolicy(sp);
}
Exemplo n.º 13
0
void ComboOptionView::_createItem() {
	myLabel = new QLabel(myOption->name().c_str(), myTab);
	myComboBox = new ZComboBox(myTab, "ZComboBox", true);
	const std::vector<std::string> &values = ((ZLComboOptionEntry*)myOption)->values();
	const std::string &initial = ((ZLComboOptionEntry*)myOption)->initialValue();
	int selectedIndex = -1;
	int index = 0;
	for (std::vector<std::string>::const_iterator it = values.begin(); it != values.end(); ++it, ++index) {
	    myComboBox->insertItem(QString(it->c_str()), index);
	    if (*it == initial) {
		selectedIndex = index;
	    }
	}
	QFont f = qApp->font();
	f.setPointSize(14);
	myLabel->setFont(f);
#if 0
	QRect rect = myComboBox->getContentRect();
	rect.setWidth(80);
	myComboBox->setGeometry(rect);
    QSizePolicy pol = myComboBox->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myComboBox->setSizePolicy(pol);
    pol = myLabel->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myLabel->setSizePolicy(pol);
    myLabel->setLineWidth(80);
#endif
	connect(myComboBox, SIGNAL(activated(int)), this, SLOT(onValueChange(int)));
	if (selectedIndex >= 0) {
		myComboBox->setCurrentItem(selectedIndex);
	}
	int width = myToColumn - myFromColumn + 1;
	myTab->addItem(myLabel, myRow, myFromColumn, myFromColumn + width * 2 /3  - 1, Qt::AlignLeft);
	myTab->addItem(myComboBox, myRow, myToColumn - width * 2 / 3, myToColumn, Qt::AlignRight);
}
Exemplo n.º 14
0
void BooleanOptionView::_createItem() {
    myCheckBox = new ZCheckBox(QString(myOption->name().c_str()).replace(QRegExp("[\\n\\r?/<>&\\\\:\"*]"),""), myTab, "ZCheckBox");
#if 0
    QRect rect;
    rect = myCheckBox->getContentRect();
    rect.setWidth(100);
    myCheckBox->setGeometry(rect);
    QSizePolicy pol = myCheckBox->sizePolicy();
    pol.setHorData(QSizePolicy::Fixed);
    myCheckBox->setSizePolicy(pol);
#endif
	QFont f = qApp->font();
	f.setPointSize(14);
	myCheckBox->setFont(f);
	if (((ZLBooleanOptionEntry*)myOption)->initialState())
	    myCheckBox->setState(ZBaseButton::on);
	myTab->addItem(myCheckBox, myRow, myFromColumn, myToColumn, Qt::AlignLeft);
	connect(myCheckBox, SIGNAL(toggled(bool)), this, SLOT(onValueChange(bool)));
}
Exemplo n.º 15
0
QOptionsDialogTab::QOptionsDialogTab(QWidget *parent) : QWidget(parent) {
	int space = 10;
	switch (ZLDeviceInfo::screenSize()) {
		case ZLDeviceInfo::SIZE_640x480:
			space = 10;
			break;
		default:
			space = 3;
			break;
	}
	myLayout = new QGridLayout(this, -1, 12, space, space);
	myRowCounter = 0;

#if 0
	QSizePolicy pol = this->sizePolicy();
	pol.setHorData(QSizePolicy::Fixed);
	this->setSizePolicy(pol);
	QRect rect = QRect(0, 0, 240, 320);
	myLayout->setGeometry(rect);
	myLayout->setColStretch(12, 12);
#endif
}
Exemplo n.º 16
0
Dialog::Dialog(UmlArtifact * art, const QCString & path_exe, QCString & pro, QCString & target, QCString & tmplt, QCString & config, QCString & defines, QCString & includepath, QCString & dependpath, QCString & objectsdir, QCString & footer)
  : QDialog(0, 0, TRUE), _art(art), _pro(pro), _target(target), _tmplt(tmplt),
    _config(config), _defines(defines), _includepath(includepath), _dependpath(dependpath),
    _objectsdir(objectsdir), _footer(footer) {
  QDir d(path_exe);
  QVBoxLayout * vbox = new QVBoxLayout(this);
  QGrid * grid = new QGrid(2, this);
  QHBox * htab;
  int index;
  
  vbox->addWidget(grid);
  vbox->setMargin(5);
  
  new QLabel(".pro file : ", grid);
  htab = new QHBox(grid);
  edpro = new QLineEdit(htab);
  edpro->setText(d.absFilePath(pro));

  new QLabel(" ", htab);
  browsepro = new SmallPushButton("browse", htab);
  connect(browsepro, SIGNAL(clicked ()), this, SLOT(browse_pro()));
  
  new QLabel("target : ", grid);
  htab = new QHBox(grid);
  edtarget = new QLineEdit(htab);
  edtarget->setText(d.absFilePath(target));
  new QLabel(" ", htab);
  browsetarget = new SmallPushButton("browse", htab);
  connect(browsetarget, SIGNAL(clicked ()), this, SLOT(browse_target()));

  new QLabel("template : ", grid);
  cbtemplate = new QComboBox(TRUE, grid);
  
  static const char * templates[] = { "app", "lib", "subdirs" };
  bool find = FALSE;

  for (index = 0; index != sizeof(templates)/sizeof(*templates); index += 1) {
    cbtemplate->insertItem(templates[index]);
    if (tmplt == templates[index]) {
      cbtemplate->setCurrentItem(index);
      find = TRUE;
    }
  }
  if (! find) {
    cbtemplate->insertItem((QString) tmplt);
    cbtemplate->setCurrentItem(index);
  }

  new QLabel("config : ", grid);
  htab = new QHBox(grid);
  cbconf[0] = new QComboBox(FALSE, htab);
  cbconf[0]->insertItem("debug");
  cbconf[0]->insertItem("release");
  
  QStringList lcnf =
    QStringList::split(" ", (const char *) config);
  QStringList::Iterator it = lcnf.begin();
  
  cbconf[0]->setCurrentItem((*it++ == "debug") ? 0 : 1);

  cbconf[1] = new QComboBox(FALSE, htab);
  cbconf[1]->insertItem("warn_on");
  cbconf[1]->insertItem("warn_off");
  cbconf[1]->setCurrentItem((*it++ == "warn_on") ? 0 : 1);
  
  QSizePolicy sp = cbconf[0]->sizePolicy();
    
  sp.setHorData(QSizePolicy::Fixed);
  cbconf[0]->setSizePolicy(sp);
  cbconf[1]->setSizePolicy(sp);
  
  new QLabel(" qt ", htab);
  it++;	// qt
  
  const char * configs[] = {
    "", "opengl", "thread", "x11", "windows",
    "console", "dll", "staticlib", 0
  };

  for (index = 2;
       index != sizeof(cbconf)/sizeof(*cbconf) - 1;
       index += 1) {
    cbconf[index] = new QComboBox(TRUE, htab);
    if (it != lcnf.end())
      cbconf[index]->insertItem(*it++);
    cbconf[index]->insertStrList(configs);
    cbconf[index]->setCurrentItem(0);
  }
  cbconf[index] = new QComboBox(TRUE, htab);
  if (it != lcnf.end()) {
    QString s = *it++;
    
    while (it != lcnf.end())
      s += " " + *it++;
    cbconf[index]->insertItem(s);
  }
  cbconf[index]->insertStrList(configs);
  cbconf[index]->setCurrentItem(0);


  new QLabel("defines : ", grid);
  eddefines = new QLineEdit(grid);
  eddefines->setText(defines);
  
  ///may be computed
  new QLabel("include paths : ", grid);
  htab = new QHBox(grid);
  edincludepath = new QLineEdit(htab);
  edincludepath->setText(includepath);
  new QLabel(" ", htab);
  computeincludepath = new SmallPushButton("compute", htab);
  connect(computeincludepath, SIGNAL(clicked ()), this, SLOT(compute_includepath()));
  
  new QLabel("depend paths : ", grid);
  eddependpath = new QLineEdit(grid);
  eddependpath->setText(dependpath);

  new QLabel("objects dir : ", grid);
  htab = new QHBox(grid);
  edobjectsdir = new QLineEdit(htab);
  edobjectsdir->setText(objectsdir);
  new QLabel(" ", htab);
  browseobjectsdir = new SmallPushButton("browse", htab);
  connect(browseobjectsdir, SIGNAL(clicked ()), this, SLOT(browse_objectsdir()));
  
  new QLabel("footer : ", grid);
  edfooter = new QMultiLineEdit(grid);
  edfooter->setText(footer);
  
  new QLabel(grid);
  new QLabel(grid);
  
  new QLabel(grid);
  htab = new QHBox(grid);
  new QLabel(htab);
  QPushButton * ok = new QPushButton("&OK", htab);
  new QLabel(htab);
  QPushButton * cancel = new QPushButton("&Cancel", htab);
  new QLabel(htab);
  QSize bs(cancel->sizeHint());
  
  ok->setDefault( TRUE );
  
  if (ok->sizeHint().width() > bs.width())
    bs.setWidth(ok->sizeHint().width());
  
  ok->setFixedSize(bs);
  cancel->setFixedSize(bs);
  
  connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
  connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
}
Exemplo n.º 17
0
FragmentDialog::FragmentDialog(const QStringList & defaults, QString & s,
                               QString & fo, BrowserNode *& d)
    : QDialog(0, "Fragment dialog", TRUE), name(s), form(fo), refer(d)
{
    setCaption(TR("Fragment dialog"));

    Q3VBoxLayout * vbox = new Q3VBoxLayout(this);
    Q3HBoxLayout * hbox;
    QLabel * lbl1;
    QLabel * lbl2;
    SmallPushButton * refer_bt;
    BrowserNode * bn;

    vbox->setMargin(5);

    hbox = new Q3HBoxLayout(vbox);
    hbox->setMargin(5);
    hbox->addWidget(lbl1 = new QLabel(TR("name : "), this));
    name_cb = new Q3ComboBox(TRUE, this);
    name_cb->insertItem(name);
    name_cb->setCurrentItem(0);
    name_cb->insertStringList(defaults);
    name_cb->setAutoCompletion(completion());
    hbox->addWidget(name_cb);

    QSizePolicy sp = name_cb->sizePolicy();

    sp.setHorData(QSizePolicy::Expanding);
    name_cb->setSizePolicy(sp);

    hbox = new Q3HBoxLayout(vbox);
    hbox->setMargin(5);
    hbox->addWidget(refer_bt = new SmallPushButton(TR("refer to : "), this));
    connect(refer_bt, SIGNAL(clicked()), this, SLOT(menu_refer()));
    diag_cb = new Q3ComboBox(FALSE, this);
    BrowserDiagram::instances(nodes, TRUE);
    diag_cb->insertItem("");

    for (bn = nodes.first(); bn != 0; bn = nodes.next())
        diag_cb->insertItem(*(bn->pixmap(0)), bn->full_name(TRUE));

    diag_cb->setCurrentItem((refer == 0)
                            ? 0
                            : nodes.findRef(refer) + 1);
    diag_cb->setSizePolicy(sp);
    hbox->addWidget(diag_cb);

    hbox = new Q3HBoxLayout(vbox);
    hbox->setMargin(5);
    hbox->addWidget(lbl2 = new QLabel(TR("arguments \n/ value : "), this));
    hbox->addWidget(ed_form = new LineEdit(this));
    ed_form->setText(form);

    same_width(lbl1, lbl2, refer_bt);

    hbox = new Q3HBoxLayout(vbox);
    hbox->setMargin(5);
    QPushButton * accept = new QPushButton(TR("&OK"), this);
    QPushButton * cancel = new QPushButton(TR("&Cancel"), this);
    QSize bs(cancel->sizeHint());

    accept->setDefault(TRUE);
    accept->setFixedSize(bs);
    cancel->setFixedSize(bs);

    hbox->addWidget(accept);
    hbox->addWidget(cancel);

    connect(accept, SIGNAL(clicked()), this, SLOT(accept()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
}
Exemplo n.º 18
0
BasicDialog::BasicDialog(BasicData * nd, QString s,
			 const QStringList & default_stereotypes,
			 QSize & sz, bool unnamed)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), data(nd), previous_size(sz) {
  nd->get_browser_node()->edit_start();
  
  if (nd->get_browser_node()->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }

  setCaption(TR(s + " dialog"));
  
  bool visit = !hasOkButton();
  
  // general tab
  
  BrowserNode * bn = data->get_browser_node();
  Q3Grid * grid = new Q3Grid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);

  if (unnamed)
    edname = 0;
  else {
    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);
  }    
  new QLabel(TR("stereotype : "), grid);
  edstereotype = new Q3ComboBox(!visit, grid);
  edstereotype->insertItem(toUnicode(data->get_stereotype()));
  if (! visit) {
    edstereotype->insertStringList(default_stereotypes);
    edstereotype->insertStringList(ProfiledStereotypes::defaults(bn->get_type()));
    edstereotype->setAutoCompletion(completion());
  }
  edstereotype->setCurrentItem(0);
  QSizePolicy sp = edstereotype->sizePolicy();
  sp.setHorData(QSizePolicy::Expanding);
  edstereotype->setSizePolicy(sp);
  
  Q3VBox * vtab = new Q3VBox(grid);
  new QLabel(TR("description :"), vtab);
  if (! visit)
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_description()));
  comment = new MultiLineEdit(grid);
  comment->setReadOnly(visit);
  comment->setText(bn->get_comment());
  QFont font = comment->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  comment->setFont(font);
  
  addTab(grid, "Uml");
  
  // USER : list key - value
  
  grid = new Q3Grid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);
  
  kvtable = new KeyValuesTable(bn, grid, visit);
  addTab(grid, TR("Properties"));
  
  open_dialog(this);
}
Exemplo n.º 19
0
AttributeDialog::AttributeDialog(AttributeData * a, bool new_st_attr)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose),
      new_in_st(new_st_attr), att(a) {
  a->browser_node->edit_start();
  
  if (a->browser_node->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }
  
  visit = !hasOkButton();
  ClassData * cld = (ClassData *) 
    ((BrowserNode *) a->browser_node->parent())->get_data();
  QString stereotype = cld->get_stereotype();
  QString lang_st;
  
  in_enum = (stereotype == "enum");
  
  lang_st = GenerationSettings::cpp_class_stereotype(stereotype);
  cpp_in_enum = in_enum || (lang_st == "enum");
  cpp_ignored = !cpp_in_enum && ((lang_st == "typedef") || (lang_st == "ignored"));
  
  lang_st = GenerationSettings::java_class_stereotype(stereotype);
  java_in_enum = in_enum || (lang_st == "enum");
  java_in_enum_pattern = !java_in_enum && (lang_st == "enum_pattern");
  java_ignored = (lang_st == "ignored");
  
  lang_st = GenerationSettings::php_class_stereotype(stereotype);
  php_in_enum = in_enum || (lang_st == "enum");
  php_ignored = !php_in_enum && (lang_st == "ignored");
  
  lang_st = GenerationSettings::python_class_stereotype(stereotype);
  python_in_enum = in_enum || (lang_st == "enum");
  python_ignored = !python_in_enum && (lang_st == "ignored");
  
  lang_st = GenerationSettings::idl_class_stereotype(stereotype);
  idl_in_enum = in_enum || (lang_st == "enum");
  idl_in_typedef = !idl_in_enum && (lang_st == "typedef");
  idl_in_struct = !idl_in_enum && ((lang_st == "struct") || (lang_st == "exception"));
  idl_in_union = !idl_in_enum && (lang_st == "union");
  
  setCaption((in_enum || java_in_enum_pattern) ? TR("Enum item dialog") : TR("Attribute dialog"));
  
  Q3Grid * grid;
  Q3HBox * htab;
  QString s;
    
  // general tab
  
  grid = new Q3Grid(2, this);
  umltab = grid;
  grid->setMargin(5);
  grid->setSpacing(5);
  
  new QLabel(TR("class : "), grid);
  new QLabel(((BrowserNode *) a->get_browser_node()->parent())->full_name(TRUE),
	     grid);
  
  new QLabel(TR("name :"), grid);
  edname = new LineEdit(a->name(), grid);
  edname->setReadOnly(visit);

  QFont font = edname->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  
  if (!java_in_enum_pattern) {
    new QLabel(TR("stereotype :"), grid);
    htab = new Q3HBox(grid);
    edstereotype = new Q3ComboBox(!visit, htab);
    edstereotype->insertItem(toUnicode(a->get_stereotype()));
    if (!visit) {
      edstereotype->insertStringList(BrowserAttribute::default_stereotypes());
      edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlAttribute));
      if (java_in_enum) {
	int n = edstereotype->count();
	
	for (attribute_st_rank = 0; attribute_st_rank != n; attribute_st_rank += 1)
	  if (edstereotype->text(attribute_st_rank) == "attribute")
	    break;
	     
	if (attribute_st_rank == n) {
	  edstereotype->insertItem("attribute");
	  n += 1;
	}
	
	for (empty_st_rank = 0; empty_st_rank != n; empty_st_rank += 1)
	  if (edstereotype->text(empty_st_rank).isEmpty())
	    break;
	     
	if (empty_st_rank == n)
	  edstereotype->insertItem("");
      }
      edstereotype->setAutoCompletion(completion());
    }
    edstereotype->setCurrentItem(0);
    
    QSizePolicy sp = edstereotype->sizePolicy();
    
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);
    
    new QLabel(TR("    multiplicity :  "), htab);
    multiplicity = new Q3ComboBox(!visit, htab);
    multiplicity->setSizePolicy(sp);
    previous_multiplicity = a->get_multiplicity();
    multiplicity->insertItem(previous_multiplicity);
    if (!visit) {
      multiplicity->insertItem("1");
      multiplicity->insertItem("0..1");
      multiplicity->insertItem("*");
      multiplicity->insertItem("1..*");
    }
    
    connect(new SmallPushButton(TR("type :"), grid), SIGNAL(clicked()),
	    this, SLOT(menu_type()));    
    edtype = new Q3ComboBox(!visit, grid);
    edtype->insertItem(a->get_type().get_full_type());
    BrowserClass::instances(nodes);
    nodes.full_names(list);        
    if (!visit) {
      QStringList l = GenerationSettings::basic_types();
      
      cld->addFormals(l);
      edtype->insertStringList(l);
      offset = edtype->count();
      edtype->insertStringList(list);
      edtype->setAutoCompletion(completion());
      view = a->browser_node->container(UmlClass);
    }
    edtype->setCurrentItem(0);
    edtype->setSizePolicy(sp);

    new QLabel(TR("initial value :"), grid);
  }
  else {
    multiplicity = 0;
    new QLabel(TR("value :"), grid);
  }
  
  htab = new Q3HBox(grid);
  edinit = new LineEdit(a->get_init_value(), htab);
  if (visit)
    edinit->setReadOnly(TRUE);
  else
    connect(new SmallPushButton(TR("Editor"), htab), SIGNAL(clicked()),
	    this, SLOT(edit_init()));

  Q3ButtonGroup * bg;
  
  if (!java_in_enum_pattern) {  
    new QLabel(grid);
    
    htab = new Q3HBox(grid);
    bg = uml_visibility.init(htab, a->get_uml_visibility(), TRUE);
    if (visit)
      bg->setEnabled(FALSE);
    
    bg = new Q3ButtonGroup(7, Qt::Horizontal, QString::null, htab);
    bg->setExclusive(FALSE);
    classattribute_cb = new QCheckBox("static", bg);
    if (a->get_isa_class_attribute())
      classattribute_cb->setChecked(TRUE);
    classattribute_cb->setDisabled(visit);
    
    volatile_cb = new QCheckBox("volatile", bg);
    if (a->isa_volatile_attribute)
      volatile_cb->setChecked(TRUE);
    volatile_cb->setDisabled(visit);
    
    constattribute_cb = new QCheckBox(TR("read-only"), bg);
    if (a->get_isa_const_attribute())
      constattribute_cb->setChecked(TRUE);
    constattribute_cb->setDisabled(visit);
    
    derived_cb = new QCheckBox(TR("derived"), bg);
    if (a->get_is_derived())
      derived_cb->setChecked(TRUE);
    derived_cb->setDisabled(visit);
    connect(derived_cb, SIGNAL(toggled(bool)), SLOT(derived_changed(bool)));
    
    derivedunion_cb = new QCheckBox("union", bg);
    if (a->get_is_derivedunion())
      derivedunion_cb->setChecked(TRUE);
    derivedunion_cb->setDisabled(visit || !derived_cb->isChecked());
    
    ordered_cb = new QCheckBox(TR("ordered"), bg);
    if (a->get_is_ordered())
      ordered_cb->setChecked(TRUE);
    ordered_cb->setDisabled(visit);
    
    unique_cb = new QCheckBox("unique", bg);
    if (a->get_is_unique())
      unique_cb->setChecked(TRUE);
    unique_cb->setDisabled(visit);
  }
  
  Q3VBox * vtab = new Q3VBox(grid);
  
  new QLabel(TR("description :"), vtab);
  if (! visit) {
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_description()));
    connect(new SmallPushButton(TR("Default"), vtab), SIGNAL(clicked()),
	    this, SLOT(default_description()));
  }
  comment = new MultiLineEdit(grid);
  comment->setReadOnly(visit);
  comment->setText(a->browser_node->get_comment());
  comment->setFont(font);
  
  vtab = new Q3VBox(grid);
  new QLabel(TR("constraint :"), vtab);
  if (! visit) {
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_constraint()));
  }
  constraint = new MultiLineEdit(grid);
  constraint->setReadOnly(visit);
  constraint->setText(a->constraint);
  constraint->setFont(font);
  
  addTab(grid, "Uml");
  
  // C++
  
  if (! cpp_ignored) {
    grid = new Q3Grid(2, this);
    cpptab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);
    
    if (!cpp_in_enum) {  
      new QLabel(TR("Visibility :"), grid);
      htab = new Q3HBox(grid);
      
      Q3ButtonGroup * bg =
	cpp_visibility.init(htab, a->get_cpp_visibility(), FALSE, 0, TR("follow uml"));
      
      if (visit)
	bg->setEnabled(FALSE);
      
      new QLabel(" ", htab);
      
      mutable_cb = new QCheckBox("mutable", htab);
      if (a->cpp_mutable)
	mutable_cb->setChecked(TRUE);
      if (visit)
	mutable_cb->setDisabled(TRUE);
      else
	connect(mutable_cb, SIGNAL(toggled(bool)), this, SLOT(cpp_update()));
    }
Exemplo n.º 20
0
PseudoStateDialog::PseudoStateDialog(PseudoStateData * ps)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), pst(ps)
{
    BrowserPseudoState * bn = (BrowserPseudoState *) pst->browser_node;
    BrowserState * refst;

    switch (bn->get_type()) {
    case EntryPointPS:
    case ExitPointPS:
        if (((BrowserNode *) bn->parent())->get_type() == UmlState) {
            refst = ((StateData *)((BrowserNode *) bn->parent())->get_data())->get_reference();
            break;
        }

        // no break
    default:
        refst = 0;
    }

    bn->edit_start();

    if (bn->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    QString s = stringify(bn->get_type());
    int index = s.find("_");

    if (index != -1)
        s.replace(index, 1, " ");

    setCaption(TR(s + " dialog"));

    visit = !hasOkButton();

    // general tab

    Q3Grid * grid = new Q3Grid(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);

    new QLabel(TR("stereotype : "), grid);
    edstereotype = new Q3ComboBox(!visit, grid);
    edstereotype->insertItem(toUnicode(pst->get_stereotype()));

    if (! visit) {
        edstereotype->insertStringList(BrowserPseudoState::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(bn->get_type()));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    if (refst != 0) {
        connect(new SmallPushButton(TR("reference :"), grid), SIGNAL(clicked()),
                this, SLOT(menu_reference()));
        edreference = new Q3ComboBox(FALSE, grid);
        edreference->setSizePolicy(sp);

        BrowserNode * ref = ((pst->get_reference() == 0) ||
                             !bn->can_reference(pst->get_reference()))
                            ? 0 : pst->get_reference();

        if (visit) {
            if (ref == 0)
                edreference->insertItem("");
            else
                edreference->insertItem(ref->full_name(TRUE));
        }
        else {
            edreference->insertItem("");
            edreference->setAutoCompletion(completion());

            Q3ListViewItem * child;
            UmlCode k = bn->get_type();

            for (child = refst->firstChild();
                 child != 0;
                 child = child->nextSibling()) {
                if (!((BrowserNode *) child)->deletedp()) {
                    UmlCode kk = ((BrowserNode *) child)->get_type();

                    if (kk == k)
                        pseudostates.append((BrowserNode *) child);
                    else if (kk == UmlRegion) {
                        for (Q3ListViewItem * schild = child->firstChild();
                             schild != 0;
                             schild = schild->nextSibling()) {
                            if (!((BrowserNode *) schild)->deletedp() &&
                                (((BrowserNode *) schild)->get_type() == k))
                                pseudostates.append((BrowserNode *) schild);
                        }
                    }
                }
            }

            pseudostates.sort();
            pseudostates.full_names(reflist);
            edreference->insertStringList(reflist);
            edreference->setCurrentItem((ref == 0)
                                        ? 0
                                        : pseudostates.indexOf(ref) + 1);
        }
    }
    else
        edreference = 0;

    Q3VBox * vtab = new Q3VBox(grid);
    new QLabel(TR("description :"), vtab);

    if (! visit)
        connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));

    comment = new MultiLineEdit(grid);
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());

    QFont font = comment->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    comment->setFont(font);

    addTab(grid, "Uml");

    // USER : list key - value

    grid = new Q3Grid(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    kvtable = new KeyValuesTable(bn, grid, visit);
    addTab(grid, TR("Properties"));

    open_dialog(this);
}
Exemplo n.º 21
0
PinDialog::PinDialog(PinData * pi)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), pin(pi) {
  pi->browser_node->edit_start();
  
  if (pi->browser_node->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }

  visit = !hasOkButton();
  setCaption(TR("Pin dialog"));
  
  Q3Grid * grid;
  Q3HBox * htab;
  QString s;
    
  // general tab
  
  grid = new Q3Grid(2, this);
  umltab = grid;
  grid->setMargin(5);
  grid->setSpacing(5);
  
  new QLabel(TR("name :"), grid);
  edname = new LineEdit(pi->name(), grid);
  edname->setReadOnly(visit);

  QFont font = edname->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  
  new QLabel(TR("stereotype : "), grid);
  edstereotype = new Q3ComboBox(!visit, grid);
  edstereotype->insertItem(toUnicode(pi->stereotype));
  if (! visit) {
    edstereotype->insertStringList(BrowserPin::default_stereotypes());
    edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlActivityPin));
    edstereotype->setAutoCompletion(completion());
  }
  edstereotype->setCurrentItem(0);
  
  QSizePolicy sp = edstereotype->sizePolicy();
  
  sp.setHorData(QSizePolicy::Expanding);
  edstereotype->setSizePolicy(sp);
    
  connect(new SmallPushButton(TR("type :"), grid), SIGNAL(clicked()),
	  this, SLOT(menu_type()));
  
  edtype = new Q3ComboBox(!visit, grid);
  edtype->insertItem(pi->get_type().get_full_type());
  if (!visit) {
    BrowserClass::instances(nodes);
    nodes.full_names(list);
    
    edtype->insertStringList(GenerationSettings::basic_types());
    offset = edtype->count();
    edtype->insertStringList(list);
    edtype->setAutoCompletion(completion());
    view = pi->browser_node->container(UmlClass);
  }
  edtype->setCurrentItem(0);
  edtype->setSizePolicy(sp);
  
  new QLabel(TR("direction :"), grid);
  htab = new Q3HBox(grid);
  eddir = new Q3ComboBox(FALSE, htab);
  
  UmlParamDirection dir = pi->get_dir();
  
  eddir->insertItem(stringify(dir));
  if (! visit) {
    // note : inout not allowed
    if (dir != UmlIn)
      eddir->insertItem(stringify(UmlIn));
    if (dir != UmlOut)
      eddir->insertItem(stringify(UmlOut));
    if (dir != UmlReturn)
      eddir->insertItem(stringify(UmlReturn));
  }
  
  new QLabel(TR("   multiplicity : "), htab);
  edmultiplicity = new Q3ComboBox(!visit, htab);
  edmultiplicity->setSizePolicy(sp);
  edmultiplicity->insertItem(pi->get_multiplicity());
  if (!visit) {
    edmultiplicity->insertItem("1");
    edmultiplicity->insertItem("0..1");
    edmultiplicity->insertItem("*");
    edmultiplicity->insertItem("1..*");
  }
  
  new QLabel(TR("   ordering : "), htab);
  edordering = new Q3ComboBox(FALSE, htab);
  
  UmlOrderingKind o = pi->get_ordering();
  
  edordering->insertItem(stringify(o));
  if (!visit) {
    if (o != UmlUnordered)
      edordering->insertItem(stringify(UmlUnordered));
    if (o != UmlOrdered)
      edordering->insertItem(stringify(UmlOrdered));
    if (o != UmlLifo)
      edordering->insertItem(stringify(UmlLifo));
    if (o != UmlFifo)
      edordering->insertItem(stringify(UmlFifo));
  }
    
  new QLabel(TR("   effect : "), htab);
  edeffect = new Q3ComboBox(FALSE, htab);
  
  UmlParamEffect e = pi->get_effect();
  
  edeffect->insertItem(stringify(e));
  if (!visit) {
    if (e != UmlNoEffect)
      edeffect->insertItem(stringify(UmlNoEffect));
    if (e != UmlCreate)
      edeffect->insertItem(stringify(UmlCreate));
    if (e != UmlRead)
      edeffect->insertItem(stringify(UmlRead));
    if (e != UmlUpdate)
      edeffect->insertItem(stringify(UmlUpdate));
    if (e != UmlDelete)
      edeffect->insertItem(stringify(UmlDelete));
  }
    
  new QLabel(TR("in state : "), grid);
  edin_state = new LineEdit(pi->in_state, grid);
  edin_state->setReadOnly(visit);
       
  new QLabel(grid);
  htab = new Q3HBox(grid);
  Q3ButtonGroup * bg = 
    new Q3ButtonGroup(2, Qt::Horizontal, QString::null, htab);
  
  is_control_cb = new QCheckBox(TR("is_control"), bg);
  if (pi->is_control)
    is_control_cb->setChecked(TRUE);
  is_control_cb->setDisabled(visit);
  
  unique_cb = new QCheckBox(TR("unique"), bg);
  if (pi->unique)
    unique_cb->setChecked(TRUE);
  unique_cb->setDisabled(visit);
  
  bg = 
    new Q3ButtonGroup(3, Qt::Horizontal, QString::null, htab);
  bg->setExclusive(TRUE);
  
  standard_rb = new QRadioButton(TR("standard"), bg);
  exception_rb = new QRadioButton(TR("exception"), bg);
  stream_rb = new QRadioButton(TR("stream"), bg);
  
  if (pi->exception)
    exception_rb->setChecked(TRUE);
  else if (pi->stream)
    stream_rb->setChecked(TRUE);
  else
    standard_rb->setChecked(TRUE);
  
  Q3VBox * vtab = new Q3VBox(grid);
  new QLabel(TR("description :"), vtab);
  if (! visit) {
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_description()));
  }
  comment = new MultiLineEdit(grid);
  comment->setReadOnly(visit);
  comment->setText(pi->browser_node->get_comment());
  comment->setFont(font);
  
  addTab(grid, "Uml");
  
  init_tab(ocltab, eduml_selection, pin->uml_selection, "Ocl",
	   SLOT(edit_uml_selection()), TRUE);

  // C++
  init_tab(cpptab, edcpp_selection, pin->cpp_selection, "C++",
	   SLOT(edit_cpp_selection()),
	   GenerationSettings::cpp_get_default_defs());

  // Java
  init_tab(javatab, edjava_selection, pin->java_selection, "Java",
	   SLOT(edit_java_selection()),
	   GenerationSettings::java_get_default_defs());
  
  // USER : list key - value
  
  grid = new Q3Grid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);
  
  kvtable = new KeyValuesTable(pi->browser_node, grid, visit);
  addTab(grid, TR("Properties"));
  
  //
    
  connect(this, SIGNAL(currentChanged(QWidget *)),
	  this, SLOT(change_tabs(QWidget *)));
  
  open_dialog(this);
}
Exemplo n.º 22
0
UseCaseDialog::UseCaseDialog(UseCaseData * u)
    : QTabDialog(0, 0, FALSE, WDestructiveClose), uc(u) {
  BrowserNode * bn = u->browser_node;
  
  bn->edit_start();
  
  if (bn->is_writable()) {
    setOkButton(TR("OK"));
    setCancelButton(TR("Cancel"));
  }
  else {
    setOkButton(QString::null);
    setCancelButton(TR("Close"));
  }

  setCaption(TR("Use Case dialog"));
  
  bool visit = !hasOkButton();
  
  // general tab
  
  QGrid * grid = new QGrid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);

  new QLabel(TR("name : "), grid);
  edname = new LineEdit(bn->get_name(), grid);
  edname->setReadOnly(visit);

  new QLabel(TR("stereotype : "), grid);
  edstereotype = new QComboBox(!visit, grid);
  edstereotype->insertItem(toUnicode(uc->get_stereotype()));
  if (! visit) {
    edstereotype->insertStringList(BrowserUseCase::default_stereotypes());
    edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlUseCase));
    edstereotype->setAutoCompletion(completion());
  }
  edstereotype->setCurrentItem(0);
  QSizePolicy sp = edstereotype->sizePolicy();
  sp.setHorData(QSizePolicy::Expanding);
  edstereotype->setSizePolicy(sp);
  
  new QLabel(TR("extension \npoints : "), grid);
  extension_points = new MultiLineEdit(grid);
  extension_points->setReadOnly(visit);
  extension_points->setText(uc->get_extension_points());
  QFont font = extension_points->font();
  if (! hasCodec())
    font.setFamily("Courier");
  font.setFixedPitch(TRUE);
  extension_points->setFont(font);

  QVBox * vtab = new QVBox(grid);
  new QLabel(TR("description :"), vtab);
  if (! visit)
    connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
	    this, SLOT(edit_description()));
  comment = new MultiLineEdit(grid);
  comment->setReadOnly(visit);
  comment->setText(bn->get_comment());
  comment->setFont(font);
  
  addTab(grid, "Uml");
  
  // USER : list key - value
  
  grid = new QGrid(2, this);
  grid->setMargin(5);
  grid->setSpacing(5);
  
  kvtable = new KeyValuesTable(bn, grid, visit);
  addTab(grid, TR("Properties"));
  
  open_dialog(this);
}
Exemplo n.º 23
0
bool DomConvenience::elementToVariant(const QDomElement& e, 
				      QVariant& v)
{
  bool ok = false;

  if (e.tagName() == "string")
  {
    if (e.hasAttribute("value"))
    {
      v = QVariant(e.attribute("value"));
      ok = true;
    }
    else
      qWarning("%s element without value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "int")
  {
    int base = getBase(e); 

    if (e.hasAttribute("value"))
      v = QVariant(e.attribute("value").toInt(&ok, base));
    else
      qWarning("%s element without value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "uint")
  {
    int base = getBase(e); 

    if (e.hasAttribute("value"))
      v = QVariant(e.attribute("value").toUInt(&ok, base));
    else
      qWarning("%s element without value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "double")
  {
    if (e.hasAttribute("value"))
      v = QVariant(e.attribute("value").toDouble(&ok));
    else
      qWarning("%s element without value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "bool")
  {
    if (e.hasAttribute("value"))
    {
      QString val = e.attribute("value");
      v = QVariant(getBoolFromString(val, ok), 0);
      
      if (!ok)
	qWarning("%s element with bogus value '%s'!",
		 (const char*)e.tagName(), (const char*)val);
    }
    else
      qWarning("%s element without value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "color")
  {
    QColor color = getColor(e);
    
    ok = color.isValid();

    v = color;

    if (!ok)
      qWarning("%s element without valid value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "pen")
  {
    int base = getBase(e);
    uint w = 0; 
    Qt::PenStyle s = Qt::SolidLine;
    Qt::PenCapStyle c = Qt::SquareCap;
    Qt::PenJoinStyle j = Qt::BevelJoin;
    QColor color = getColor(e);

    if (e.hasAttribute("style"))
      s = (Qt::PenStyle)e.attribute("style").toInt(0, base);
    if (e.hasAttribute("cap"))
      c = (Qt::PenCapStyle)e.attribute("cap").toInt(0, base);
    if (e.hasAttribute("join"))
      j = (Qt::PenJoinStyle)e.attribute("join").toInt(0, base);
    
    ok = color.isValid();

    v = QPen(color, w, s, c, j);

    if (!ok)
      qWarning("%s element without valid value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "brush")
  {
    int base = getBase(e);
    QColor color = getColor(e);
    Qt::BrushStyle s = Qt::SolidPattern;
    if (e.hasAttribute("style"))
      s = (Qt::BrushStyle)e.attribute("style").toInt(0, base);
    
    ok = color.isValid();
    
    v = QBrush(color, s);

    if (!ok)
      qWarning("%s element without valid value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "point")
  {
    int base = getBase(e);
    bool coordOk;

    int x = 0, y = 0;
    if (e.hasAttribute("x"))
      x = e.attribute("x").toInt(&coordOk, base);

    if (e.hasAttribute("y"))
      y = e.attribute("y").toInt(&coordOk, base);
    
    v = QVariant(QPoint(x, y));
    ok = true;
  }
  else if (e.tagName() == "rect")
  {
    int base = getBase(e);
    bool coordOk;

    int x = 0, y = 0, width = 0, height = 0;
    if (e.hasAttribute("x"))
      x = e.attribute("x").toInt(&coordOk, base);

    if (e.hasAttribute("y"))
      y = e.attribute("y").toInt(&coordOk, base);

    if (e.hasAttribute("width"))
      width = e.attribute("width").toInt(&coordOk, base);

    if (e.hasAttribute("height"))
      height = e.attribute("height").toInt(&coordOk, base);
    
    v = QVariant(QRect(x, y, width, height));
    ok = true;
  }
  else if (e.tagName() == "size")
  {
    int base = getBase(e);
    bool coordOk;

    int width = 0, height = 0;
    if (e.hasAttribute("width"))
      width = e.attribute("width").toInt(&coordOk, base);

    if (e.hasAttribute("height"))
      height = e.attribute("height").toInt(&coordOk, base);
    
    v = QVariant(QSize(width, height));
    ok = true;
  }
  else if (e.tagName() == "key")
  {
    int key;
    if (e.hasAttribute("sequence"))
    {
      key = QAccel::stringToKey(e.attribute("sequence"));

      // fix the key code (deal with Qt brain death)
      key &= ~Qt::UNICODE_ACCEL;

#if QT_VERSION >= 300
      v = QVariant(QKeySequence(key));
#else
      v = QVariant(key);
#endif
      ok = true;
    }
  }
  else if (e.tagName() == "font")
  {
    QFont f;
    bool boolOk;

    if (e.hasAttribute("family"))
      f.setFamily(e.attribute("family"));
    if (e.hasAttribute("pointsize"))
      f.setPointSize(e.attribute("pointsize").toInt());
    if (e.hasAttribute("bold"))
      f.setBold(getBoolFromString(e.attribute("bold"), boolOk));
    if (e.hasAttribute("italic"))
      f.setItalic(getBoolFromString(e.attribute("italic"), boolOk));
    if (e.hasAttribute("strikeout"))
      f.setStrikeOut(getBoolFromString(e.attribute("strikeout"), boolOk));

    v = QVariant(f);
    ok = true;
  }
  else if (e.tagName() == "sizepolicy")
  {
    QSizePolicy sp;
    
    if (e.hasAttribute("hsizetype"))
      sp.setHorData((QSizePolicy::SizeType)e.attribute("hsizetype").toInt());
    if (e.hasAttribute("vsizetype"))
      sp.setVerData((QSizePolicy::SizeType)e.attribute("vsizetype").toInt());
#if (QT_VERSION >= 300)
    if (e.hasAttribute("horstretch"))
      sp.setHorStretch(e.attribute("horstretch").toInt());
    if (e.hasAttribute("verstretch"))
      sp.setHorStretch(e.attribute("verstretch").toInt());
#endif
    v = QVariant(sp);
    ok = true;
  }
  else if (e.tagName() == "cursor")
  {
    if (e.hasAttribute("shape"))
      v = QVariant(QCursor(e.attribute("shape").toInt(&ok, 10)));
    else
      qWarning("%s element without value!", (const char*)e.tagName());
  }
  else if (e.tagName() == "stringlist")
  {
    QDomNodeList stringNodeList = e.elementsByTagName("string");
    QStringList stringList;
    QDomElement stringElement;
    
    for (uint i = 0; i < stringNodeList.length(); i++)
    {
      stringElement = stringNodeList.item(i).toElement();
      if (!stringElement.hasAttribute("value"))
      {
	qWarning("%s element in %s without value! Ignoring!",
		 (const char*)stringElement.tagName(),
		 (const char*)e.tagName());
	continue;
      }

      stringList.append(e.attribute("value"));
    }

    v = stringList;

    ok = true;
  }
  else if (e.tagName() == "uint64")
  {
    QString value = e.attribute("value");

    // borrowed more or less from Qt 3.2 (since we have to support older)
    uint64_t val = 0;
    const QChar* p = value.unicode();
    int l = value.length();
    const uint64_t max_mult = UINT64_MAX / 16;

    if (!p)
    {
      qWarning("Invalid value for tag: %s", (const char*)e.tagName());
      return false;
    }

    while ( l && p->isSpace() )                 // skip leading space
      l--,p++;
    if ( !l )
      return false;
    if ( *p == '+' )
      l--,p++;
    
    if ( !l || !ok_in_hex(*p) )
        return false;
    while ( l && ok_in_hex(*p) ) 
    {
      l--;
      uint dv;
      if ( p->isDigit() ) 
	dv = p->digitValue();
      else 
      {
	if ( *p >= 'a' && *p <= 'f' )
	  dv = *p - 'a' + 10;
	else
	  dv = *p - 'A' + 10;
      }
      if ( val > max_mult || (val == max_mult && dv > UINT64_MAX % 16) )
	return false;
      val = 16 * val + dv;
      p++;
    }

    QByteArray ba;
    ba.duplicate((const char*)&val, sizeof(uint64_t));

    v = ba;
    ok = true;
  }
  else if (e.tagName() == "list")
  {
    qWarning("Unimplemented tag: %s", (const char*)e.tagName());
  }
  else if (e.tagName() == "map")
  {
    qWarning("Unimplemented tag: %s", (const char*)e.tagName());
  }
  else
  {
    qWarning("Unknown tag: %s", (const char*)e.tagName());
  }

  return ok;
}
Exemplo n.º 24
0
/*!
  Interprets element \a e as variant and returns the result of the interpretation.
 */
QVariant DomTool::elementToVariant( const QDomElement& e, const QVariant& defValue, QString &comment )
{
    QVariant v;
    if ( e.tagName() == "rect" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0, w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QRect( x, y, w, h ) );
    } else if ( e.tagName() == "point" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QPoint( x, y ) );
    } else if ( e.tagName() == "size" ) {
	QDomElement n3 = e.firstChild().toElement();
	int w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QSize( w, h ) );
    } else if ( e.tagName() == "color" ) {
	v = QVariant( readColor( e ) );
    } else if ( e.tagName() == "font" ) {
	QDomElement n3 = e.firstChild().toElement();
	QFont f( defValue.toFont()  );
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "family" )
		f.setFamily( n3.firstChild().toText().data() );
	    else if ( n3.tagName() == "pointsize" )
		f.setPointSize( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "bold" )
		f.setBold( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "italic" )
		f.setItalic( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "underline" )
		f.setUnderline( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "strikeout" )
		f.setStrikeOut( n3.firstChild().toText().data().toInt() );
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( f );
    } else if ( e.tagName() == "string" ) {
	v = QVariant( e.firstChild().toText().data() );
	QDomElement n = e;
	n = n.nextSibling().toElement();
	if ( n.tagName() == "comment" )
	    comment = n.firstChild().toText().data();
    } else if ( e.tagName() == "cstring" ) {
	v = QVariant( QCString( e.firstChild().toText().data() ) );
    } else if ( e.tagName() == "number" ) {
	bool ok = TRUE;
	v = QVariant( e.firstChild().toText().data().toInt( &ok ) );
	if ( !ok )
	    v = QVariant( e.firstChild().toText().data().toDouble() );
    } else if ( e.tagName() == "bool" ) {
	QString t = e.firstChild().toText().data();
	v = QVariant( t == "true" || t == "1", 0 );
    } else if ( e.tagName() == "pixmap" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "iconset" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "image" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "enum" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "set" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "sizepolicy" ) {
	QDomElement n3 = e.firstChild().toElement();
	QSizePolicy sp;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hsizetype" )
		sp.setHorData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "vsizetype" )
		sp.setVerData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "horstretch" )
		sp.setHorStretch( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "verstretch" )
		sp.setVerStretch( n3.firstChild().toText().data().toInt() );
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( sp );
    } else if ( e.tagName() == "cursor" ) {
	v = QVariant( QCursor( e.firstChild().toText().data().toInt() ) );
    } else if ( e.tagName() == "stringlist" ) {
	QStringList lst;
	QDomElement n;
	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() )
	    lst << n.firstChild().toText().data();
	v = QVariant( lst );
    } else if ( e.tagName() == "date" ) {
	QDomElement n3 = e.firstChild().toElement();
	int y, m, d;
	y = m = d = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "year" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "month" )
		m = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "day" )
		d = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QDate( y, m, d ) );
    } else if ( e.tagName() == "time" ) {
	QDomElement n3 = e.firstChild().toElement();
	int h, m, s;
	h = m = s = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hour" )
		h = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "minute" )
		m = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "second" )
		s = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QTime( h, m, s ) );
    } else if ( e.tagName() == "datetime" ) {
	QDomElement n3 = e.firstChild().toElement();
	int h, mi, s, y, mo, d ;
	h = mi = s = y = mo = d = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hour" )
		h = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "minute" )
		mi = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "second" )
		s = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "year" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "month" )
		mo = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "day" )
		d = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QDateTime( QDate( y, mo, d ), QTime( h, mi, s ) ) );
    }
    return v;
}
Exemplo n.º 25
0
ActivityPartitionDialog::ActivityPartitionDialog(ActivityPartitionData * d)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), data(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    setCaption(TR("Activity Partition dialog"));

    bool visit = !hasOkButton();

    // general tab

    BrowserNode * bn = data->get_browser_node();
    Q3Grid * grid = new Q3Grid(2, this);

    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);

    new QLabel(TR("stereotype : "), grid);
    edstereotype = new Q3ComboBox(!visit, grid);
    edstereotype->insertItem(toUnicode(data->get_stereotype()));

    if (! visit) {
        edstereotype->insertStringList(BrowserActivityPartition::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlActivityPartition));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    connect(new SmallPushButton(TR("represents :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_represents()));
    edrepresents = new Q3ComboBox(FALSE, grid);

    if ((data->represents != 0) && !data->represents->deletedp()) {
        represented = data->represents;
        edrepresents->insertItem(*(data->represents->pixmap(0)),
                                 data->represents->full_name(TRUE));
    }
    else {
        represented = 0;
        edrepresents->insertItem("");
    }

    if (! visit)
        edrepresents->insertItem("");

    edrepresents->setCurrentItem(0);
    edrepresents->setSizePolicy(sp);

    Q3HBox * htab;

    new QLabel(grid);
    htab = new Q3HBox(grid);
    new QLabel("  ", htab);
    dimension_cb = new QCheckBox(TR("is dimension"), htab);

    if (data->is_dimension)
        dimension_cb->setChecked(TRUE);

    dimension_cb->setDisabled(visit);
    new QLabel("", htab);
    external_cb = new QCheckBox(TR("is external"), htab);

    if (data->is_external)
        external_cb->setChecked(TRUE);

    external_cb->setDisabled(visit);
    new QLabel("", htab);

    Q3VBox * vtab = new Q3VBox(grid);
    new QLabel(TR("description :"), vtab);

    if (! visit)
        connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));

    comment = new MultiLineEdit(grid);
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    QFont font = comment->font();

    if (! hasCodec())
        font.setFamily("Courier");

    font.setFixedPitch(TRUE);
    comment->setFont(font);

    addTab(grid, "Uml");

    // USER : list key - value

    grid = new Q3Grid(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    kvtable = new KeyValuesTable(bn, grid, visit);
    addTab(grid, TR("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}
Exemplo n.º 26
0
ActivityDialog::ActivityDialog(ActivityData * d)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), activity(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    setCaption(TR("Activity dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = activity->browser_node;
    Q3Grid * grid;

    //
    // general tab
    //

    grid = new Q3Grid(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);

    new QLabel(TR("stereotype : "), grid);
    edstereotype = new Q3ComboBox(!visit, grid);
    edstereotype->insertItem(toUnicode(activity->get_stereotype()));

    if (!visit) {
        edstereotype->insertStringList(BrowserActivity::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlActivity));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    connect(new SmallPushButton(TR("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    edspecification = new Q3ComboBox(FALSE, grid);
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (activity->get_specification() == 0)
            edspecification->insertItem("");
        else
            edspecification->insertItem(activity->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->insertItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(list);
        edspecification->insertStringList(list);
        edspecification->setCurrentItem((activity->get_specification() == 0)
                                        ? 0
                                        : opers.findRef(activity->get_specification()) + 1);
    }

    new QLabel(grid);
    Q3ButtonGroup * bg =
        new Q3ButtonGroup(3, Qt::Horizontal, QString(), grid);

    readonly_cb = new QCheckBox(TR("read only"), bg);

    if (activity->read_only)
        readonly_cb->setChecked(TRUE);

    readonly_cb->setDisabled(visit);

    singlexec_cb = new QCheckBox(TR("single execution"), bg);

    if (activity->single_execution)
        singlexec_cb->setChecked(TRUE);

    singlexec_cb->setDisabled(visit);

    active_cb = new QCheckBox(TR("active"), bg);

    if (activity->is_active)
        active_cb->setChecked(TRUE);

    active_cb->setDisabled(visit);

    Q3VBox * vtab = new Q3VBox(grid);
    new QLabel(TR("description :"), vtab);

    if (! visit)
        connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));

    comment = new MultiLineEdit(grid);
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());
    //comment->setFont(font);

    vtab = new Q3VBox(grid);
    new QLabel(TR("constraint :"), vtab);

    if (! visit) {
        connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_constraint()));
    }

    constraint = new MultiLineEdit(grid);
    constraint->setReadOnly(visit);
    constraint->setText(activity->constraint);
    //constraint->setFont(font);

    addTab(grid, "Uml");

    // UML / OCL
    init_tab(uml, activity->uml_condition, "Ocl", TRUE);

    // CPP
    init_tab(cpp, activity->cpp_condition, "C++",
             GenerationSettings::cpp_get_default_defs());

    // Java
    init_tab(java, activity->java_condition, "Java",
             GenerationSettings::java_get_default_defs());

    // USER : list key - value

    grid = new Q3Grid(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    kvtable = new KeyValuesTable(bn, grid, visit);
    addTab(grid, TR("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}
Exemplo n.º 27
0
/*!
  Interprets element \a e as variant and returns the result of the interpretation.
 */
QVariant DomTool::elementToVariant( const QDomElement& e, const QVariant& defValue, QString *comment )
{
    QVariant v;
    if ( e.tagName() == "rect" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0, w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QRect( x, y, w, h ) );
    } else if ( e.tagName() == "point" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QPoint( x, y ) );
    } else if ( e.tagName() == "size" ) {
	QDomElement n3 = e.firstChild().toElement();
	int w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( QSize( w, h ) );
    } else if ( e.tagName() == "color" ) {
	v = QVariant( readColor( e ) );
    } else if ( e.tagName() == "font" ) {
	QDomElement n3 = e.firstChild().toElement();
	QFont f( defValue.toFont()  );
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "family" )
		f.setFamily( n3.firstChild().toText().data() );
	    else if ( n3.tagName() == "pointsize" )
		f.setPointSize( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "bold" )
		f.setBold( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "italic" )
		f.setItalic( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "underline" )
		f.setUnderline( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "strikeout" )
		f.setStrikeOut( n3.firstChild().toText().data().toInt() );
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( f );
    } else if ( e.tagName() == "string" ) {
	v = QVariant( e.firstChild().toText().data() );
	QDomElement n = e;
	n = n.nextSibling().toElement();
	if ( comment && n.tagName() == "comment" )
	    *comment = n.firstChild().toText().data();
    } else if ( e.tagName() == "cstring" ) {
	v = QVariant( QCString( e.firstChild().toText().data() ) );
    } else if ( e.tagName() == "number" ) {
	v = QVariant( e.firstChild().toText().data().toInt() );
    } else if ( e.tagName() == "bool" ) {
	QString t = e.firstChild().toText().data();
	v = QVariant( t == "true" || t == "1", 0 );
    } else if ( e.tagName() == "pixmap" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "iconset" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "image" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "enum" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "set" ) {
	v = QVariant( e.firstChild().toText().data() );
    } else if ( e.tagName() == "sizepolicy" ) {
	QDomElement n3 = e.firstChild().toElement();
	QSizePolicy sp;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hsizetype" )
		sp.setHorData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "vsizetype" )
		sp.setVerData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    n3 = n3.nextSibling().toElement();
	}
	v = QVariant( sp );
    } else if ( e.tagName() == "cursor" ) {
	v = QVariant( QCursor( e.firstChild().toText().data().toInt() ) );
    }

    return v;
}
Exemplo n.º 28
0
StateDialog::StateDialog(StateData * d)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), state(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    setCaption(TR("State dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = state->browser_node;
    Q3Grid * grid;

    //
    // general tab
    //

    grid = new Q3Grid(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);

    new QLabel(TR("stereotype : "), grid);
    edstereotype = new Q3ComboBox(!visit, grid);
    edstereotype->insertItem(toUnicode(state->get_stereotype()));

    if (!visit) {
        edstereotype->insertStringList(BrowserState::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlState));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    connect(new SmallPushButton(TR("specification :"), grid), SIGNAL(clicked()),
            this, SLOT(menu_specification()));
    edspecification = new Q3ComboBox(FALSE, grid);
    edspecification->setSizePolicy(sp);

    if (visit) {
        if (state->get_specification() == 0)
            edspecification->insertItem("");
        else
            edspecification->insertItem(state->get_specification()->full_name(TRUE));
    }
    else {
        edspecification->insertItem("");
        edspecification->setAutoCompletion(completion());
        BrowserOperation::instances(opers);
        opers.full_names(speclist);
        edspecification->insertStringList(speclist);
        edspecification->setCurrentItem((state->get_specification() == 0)
                                        ? 0
                                        : opers.findRef(state->get_specification()) + 1);
    }

    switch (((BrowserNode *) bn->parent())->get_type()) {
    case UmlState:
    case UmlRegion:
        if ((state->get_reference() != 0) || (bn->firstChild() == 0)) {
            connect(new SmallPushButton(TR("reference :"), grid), SIGNAL(clicked()),
                    this, SLOT(menu_reference()));
            edreference = new Q3ComboBox(FALSE, grid);
            edreference->setSizePolicy(sp);

            if (visit) {
                if (state->get_reference() == 0)
                    edreference->insertItem("");
                else
                    edreference->insertItem(state->get_reference()->full_name(TRUE));
            }
            else {
                edreference->insertItem("");
                edreference->setAutoCompletion(completion());

                if (((BrowserState *) bn)->can_reference()) {
                    BrowserState::instances(states, TRUE);

                    BrowserNode * st = states.first();

                    while (st != 0) {
                        if (!((BrowserState *) bn)->can_reference((BrowserState *) st) ||
                            ((BrowserState *) st)->is_ref()) {
                            states.remove();
                            st = states.current();
                        }
                        else
                            st = states.next();
                    }
                }
                else
                    states.append(state->get_reference());

                states.full_names(reflist);
                edreference->insertStringList(reflist);
                edreference->setCurrentItem((state->get_reference() == 0)
                                            ? 0
                                            : states.findRef(state->get_reference()) + 1);

                connect(edreference, SIGNAL(activated(int)), this, SLOT(ed_ref_activated(int)));
            }

            break;
        }

        // no break
    default:
        edreference = 0;
    }
Exemplo n.º 29
0
/*!  Attention: this function has to be in sync with
  Resource::saveProperty() and DomTool::elementToVariant. If you
  change one, change all.
 */
QString Uic::setObjectProperty( const QString& objClass, const QString& obj, const QString &prop, const QDomElement &e, bool stdset )
{
    QString v;
    if ( e.tagName() == "rect" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0, w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QRect( %1, %2, %3, %4 )";
	v = v.arg(x).arg(y).arg(w).arg(h);

    } else if ( e.tagName() == "point" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QPoint( %1, %2 )";
	v = v.arg(x).arg(y);
    } else if ( e.tagName() == "size" ) {
	QDomElement n3 = e.firstChild().toElement();
	int w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QSize( %1, %2 )";
	v = v.arg(w).arg(h);
    } else if ( e.tagName() == "color" ) {
	QDomElement n3 = e.firstChild().toElement();
	int r = 0, g = 0, b = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "red" )
		r = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "green" )
		g = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "blue" )
		b = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QColor( %1, %2, %3 )";
	v = v.arg(r).arg(g).arg(b);
    } else if ( e.tagName() == "font" ) {
	QDomElement n3 = e.firstChild().toElement();
	QString attrname = e.parentNode().toElement().attribute( "name", "font" );
	QString fontname;
	if ( !obj.isEmpty() ) {
	    fontname = registerObject( obj + "_" + attrname );
	    out << indent << "QFont "  << fontname << "(  " << obj << "->font() );" << endl;
	} else {
	    fontname = registerObject( "f" );
	    out << indent << "QFont "  << fontname << "( font() );" << endl;
	}
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "family" )
		out << indent << fontname << ".setFamily( \"" << n3.firstChild().toText().data() << "\" );" << endl;
	    else if ( n3.tagName() == "pointsize" )
		out << indent << fontname << ".setPointSize( " << n3.firstChild().toText().data() << " );" << endl;
	    else if ( n3.tagName() == "bold" )
		out << indent << fontname << ".setBold( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    else if ( n3.tagName() == "italic" )
		out << indent << fontname << ".setItalic( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    else if ( n3.tagName() == "underline" )
		out << indent << fontname << ".setUnderline( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    else if ( n3.tagName() == "strikeout" )
		out << indent << fontname << ".setStrikeOut( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    n3 = n3.nextSibling().toElement();
	}

	if ( prop == "font" ) {
	    if ( !obj.isEmpty() )
		out << indent << obj << "->setFont( " << fontname << " ); " << endl;
	    else
		out << indent << "setFont( " << fontname << " ); " << endl;
	} else {
	    v = fontname;
	}
    } else if ( e.tagName() == "string" ) {
	QString txt = e.firstChild().toText().data();
	QString com = getComment( e.parentNode() );

	if ( prop == "toolTip" && objClass != "QAction" && objClass != "QActionGroup" ) {
	    if ( !obj.isEmpty() )
		trout << indent << "QToolTip::add( " << obj << ", "
		      << trcall( txt, com ) << " );" << endl;
	    else
		trout << indent << "QToolTip::add( this, "
		      << trcall( txt, com ) << " );" << endl;
	} else if ( prop == "whatsThis" && objClass != "QAction" && objClass != "QActionGroup" ) {
	    if ( !obj.isEmpty() )
		trout << indent << "QWhatsThis::add( " << obj << ", "
		      << trcall( txt, com ) << " );" << endl;
	    else
		trout << indent << "QWhatsThis::add( this, "
		      << trcall( txt, com ) << " );" << endl;
	} else {
	    v = trcall( txt, com );
	}
    } else if ( e.tagName() == "cstring" ) {
	    v = "\"%1\"";
	    v = v.arg( e.firstChild().toText().data() );
    } else if ( e.tagName() == "number" ) {
	v = "%1";
	v = v.arg( e.firstChild().toText().data() );
    } else if ( e.tagName() == "bool" ) {
	if ( stdset )
	    v = "%1";
	else
	    v = "QVariant( %1, 0 )";
	v = v.arg( mkBool( e.firstChild().toText().data() ) );
    } else if ( e.tagName() == "pixmap" ) {
	v = e.firstChild().toText().data();
	if ( !pixmapLoaderFunction.isEmpty() ) {
	    v.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );
	    v.append( QString( externPixmaps ? "\"" : "" ) + " )" );
	}
    } else if ( e.tagName() == "iconset" ) {
	v = "QIconSet( %1 )";
	QString s = e.firstChild().toText().data();
	if ( !pixmapLoaderFunction.isEmpty() ) {
	    s.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );
	    s.append( QString( externPixmaps ? "\"" : "" ) + " )" );
	}
	v = v.arg( s );
    } else if ( e.tagName() == "image" ) {
	v = e.firstChild().toText().data() + ".convertToImage()";
    } else if ( e.tagName() == "enum" ) {
	if ( stdset )
	    v = "%1::%2";
	else
	    v = "\"%1\"";
	QString oc = objClass;
	QString ev = e.firstChild().toText().data();
	if ( oc == "QListView" && ev == "Manual" ) // #### workaround, rename QListView::Manual in 4.0
	    oc = "QScrollView";
	if ( stdset )
	    v = v.arg( oc ).arg( ev );
	else
	    v = v.arg( ev );
    } else if ( e.tagName() == "set" ) {
	QString keys( e.firstChild().toText().data() );
	QStringList lst = QStringList::split( '|', keys );
	v = "int( ";
	QStringList::Iterator it = lst.begin();
	while ( it != lst.end() ) {
	    v += objClass + "::" + *it;
	    if ( it != lst.fromLast() )
		v += " | ";
	    ++it;
	}
	v += " )";
    } else if ( e.tagName() == "sizepolicy" ) {
	QDomElement n3 = e.firstChild().toElement();
	QSizePolicy sp;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hsizetype" )
		sp.setHorData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "vsizetype" )
		sp.setVerData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "horstretch" )
		sp.setHorStretch( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "verstretch" )
		sp.setVerStretch( n3.firstChild().toText().data().toInt() );
	    n3 = n3.nextSibling().toElement();
	}
	QString tmp;
	if ( !obj.isEmpty() )
	    tmp = obj + "->";
	v = "QSizePolicy( (QSizePolicy::SizeType)%1, (QSizePolicy::SizeType)%2, %3, %4, " + tmp + "sizePolicy().hasHeightForWidth() )";
	v = v.arg( (int)sp.horData() ).arg( (int)sp.verData() ).arg( sp.horStretch() ).arg( sp.verStretch() );
    } else if ( e.tagName() == "palette" ) {
	QPalette pal;
	bool no_pixmaps = e.elementsByTagName( "pixmap" ).count() == 0;
	QDomElement n;
	if ( no_pixmaps ) {
	    n = e.firstChild().toElement();
	    while ( !n.isNull() ) {
		QColorGroup cg;
		if ( n.tagName() == "active" ) {
		    cg = loadColorGroup( n );
		    pal.setActive( cg );
		} else if ( n.tagName() == "inactive" ) {
		    cg = loadColorGroup( n );
		    pal.setInactive( cg );
		} else if ( n.tagName() == "disabled" ) {
		    cg = loadColorGroup( n );
		    pal.setDisabled( cg );
		}
		n = n.nextSibling().toElement();
	    }
	}
	if ( no_pixmaps && pal == QPalette( pal.active().button(), pal.active().background() ) ) {
	    v = "QPalette( QColor( %1, %2, %3 ), QColor( %1, %2, %3 ) )";
	    v = v.arg( pal.active().button().red() ).arg( pal.active().button().green() ).arg( pal.active().button().blue() );
	    v = v.arg( pal.active().background().red() ).arg( pal.active().background().green() ).arg( pal.active().background().blue() );
	} else {
	    QString palette = "pal";
	    if ( !pal_used ) {
		out << indent << "QPalette " << palette << ";" << endl;
		pal_used = TRUE;
	    }
	    QString cg = "cg";
	    if ( !cg_used ) {
		out << indent << "QColorGroup " << cg << ";" << endl;
		cg_used = TRUE;
	    }
	    n = e.firstChild().toElement();
	    while ( !n.isNull() && n.tagName() != "active" )
		n = n.nextSibling().toElement();
	    createColorGroupImpl( cg, n );
	    out << indent << palette << ".setActive( " << cg << " );" << endl;

	    n = e.firstChild().toElement();
	    while ( !n.isNull() && n.tagName() != "inactive" )
		n = n.nextSibling().toElement();
	    createColorGroupImpl( cg, n );
	    out << indent << palette << ".setInactive( " << cg << " );" << endl;

	    n = e.firstChild().toElement();
	    while ( !n.isNull() && n.tagName() != "disabled" )
		n = n.nextSibling().toElement();
	    createColorGroupImpl( cg, n );
	    out << indent << palette << ".setDisabled( " << cg << " );" << endl;
	    v = palette;
	}
    } else if ( e.tagName() == "cursor" ) {
	v = "QCursor( %1 )";
	v = v.arg( e.firstChild().toText().data() );
    } else if ( e.tagName() == "date" ) {
	QDomElement n3 = e.firstChild().toElement();
	int y, m, d;
	y = m = d = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "year" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "month" )
		m = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "day" )
		d = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QDate( %1, %2, %3 )";
	v = v.arg(y).arg(m).arg(d);
    } else if ( e.tagName() == "time" ) {
	QDomElement n3 = e.firstChild().toElement();
	int h, m, s;
	h = m = s = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hour" )
		h = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "minute" )
		m = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "second" )
		s = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QTime( %1, %2, %3 )";
	v = v.arg(h).arg(m).arg(s);
    } else if ( e.tagName() == "datetime" ) {
	QDomElement n3 = e.firstChild().toElement();
	int h, mi, s, y, mo, d;
	h = mi = s = y = mo = d = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hour" )
		h = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "minute" )
		mi = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "second" )
		s = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "year" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "month" )
		mo = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "day" )
		d = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QDateTime( QDate( %1, %2, %3 ), QTime( %4, %5, %6 ) )";
	v = v.arg(y).arg(mo).arg(d).arg(h).arg(mi).arg(s);
    } else if ( e.tagName() == "stringlist" ) {
	QStringList l;
	QDomElement n3 = e.firstChild().toElement();
	QString listname = "l";
	if ( !obj.isEmpty() ) {
	    listname = obj + "_stringlist";
	    listname = registerObject( listname );
	    out << indent << "QStringList "  << listname << ";" << endl;
	} else {
	    listname = registerObject( listname );
	    out << indent << "QStringList "  << listname << ";" << endl;
	}
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "string" )
		out << indent << listname << " << \"" << n3.firstChild().toText().data().simplifyWhiteSpace() << "\";" << endl;
	    n3 = n3.nextSibling().toElement();
	}
	v = listname;
    }
    return v;
}
Exemplo n.º 30
0
FlowDialog::FlowDialog(FlowData * d)
    : Q3TabDialog(0, 0, FALSE, Qt::WDestructiveClose), flow(d)
{
    d->browser_node->edit_start();

    if (d->browser_node->is_writable()) {
        setOkButton(TR("OK"));
        setCancelButton(TR("Cancel"));
    }
    else {
        setOkButton(QString());
        setCancelButton(TR("Close"));
    }

    setCaption(TR("Flow dialog"));
    visit = !hasOkButton();

    BrowserNode * bn = flow->browser_node;
    Q3Grid * grid;

    //
    // general tab
    //

    grid = new Q3Grid(2, this);
    umltab = grid;
    grid->setMargin(5);
    grid->setSpacing(5);

    new QLabel(TR("name : "), grid);
    edname = new LineEdit(bn->get_name(), grid);
    edname->setReadOnly(visit);

    new QLabel(TR("stereotype : "), grid);
    edstereotype = new Q3ComboBox(!visit, grid);
    edstereotype->insertItem(toUnicode(flow->get_stereotype()));

    if (!visit) {
        edstereotype->insertStringList(BrowserFlow::default_stereotypes());
        edstereotype->insertStringList(ProfiledStereotypes::defaults(UmlFlow));
        edstereotype->setAutoCompletion(completion());
    }

    edstereotype->setCurrentItem(0);
    QSizePolicy sp = edstereotype->sizePolicy();
    sp.setHorData(QSizePolicy::Expanding);
    edstereotype->setSizePolicy(sp);

    Q3VBox * vtab = new Q3VBox(grid);
    new QLabel(TR("description :"), vtab);

    if (! visit)
        connect(new SmallPushButton(TR("Editor"), vtab), SIGNAL(clicked()),
                this, SLOT(edit_description()));

    comment = new MultiLineEdit(grid);
    comment->setReadOnly(visit);
    comment->setText(bn->get_comment());

    addTab(grid, "Uml");

    // UML / OCL
    init_tab(uml, flow->uml, "Ocl", SLOT(edit_uml_guard()),
             SLOT(edit_uml_selection()), SLOT(edit_uml_transformation()),
             TRUE);

    // CPP
    init_tab(cpp, flow->cpp, "C++", SLOT(edit_cpp_guard()),
             SLOT(edit_cpp_selection()), SLOT(edit_cpp_transformation()),
             GenerationSettings::cpp_get_default_defs());

    // Java
    init_tab(java, flow->java, "Java", SLOT(edit_java_guard()),
             SLOT(edit_java_selection()), SLOT(edit_java_transformation()),
             GenerationSettings::java_get_default_defs());

    // USER : list key - value

    grid = new Q3Grid(2, this);
    grid->setMargin(5);
    grid->setSpacing(5);

    kvtable = new KeyValuesTable(bn, grid, visit);
    addTab(grid, TR("Properties"));

    //

    connect(this, SIGNAL(currentChanged(QWidget *)),
            this, SLOT(change_tabs(QWidget *)));

    open_dialog(this);
}