Beispiel #1
0
void BasicDialog::accept() {
  if (!check_edits(edits) || !kvtable->check_unique())
    return;
    
  BrowserNode * bn = data->get_browser_node();

  if (edname != 0) {
    QString s = edname->text().stripWhiteSpace();

    if ((s != bn->get_name()) &&
	((BrowserNode *) bn->parent())->wrong_child_name(s, bn->get_type(),
							 bn->allow_spaces(),
							 bn->allow_empty())) {
      msg_critical(TR("Error"), edname->text() + TR("\n\nillegal name or already used"));
      return;
    }
    else
      bn->set_name(s);
  }

  bool newst = data->set_stereotype(fromUnicode(edstereotype->currentText().stripWhiteSpace()));
  
  bn->set_comment(comment->text());
  UmlWindow::update_comment_if_needed(bn);
    
  kvtable->update(bn);
  
  ProfiledStereotypes::modified(bn, newst);
  
  bn->package_modified();
  data->modified();
    
  Q3TabDialog::accept();
}
Beispiel #2
0
void SubjectCanvas::send(ToolCom * com, Q3CanvasItemList & all)
{
  Q3PtrList<SubjectCanvas> subjects;
  Q3CanvasItemList::Iterator cit;

  for (cit = all.begin(); cit != all.end(); ++cit) {
    DiagramItem *di = QCanvasItemToDiagramItem(*cit);
    
    if ((di != 0) && 
	(*cit)->visible() &&
	(di->type() == UmlSubject))
      subjects.append((SubjectCanvas *) di);
  }
  
  com->write_unsigned(subjects.count());
  
  SubjectCanvas * sc;
  
  for (sc = subjects.first(); sc != 0; sc = subjects.next()) {
    Q3CString s = fromUnicode(sc->name);
    
    com->write_string((const char *) s);
    com->write(sc->rect());
  }
}
Beispiel #3
0
void TextCanvas::open()
{
    static QSize sz;

    // warning : 'note' is already unicode
    QString s = fromUnicode(text);
    bool created = s.isEmpty();

    MLEDialog::get(s, QCursor::pos(), sz);

    if (s.isEmpty())
        delete_it();
    else {
        text = s;

        if (created) {
            QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
            QSize sz = fm.size(0, text);

            DiagramCanvas::resize(sz.width(), sz.height());
        }

        // force son reaffichage
        hide();
        show();
    }

    canvas()->update();

    package_modified();
}
Beispiel #4
0
void KeyValuesTable::update(HaveKeyValueData * oper) {
  forceUpdateCells();
  
  unsigned n = numRows();
  unsigned index;
  
  if (text(n - 1, 0).isEmpty())
    n -= 1;
  
  oper->set_n_keys(n);
  
  for (index = 0; index != n; index += 1) {
    oper->set_key(index, fromUnicode(text(index, 0)));
    oper->set_value(index, fromUnicode(text(index, 1)));
  }
}
Beispiel #5
0
bool BrowserNode::wrong_child_name(const QString & s, UmlCode type,
				   bool allow_spaces, bool allow_empty) const {
  if (s.isEmpty())
    return !allow_empty;
  
  const char * str = s;

  if (str != fromUnicode(s))
    return true;
  
  if (allow_empty)
    // synonymous allowed
    return FALSE;
  
  switch (type) {
  case UmlOperation:
    switch (*str) {
    case ' ':
    case '\t':
    case '\r':
      return TRUE;
    default:
      // synonymous allowed
      return FALSE;
    }
  default:
    if (type <= UmlClass) {
      while (*str) {
	char c = *str++;
	
	if (((c >= 'a') && (c <= 'z')) ||
	    ((c >= 'A') && (c <= 'Z')) ||
	    ((c >= '0') && (c <= '9')) ||
	    (c == '_'))
	  ;
	else if ((strchr("()&^[]%|!+-*/=>", c) != 0) ||
		 (((c == ' ') || (c == '\t') || (c == '\r')) && 
		  !allow_spaces))
	  return TRUE;
	else if (c == '<') {
	  if (type == UmlClass)
	    // suppose it is a valid template
	    break;
	  else
	    return TRUE;
	}
      }
    }
  }
  
  // check unicity
  
  for (Q3ListViewItem * child = firstChild(); child; child = child->nextSibling())
    if (!((BrowserNode *) child)->deletedp() &&
	((BrowserNode *) child)->same_name(s, type))
      return TRUE;
  
  return FALSE;
}
Beispiel #6
0
void TabDialog::accept()
{
    for (unsigned i = 0; i != sizeof(Tabs) / sizeof(*Tabs); i += 1)
        uc->set_PropertyValue(Tabs[i].key, fromUnicode((this->*(Tabs[i]).a)->text()));

    UmlCom::bye();
    Q3TabDialog::accept();
}
Beispiel #7
0
void ICQClient::snac_login(unsigned short type, unsigned short)
{
    unsigned long newUin;
    switch (type){
    case ICQ_SNACxLOGIN_ERROR:
        m_reconnect = NO_RECONNECT;
        m_socket->error_state(I18N_NOOP("Login error"), AuthError);
        break;
    case ICQ_SNACxLOGIN_REGISTER:
        if (data.owner.Uin){
            m_socket->error_state(I18N_NOOP("Registered in no register state"));
            break;
        }
        m_socket->readBuffer.incReadPos(0x2E);
        m_socket->readBuffer.unpack(newUin);
        log(L_DEBUG, "Register %u %08lX", newUin, newUin);
        setUin(newUin);
        setState(Connecting);
        m_socket->connect(getServer(), getPort(), this);
        break;
    case ICQ_SNACxLOGIN_AUTHxKEYxRESPONSE:
        if (data.owner.Screen){
            string md5_key;
            m_socket->readBuffer.unpackStr(md5_key);
            snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_MD5xLOGIN, false, false);
            m_socket->writeBuffer.tlv(0x0001, data.owner.Screen);
            MD5_CTX c;
            MD5_Init(&c);
            unsigned char md[MD5_DIGEST_LENGTH];
            MD5_Update(&c, md5_key.c_str(), md5_key.length());
            string pswd = fromUnicode(getPassword(), &data.owner);
            MD5_Update(&c, pswd.c_str(), pswd.length());
            pswd = "AOL Instant Messenger (SM)";
            MD5_Update(&c, pswd.c_str(), pswd.length());
            MD5_Final(md, &c);

            m_socket->writeBuffer.tlv(0x0025, (char*)&md, sizeof(md));
            m_socket->writeBuffer.tlv(0x0003, "AOL Instant Messenger, version 5.1.3036/WIN32");
            m_socket->writeBuffer.tlv(0x0016, (unsigned short)0x0109);
            m_socket->writeBuffer.tlv(0x0017, (unsigned short)0x0005);
            m_socket->writeBuffer.tlv(0x0018, (unsigned short)0x0001);
            m_socket->writeBuffer.tlv(0x0019, (unsigned short)0x0000);
            m_socket->writeBuffer.tlv(0x001A, (unsigned short)0x0BDC);
            m_socket->writeBuffer.tlv(0x0014, 0x000000D2L);
            m_socket->writeBuffer.tlv(0x000F, "en");
            m_socket->writeBuffer.tlv(0x000E, "us");
            m_socket->writeBuffer.tlv(0x004A, "\x01");
            sendPacket();
        }
        break;
    case ICQ_SNACxLOGIN_LOGINxREPLY:
        chn_close();
        break;
    default:
        log(L_WARN, "Unknown login family type %04X", type);
    }
}
Beispiel #8
0
void UseCaseData::save(QTextStream & st, QString & warning) const {
  if (!extension_points.isEmpty()) {
    nl_indent(st);
    st << "extension_points ";
    save_string(fromUnicode(extension_points), st);  
  }
  
  BasicData::save(st, warning);
}
Beispiel #9
0
void SubjectCanvas::open() {
  BooL ok;
  QString s = MyInputDialog::getText(TR("Subject dialog"), TR("subject : "),
				     fromUnicode(name), ok);
  
  if (ok) {
    name = toUnicode(s);
    modified();
  }
}
Beispiel #10
0
void NoteCanvas::open() {
  static QSize sz;
  
  // warning : 'note' is already unicode
  QString s = fromUnicode(note);
  
  MLEDialog::get(s, QCursor::pos(), sz);
  note = toUnicode(s);
  
  modified();
}
Beispiel #11
0
void NoteCanvas::save_internal(Q3TextStream & st) const {
  save_string(fromUnicode(note), st);
  nl_indent(st);
  if (itscolor != UmlDefaultColor)
    st << "  color " << stringify(itscolor);
  if (itsfont != UmlNormalFont)
    st << "  font " << stringify(itsfont);
  if (fg_c != UmlBlack)
    st << "  fg " << stringify(fg_c);
  save_xyzwh(st, this, "  xyzwh");
}
Beispiel #12
0
void CreateEntityDialog::add()
{
    if (m_delegate.container().entities().size() == 0)
        QMessageBox::warning(this, windowTitle(), tr("There is no entities!"));
    else
    {
        StringDialog dialog(tr("New property name"), tr("Name"), QString(), this);

        if (dialog.exec() == StringDialog::Accepted)
            m_model.add((*m_delegate.container().entities().begin()).second, fromUnicode(dialog.value()).data());
    }
}
bool KeyValuesTable::EqualData(HaveKeyValueData * kvData)
{
    if(!kvData)
        return false;
    unsigned n = rowCount();

    if (text(n - 1, 0).isEmpty())
        n -= 1;

    if(kvData->get_n_keys() != n)
        return false;

    unsigned index;
    for (index = 0; index != n; index += 1)
    {
        if(kvData->has_key(fromUnicode(text(index, 0))) == -1)
            return false;
        if(kvData->get_value(fromUnicode(text(index, 0))) != fromUnicode(text(index, 1)))
            return false;
    }
    return true;
}
Beispiel #14
0
void ImageCanvas::save(QTextStream & st, bool ref, QString &) const {
    if (ref) {
        st << "image_ref " << get_ident();
    }
    else {
        nl_indent(st);

        st << "image " << get_ident() << ' ';
        save_string(fromUnicode(path), st);
        save_xyz(st, this, " xyz");
        st << " end";
    }
}
Beispiel #15
0
void ActivityDialog::accept()
{
    if (!check_edits(edits) || !kvtable->check_unique())
        return;

    BrowserNode * bn = activity->browser_node;
    QString s;

    s = edname->text().trimmed();

    if ((s != bn->get_name()) &&
            ((BrowserNode *) bn->parent())->wrong_child_name(s, UmlActivity,
                                                             bn->allow_spaces(),
                                                             bn->allow_empty()))
        msg_critical(tr("Error"), s + tr("\n\nillegal name or already used"));
    else {
        bn->set_name(s);

        bool newst = activity->set_stereotype(fromUnicode(edstereotype->currentText().trimmed()));
        int index = list.indexOf(edspecification->currentText().trimmed());

        activity->set_specification((index != -1)
                                    ? (BrowserOperation *) opers.at(index)
                                    : 0);

        activity->read_only = readonly_cb->isChecked();
        activity->single_execution = singlexec_cb->isChecked();
        activity->is_active = active_cb->isChecked();

        uml.accept(activity->uml_condition);
        cpp.accept(activity->cpp_condition);
        java.accept(activity->java_condition);

        bn->set_comment(comment->text());
        UmlWindow::update_comment_if_needed(bn);

        activity->constraint = constraint->trimmedText();

        kvtable->updateNodeFromThis(bn);

        ProfiledStereotypes::modified(bn, newst);

        bn->modified();
        bn->package_modified();
        activity->modified();

        TabDialog::accept();
    }
}
void PseudoStateDialog::accept()
{
    if (!check_edits(edits) || !kvtable->check_unique())
        return;

    QString s = edname->text().stripWhiteSpace();
    BrowserPseudoState * bn = (BrowserPseudoState *) pst->browser_node;

    if ((s != bn->get_name()) &&
        ((BrowserNode *) bn->parent())->wrong_child_name(s, UmlPseudoState,
                bn->allow_spaces(),
                bn->allow_empty())) {
        msg_critical(TR("Error"), edname->text() + TR("\n\nillegal name or already used"));
        return;
    }
    else
        bn->set_name(s);

    bool newst = pst->set_stereotype(fromUnicode(edstereotype->currentText().stripWhiteSpace()));

    bn->set_comment(comment->text());
    UmlWindow::update_comment_if_needed(bn);

    kvtable->updateNodeFromThis(bn);

    if (edreference != 0) {
        int index = reflist.findIndex(edreference->currentText());
        BrowserPseudoState * ps;

        if (index != -1) {
            ps = (BrowserPseudoState *) pseudostates.at(index);

            if (! bn->can_reference(ps))
                ps = 0;
        }
        else
            ps = 0;

        pst->set_reference(ps);
    }

    ProfiledStereotypes::modified(bn, newst);

    bn->modified();
    bn->package_modified();
    pst->modified();

    Q3TabDialog::accept();
}
Beispiel #17
0
void SubjectCanvas::save(Q3TextStream & st, bool ref, QString &) const {
  if (ref) {
    st << "subject_ref " << get_ident();
  }
  else {
    nl_indent(st);
    
    st << "subject " << get_ident() << ' ';
    save_string(fromUnicode(name), st);
    nl_indent(st);
    if (itscolor != UmlDefaultColor)
      st << "  color " << stringify(itscolor);
    save_xyzwh(st, this, "  xyzwh");
  }
}
void ActivityObjectDialog::accept()
{
    if (!check_edits(edits))
        return;

    BrowserNode * bn = data->browser_node;
    QString s = edname->text().stripWhiteSpace();

    bn->set_name(s);

    bool newst = data->set_stereotype(fromUnicode(edstereotype->currentText().stripWhiteSpace()));
    AType t;

    s = edtype->currentText().stripWhiteSpace();

    if (!s.isEmpty()) {
        int index = list.findIndex(s);

        if (index >= 0)
            t.type = (BrowserClass *) nodes.at(index);
        else
            t.explicit_type = s;
    }

    data->set_type(t);
    data->multiplicity =
        edmultiplicity->currentText().stripWhiteSpace();
    data->ordering = ordering(edordering->currentText());
    data->is_control = is_control_cb->isChecked();
    data->in_state = edin_state->text().stripWhiteSpace();
    data->uml_selection = eduml_selection->text().stripWhiteSpace();
    data->cpp_selection = edcpp_selection->text().stripWhiteSpace();
    data->java_selection = edjava_selection->text().stripWhiteSpace();

    bn->set_comment(comment->text());
    UmlWindow::update_comment_if_needed(bn);

    kvtable->updateNodeFromThis(bn);

    ProfiledStereotypes::modified(bn, newst);

    bn->modified();
    bn->package_modified();
    data->modified();

    Q3TabDialog::accept();
}
Beispiel #19
0
void TextCanvas::save(QTextStream & st, bool ref, QString &) const {
    if (ref)
        st << "textcanvas_ref " << get_ident();
    else {
        nl_indent(st);
        st << "textcanvas " << get_ident() << ' ';
        save_string(fromUnicode(text), st);
        nl_indent(st);
        if (itsfont != UmlNormalFont)
            st << "  font " << stringify(itsfont);
        if (fg_c != UmlBlack)
            st << "  fg " << stringify(fg_c);
        if (bg_c != UmlTransparent)
            st << "  bg " << stringify(bg_c);
        save_xyzwh(st, this, "  xyzwh");
    }
}
void TransitionDialog::accept()
{
    if (!check_edits(edits) || !kvtable->check_unique())
        return;

    BrowserNode * bn = rel->browser_node;
    QString s;

    s = edname->text().trimmed();

    if (s.isEmpty())
        s = "<transition>";

    if ((s != bn->get_name()) &&
        ((BrowserNode *) bn->parent())->wrong_child_name(s, UmlTransition,
                bn->allow_spaces(),
                bn->allow_empty()))
        msg_critical(tr("Error"), s + tr("\n\nillegal name or already used"));
    else {
        bn->set_name(s);

        bool newst = rel->set_stereotype(fromUnicode(edstereotype->currentText().trimmed()));

        if (internal_cb != 0)
            rel->set_internal(internal_cb->isChecked());

        uml.accept(rel->uml);
        cpp.accept(rel->cpp);
        java.accept(rel->java);

        bn->set_comment(comment->text());
        UmlWindow::update_comment_if_needed(bn);

        kvtable->updateNodeFromThis(bn);

        ProfiledStereotypes::modified(bn, newst);

        bn->modified();
        bn->package_modified();
        rel->modified();

        TabDialog::accept();
    }
}
Beispiel #21
0
void SimpleRelationDialog::accept() {
  if (!check_edits(edits) || !kvtable->check_unique())
    return;
    
  BrowserNode * bn = rel->get_browser_node();
  bool newst = rel->set_stereotype(fromUnicode(edstereotype->currentText().stripWhiteSpace()));
  
  bn->set_comment(comment->text());
  UmlWindow::update_comment_if_needed(bn);
  
  kvtable->update(bn);
  
  ProfiledStereotypes::modified(bn, newst);
  
  bn->package_modified();
  rel->modified();
  
  QTabDialog::accept();
}
Beispiel #22
0
void ParameterSetDialog::accept()
{
    if (!check_edits(edits) || !kvtable->check_unique())
        return;

    QString s = edname->text().stripWhiteSpace();
    BrowserParameterSet * bn =
        (BrowserParameterSet *) data->get_browser_node();

    if ((s != bn->get_name()) &&
        ((BrowserNode *) bn->parent())->wrong_child_name(s, bn->get_type(),
                bn->allow_spaces(),
                bn->allow_empty()))
        msg_critical(TR("Error"), edname->text() + TR("\n\nillegal name or already used"));
    else {
        bn->set_name(s);
        bn->set_comment(comment->text());
        UmlWindow::update_comment_if_needed(bn);

        QString stereotype =
            fromUnicode(edstereotype->currentText().stripWhiteSpace());
        bool newst = data->set_stereotype(stereotype);
        Q3ValueList<BrowserPin *> l;
        unsigned n = lb_member->count();

        for (unsigned i = 0; i != n; i += 1)
            l.append((BrowserPin *)
                     (((ListBoxBrowserNode *) lb_member->item(i))
                      ->browser_node));

        data->set_pins(l);

        kvtable->updateNodeFromThis(bn);

        ProfiledStereotypes::modified(bn, newst);

        bn->modified();
        bn->package_modified();
        data->modified();

        Q3TabDialog::accept();
    }
}
Beispiel #23
0
void TextCanvas::send(ToolCom * com, QList<QGraphicsItem*> & all)
{
    QList<QGraphicsItem*>::Iterator cit;

    for (cit = all.begin(); cit != all.end(); ++cit) {
        DiagramItem * di = QCanvasItemToDiagramItem(*cit);

        if ((di != 0) &&
                (*cit)->isVisible() &&
                (di->typeUmlCode() == UmlText)) {
            TextCanvas * tx = (TextCanvas *) di;
            WrapperStr s = fromUnicode(tx->text);

            com->write_bool(TRUE);	// one more
            com->write_string((const char *) s);
            com->write(tx->rect());
        }
    }

    com->write_bool(FALSE);	// done
}
bool embeddedResult::reset (const QString& query)
{
    if (!driver() || !driver()->isOpen() || driver()->isOpenError() || !d->driver)
        return false;

    d->preparedQuery = false;

    cleanup();

    //qDebug() << "In reset: " + query;

    const QByteArray encQuery(fromUnicode(d->driver->d->tc, query));
    //const QByteArray encQuery = query.toLocal8Bit();

    if (mysql_real_query(d->driver->d->mysql, encQuery.data(), encQuery.length())) {
        setLastError(qMakeError(QCoreApplication::translate("embeddedResult", "Unable to execute query"),
                     QSqlError::StatementError, d->driver->d));
        return false;
    }
    d->result = mysql_store_result(d->driver->d->mysql);
    if (!d->result && mysql_field_count(d->driver->d->mysql) > 0) {
        setLastError(qMakeError(QCoreApplication::translate("embeddedResult", "Unable to store result"),
                    QSqlError::StatementError, d->driver->d));
        return false;
    }
    int numFields = mysql_field_count(d->driver->d->mysql);
    setSelect(numFields != 0);
    d->fields.resize(numFields);
    d->rowsAffected = mysql_affected_rows(d->driver->d->mysql);

    if (isSelect()) {
        for(int i = 0; i < numFields; i++) {
            MYSQL_FIELD* field = mysql_fetch_field_direct(d->result, i);
            d->fields[i].type = qDecodeMYSQLType(field->type, field->flags);
        }
        setAt(QSql::BeforeFirstRow);
    }
    setActive(true);
    return isActive();
}
void ExpansionRegionDialog::accept()
{
    if (!check_edits(edits) || !kvtable->check_unique())
        return;

    BrowserNode * bn = data->get_browser_node();

    if (edname != 0) {
        QString s = edname->text().trimmed();

        if ((s != bn->get_name()) &&
                ((BrowserNode *) bn->parent())->wrong_child_name(s, bn->get_type(),
                        bn->allow_spaces(),
                        bn->allow_empty())) {
            msg_critical(TR("Error"), edname->text() + TR("\n\nillegal name or already used"));
            return;
        }
        else
            bn->set_name(s);
    }

    data->must_isolate = must_isolate_cb->isChecked();
    data->mode = expansion_mode_kind(edmode->currentText().toLatin1().constData());

    bool newst = data->set_stereotype(fromUnicode(edstereotype->currentText().trimmed()));

    bn->set_comment(comment->text());
    UmlWindow::update_comment_if_needed(bn);

    kvtable->updateNodeFromThis(bn);

    ProfiledStereotypes::modified(bn, newst);

    bn->package_modified();
    data->modified();

    TabDialog::accept();
}
Beispiel #26
0
void FlowDialog::accept()
{
    if (!check_edits(edits) || !kvtable->check_unique())
        return;

    BrowserNode * bn = flow->browser_node;
    QString s;

    s = edname->text().stripWhiteSpace();

    if ((s != bn->get_name()) &&
        ((BrowserNode *) bn->parent())->wrong_child_name(s, UmlFlow,
                bn->allow_spaces(),
                bn->allow_empty()))
        msg_critical(TR("Error"), s + TR("\n\nillegal name or already used"));
    else {
        bn->set_name(s);

        bool newst = flow->set_stereotype(fromUnicode(edstereotype->currentText().stripWhiteSpace()));

        uml.accept(flow->uml);
        cpp.accept(flow->cpp);
        java.accept(flow->java);

        bn->set_comment(comment->text());
        UmlWindow::update_comment_if_needed(bn);

        kvtable->updateNodeFromThis(bn);

        ProfiledStereotypes::modified(bn, newst);

        bn->modified();
        bn->package_modified();
        flow->modified();

        Q3TabDialog::accept();
    }
}
Beispiel #27
0
void CodClassInstCanvas::send(ToolCom * com, QCanvasItemList & all)
{
  QList<CodClassInstCanvas> l;
  QCanvasItemList::Iterator cit;

  for (cit = all.begin(); cit != all.end(); ++cit) {
    DiagramItem *di = QCanvasItemToDiagramItem(*cit);
    
    if ((di != 0) && (*cit)->visible()) {
       switch (di->type()) {
       case UmlClass:
       case UmlClassInstance:
	 l.append((CodClassInstCanvas *) di);
	 break;
       default:
	 break;
       }
    }
  }

  com->write_unsigned(l.count());
  
  QListIterator<CodClassInstCanvas> it(l);
  
  for (; it.current(); ++it) {
    CodClassInstCanvas * i = it.current();
    
    com->write_unsigned((unsigned) i->get_ident());
    if (i->browser_node->get_type() == UmlClass) {      
      com->write_id(0);
      
      QCString s = fromUnicode(i->iname);
      
      com->write_string((const char *) s);
    }
    i->browser_node->write_id(com);
  }
}
Beispiel #28
0
// text() redefinition
QString LineEdit::text() const
{
    QString t = QLineEdit::text();

    return fromUnicode(t);
}
Beispiel #29
0
QString MultiLineEdit::stripWhiteSpaceText() const
{
    QString t = Q3TextEdit::text();

    return fromUnicode(t.stripWhiteSpace());
}
Beispiel #30
0
// text() redefinition
QString MultiLineEdit::text() const
{
    QString t = Q3TextEdit::text();

    return fromUnicode(t);
}