// return pixmap for zoom 100% QPixmap * get_pixmap(const char * path) { QPixmap * px = DiagramPixmap.find(path); if (px == 0) { QString abspath; if (!QDir::isRelativePath(path)) abspath = path; else if ((UmlWindow::images_root_dir().isEmpty() || !QFile::exists(abspath = QDir::cleanDirPath(UmlWindow::images_root_dir() + '/' + path))) && !QFile::exists(abspath = path)) abspath = BrowserView::get_dir().absFilePath(path); px = new QPixmap(abspath); DiagramPixmap.insert(path, px); if (px->isNull()) { msg_critical(TR("Error"), QString(path) + TR("\ndoesn't exist or is not a know image format")); return 0; } DiagramScaledPixmap.insert(path, new Q3PtrDict<QPixmap>()); } return (px->isNull()) ? 0 : px; }
void UmlClass::java(Q3Dict<Q3CString> & prop) { if (!scanning) { Q3CString d = (stereotype() == "interface") ? JavaSettings::interfaceDecl() : JavaSettings::classDecl(); Q3CString * v; if ((v = prop.find("Java/Final")) != 0) { if (*v == "TRUE") set_isJavaFinal(TRUE); prop.remove("Java/Final"); } if ((v = prop.find("Java/Strictfp")) != 0) { if (*v == "TRUE") { int index; if ((index = d.find("${public}")) != -1) d.insert((unsigned) index + 9, "strictfp "); else if ((index = d.find("${visibility}")) != -1) d.insert((unsigned) index + 13, "strictfp "); } prop.remove("Java/Strictfp"); } set_JavaDecl(d); } }
void init_images() { DiagramPixmap.setAutoDelete(TRUE); DiagramPixmap.clear(); DiagramScaledPixmap.setAutoDelete(TRUE); DiagramScaledPixmap.clear(); }
// this is useful, memorize it and its diagrams and classes body file void BrowserNode::memo(Q3Dict<void> & useful) { useful.insert(filename, (void *) 1); QStringList::Iterator its; for (its = diagrams.begin(); its != diagrams.end(); ++its) useful.insert(*its, (void *) 1); for (its = classes.begin(); its != classes.end(); ++its) useful.insert(*its, (void *) 1); }
bool UmlClass::isAppliedStereotype(Token & tk, WrapperStr & prof_st, Q3ValueList<WrapperStr> & base_v) { static Q3Dict<WrapperStr> stereotypes; static Q3Dict<Q3ValueList<WrapperStr> > bases; WrapperStr s = tk.what(); WrapperStr * st = stereotypes[s]; if (st != 0) { prof_st = *st; base_v = *bases[s]; return TRUE; } base_v.clear(); if (tk.xmiType().isEmpty() && (getFct(tk) == 0)) { int index = s.find(':'); if ((index != -1) && ((index != 3) || ((s.left(3) != "uml") && (s.left(3) != "xmi")))) { UmlClass * cl = findStereotype(s, FALSE); if (cl != 0) { const Q3PtrVector<UmlItem> ch = cl->children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) { UmlItem * x = ch[i]; if ((x->kind() == aRelation) && (((UmlRelation *) x)->relationKind() == aDirectionalAssociation) && (((UmlRelation *) x)->roleType()->stereotype() == "metaclass")) base_v.append("base_" + ((UmlRelation *) x)->roleType()->name().lower()); } if (base_v.isEmpty()) base_v.append("base_element"); prof_st = cl->parent()->parent()->name() + ":" + cl->name(); stereotypes.insert(s, new WrapperStr(prof_st)); bases.insert(s, new Q3ValueList<WrapperStr>(base_v)); return TRUE; } } } return FALSE; }
void Package::scan_dir(int & n) { // count files UmlCom::message("count files ..."); n = count_file_number(); H_Managed.clear(); Src_Managed.clear(); set_step(1, n); scan_dir(); H_Managed.clear(); Src_Managed.clear(); set_step(1, -1); }
Package::Package(Package * parent, UmlPackage * pk) : BrowserNode(parent, pk->name()) { //if (text(0) == "unknown") // unknown = this; uml = pk; QDir d_root(RootSDir); h_path = force_final_slash(pk->cppHDir()); if (h_path.isEmpty()) h_path = RootCDir; else if (QDir::isRelativePath(h_path)) { if (RootCDir.isEmpty()) { WrapperStr err = "<font face=helvetica><b>root path not set in <i>generation settings</i>, " "don't know where is <i>" + h_path + "<i></b></font><br>"; UmlCom::trace(err); } else h_path = force_final_slash(d_root.filePath(h_path)); } src_path = force_final_slash(pk->cppSrcDir()); if (src_path.isEmpty()) src_path = RootCDir; else if (QDir::isRelativePath(src_path)) { if (RootCDir.isEmpty()) { WrapperStr err = "<font face=helvetica><b>root path not set in <i>generation settings</i>, " "don't know where is <i>" + src_path + "<i></b></font><br>"; UmlCom::trace(err); } else src_path = force_final_slash(d_root.filePath(src_path)); } namespace_ = pk->cppNamespace(); if (!h_path.isEmpty()) Pack_From_Path.replace(h_path, this); if ((h_path != src_path) && !src_path.isEmpty()) Pack_From_Path.replace(src_path, this); }
void Package::own(UmlArtifact * art) { QDir hd(h_path); QDir sd(src_path); Roundtriped.insert(hd.absFilePath(art->name() + "." + CppSettings::headerExtension()), art); Roundtriped.insert(sd.absFilePath(art->name() + "." + CppSettings::sourceExtension()), art); }
void UmlClass::cplusplus(Q3Dict<Q3CString> & prop) { if (!scanning) { if (stereotype() == "typedef") { Q3CString * bt = prop.find("Cplusplus/ImplementationType"); if (bt != 0) { UmlTypeSpec t; t.explicit_type = *bt; // no quidu set_BaseType(t); } set_CppDecl(CppSettings::typedefDecl()); } else if (stereotype() == "struct") set_CppDecl(CppSettings::structDecl()); else if (stereotype() == "union") set_CppDecl(CppSettings::unionDecl()); else if (stereotype() == "enum") set_CppDecl(CppSettings::enumDecl()); else set_CppDecl(CppSettings::classDecl()); prop.remove("Cplusplus/ImplementationType"); } Q3CString * v; if ((v = prop.find("Cplusplus/BodySourceFile")) != 0) { _body_file = *v; prop.remove("Cplusplus/BodySourceFile"); } else if ((v = prop.find("Traversal/BodyFile")) != 0) { _body_file = *v; prop.remove("Traversal/BodyFile"); } if ((v = prop.find("Cplusplus/HeaderSourceFile")) != 0) { _file = *v; prop.remove("Cplusplus/HeaderSourceFile"); } else if ((v = prop.find("Traversal/CodeFile")) != 0) { _file = *v; prop.remove("Traversal/CodeFile"); } }
void UmlClass::importIdlConstant(UmlItem * parent, const Q3CString & id, const Q3CString & s, const Q3CString & doc, Q3Dict<Q3CString> & prop) { // use a class to define the constant ! UmlClass * x; if ((x = UmlClass::create(parent, legalName(s))) == 0) { UmlCom::trace("<br>cannot create class '" + s + "' in " + parent->fullName()); throw 0; } newItem(x, id); x->lang = Corba; x->set_Stereotype("constant"); if (!doc.isEmpty()) x->set_Description(doc); Q3CString type; Q3CString value; Q3CString * v; if ((v = prop.find("CORBA/ImplementationType")) != 0) { type = *v; prop.remove("CORBA/ImplementationType"); } if ((v = prop.find("CORBA/ConstValue")) != 0) { if (!v->isEmpty()) value = " = " + *v; prop.remove("CORBA/ConstValue"); } Q3CString d = IdlSettings::constDecl(); int index; if ((index = d.find("${type}")) != -1) d.replace(index, 7, type); if ((index = d.find("${value}")) != -1) d.replace(index, 8, value); x->setProperties(prop); x->set_IdlDecl(d); }
/** * CustomLoginFlagEditor::fillTable() * * Fills the table with the flags and values for the user. */ void CustomLoginFlagEditor::fillTable() { ADB db; long loginType; Q3Dict<QString> flagDict; // Get the login type. db.query("select LoginType from Logins where LoginID = '%s'", myLoginID); if (!db.rowCount) return; db.getrow(); loginType = atoi(db.curRow["LoginType"]); // Get the available login flags for this login type db.query("select Tag, Value from LoginTypeFlags where LoginTypeID = %ld", loginType); if (!db.rowCount) return; // Load the dictionary while(db.getrow()) { flagDict.insert(db.curRow["Tag"], new QString(db.curRow["Value"])); } // Get whatever data is in the LoginFlagValues that is custom for this user. db.query("select * from LoginFlagValues where LoginID = '%s'", myLoginID); if (db.rowCount) while (db.getrow()) { flagDict.replace(db.curRow["LoginFlag"], new QString(db.curRow["FlagValue"])); } // Now put the stuff from our flagDict into the grid Q3DictIterator<QString> it(flagDict); for( ; it.current(); ++it ) { flagTable->insertRows(flagTable->numRows(), 1); flagTable->setText(flagTable->numRows()-1, 0, it.currentKey()); flagTable->setText(flagTable->numRows()-1, 1, it.current()->ascii()); } // Set column 0(1) to be read only flagTable->setColumnReadOnly(0, true); flagTable->adjustColumn(1); }
void UmlClass::corba(Q3Dict<Q3CString> & prop) { if (!scanning) { Q3CString * v; if (stereotype() == "union") { if ((v = prop.find("CORBA/ImplementationType")) != 0) { UmlTypeSpec t; t.explicit_type = *v; // !!!!!!!!!!!! set_SwitchType(t); prop.remove("CORBA/ImplementationType"); } set_IdlDecl(IdlSettings::unionDecl()); } else if (stereotype() == "typedef") { if ((v = prop.find("CORBA/ImplementationType")) != 0) { UmlTypeSpec t; t.explicit_type = *v; // no quidu set_BaseType(t); prop.remove("CORBA/ImplementationType"); } QString d = IdlSettings::typedefDecl(); if ((v = prop.find("CORBA/ArrayDimensions")) != 0) { if (!v->isEmpty()) { int index; if ((index = d.find("${name}")) != -1) d.insert(index + 7, "[" + *v + "]"); } prop.remove("CORBA/ArrayDimensions"); } set_IdlDecl(d); } else if (stereotype() == "struct") set_IdlDecl(IdlSettings::structDecl()); else if (stereotype() == "enum") set_IdlDecl(IdlSettings::enumDecl()); else if (stereotype() == "interface") set_IdlDecl(IdlSettings::interfaceDecl()); else if (stereotype() == "exception") set_IdlDecl(IdlSettings::exceptionDecl()); else if (stereotype() == "") set_IdlDecl(IdlSettings::valuetypeDecl()); } }
void UmlPackage::getAuxFiles(Q3Dict<void> & files) { static const char * aux[] = { "cpp_includes", "generation_settings", "idl_includes", "java_imports", "stereotypes", "tools", 0 }; const char ** p = aux; QFileInfo prjpath(supportFile()); QString dir = prjpath.dirPath(TRUE) + "/"; while(*p != 0) { QFileInfo fi(dir + *p); if (fi.exists()) files.replace(*p, (void *) 1); p += 1; } }
PlotLine * SYMBOL::getSYMBOL () { QString s; Config config; config.getData(Config::IndexPath, s); DBIndex index; index.open(s); PlotLine *line = new PlotLine(); DbPlugin db; if (db.open(symbol, &index)) { db.close(); index.close(); return line; } QDateTime date; data->getDate(0, date); QString ts; config.getData(Config::BarLength, ts); db.setBarLength((BarData::BarLength) ts.toInt()); config.getData(Config::Bars, ts); db.setBarRange(ts.toInt()); BarData *recordList = new BarData(symbol); QDateTime dt = QDateTime::currentDateTime(); db.getHistory(recordList, dt); Q3Dict<Setting> dict; dict.setAutoDelete(TRUE); int loop; ts = "Close"; QString ts2; for (loop = 0; loop < (int) recordList->count(); loop++) { Setting *r = new Setting; ts2 = QString::number(recordList->getClose(loop)); r->setData(ts, ts2); recordList->getDate(loop, dt); QString s = dt.toString("yyyyMMddhhmmss"); dict.insert(s, r); } double val = 0; for (loop = 0; loop < (int) data->count(); loop++) { data->getDate(loop, dt); QString s = dt.toString("yyyyMMddhhmmss"); Setting *r2 = dict[s]; if (r2) { val = r2->getDouble(ts); line->append(val); } } delete recordList; db.close(); index.close(); line->setScaleFlag(TRUE); return line; }
bool CppRefType::add(const WrapperStr & t, Q3PtrList<CppRefType> & l, bool incl) { if (t.isEmpty()) return FALSE; static Q3Dict<char> cpp_builtin_types; if (cpp_builtin_types.count() == 0) { cpp_builtin_types.insert("unsigned", " "); cpp_builtin_types.insert("signed", " "); cpp_builtin_types.insert("char", " "); cpp_builtin_types.insert("short", " "); cpp_builtin_types.insert("int", " "); cpp_builtin_types.insert("long", " "); cpp_builtin_types.insert("float", " "); cpp_builtin_types.insert("double", " "); cpp_builtin_types.insert("bool", " "); cpp_builtin_types.insert("void", " "); } if (cpp_builtin_types[t] != 0) return TRUE; CppRefType * ref; Weight w = (incl) ? Medium : Low; for (ref = l.first(); ref; ref = l.next()) { if (ref->type.toString() == t) { if (w > ref->weight) ref->included = incl; return TRUE; } } l.append(new CppRefType(t, incl, w)); return TRUE; }
// synchronize all in todir, current packages are 'nodes' void BrowserNode::synchronize(QDir & todir, Q3Dict<BrowserNode> & nodes) { static Q3Dict<void> useful(9973); // all useful files static bool made_useful = TRUE; // set at the first call // compare nodes with young packages Q3DictIterator<BrowserNode> ity(Youngs); for (; ity.current(); ++ity) { BrowserNode * from = ity.current(); BrowserNode * curr_bn = nodes.find(ity.currentKey()); if ((curr_bn == 0) || (curr_bn->state == Old)) { // don't exist or must be updated if (made_useful) useful.insert(ity.currentKey(), (void *) 1); QDir & fromdir = from->view->get_dir(); // copy package file copy(fromdir, todir, from->filename); // copy diagrams files QStringList::Iterator its; QStringList & diags = from->diagrams; if (made_useful) { for (its = diags.begin(); its != diags.end(); ++its) { copy_if_needed(fromdir, todir, *its); useful.insert(*its, (void *) 1); } } else for (its = diags.begin(); its != diags.end(); ++its) copy_if_needed(fromdir, todir, *its); // copy class body files QStringList & cls = from->classes; if (made_useful) { for (its = cls.begin(); its != cls.end(); ++its) { copy_if_needed(fromdir, todir, *its); useful.insert(*its, (void *) 1); } } else for (its = cls.begin(); its != cls.end(); ++its) copy_if_needed(fromdir, todir, *its); if (from->parent() == 0) { // project, special files copy_if_needed(fromdir, todir, "cpp_includes"); copy_if_needed(fromdir, todir, "idl_includes"); copy_if_needed(fromdir, todir, "java_imports"); copy_if_needed(fromdir, todir, "generation_settings"); copy_if_needed(fromdir, todir, "import"); copy_if_needed(fromdir, todir, "include"); copy_if_needed(fromdir, todir, "stereotypes"); copy_if_needed(fromdir, todir, "tools"); } } else if (made_useful) // young, memorize packages, diagrams and classes body file from->memo(useful); } if (made_useful) { // memorize up to date packages, diagrams and classes body file Q3DictIterator<BrowserNode> itn(nodes); for (; itn.current(); ++itn) if (itn.current()->state == UpToDate) itn.current()->memo(useful); made_useful = FALSE; } // remove files associated to deleted elements purge(todir, useful); }
//==================================== // removeInputDevice //------------------------------------ int SaXManipulateDevices::removeInputDevice (int id) { // .../ //! remove the input device of the given id (id) and return the //! previous input device id. The current input device id is set //! to this previous input device id. If the input device does //! not exist or the input device id is the core (0|1) mouse or //! keyboard the method will return (-1) // ---- if (! inputHandlingAllowed) { return -1; } //==================================== // don't allow removing the core entry //------------------------------------ if ((id <= 1) && (mInput->getCount() <= 2)) { excInvalidArgument (id); qError (errorString(),EXC_INVALIDARGUMENT); return -1; } //==================================== // remove input devices... //------------------------------------ if (! mInput->delID (id)) { return -1; } //==================================== // select previous input device //------------------------------------ for (int i=1;i<=2;i++) { Q3Dict<QString>* data = mInput->getTablePointer (i); if ((data) && (! data->isEmpty())) { mInput->setID (i); break; } } //==================================== // check input device type //------------------------------------ bool isMouse = true; QString baseItem ("InputDevice"); QString baseID ("Mouse"); if (mInput->getCurrentID() % 2 == 0) { isMouse = false; baseItem = "Keyboard"; baseID = "Keyboard"; } //==================================== // update server layout //------------------------------------ QString result; QString IDstring; IDstring.sprintf ("%d",id); QString deviceList = mLayout -> getItem (baseItem); QStringList optlist = QStringList::split ( ",", deviceList ); for ( QStringList::Iterator in = optlist.begin(); in != optlist.end(); ++in ) { QString item (*in); if (item == QString(baseID + "["+IDstring+"]")) { continue; } QRegExp identifier ("\\[(.+)\\]"); int pos = identifier.search (item); if (pos >= 0) { int curID = identifier.cap(1).toInt(); if ( curID > id ) { QString newMK; newMK.sprintf ("%s[%d],",baseID.ascii(),curID - 2); result.append ( newMK ); } else { result.append (item+","); } } } result.remove (result.length()-1,result.length()); mLayout -> setItem (baseItem,result); return mInput -> getCurrentID(); }
//==================================== // addInputDevice //------------------------------------ int SaXManipulateDevices::addInputDevice (const char* fashion) { // .../ //! add a new input device at the end of the current input //! device list. The new input device ID is returned. pointer //! input devices are following the odd order (1,3,5,7...) //! whereas keyboard input devices use the even order (0,2,4,6...) // ---- if (! inputHandlingAllowed) { return -1; } //==================================== // check fashion string... //------------------------------------ QString inputFashion (fashion); if ( (inputFashion != SAX_INPUT_TOUCHPANEL) && (inputFashion != SAX_INPUT_TABLET) && (inputFashion != SAX_INPUT_PEN) && (inputFashion != SAX_INPUT_PAD) && (inputFashion != SAX_INPUT_ERASER) && (inputFashion != SAX_INPUT_MOUSE) && (inputFashion != SAX_INPUT_VNC) && (inputFashion != SAX_INPUT_KEYBOARD) ) { excWrongInputFashion (fashion); qError (errorString(),EXC_WRONGINPUTFASHION); return -1; } //==================================== // determine new input device ID... //------------------------------------ QString baseID ("Mouse"); QString baseDriver ("mouse"); if (fashion == (char*)SAX_INPUT_VNC) { baseDriver = "rfbmouse"; } Q3Dict<QString>* data = mInput->getTablePointer (0); int newID = mInput->getCount (true) * 2 + 1; if ((data) && (! data->isEmpty())) { baseDriver ="kbd"; if (fashion == (char*)SAX_INPUT_VNC) { baseDriver = "rfbkeyb"; } baseID = "Keyboard"; newID = mInput->getCount (true) * 2; } if (! mInput -> addID (newID)) { return -1; } //==================================== // add new input device section... //------------------------------------ QString newIDstring; newIDstring.sprintf ("%d",newID); mInput -> setItem ("Identifier",baseID + "[" + newIDstring + "]"); mInput -> setItem ("InputFashion",fashion); //==================================== // set some defaults... //------------------------------------ mInput -> setItem ("Driver",baseDriver); //==================================== // update server layout //------------------------------------ if (baseID == "Mouse") { QString inputDevice; QTextOStream (&inputDevice) << mLayout -> getItem ("InputDevice") << ",Mouse[" << newIDstring << "]"; mLayout -> setItem ("InputDevice",inputDevice); } if (baseID == "Keyboard") { QString inputDevice; QTextOStream (&inputDevice) << mLayout -> getItem ("Keyboard") << ",Keyboard[" << newIDstring << "]"; mLayout -> setItem ("Keyboard",inputDevice); } return mInput -> getCurrentID(); }