summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/config.cpp
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2014-04-03 10:50:02 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-02 09:56:24 +0200
commit9e44204bf84edcfe2befaaa9b7280257c9268548 (patch)
treee9ea0cb7f5cbac8ed98b345b104fd4ed99d31ca7 /src/tools/qdoc/config.cpp
parent2e44a9e4918cd6d9d7f33f61330c456249dd9b0f (diff)
qdoc: Simplify config code for reading file paths
This change greatly simplifies the code used for reading paths from config files: near-identical functions Config::getCanonicalPathList() and Config::getPathList() are combined into one, and the use of Config::getCleanPathList() is replaced with the above. Effectively, all paths read from the config files are now converted into canonical ones. It also adds support for absolute paths in config files. Task-number: QTBUG-36193 Change-Id: I2dc1ee6a67a400e056404ec1c09c6e81f643aa77 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src/tools/qdoc/config.cpp')
-rw-r--r--src/tools/qdoc/config.cpp106
1 files changed, 20 insertions, 86 deletions
diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp
index 185c1c77f1..644eab8a56 100644
--- a/src/tools/qdoc/config.cpp
+++ b/src/tools/qdoc/config.cpp
@@ -454,87 +454,21 @@ QStringList Config::getStringList(const QString& var) const
}
/*!
- \brief Returns the a path list where all paths are canonicalized, then
- made relative to the config file.
- \param var The variable containing the list of paths.
- \see Location::canonicalRelativePath()
- */
-QStringList Config::getCanonicalPathList(const QString& var) const
-{
- QStringList t;
- QList<ConfigVar> configVars = configVars_.values(var);
- if (!configVars.empty()) {
- int i = configVars.size() - 1;
- while (i >= 0) {
- const ConfigVar& cv = configVars[i];
- if (!cv.location_.isEmpty())
- (Location&) lastLocation_ = cv.location_;
- if (!cv.plus_)
- t.clear();
- const QString d = cv.currentPath_;
- const QStringList& sl = cv.values_;
- if (!sl.isEmpty()) {
- t.reserve(t.size() + sl.size());
- for (int i=0; i<sl.size(); ++i) {
- QDir dir(d + "/" + sl[i]);
- t.append(dir.canonicalPath());
- }
- }
- --i;
- }
- }
- return t;
-}
+ Returns the a path list where all paths from the config variable \a var
+ are canonicalized. If \a validate is true, a warning for invalid paths is
+ generated.
-/*!
- This function should only be called when the configuration
- variable \a var maps to string lists that contain file paths.
- It cleans the paths with QDir::cleanPath() before returning
- them.
- */
-QStringList Config::getCleanPathList(const QString& var) const
-{
- QStringList t;
- QList<ConfigVar> configVars = configVars_.values(var);
- if (!configVars.empty()) {
- int i = configVars.size() - 1;
- while (i >= 0) {
- const ConfigVar& cv = configVars[i];
- if (!cv.plus_)
- t.clear();
- if (!cv.location_.isEmpty())
- (Location&) lastLocation_ = cv.location_;
- const QStringList& sl = cv.values_;
- if (!sl.isEmpty()) {
- t.reserve(t.size() + sl.size());
- for (int i=0; i<sl.size(); ++i) {
- t.append(QDir::cleanPath(sl[i].simplified()));
- }
- }
- --i;
- }
- }
- return t;
-}
-
-/*!
- This function should only be called when the configuration
- variable \a var maps to string lists that contain file paths.
- It cleans the paths with QDir::cleanPath() before returning
- them.
-
- First, this function looks up the configuration variable \a var
- in the location map and, if found, sets the internal variable
- \c{lastLocation_} the Location that \a var maps to.
+ First, this function looks up the configuration variable \a var
+ in the location map and, if found, sets the internal variable
+ \c{lastLocation_} the Location that \a var maps to.
- Then it looks up the configuration variable \a var in the string
- list map, which maps to one or more records that each contains a
- list of file paths.
+ Then it looks up the configuration variable \a var in the string
+ list map, which maps to one or more records that each contains a
+ list of file paths.
- These paths might not be clean, so QDir::cleanPath() is called
- for each one. The string list returned contains cleaned paths.
+ \sa Location::canonicalRelativePath()
*/
-QStringList Config::getPathList(const QString& var) const
+QStringList Config::getCanonicalPathList(const QString& var, bool validate) const
{
QStringList t;
QList<ConfigVar> configVars = configVars_.values(var);
@@ -542,22 +476,23 @@ QStringList Config::getPathList(const QString& var) const
int i = configVars.size() - 1;
while (i >= 0) {
const ConfigVar& cv = configVars[i];
- if (!cv.plus_)
- t.clear();
if (!cv.location_.isEmpty())
(Location&) lastLocation_ = cv.location_;
+ if (!cv.plus_)
+ t.clear();
const QString d = cv.currentPath_;
const QStringList& sl = cv.values_;
if (!sl.isEmpty()) {
t.reserve(t.size() + sl.size());
for (int i=0; i<sl.size(); ++i) {
- QFileInfo fileInfo;
- QString path = d + "/" + QDir::cleanPath(sl[i].simplified());
- fileInfo.setFile(path);
- if (!fileInfo.exists())
- lastLocation_.warning(tr("File '%1' does not exist").arg(path));
+ QDir dir(sl[i].simplified());
+ QString path = dir.path();
+ if (dir.isRelative())
+ dir.setPath(d + "/" + path);
+ if (validate && !QFileInfo::exists(dir.path()))
+ lastLocation_.warning(tr("Cannot find file or directory: %1").arg(path));
else
- t.append(path);
+ t.append(dir.canonicalPath());
}
}
--i;
@@ -566,7 +501,6 @@ QStringList Config::getPathList(const QString& var) const
return t;
}
-
/*!
Calls getRegExpList() with the control variable \a var and
iterates through the resulting list of regular expressions,