void ColMsgTable::refresh(ColMsgList & m) { ColMsg * msg; Q3PtrListIterator<ColMsg> it(m); for ( ; (msg = it.current()) != 0; ++it) { QString def = msg->def(FALSE, TRUE, UmlView, DefaultShowContextMode); CodObjCanvas * from; CodObjCanvas * to; int r = numRows(); msg->in->get_from_to(from, to, msg->is_forward); setNumRows(r + 1); setItem(r, ABS_RANK_COL, new MsgTableItem(this, msg->absolute_rank)); setItem(r, HI_RANK_COL, new MsgTableItem(this, msg->hierarchical_rank)); setItem(r, FROM_COL, new MsgTableItem(this, from->get_full_name())); setItem(r, MSG_COL, new MsgTableItem(this, def.mid(def.find(' ') + 1))); setItem(r, TO_COL, new MsgTableItem(this, to->get_full_name())); setItem(r, CMD_COL, new MsgTableItem(this, TR("do"), Qt::AlignHCenter)); flat_msg_list.append(msg); if (rec) refresh(msg->msgs); } }
ColMsg * ColMsg::new_one(const OperationData * d, const QString & e, bool f, const QString & hr, CodMsgSupport * in) { ColMsg * result = new ColMsg(f, d, e, hr, in); result->place_in_its_support(); return result; }
bool CodMsgSupport::supports(BrowserNode * bn) { BasicData * data = bn->get_data(); ColMsg * msg; for (msg = msgs.first(); msg != 0; msg = msgs.next()) if ((BasicData *) msg->get_operation() == data) return TRUE; return FALSE; }
void ColMsgTable::edit_msg(int row) { ColMsg * msg = flat_msg_list[row]; CodChangeMsgDialog d(this, msg); if (d.exec() == QDialog::Accepted) { QString def = msg->def(FALSE, TRUE, UmlView, DefaultShowContextMode); msg->in->update_msgs(); item(row, MSG_COL)->setText(def.mid(def.find(' ') + 1)); updateCell(row, MSG_COL); } }
void ColMsgTable::save_list(ColMsgList & l, Q3PtrDict<ColMsgList> & saved) { if (saved.find(&l) == 0) { saved.insert(&l, new ColMsgList(l)); Q3PtrListIterator<ColMsg> it(l); for (; it.current(); ++it) { ColMsg * m = it.current(); save_list(m->get_msgs(), saved); save_list(m->in->get_msgs(), saved); } } }
void ColMsgTable::change_ranks(int row, int col) { ColMsg * msg = flat_msg_list[row]; HierarchicalRankValidator validator(view, msg->hierarchical_rank); BooL ok; QString new_hr = MyInputDialog::getText(TR("Enter new hierarchical rank"), TR("Hierarchical rank : "), msg->hierarchical_rank, ok, &validator); if (ok && (new_hr != msg->hierarchical_rank)) { QString old_hr = msg->hierarchical_rank; #ifndef NEW_METHOD // it may be (?, not reproduced) not possible to reintroduce the message // at its original rank when the new rank is wrong => stop to follow this // way and save the original def before trying to use the new rank ;-( // // Fixed by doing a ColDiagramView::update_msgs() after load ? for (;;) { msg->in->remove_it(msg); msg->extract_it(view->get_msgs()); ColMsg::update_ranks(view->get_msgs()); msg->hierarchical_rank = new_hr; msg->place_in_internal(view->get_msgs()); msg->place_in_its_support(); ColMsg::update_ranks(view->get_msgs()); if (new_hr.find('.') != -1) { // upper level msg dest must be msg start ColMsg * upper = ColMsg::find_rec(new_hr.left(new_hr.findRev('.')), view->get_msgs()); if (upper == 0) // error new_hr = QString::null; else { CodObjCanvas * from; CodObjCanvas * from_bis; CodObjCanvas * to; msg->in->get_from_to(from, to, msg->is_forward); upper->in->get_from_to(from_bis, to, upper->is_forward); if (to != from) // error new_hr = QString::null; } } if (msg->hierarchical_rank != new_hr) { msg_warning(TR("Warning"), TR("Invalid hierarchical rank")); new_hr = old_hr; } else break; } view->update_msgs(); if (new_hr != old_hr) { refresh(); setCurrentCell(flat_msg_list.findIndex(msg), col); } #else // save all the messages Q3PtrDict<ColMsgList> saved; saved.setAutoDelete(TRUE); save_list(view->get_msgs(), saved); // remove the message msg->in->remove_it(msg); msg->extract_it(view->get_msgs()); ColMsg::update_ranks(view->get_msgs()); // try to insert the msg with the asked rank msg->hierarchical_rank = new_hr; msg->place_in_internal(view->get_msgs()); msg->place_in_its_support(); ColMsg::update_ranks(view->get_msgs()); if (new_hr.find('.') != -1) { // upper level msg dest must be msg start ColMsg * upper = ColMsg::find_rec(new_hr.left(new_hr.findRev('.')), view->get_msgs()); if (upper == 0) // error new_hr = QString::null; else { CodObjCanvas * from; CodObjCanvas * from_bis; CodObjCanvas * to; msg->in->get_from_to(from, to, msg->is_forward); upper->in->get_from_to(from_bis, to, upper->is_forward); if (to != from) // error new_hr = QString::null; } } if (msg->hierarchical_rank != new_hr) { msg_warning(TR("Warning"), TR("Invalid hierarchical rank")); msg->hierarchical_rank = old_hr; // restore saved lists Q3PtrDictIterator<ColMsgList> it(saved); while (it.current()) { *((ColMsgList *) it.currentKey()) = *(it.current()); ++it; } } view->update_msgs(); refresh(); setCurrentCell(flat_msg_list.findIndex(msg), col); #endif } }
CodAddMsgDialog::CodAddMsgDialog(CodObjCanvas * from, CodObjCanvas * to, CodMsgSupport * i, ColDiagramView * v, bool fo) : QDialog(0, "add msg dialog", TRUE), in(i), view(v), forward(fo) { setCaption(TR("Add message dialog")); QVBoxLayout * vbox = new QVBoxLayout(this); QHBoxLayout * hbox; vbox->setMargin(5); hbox = new QHBoxLayout(vbox); hbox->setMargin(10); QLabel * label1 = new QLabel(TR("Add message to %1", to->get_full_name()), this); label1->setAlignment(AlignCenter); hbox->addWidget(label1); QGrid * grid = new QGrid(2, this); vbox->addWidget(grid); new QLabel(TR("rank : "), grid); cbrank = new QComboBox(FALSE, grid); ColMsgList all_in; ColMsgList all_out; from->get_all_in_all_out(all_in, all_out); ColMsg * m; QStringList new_ones; QListIterator<ColMsg> itout(all_out); for (; (m = itout.current()) != 0; ++itout) { QString s = m->next_hierarchical_rank(); if ((s.find('.') != - 1) && (ColMsg::find(s, all_out) == 0)) { cbrank->insertItem(QString::number(m->get_rank() + 1) + " : " + s); new_ones.append(s); } } QListIterator<ColMsg> itin(all_in); for (; (m = itin.current()) != 0; ++itin) { QString s = m->get_hierarchical_rank() + ".1"; if ((ColMsg::find(s, all_out) == 0) && (new_ones.findIndex(s) == -1)) { cbrank->insertItem(QString::number(m->get_rank() + 1) + " : " + s); new_ones.append(s); } } // add a the rank for a new toplevel link cbrank->insertItem(QString::number(ColMsg::last_rank(view->get_msgs()) + 1) + " : " + QString::number(view->get_msgs().count() + 1)); // the default new one follow the last input or output or view's last msg cbrank->setCurrentItem((cbrank->count() == 1) ? 0 : cbrank->count() - 2); QSizePolicy sp = cbrank->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); cbrank->setSizePolicy(sp); new QLabel("", grid); new QLabel("", grid); // the operations SmallPushButton * b = new SmallPushButton(TR("message :"), grid); connect(b, SIGNAL(clicked()), this, SLOT(menu_op())); edoper = new QComboBox(TRUE, grid); edoper->setAutoCompletion(completion()); // gets operations cl = to->get_class(); if (cl != 0) { cl->get_opers(opers, list); edoper->insertStringList(list); if (!cl->is_writable()) cl = 0; } edoper->setSizePolicy(sp); new QLabel("", grid); new QLabel("", grid); // ok & cancel hbox = new QHBoxLayout(vbox); hbox->setMargin(5); QPushButton * ok = new QPushButton(TR("&OK"), this); QPushButton * cancel = new QPushButton(TR("&Cancel"), this); QSize bs(cancel->sizeHint()); ok->setDefault(TRUE); ok->setFixedSize(bs); cancel->setFixedSize(bs); hbox->addWidget(ok); hbox->addWidget(cancel); connect(ok, SIGNAL(clicked()), this, SLOT(accept())); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); }