Added API to get a valid TitleBlockTemplateLocation from a string.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1468 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-01-15 19:26:40 +00:00
parent 9c658d84b1
commit aa0a83e0d6
4 changed files with 88 additions and 4 deletions

View File

@@ -36,6 +36,15 @@ TitleBlockTemplateLocation::TitleBlockTemplateLocation(const QString &name, Titl
TitleBlockTemplateLocation::~TitleBlockTemplateLocation() {
}
/**
@param loc_str String describing the location of a title block template.
*/
TitleBlockTemplateLocation TitleBlockTemplateLocation::locationFromString(const QString &loc_str) {
TitleBlockTemplateLocation loc;
loc.fromString(loc_str);
return(loc);
}
/**
@return the parent collection of the template, or 0 if none was defined
*/
@@ -72,6 +81,20 @@ bool TitleBlockTemplateLocation::isValid() const {
return(!name_.isEmpty());
}
/**
@param loc_str String describing the location of a title block template.
*/
void TitleBlockTemplateLocation::fromString(const QString &loc_str) {
collection_ = QETApp::titleBlockTemplatesCollection(QUrl(loc_str).scheme());
QRegExp name_from_url("^[^:]*:\\/\\/(.*)$");
if (name_from_url.exactMatch(loc_str)) {
name_ = name_from_url.capturedTexts().at(1);
} else {
name_ = QString();
}
}
/**
@return A string representation of the location
*/