History

started on making ~ mean the application directory in script paths

Seth Alves committed 10 years ago

Commit 7c0bb721 parent 2ad02944 files · +46 −20Browse files

Showing the changes to libraries/script-engine/src/ScriptsModel.cpp (1 of 4 files). Show all

Unified · Split

libraries/script-engine/src/ScriptsModel.cpp+6−14
@@ -161,12 +161,8 @@ void ScriptsModel::requestDefaultFiles(QString marker) { · 160 unmodified lines
161161 QString localDir = url.toLocalFile() + "/scripts";
162162 QDirIterator it(localDir, QStringList() << "*.js", QDir::Files, QDirIterator::Subdirectories);
163163 while (it.hasNext()) {
164− QString jsFullPath = it.next();
165− QString jsPartialPath = jsFullPath.mid(localDir.length() + 1); // + 1 to skip a separator
166− #if defined(Q_OS_WIN) || defined(Q_OS_OSX)
167− jsFullPath = jsFullPath.toLower();
168− jsPartialPath = jsPartialPath.toLower();
169− #endif
164+ QString jsFullPath = normalizeScriptUrl(it.next());
165+ QString jsPartialPath = normalizeScriptUrl(jsFullPath.mid(localDir.length() + 1)); // + 1 to skip a separator
170166 _treeNodes.append(new TreeNodeScript(jsPartialPath, jsFullPath, SCRIPT_ORIGIN_DEFAULT));
171167 }
172168 } else {
@@ -231,7 +227,7 @@ bool ScriptsModel::parseXML(QByteArray xmlFile) { · 58 unmodified lines
231227 while (!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == CONTAINER_NAME)) {
232228 if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == KEY_NAME) {
233229 xml.readNext();
234− lastKey = xml.text().toString();
230+ lastKey = normalizeScriptUrl(xml.text().toString());
235231 if (jsRegex.exactMatch(xml.text().toString())) {
236232 _treeNodes.append(new TreeNodeScript(lastKey.mid(MODELS_LOCATION.length()),
237233 defaultScriptsLocation() + "/" + lastKey,
@@ -278,12 +274,8 @@ void ScriptsModel::reloadLocalFiles() { · 40 unmodified lines
278274 const QFileInfoList localFiles = _localDirectory.entryInfoList();
279275 for (int i = 0; i < localFiles.size(); i++) {
280276 QFileInfo file = localFiles[i];
281− QString fileName = file.fileName();
282− QString absPath = file.absoluteFilePath();
283− #if defined(Q_OS_WIN) || defined(Q_OS_OSX)
284− fileName = fileName.toLower();
285− absPath = absPath.toLower();
286− #endif
277+ QString fileName = normalizeScriptUrl(file.fileName());
278+ QString absPath = normalizeScriptUrl(file.absoluteFilePath());
287279 _treeNodes.append(new TreeNodeScript(fileName, absPath, SCRIPT_ORIGIN_LOCAL));
288280 }
289281 rebuildTree();
@@ -310,7 +302,7 @@ void ScriptsModel::rebuildTree() { · 20 unmodified lines
310302 for (pathIterator = pathList.constBegin(); pathIterator != pathList.constEnd(); ++pathIterator) {
311303 hash.append(*pathIterator + "/");
312304 if (!folders.contains(hash)) {
313− folders[hash] = new TreeNodeFolder(*pathIterator, parent);
305+ folders[hash] = new TreeNodeFolder(normalizeScriptUrl(*pathIterator), parent);
314306 }
315307 parent = folders[hash];
316308 }