Reworked the DiagramContext class to sort custom variables.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1884 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-06-29 05:21:46 +00:00
parent 805ee08e1b
commit 4a01fed0ba
4 changed files with 31 additions and 8 deletions

View File

@@ -21,8 +21,18 @@
/**
@return a list containing all the keys in the context object.
*/
QList<QString> DiagramContext::keys() const {
return(content_.keys());
QList<QString> DiagramContext::keys(DiagramContext::KeyOrder order) const {
if (order == None) {
return content_.keys();
} else {
QList<QString> keys_list = content_.keys();
if (order == Alphabetical) {
qSort(keys_list);
} else {
qSort(keys_list.begin(), keys_list.end(), DiagramContext::stringLongerThan);
}
return(keys_list);
}
}
/**
@@ -71,6 +81,13 @@ QString DiagramContext::validKeyRegExp() {
return("^[a-z0-9-]+$");
}
/**
@return True if \a a is longer than \a b, false otherwise.
*/
bool DiagramContext::stringLongerThan(const QString &a, const QString &b) {
return (a.length() > b.length());
}
/**
@param key a key string
@return true if that key is acceptable, false otherwise