[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sun Sep 17 17:57:28 UTC 2006
SVN commit 585671 by okellogg:
get{Package,Packages}: Add the includeRoot arg (see getFullyQualifiedName())
M +8 -14 umlobject.cpp
M +7 -2 umlobject.h
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #585670:585671
@@ -343,29 +343,23 @@
return name;
}
-QString UMLObject::getPackage(QString separator) {
- if (m_pUMLPackage == NULL)
+QString UMLObject::getPackage(QString separator, bool includeRoot) {
+ QString fqn = getFullyQualifiedName(separator, includeRoot);
+ if (!fqn.contains(separator))
return "";
- UMLPackageList pkgList;
- QStringList pkgNames;
- UMLPackage* pkg = m_pUMLPackage;
- do {
- pkgList.prepend(pkg);
- pkgNames.prepend(pkg->getName());
- pkg = pkg->getUMLPackage();
- } while (pkg != NULL && !pkgList.containsRef(pkg));
- if (separator.isEmpty())
- separator = UMLApp::app()->activeLanguageScopeSeparator();
- return pkgNames.join(separator);
+ QString scope = fqn.left(fqn.length() - separator.length() - m_Name.length());
+ return scope;
}
-UMLPackageList UMLObject::getPackages() const {
+UMLPackageList UMLObject::getPackages(bool includeRoot) const {
UMLPackageList pkgList;
UMLPackage* pkg = m_pUMLPackage;
while (pkg != NULL) {
pkgList.prepend(pkg);
pkg = pkg->getUMLPackage();
}
+ if (!includeRoot)
+ pkgList.removeFirst();
return pkgList;
}
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.h #585670:585671
@@ -192,17 +192,22 @@
* individual package prefixes (optional.)
* If no separator is given then the separator
* of the currently selected language is used.
+ * @param includeRoot Whether to prefix the root folder name.
+ * Default: false.
* @return The UMLObject's enclosing package(s) as a text.
*/
- QString getPackage(QString separator = QString::null);
+ QString getPackage(QString separator = QString::null,
+ bool includeRoot = false);
/**
* Return a list of the packages in which this class is embedded.
* The outermost package is first in the list.
*
+ * @param includeRoot Whether to prefix the root folder name.
+ * Default: false.
* @return UMLPackageList of the containing packages.
*/
- UMLPackageList getPackages() const;
+ UMLPackageList getPackages(bool includeRoot = false) const;
/**
* Returns the UMLPackage that this class is located in.
More information about the umbrello-devel
mailing list