// FIXME void GalleryWindow::slotAlbums(const QList<GAlbum>& albumList) { d->albumDict.clear(); d->albumView->clear(); // album work list QList<GAlbum> workList(albumList); QList<QTreeWidgetItem *> parentItemList; // fill QTreeWidget while( !workList.isEmpty() ) { // the album to work on GAlbum album = workList.takeFirst(); int parentRefNum = album.parent_ref_num; if ( parentRefNum == 0 ) { QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, cleanName(album.title) ); item->setIcon(0, KIcon("inode-directory") ); item->setText(1, album.name ); firstAlbumName = album.name; item->setText(2, i18n("Album") ); d->albumView->addTopLevelItem(item); d->albumDict.insert(album.title, album); parentItemList << item; } else { QTreeWidgetItem *parentItem = 0; bool found = false; int i = 0; while( !found && i < parentItemList.size() ) { parentItem = parentItemList.at(i); if(parentItem && (parentItem->text(1) == QString::number(parentRefNum))) { QTreeWidgetItem *item = new QTreeWidgetItem(parentItem); item->setText(0, cleanName(album.title) ); item->setIcon(0, KIcon("inode-directory") ); item->setText(1, album.name ); item->setText(2, i18n("Album") ); d->albumDict.insert(album.title, album); parentItemList << item; found = true; } i++; } if ( i == parentItemList.size() ) { workList.append(album); } } } }
void CSharpWriter::writeAssociatedAttributes(UMLAssociationList &associated, UMLClassifier *c, QTextStream &cs) { UMLAssociation *a; for (a = associated.first(); a ; a = associated.next()) { if (c != a->getObject(Uml::A)) // we need to be at the A side continue; UMLObject *o = a->getObject(Uml::B); if (o == NULL) { kError() << "composition role B object is NULL" << endl; continue; } // Take name and documentaton from Role, take type name from the referenced object QString roleName = cleanName(a->getRoleName(Uml::B)); QString typeName = cleanName(o->getName()); if (roleName.isEmpty()) { roleName = QString("UnnamedRoleB_%1").arg(m_unnamedRoles++); } QString roleDoc = a->getRoleDoc(Uml::B); //FIXME:is this simple condition enough? if (a->getMulti(Uml::B).isEmpty() || a->getMulti(Uml::B) == "1") { // normal attribute writeAttribute(roleDoc, a->getVisibility(Uml::B), false, typeName, roleName, "", ( a->getVisibility(Uml::B) != Uml::Visibility::Private), cs); } else { // array roleDoc += "\n(Array of " + typeName + ')'; writeAttribute(roleDoc, a->getVisibility(Uml::B), false, "ArrayList", roleName, "", ( a->getVisibility(Uml::B) != Uml::Visibility::Private), cs); } } }
/** * Call this method to generate C++ code for a UMLClassifier. * @param c the class you want to generate code for */ void PythonWriter::writeClass(UMLClassifier *c) { if (!c) { uDebug() << "Cannot write class of NULL concept!"; return; } QString classname = cleanName(c->name()); UMLClassifierList superclasses = c->getSuperClasses(); UMLAssociationList aggregations = c->getAggregations(); UMLAssociationList compositions = c->getCompositions(); m_bNeedPass = true; //find an appropriate name for our file QString fileName = findFileName(c, QLatin1String(".py")); if (fileName.isEmpty()) { emit codeGenerated(c, false); return; } QFile fileh; if (!openFile(fileh, fileName)) { emit codeGenerated(c, false); return; } QTextStream h(&fileh); ////////////////////////////// //Start generating the code!! ///////////////////////////// //try to find a heading file (license, coments, etc) QString str; str = getHeadingFile(QLatin1String(".py")); if (!str.isEmpty()) { str.replace(QRegExp(QLatin1String("%filename%")), fileName); str.replace(QRegExp(QLatin1String("%filepath%")), fileh.fileName()); h<<str<<m_endl; } h << "# coding=" << h.codec()->name() << m_endl; // generate import statement for superclasses and take packages into account str = cleanName(c->name()); QString pkg = cleanName(c->package()); if (!pkg.isEmpty()) str.prepend(pkg + QLatin1Char('.')); QStringList includesList = QStringList(str); //save imported classes int i = superclasses.count(); foreach (UMLClassifier *classifier, superclasses) { str = cleanName(classifier->name()); pkg = cleanName(classifier->package()); if (!pkg.isEmpty()) str.prepend(pkg + QLatin1Char('.')); includesList.append(str); h << "from " << str << " import *" << m_endl; i--; }
void PiwigoWindow::slotAlbums(const QList<PiwigoAlbum>& albumList) { d->albumDict.clear(); d->albumView->clear(); // album work list QList<PiwigoAlbum> workList(albumList); QList<QTreeWidgetItem*> parentItemList; // fill QTreeWidget while ( !workList.isEmpty() ) { // the album to work on PiwigoAlbum album = workList.takeFirst(); int parentRefNum = album.m_parentRefNum; if (parentRefNum == -1) { QTreeWidgetItem* const item = new QTreeWidgetItem(); item->setText(0, cleanName(album.m_name) ); item->setIcon(0, QIcon::fromTheme(QLatin1String("inode-directory")) ); item->setData(1, Qt::UserRole, QVariant(album.m_refNum) ); item->setText(2, i18n("Album") ); qCDebug(DIGIKAM_WEBSERVICES_LOG) << "Top : " << album.m_name << " " << album.m_refNum << "\n"; d->albumView->addTopLevelItem(item); d->albumDict.insert(album.m_name, album); parentItemList << item; } else { QTreeWidgetItem* parentItem = nullptr; bool found = false; int i = 0; while ( !found && i < parentItemList.size() ) { parentItem = parentItemList.at(i); if (parentItem && (parentItem->data(1, Qt::UserRole).toInt() == parentRefNum)) { QTreeWidgetItem* const item = new QTreeWidgetItem(parentItem); item->setText(0, cleanName(album.m_name) ); item->setIcon(0, QIcon::fromTheme(QLatin1String("inode-directory")) ); item->setData(1, Qt::UserRole, album.m_refNum ); item->setText(2, i18n("Album") ); parentItem->addChild(item); d->albumDict.insert(album.m_name, album); parentItemList << item; found = true; } i++; } } } }
void TclWriter::writeClass(UMLClassifier * c) { if (!c) { uDebug() << "Cannot write class of NULL concept!"; return; } QFile fileh, filetcl; // find an appropriate name for our file fileName_ = findFileName(c, ".tcl"); if (fileName_.isEmpty()) { emit codeGenerated(c, false); return; } if (!openFile(fileh, fileName_)) { emit codeGenerated(c, false); return; } // preparations className_ = cleanName(c->name()); if (!c->package().isEmpty()) { mNamespace = "::" + cleanName(c->package()); mClassGlobal = mNamespace + "::" + className_; } else { mNamespace = "::"; mClassGlobal = "::" + className_; } // write Header file writeHeaderFile(c, fileh); fileh.close(); // Determine whether the implementation file is required. // (It is not required if the class is an enumeration.) bool need_impl = true; if (!c->isInterface()) { if (c->baseType() == UMLObject::ot_Enum) need_impl = false; } if (need_impl) { if (!openFile(filetcl, fileName_ + "body")) { emit codeGenerated(c, false); return; } // write Source file writeSourceFile(c, filetcl); filetcl.close(); } // emit done code emit codeGenerated(c, true); }
void DWriter::writeModuleImports(UMLClassifier *c, QTextStream &d) { // another preparation, determine what we have UMLAssociationList associations = c->getSpecificAssocs(Uml::AssociationType::Association); // BAD! only way to get "general" associations. UMLAssociationList uniAssociations = c->getUniAssociationToBeImplemented(); UMLAssociationList aggregations = c->getAggregations(); UMLAssociationList compositions = c->getCompositions(); bool hasAssociations = aggregations.count() + associations.count() + compositions.count() + uniAssociations.count() > 0; if (hasAssociations) { // import tango, if that mode is set writeBlankLine(d); } //only import classes in a different package as this class UMLPackageList imports; findObjectsRelated(c, imports); foreach (UMLPackage* con, imports) { if (con->baseType() == UMLObject::ot_Datatype) continue; QString pkg = con->package(); if (!pkg.isEmpty() && pkg != c->package()) d << "import " << pkg << "." << cleanName(con->name()) << ";" << m_endl; } writeBlankLine(d); }
void XMLSchemaWriter::writeAttributeDecl(UMLAttribute *attrib, QTextStream &XMLschema ) { QString documentation = attrib->getDoc(); QString typeName = fixTypeName(attrib->getTypeName()); bool isStatic = attrib->getStatic(); QString initialValue = fixInitialStringDeclValue(attrib->getInitialValue(), typeName); if(!documentation.isEmpty()) writeComment(documentation, XMLschema); XMLschema<<getIndent()<<"<"<<makeSchemaTag("attribute") <<" name=\""<<cleanName(attrib->getName())<<"\"" <<" type=\""<<typeName<<"\""; // default value? if(!initialValue.isEmpty()) { // IF its static, then we use "fixed", otherwise, we use "default" decl. // For the default decl, we _must_ use "optional" decl if(isStatic) XMLschema<<" use=\"required\" fixed=\""<<initialValue<<"\""; else XMLschema<<" use=\"optional\" default=\""<<initialValue<<"\""; } // finish decl XMLschema<<"/>"<<m_endl; }
/** * Call this method to generate sql code for a UMLClassifier. * @param c the class to generate code for */ void SQLWriter::writeClass(UMLClassifier *c) { UMLEntity* e = c->asUMLEntity(); if (!e) { uError() << "Invalid cast from" << c->baseTypeStr() << "'" << c->name() << "' to UMLEntity*"; return; } m_pEntity = e; QString entityname = cleanName(m_pEntity->name()); //find an appropriate name for our file QString fileName = findFileName(m_pEntity, QLatin1String(".sql")); if (fileName.isEmpty()) { emit codeGenerated(m_pEntity, false); return; } QFile file; if (!openFile(file, fileName)) { emit codeGenerated(m_pEntity, false); return; } //Start generating the code!! QTextStream sql(&file); //try to find a heading file (license, coments, etc) QString str; str = getHeadingFile(QLatin1String(".sql")); if (!str.isEmpty()) { str.replace(QRegExp(QLatin1String("%filename%")), fileName); str.replace(QRegExp(QLatin1String("%filepath%")), file.fileName()); sql << str << m_endl; } //Write class Documentation if there is somthing or if force option if (forceDoc() || !m_pEntity->doc().isEmpty()) { sql << m_endl << "--" << m_endl; sql << "-- TABLE: " << entityname << m_endl; sql << formatDoc(m_pEntity->doc(),QLatin1String("-- ")); sql << "-- " << m_endl << m_endl; } // write all entity attributes UMLEntityAttributeList entAttList = m_pEntity->getEntityAttributes(); sql << "CREATE TABLE " << entityname << " ("; printEntityAttributes(sql, entAttList); sql << m_endl << ");" << m_endl; // auto increments UMLEntityAttributeList autoIncrementList; foreach(UMLEntityAttribute* entAtt, entAttList) { autoIncrementList.append(entAtt); }
QString PascalWriter::qualifiedName(UMLPackage *p, bool withType, bool byValue) { UMLPackage *umlPkg = p->umlPackage(); QString className = cleanName(p->name()); QString retval; if (umlPkg == UMLApp::app()->document()->rootFolder(Uml::ModelType::Logical)) umlPkg = NULL; UMLClassifier *c = dynamic_cast<UMLClassifier*>(p); if (umlPkg == NULL) { retval = className; if (c == NULL || !isOOClass(c)) retval.append(defaultPackageSuffix); } else { retval = umlPkg->fullyQualifiedName(QLatin1String(".")); if (c && isOOClass(c)) { retval.append(QLatin1String(".")); retval.append(className); } } if (! withType) return retval; if (c && isOOClass(c)) { retval.append(QLatin1String(".Object")); if (! byValue) retval.append(QLatin1String("_Ptr")); } else { retval.append(QLatin1String(".")); retval.append(className); } return retval; }
fstring FCDEntity::CleanName(const fchar* c) { size_t len = 0; for (; len < MAX_NAME_LENGTH; len++) { if (c[len] == 0) break; } fstring cleanName(len, *c); fchar* id = cleanName.begin(); if (*c != 0) { // First character: alphabetic or '_'. if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || *c == '_') *id = *c; else *id = '_'; // Other characters: alphabetic, numeric, '_'. // NOTE: ':' and '.' are NOT acceptable characters. for (size_t i = 1; i < len; ++i) { ++id; ++c; if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || *c == '_' || *c == '-') *id = *c; else *id = '_'; } *(++id) = 0; } return cleanName; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void PMFileGenerator::pluginNameChanged(const QString& pluginName) { // qDebug() << "PMFileGenerator::pluginNameChanged" << "\n"; QString pin = cleanName(pluginName); if (pin.isEmpty() == true) { setPluginName("Unknown Plugin Name"); } else { setPluginName(pin); } if (isNameChangeable() == false) { return; } m_FileName = pin + getDisplaySuffix(); if (NULL != getTreeWidgetItem()) { getTreeWidgetItem()->setText(0, m_FileName ); } }
/** * Convert C++ names such as 'm_foobar' or pFoobar to * just 'foobar' for ruby. * @param cppName the C++ name to be converted */ QString RubyWriter::cppToRubyName(const QString &nameStr) { QString name = cleanName(nameStr); name.remove(QRegExp(QLatin1String("^m_"))); name.remove(QRegExp(QLatin1String("^[pbn](?=[A-Z])"))); name = name.mid(0, 1).toLower() + name.mid(1); return name; }
/** * Convert C++ names such as 'm_foobar' or pFoobar to * just 'foobar' for ruby. * @param cppName the C++ name to be converted * @return the ruby name as string */ QString RubyCodeGenerator::cppToRubyName(const QString &cppName) { QString name = cleanName(cppName); name.remove(QRegExp(QLatin1String("^m_"))); name.remove(QRegExp(QLatin1String("^[pbn](?=[A-Z])"))); name = name.mid(0, 1).toLower() + name.mid(1); return name; }
/** * IF the type is "string" we need to declare it as * the D Object "String" (there is no string primative in D). * Same thing again for "bool" to "boolean". * @param item the item to change * @return the changed item */ QString DCodeGenerator::fixTypeName(const QString &item) { if (item.isEmpty() || item.contains(QRegExp("^\\s+$"))) return "void"; if (item == "string") return "char[]"; return cleanName(item); }
void CSharpWriter::writeAttribute(QString doc, Uml::Visibility visibility, bool isStatic, QString typeName, QString name, QString initialValue, bool asProperty, QTextStream &cs) { if (forceDoc() || !doc.isEmpty()) { cs << m_container_indent << m_indentation << "/// <summary>" << m_endl; cs << formatDoc(doc, m_container_indent + m_indentation + "/// "); cs << m_container_indent << m_indentation << "/// </summary>" << m_endl; } cs << m_container_indent << m_indentation; cs << visibility.toString() << " "; if (isStatic) cs << "static "; //Variable type with/without namespace path cs << typeName << " "; cs << cleanName(name); // FIXME: may need a GUI switch to not generate as Property? // Generate as Property if not private if (asProperty) { cs << m_endl; cs << m_container_indent << m_indentation << "{" << m_endl; cs << m_container_indent << m_indentation << m_indentation << "get" << m_endl; cs << m_container_indent << m_indentation << m_indentation << "{" << m_endl; cs << m_container_indent << m_indentation << m_indentation << m_indentation << "return m_" << cleanName(name) << ";" << m_endl; cs << m_container_indent << m_indentation << m_indentation << "}" << m_endl; cs << m_container_indent << m_indentation << m_indentation << "set" << m_endl; cs << m_container_indent << m_indentation << m_indentation << "{" << m_endl; cs << m_container_indent << m_indentation << m_indentation << m_indentation << "m_" << cleanName(name) << " = value;" << m_endl; cs << m_container_indent << m_indentation << m_indentation << "}" << m_endl; cs << m_container_indent << m_indentation << "}" << m_endl; cs << m_container_indent << m_indentation << "private "; if (isStatic) cs << "static "; cs << typeName << " m_" << cleanName(name); } if (!initialValue.isEmpty()) cs << " = " << initialValue; cs << ";" << m_endl << m_endl; }
/** * Call this method to generate Pascal code for a UMLClassifier. * @param c the class to generate code for */ void PascalWriter::writeClass(UMLClassifier *c) { if (!c) { uDebug() << "Cannot write class of NULL concept!"; return; } const bool isClass = !c->isInterface(); QString classname = cleanName(c->name()); QString fileName = qualifiedName(c).toLower(); fileName.replace(QLatin1Char('.'), QLatin1Char('-')); //find an appropriate name for our file fileName = overwritableName(c, fileName, QLatin1String(".pas")); if (fileName.isEmpty()) { emit codeGenerated(c, false); return; } QFile file; if (!openFile(file, fileName)) { emit codeGenerated(c, false); return; } // Start generating the code. QTextStream pas(&file); //try to find a heading file(license, comments, etc) QString str; str = getHeadingFile(QLatin1String(".pas")); if (!str.isEmpty()) { str.replace(QRegExp(QLatin1String("%filename%")), fileName); str.replace(QRegExp(QLatin1String("%filepath%")), file.fileName()); pas << str << endl; } QString unit = qualifiedName(c); pas << "unit " << unit << ";" << m_endl << m_endl; pas << "INTERFACE" << m_endl << m_endl; // Use referenced classes. UMLPackageList imports; findObjectsRelated(c, imports); if (imports.count()) { pas << "uses" << m_endl; bool first = true; foreach (UMLPackage* con, imports) { if (con->baseType() != UMLObject::ot_Datatype) { if (first) first = false; else pas << "," << m_endl; pas << " " << qualifiedName(con); } } pas << ";" << m_endl << m_endl; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AddFilterWidget::on_filterName_textChanged(const QString & text) { QString filterName_clean = cleanName(filterName->text()); if ( filterName_clean.isEmpty() ) { addfilterOKButton->setEnabled(false); } else { addfilterOKButton->setEnabled(true); } }
bool PerlWriter::GetUseStatements(UMLClassifier *c, QString &Ret, QString &ThisPkgName) { if (!c){ return(false); } UMLPackageList includes; findObjectsRelated(c,includes); QString AV = QChar('@'); QString SV = QChar('$'); QString HV = QChar('%'); foreach (UMLPackage* conc, includes ) { if (conc->baseType() == Uml::ot_Datatype) continue; QString neatName = cleanName(conc->name()); if (neatName != AV && neatName != SV && neatName != HV) { QString OtherPkgName = conc->package("."); OtherPkgName.replace(QRegExp("\\."),"::"); QString OtherName = OtherPkgName + "::" + cleanName(conc->name()); // Only print out the use statement if the other package isn't the // same as the one we are working on. (This happens for the // "Singleton" design pattern.) if (OtherName != ThisPkgName){ Ret += "use "; Ret += OtherName; Ret += ';'; Ret += m_endl; } } } UMLClassifierList superclasses = c->getSuperClasses(); if (superclasses.count()) { Ret += m_endl; Ret += "use base qw( "; foreach (UMLClassifier *obj , superclasses ) { QString packageName = obj->package("."); packageName.replace(QRegExp("\\."),"::"); Ret += packageName + "::" + cleanName(obj->name()) + ' '; }
void JSWriter::writeOperations(QString classname, UMLOperationList *opList, QTextStream &js) { UMLOperation *op; UMLAttribute *at; for(op = opList->first(); op; op = opList->next()) { UMLAttributeList atl = op->getParmList(); //write method doc if we have doc || if at least one of the params has doc bool writeDoc = forceDoc() || !op->getDoc().isEmpty(); for (at = atl.first(); at; at = atl.next()) writeDoc |= !at->getDoc().isEmpty(); if( writeDoc ) //write method documentation { js << "/**" << m_endl << formatDoc(op->getDoc()," * "); for (at = atl.first(); at; at = atl.next()) //write parameter documentation { if(forceDoc() || !at->getDoc().isEmpty()) { js << " * @param " + cleanName(at->getName())<<m_endl; js << formatDoc(at->getDoc()," * "); } }//end for : write parameter documentation js << " */" << m_endl; }//end if : write method documentation js << classname << ".prototype." << cleanName(op->getName()) << " = function " << "("; int i = atl.count(); int j=0; for (at = atl.first(); at ;at = atl.next(),j++) { js << cleanName(at->getName()) << (!(at->getInitialValue().isEmpty()) ? (QString(" = ")+at->getInitialValue()) : QString("")) << ((j < i-1)?", ":""); } js << ")" << m_endl << "{" << m_endl << m_indentation << m_endl << "}" << m_endl; js << m_endl << m_endl; }//end for }
void XmlNode::finalize() { cleanName(); if(parent != 0) defineDefaultStyleByParent(); deleteUslessStyle(); deleteUslessAttibut(); deleteThisUslessBalise(); }
void JSWriter::writeAssociation(QString& classname, UMLAssociationList& assocList , QTextStream &js) { for (UMLAssociation *a = assocList.first(); a; a = assocList.next()) { // association side Uml::Role_Type role = (a->getObject(Uml::A)->getName() == classname ? Uml::B : Uml::A); QString roleName(cleanName(a->getRoleName(role))); if (!roleName.isEmpty()) { // association doc if (forceDoc() || !a->getDoc().isEmpty()) { js << m_indentation << "/**" << m_endl << formatDoc(a->getDoc(), m_indentation + " * ") << m_indentation << " */" << m_endl; } // role doc if (forceDoc() || !a->getRoleDoc(role).isEmpty()) { js << m_indentation << "/**" << m_endl << formatDoc(a->getRoleDoc(role), m_indentation + " * ") << m_indentation << " */" << m_endl; } bool okCvt; int nMulti = a->getMulti(role).toInt(&okCvt,10); bool isNotMulti = a->getMulti(role).isEmpty() || (okCvt && nMulti == 1); QString typeName(cleanName(a->getObject(role)->getName())); if (isNotMulti) js << m_indentation << "this.m_" << roleName << " = new " << typeName << "();" << m_endl; else js << m_indentation << "this.m_" << roleName << " = new Array();" << m_endl; // role visibility } } }
/** * Call this method to generate Actionscript code for a UMLClassifier. * @param c the class you want to generate code for */ void ASWriter::writeClass(UMLClassifier *c) { if (!c) { uDebug()<<"Cannot write class of NULL concept!"; return; } QString classname = cleanName(c->name()); QString fileName = c->name().toLower(); //find an appropriate name for our file fileName = findFileName(c, QLatin1String(".as")); if (fileName.isEmpty()) { emit codeGenerated(c, false); return; } QFile fileas; if (!openFile(fileas, fileName)) { emit codeGenerated(c, false); return; } QTextStream as(&fileas); ////////////////////////////// //Start generating the code!! ///////////////////////////// //try to find a heading file (license, coments, etc) QString str; str = getHeadingFile(QLatin1String(".as")); if (!str.isEmpty()) { str.replace(QRegExp(QLatin1String("%filename%")), fileName + QLatin1String(".as")); str.replace(QRegExp(QLatin1String("%filepath%")), fileas.fileName()); as << str << m_endl; } //write includes UMLPackageList includes; findObjectsRelated(c, includes); foreach (UMLPackage* conc, includes) { QString headerName = findFileName(conc, QLatin1String(".as")); if (!headerName.isEmpty()) { as << "#include \"" << findFileName(conc, QLatin1String(".as")) << "\"" << m_endl; } }
/** * Convert a C++ type such as 'int' or 'QWidget' to * ruby types Integer and Qt::Widget. * @param cppType the C++ type to be converted */ QString RubyWriter::cppToRubyType(const QString &typeStr) { QString type = cleanName(typeStr); type.remove(QLatin1String("const ")); type.remove(QRegExp(QLatin1String("[*&\\s]"))); type.replace(QRegExp(QLatin1String("[<>]")), QLatin1String("_")); type.replace(QLatin1String("QStringList"), QLatin1String("Array")); type.replace(QLatin1String("QString"), QLatin1String("String")); type.replace(QLatin1String("bool"), QLatin1String("true|false")); type.replace(QRegExp(QLatin1String("^(uint|int|ushort|short|ulong|long)$")), QLatin1String("Integer")); type.replace(QRegExp(QLatin1String("^(float|double)$")), QLatin1String("Float")); type.replace(QRegExp(QLatin1String("^Q(?=[A-Z])")), QLatin1String("Qt::")); type.replace(QRegExp(QLatin1String("^K(?!(DE|Parts|IO)")), QLatin1String("KDE::")); return type; }
// FIXME: avoid duplications void GalleryWindow::slotPhotos(const QList<GPhoto>& photoList) { QTreeWidgetItem* parentItem = d->albumView->currentItem(); typedef QList<GPhoto> GPhotoList; GPhotoList::const_iterator iterator; for (iterator = photoList.begin(); iterator != photoList.end(); ++iterator) { QString plain = (*iterator).caption; QTreeWidgetItem *item = new QTreeWidgetItem(parentItem); item->setText(0, cleanName(plain) ); item->setIcon(0, KIcon("image-x-generic") ); item->setText(1, (*iterator).name); item->setText(2, i18n("Image") ); } }
/** * Call this method to generate cpp code for a UMLClassifier. * @param c the class to generate code for */ void CppWriter::writeClass(UMLClassifier *c) { if (!c) { uDebug() << "Cannot write class of NULL concept!"; return; } QFile fileh, filecpp; // find an appropriate name for our file fileName_ = findFileName(c, ".h"); if (fileName_.isEmpty()) { emit codeGenerated(c, false); return; } className_ = cleanName(c->name()); if (c->visibility() != Uml::Visibility::Implementation) { if( !openFile(fileh, fileName_)) { emit codeGenerated(c, false); return; } // write Header file writeHeaderFile(c, fileh); fileh.close(); } // Determine whether the implementation file is required. // (It is not required if the class is an enumeration.) bool need_impl = true; if (c->baseType() == Uml::ot_Enum) { need_impl = false; } if (need_impl) { fileName_.replace( QRegExp(".h$"), ".cpp"); if( !openFile(filecpp, fileName_)) { emit codeGenerated(c, false); return; } // write Source file writeSourceFile(c, filecpp); filecpp.close(); } emit codeGenerated(c, true); }
QString CPPCodeClassField::getFieldName() { if (parentIsAttribute()) { UMLAttribute * at = (UMLAttribute*) getParentObject(); return cleanName(at->getName()); } else { UMLRole * role = (UMLRole*) getParentObject(); QString roleName = role->getName(); if(fieldIsSingleValue()) { return roleName.replace(0, 1, roleName.left(1).lower()); } else { return roleName.lower() + "Vector"; } } }
/** * Convert a C++ type such as 'int' or 'QWidget' to * ruby types Integer and Qt::Widget. * @param cppType the C++ type to be converted * @return the ruby type as string */ QString RubyCodeGenerator::cppToRubyType(const QString &cppType) { QString type = cleanName(cppType); type.remove("const "); type.remove(QRegExp("[*&\\s]")); type.replace(QRegExp("[<>]"), "_"); type.replace("QStringList", "Array"); type.replace(QRegExp("^string$"),"String"); type.replace("QString", "String"); type.replace("bool", "true|false"); type.replace(QRegExp("^(uint|int|ushort|short|ulong|long)$"), "Integer"); type.replace(QRegExp("^(float|double)$"), "Float"); type.replace(QRegExp("^Q(?=[A-Z])"), "Qt::"); type.replace(QRegExp("^K(?!(DE|Parts|IO)"), "KDE::"); return type; }
QString RubyCodeClassField::getFieldName() { if (parentIsAttribute()) { UMLAttribute * at = (UMLAttribute*) getParentObject(); return cleanName(at->name()); } else { UMLRole * role = (UMLRole*) getParentObject(); QString roleName = role->name(); if(fieldIsSingleValue()) { return roleName.replace(0, 1, roleName.left(1).toLower()); } else { return roleName.toLower() + QLatin1String("Array"); } } }
void CData::LevelMetricTypeAsync( const std::string& type, const std::string name, const std::string& level, int day, int month, int year, RequestDelegate targetDelegate ) { std::string cleanName(name); std::string cleanLevel(level); CleanString(cleanName); CleanString(cleanLevel); char date[60]; sprintf_s(date,59,"%d", gPlaytomic->GameId()); std::string url(kDataLevelUrl1); url += gPlaytomic->GetGameGuid() + kDataLevelUrl2 + type + kDataLevelUrl3; url += date; url += kDataLevelUrl4 + cleanName ; url += kDataLevelUrl5 + cleanLevel ; sprintf_s(date,59,"%d%s%d%s%d", day, kDataLevelUrl7, month, kDataLevelUrl8, year); url += kDataLevelUrl6;url += date; GetDataAsync(url, targetDelegate); }
CPlaytomicResponsePtr CData::LevelMetricType( const std::string& type, const std::string name, const std::string& level, int day, int month, int year ) { std::string cleanName(name); std::string cleanLevel(level); CleanString(cleanName); CleanString(cleanLevel); char date[60]; sprintf_s(date,59,"%d", gPlaytomic->GameId()); std::string url(kDataLevelUrl1); url += gPlaytomic->GetGameGuid() + kDataLevelUrl2 + type + kDataLevelUrl3; url += date; url += kDataLevelUrl4 + cleanName ; url += kDataLevelUrl5 + cleanLevel ; sprintf_s(date,59,"%d%s%d%s%d", day, kDataLevelUrl7, month, kDataLevelUrl8, year); url += kDataLevelUrl6;url += date; return GetData(url); }