aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <[email protected]>2014-08-12 17:25:37 +0200
committerAndreas Cord-Landwehr <[email protected]>2014-08-12 17:27:03 +0200
commitd718ccb1fc0207604ab427e8b691c480b8a11bd2 (patch)
tree97b8018eb8d42f2e9da3639918857ae5317bb787
parenta673dae1fca18958cf5e71589a8ac401d2330de3 (diff)
Find course files.
-rw-r--r--src/core/resourcemanager.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/core/resourcemanager.cpp b/src/core/resourcemanager.cpp
index 36a46e5..92d6661 100644
--- a/src/core/resourcemanager.cpp
+++ b/src/core/resourcemanager.cpp
@@ -42,6 +42,7 @@
#include <QDomDocument>
#include <QUuid>
#include <QDir>
+#include <QDirIterator>
#include <QDebug>
#include <QUrl>
#include <QStandardPaths>
@@ -108,13 +109,21 @@ void ResourceManager::loadCourseResources()
}
// register GHNS course resources
- QStringList courseFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString("artikulate/courses/*/*/*.xml"));
- foreach (const QString &file, courseFiles) {
- QUrl courseFile = QUrl::fromLocalFile(file);
- // get directory name, which is the language identifier for this course
- // TODO allow usage of non-language ID named course folders
- QString directory = courseFile.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path().section('/', -1);
- addCourse(courseFile);
+ QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
+ foreach (const QString &testdir, dirs) {
+ QDirIterator it(testdir + "/courses/", QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ QDir dir(it.next());
+ dir.setFilter(QDir::Files | QDir::NoSymLinks);
+ QFileInfoList list = dir.entryInfoList();
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
+ if (fileInfo.completeSuffix() != "xml") {
+ continue;
+ }
+ addCourse(QUrl::fromLocalFile(fileInfo.absoluteFilePath()));
+ }
+ }
}
//TODO this signal should only be emitted when repository was added/removed