void SdDurationCanvas::merge(Q3PtrList<SdDurationCanvas> & l) { l.removeRef(this); QRect r = rect(); int vmin = r.top(); int vmax = r.bottom(); SdDurationCanvas * d; for (d = l.first(); d != 0; d = l.next()) { QRect dr = d->rect(); if (dr.top() < vmin) vmin = dr.top(); if (dr.bottom() > vmax) vmax = dr.bottom(); collapse(d); } if (vmin < r.top()) Q3CanvasItem::moveBy(0, vmin - r.top()); resize(r.width(), vmax - vmin + 1); update_self(); }
// ----------------------------------------------------------- void QucsApp::slotCursorLeft(bool left) { int sign = 1; if(left){ sign = -1; } if(!editText->isHidden()) return; // for edit of component property ? Q3PtrList<Element> movingElements; Schematic *Doc = (Schematic*)DocumentTab->currentWidget(); int markerCount = Doc->copySelectedElements(&movingElements); if((movingElements.count() - markerCount) < 1) { if(markerCount > 0) { // only move marker if nothing else selected Doc->markerLeftRight(left, &movingElements); } else if(left) { if(Doc->scrollLeft(Doc->horizontalScrollBar()->singleStep())) Doc->scrollBy(-Doc->horizontalScrollBar()->singleStep(), 0); }else{ // right if(Doc->scrollRight(-Doc->horizontalScrollBar()->singleStep())) Doc->scrollBy(Doc->horizontalScrollBar()->singleStep(), 0); } Doc->viewport()->update(); view->drawn = false; return; } else { // random selection. move all of them view->moveElements(&movingElements, sign*Doc->GridX, 0); view->MAx3 = 1; // sign for moved elements view->endElementMoving(Doc, &movingElements); } }
void ClassData::get_actuals(Q3PtrList<ActualParamData> & l, BrowserClass * parent) { if (((BrowserNode *) parent->parent())->get_type() == UmlClass) get_actuals(l, (BrowserClass *) parent->parent()); ActualParamData * actual; int n = ((ClassData *) parent->get_data())->nformals; if (n != 0) { // search the first associated actual for (actual = actuals.first(); actual != 0; actual = actuals.next()) { if ((actual->get_class() == parent) && (l.findRef(actual) == -1)) // find; break; } int nth = 0; // progress on still present formals while (actual && (nth < n) && (actual->get_class() == parent)) { // actual ok l.append(actual); actual = actuals.next(); nth += 1; } } }
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()); } }
void ClassData::update_actuals() { if (DontUpdateActuals) return; // an inherited parent was modified/deleted, updates all actuals Q3PtrList<BrowserNode> parents = browser_node->parents(); Q3PtrList<ActualParamData> new_actuals; Q3PtrList<ActualParamData> managed; BrowserClass * parent; for (parent = (BrowserClass *) parents.first(); parent != 0; parent = (BrowserClass *) parents.next()) update_actuals(parent, new_actuals, managed); if (!(actuals == new_actuals)) { ActualParamData * actual; for (actual = actuals.first(); actual != 0; actual = actuals.next()) if (new_actuals.findRef(actual) == -1) delete actual; actuals = new_actuals; browser_node->package_modified(); } // note : even if actuals == new_actuals to take // into account change in already existing formal and actual emit actuals_changed(); }
void ReferenceDialog::compute() { QApplication::setOverrideCursor(Qt::waitCursor); Q3PtrList<BrowserNode> l; BrowserNode * bn; nodes.clear(); results->clear(); target->referenced_by(l); for (bn = l.first(); bn; bn = l.next()) nodes.append(bn); nodes.sort(); // remove duplicats nodes.first(); while ((bn = nodes.current()) != 0) if (bn == nodes.next()) nodes.remove(); QStringList names; nodes.full_names(names); QStringList::Iterator it; for (bn = nodes.first(), it = names.begin(); bn; bn = nodes.next(), ++it) results->insertItem(*(bn->pixmap(0)), *it); selected((nodes.isEmpty()) ? -1 : 0); QApplication::restoreOverrideCursor(); }
void QueueEditor::recursiveSaveData(KFTPQueue::TransferDir *parent, const KUrl &srcUrl, const KUrl &dstUrl) { KFTPQueue::QueueObject *o; Q3PtrList<KFTPQueue::QueueObject> children = parent->getChildrenList(); KUrl sUrl, dUrl; for (o = children.first(); o; o = children.next()) { KFTPQueue::Transfer *i = static_cast<KFTPQueue::Transfer*>(o); // Modify the urls sUrl = srcUrl; dUrl = dstUrl; sUrl.addPath(i->getSourceUrl().fileName()); dUrl.addPath(i->getDestUrl().fileName()); // Set the urls i->setSourceUrl(sUrl); i->setDestUrl(dUrl); i->setTransferType(m_lastTransferType); i->emitUpdate(); if (i->isDir()) recursiveSaveData(static_cast<KFTPQueue::TransferDir*>(i), sUrl, dUrl); } }
void UmlJunctionPseudoState::generate(UmlClass * machine, UmlClass * anystate, UmlState * state) { // create an operation because a priori shared if (_oper.isEmpty()) _oper.sprintf("_junction%d", ++_rank); UmlClass * cl = state->assocClass(); UmlOperation * junction; if (((junction = (UmlOperation *) cl->getChild(anOperation, _oper)) == 0) && ((junction = UmlBaseOperation::create(cl, _oper)) == 0)) { UmlCom::trace("Error : cannot create operation '" + _oper + "' in class '" + cl->name() + "'<br>"); throw 0; } junction->defaultDef(); junction->setComment("implement a junction, through an operation because shared, internal"); junction->setType("void", "${type}"); junction->addParam(0, InputOutputDirection, "stm", machine); junction->setParams("${t0} & ${p0}"); Q3CString body; const Q3PtrVector<UmlItem> ch = children(); Q3PtrList<UmlTransition> trs; unsigned index; for (index = 0; index != ch.count(); index += 1) if (ch[index]->kind() == aTransition) // theo mandatory trs.append((UmlTransition *) ch[index]); UmlTransition::generate(trs, machine, anystate, state, body, " ", FALSE); junction->set_CppBody(body); }
void BrowserNode::signal_unconsistencies() { QString pfix = TR("<p><b>Warning, the model is not consistent because some elements have\n" "the same internal identifier.</b></p>\n" "<p>Users working on the same project have the same use identifier,\n" "or you had change the model files, or used Project synchro\n" "without following the mandatory rules</p>\n"); QString msg; if (!UnconsistencyDeletedMsg.isEmpty()) msg = pfix + "<p>" + TR("These elements was <b>removed</b>") + " :</p>\n <ul>" + UnconsistencyDeletedMsg + "</ul>\n"; if (!UnconsistencyFixedMsg.isEmpty()) { if (UnconsistencyDeletedMsg.isEmpty()) msg = pfix; msg += "<p>" + TR("The internal identifier of these elements was changed,\n" "but <u>I can't garantee the references to them are the right one</u>,\n" "check your model") + " :</p>\n<ul>" + UnconsistencyFixedMsg + "</ul>\n"; do_change_shared_ids(); do ModifiedPackages.take(0)->is_modified = TRUE; while (! ModifiedPackages.isEmpty()); } if (! msg.isEmpty()) { UnconsistencyDeletedMsg = UnconsistencyFixedMsg = QString::null; warn(msg); } }
void DOMTreeView::slotMovedItems(Q3PtrList<QTreeWidgetItem> &items, Q3PtrList<QTreeWidgetItem> &/*afterFirst*/, Q3PtrList<QTreeWidgetItem> &afterNow) { MultiCommand *cmd = new MultiCommand(i18n("Move Nodes")); _refreshed = false; Q3PtrList<QTreeWidgetItem>::Iterator it = items.begin(); Q3PtrList<QTreeWidgetItem>::Iterator anit = afterNow.begin(); for (; it != items.end(); ++it, ++anit) { DOMListViewItem *item = static_cast<DOMListViewItem *>(*it); DOMListViewItem *anitem = static_cast<DOMListViewItem *>(*anit); DOM::Node parent = static_cast<DOMListViewItem *>(item->parent())->node(); Q_ASSERT(!parent.isNull()); // kDebug(90180) << " afternow " << anitem << " node " << (anitem ? anitem->node().nodeName().string() : QString()) << "=" << (anitem ? anitem->node().nodeValue().string() : QString()); cmd->addCommand(new MoveNodeCommand(item->node(), parent, anitem ? anitem->node().nextSibling() : parent.firstChild()) ); } mainWindow()->executeAndAddCommand(cmd); // refresh *anyways*, otherwise consistency is disturbed if (!_refreshed) refresh(); slotShowNode(current_node); }
// ----------------------------------------------------------- void QucsApp::slotCursorRight() { if(!editText->isHidden()) return; // for edit of component property ? Q3PtrList<Element> movingElements; Schematic *Doc = (Schematic*)DocumentTab->currentPage(); int markerCount = Doc->copySelectedElements(&movingElements); if((movingElements.count() - markerCount) < 1) { if(markerCount > 0) { // only move marker if nothing else selected Doc->markerLeftRight(false, &movingElements); movingElements.clear(); } else { if(Doc->scrollRight(-Doc->horizontalScrollBar()->lineStep())) Doc->scrollBy(Doc->horizontalScrollBar()->lineStep(), 0); } Doc->viewport()->update(); view->drawn = false; return; } view->moveElements(&movingElements, Doc->GridX, 0); // move "GridX" to right view->MAx3 = 1; // sign for moved elements view->endElementMoving(Doc, &movingElements); }
PlotLine * SINWAV::calculateCustom (QString &, Q3PtrList<PlotLine> &) { Q3PtrList<PlotLine> pll; pll.setAutoDelete(FALSE); getSINWAV(pll); pll.remove(1); return pll.at(0); }
void UmlClass::extend(WrapperStr mcl) { if (parent()->parent()->kind() != aPackage) return; int index = mcl.find('#'); if (index == -1) return; WrapperStr path = mcl.left(index); const char * defltpath0 = "http://schema.omg.org/spec/UML/2.0/uml.xml"; const char * defltpath1 = "http://schema.omg.org/spec/UML/2.1/uml.xml"; bool dflt = ((path == defltpath0) || (path == defltpath1)); mcl = mcl.mid(index + 1); static Q3PtrList<UmlClass> metaclasses; Q3PtrListIterator<UmlClass> it(metaclasses); UmlClass * metacl = UmlClass::get(mcl, 0); WrapperStr s; if ((metacl == 0) || (metacl->stereotype() != "metaclass") || !((dflt) ? (!metacl->propertyValue("metaclassPath", s) || (s == defltpath0) || (s == defltpath1)) : (metacl->propertyValue("metaclassPath", s) && (path == s)))) { metacl = 0; if (dflt) { for (; (metacl = it.current()) != 0; ++it) { if (!strcmp(mcl, metacl->name()) && (!metacl->propertyValue("metaclassPath", s) || (s == defltpath0) || (s == defltpath1))) break; } } else { for (; (metacl = it.current()) != 0; ++it) { if (!strcmp(mcl, metacl->name()) && metacl->propertyValue("metaclassPath", s) && (path == s)) break; } } if (metacl == 0) { metacl = addMetaclass(mcl, (dflt) ? 0 : (const char *)path); //[rageek] different types for ? : metaclasses.append(metacl); } } UmlRelation::create(aDirectionalAssociation, this, metacl); }
bool ClassInstanceData::change_rel(ToolCom * com, const char * args, bool isadd) { com->get_unsigned(args); // 2 BrowserRelation * r = (BrowserRelation *) com->get_id(args); BrowserClassInstance * other = (BrowserClassInstance *) com->get_id(args); if (r->deletedp() || other->deletedp()) { com->write_ack(FALSE); return FALSE; } RelationData * rd = (RelationData *) r->get_data(); Q3ValueList<SlotRel>::Iterator it; for (it = relations.begin(); it != relations.end(); ++it) { const SlotRel & slot_rel = *it; if ((slot_rel.value == other) && (r == ((slot_rel.is_a) ? rd->get_start() : rd->get_end()))) break; } if (isadd) { if (it == relations.end()) { // not yet present Q3PtrList<BrowserRelation> l; cl->get_rels(((ClassInstanceData *)other->get_data())->cl, l); if ((l.findRef(r) == -1) || (!other->is_writable() && !root_permission())) { // illegal com->write_ack(FALSE); return FALSE; } // add it if (rd->is_a(r)) add(other, rd); else ((ClassInstanceData *)other->get_data()) ->add((BrowserClassInstance *) browser_node, rd); } } else if (it != relations.end()) { // remove it if (!other->is_writable() && !root_permission()) { // illegal com->write_ack(FALSE); return FALSE; } replace(other, rd, 0, (*it).is_a, 0); } return TRUE; }
void UmlCanvas::update_global_settings() { UmlCanvas * c; for (c = All.first(); c != 0; c = All.next()) { c->br_diagram->update_drawing_settings(); c->show_shadow = c->br_diagram->get_shadow(); c->draw_all_relations = c->br_diagram->get_draw_all_relations(); } }
void RuleStack::push( Q3PtrList<KScoringRule> &l ) { kDebug(5100) <<"RuleStack::push pushing list with" << l.count() <<" rules"; KScoringManager::ScoringRuleList *l1 = new KScoringManager::ScoringRuleList; for ( KScoringRule *r=l.first(); r != 0; r=l.next() ) { l1->append( new KScoringRule( *r ) ); } stack.push( l1 ); kDebug(5100) <<"now there are" << stack.count() <<" lists on the stack"; }
void RelationData::post_load() { while (! IncludeToHeaderIfExternal.isEmpty()) { RelationData * rd = IncludeToHeaderIfExternal.take(0); if ((rd->end_removed_from != 0) && (rd->end_removed_from->get_type() == UmlClass) && ((ClassData *) rd->end_removed_from->get_data())->cpp_is_external()) rd->a.cpp_decl = "#include in header"; } }
void UmlTransition::generate(UmlClass * machine, UmlClass * anystate, UmlState * state, Q3CString & body, Q3CString indent) { if (!cppTrigger().isEmpty()) { UmlCom::trace("Error : transition from a pseudo state can't have trigger<br>"); throw 0; } Q3PtrList<UmlTransition> l; l.append(this); generate(l, machine, anystate, state, body, indent, FALSE); }
void BrowserNode::unconsistent_fixed(const char * what, BrowserNode * newone) { UnconsistencyFixedMsg += QString("<li>") + what + QString(" <i>") + quote(full_name()) + QString("</i> and <i>") + quote(newone->full_name()) + QString("</i></li>\n"); BrowserNode * bn = this; while (bn->get_type() != UmlPackage) bn = (BrowserNode *) bn->parent(); if (ModifiedPackages.findRef(bn) == -1) ModifiedPackages.append(bn); }
// check inheritance QString BrowserNode::check_inherit(const BrowserNode * new_parent) const { Q3PtrList<BrowserNode> all_parents; Q3PtrList<BrowserNode> notyet = parents(); if (notyet.findRef(new_parent) != -1) return TR("already generalize / realize"); notyet.append(new_parent); do { BrowserNode * cl = notyet.getFirst(); notyet.removeFirst(); if (cl == this) return TR("can't have circular generalization / realization"); if (all_parents.findRef(cl) == -1) { all_parents.append(cl); Q3PtrList<BrowserNode> grand_parents = cl->parents(); for (cl = grand_parents.first(); cl; cl = grand_parents.next()) if (notyet.findRef(cl) == -1) notyet.append(cl); } } while (! notyet.isEmpty()); return 0; }
void ClassData::update_actuals(BrowserClass * parent, Q3PtrList<ActualParamData> & new_actuals, Q3PtrList<ActualParamData> & managed) { if (((BrowserNode *) parent->parent())->get_type() == UmlClass) update_actuals((BrowserClass *) parent->parent(), new_actuals, managed); ActualParamData * actual; int n = ((ClassData *) parent->get_data())->nformals; if (n != 0) { // search the first associated actual for (actual = actuals.first(); actual != 0; actual = actuals.next()) { if ((actual->get_class() == parent) && (managed.findRef(actual) == -1)) // find; break; } int nth = 0; // progress on still present formals while (actual && (nth < n) && (actual->get_class() == parent)) { // actual ok new_actuals.append(actual); managed.append(actual); actual = actuals.next(); nth += 1; } if (nth < n) { // adds necessary actuals if (nth == 0) { // new inheritance connect(parent->get_data(), SIGNAL(deleted()), this, SLOT(update_actuals())); connect(parent->get_data(), SIGNAL(changed()), this, SLOT(update_actuals())); } do { new_actuals.append(new ActualParamData(parent, nth)); nth += 1; } while (nth != n); } } }
Indicator * SINWAV::calculate () { Indicator *output = new Indicator; output->setDateFlag(dateFlag); output->setLogScale(logScale); Q3PtrList<PlotLine> pll; pll.setAutoDelete(FALSE); getSINWAV(pll); int loop; for (loop = 0; loop < (int) pll.count(); loop++) output->addLine(pll.at(loop)); return output; }
void UmlArtifact::mark_useless(Q3PtrList<UmlItem> & l) { if (useless) { set_isMarked(TRUE); parent()->set_childrenVisible(TRUE); l.append(this); } }
void Q3SocketPrivate::close() { closeSocket(); wsize = 0; rba.clear(); wba.clear(); windex = 0; }
void CppRefType::force_ref(UmlClass * cl, Q3PtrList<CppRefType> & l) { CppRefType * ref; WrapperStr t = cl->name(); for (ref = l.first(); ref; ref = l.next()) { // don't use ref->type.toString() because of synonymous // in several namespaces if ((ref->type.type != 0) ? (ref->type.type == cl) : (ref->type.explicit_type == t)) { ref->included = FALSE; return; } } }
void RuleStack::pop( Q3PtrList<KScoringRule> &l ) { top( l ); drop(); kDebug(5100) <<"RuleStack::pop pops list with" << l.count() <<" rules"; kDebug(5100) <<"now there are" << stack.count() <<" lists on the stack"; }
// ----------------------------------------------------------- void QucsApp::slotCursorDown() { if(!editText->isHidden()) { // for edit of component property ? if(view->MAx3 == 0) return; // edit component namen ? Component *pc = (Component*)view->focusElement; Property *pp = pc->Props.at(view->MAx3-1); // current property int Pos = pp->Description.find('['); if(Pos < 0) return; // no selection list ? Pos = pp->Description.find(editText->text(), Pos); // current list item if(Pos < 0) return; // should never happen Pos = pp->Description.find(',', Pos); if(Pos < 0) return; // was last item ? Pos++; if(pp->Description.at(Pos) == ' ') Pos++; // remove leading space int End = pp->Description.find(',', Pos); if(End < 0) { // is last item ? End = pp->Description.find(']', Pos); if(End < 0) return; // should never happen } editText->setText(pp->Description.mid(Pos, End-Pos)); editText->selectAll(); return; } Q3PtrList<Element> movingElements; Schematic *Doc = (Schematic*)DocumentTab->currentPage(); int markerCount = Doc->copySelectedElements(&movingElements); if((movingElements.count() - markerCount) < 1) { if(markerCount > 0) { // only move marker if nothing else selected Doc->markerUpDown(false, &movingElements); movingElements.clear(); } else { if(Doc->scrollDown(-Doc->verticalScrollBar()->lineStep())) Doc->scrollBy(0, Doc->verticalScrollBar()->lineStep()); } Doc->viewport()->update(); view->drawn = false; return; } view->moveElements(&movingElements, 0, Doc->GridY); // move "GridY" down view->MAx3 = 1; // sign for moved elements view->endElementMoving(Doc, &movingElements); }
void Q3SocketPrivate::connectionClosed() { // We keep the open state in case there's unread incoming data state = Q3Socket::Idle; closeSocket(); wba.clear(); windex = wsize = 0; }
int main(int /*argc*/, char ** /*argv*/) { Q3PtrList<Node> list; list.setAutoDelete(true); Q3AsciiDict<Node> dict; KOffice::PriorityQueue<Node> queue; srand(time(0)); for (int i = 0; i < 12; ++i) { Node *n = new Node(rand() % 20); list.append(n); queue.insert(n); // Check whether the AsciiDict CTOR is okay Node *n2 = new Node(*n); dict.insert(keys[ i ], n2); } kDebug() << "##### Queue 1:"; queue.dump(); kDebug() << "##### Queue 2:"; KOffice::PriorityQueue<Node> queue2(dict); queue2.dump(); Node *n = list.at(6); kDebug() << "##### Decreasing node:" << n->key() << " at" << n->index(); n->setKey(2); queue.keyDecreased(n); queue.dump(); n = list.at(2); kDebug() << "##### Decreasing node:" << n->key() << " at" << n->index(); n->setKey(0); queue.keyDecreased(n); queue.dump(); n = queue.extractMinimum(); while (n) { queue.dump(); n = queue.extractMinimum(); } return 0; }
// returns all parents for NON class Q3PtrList<BrowserNode> BrowserNode::parents() const { Q3PtrList<BrowserNode> l; Q3ListViewItem * child; for (child = firstChild(); child != 0; child = child->nextSibling()) { BrowserNode * ch = ((BrowserNode *) child); switch (ch->get_type()) { case UmlInherit: if (!ch->deletedp()) l.append(((SimpleRelationData *) ch->get_data()) ->get_end_node()); default: break; } } return l; }