diff options
author | hjk <qthjk@ovi.com> | 2012-01-26 00:25:37 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2012-01-30 13:05:05 +0100 |
commit | e99e435818eaa13cbe95b6429a4615ae5416ac60 (patch) | |
tree | 9bae654b43956bad666fad8391f262399566332e /src/plugins/qtsupport/qmlobservertool.cpp | |
parent | 52b47364de371f2797c597c747c1bc10ad371c1d (diff) | |
download | qt-creator-e99e435818eaa13cbe95b6429a4615ae5416ac60.tar.gz |
qtsupport: remove unneeded thing from headers, style.
Change-Id: I059af357fa772290a78f62c31cb7c532ae7d77ff
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src/plugins/qtsupport/qmlobservertool.cpp')
-rw-r--r-- | src/plugins/qtsupport/qmlobservertool.cpp | 96 |
1 files changed, 47 insertions, 49 deletions
diff --git a/src/plugins/qtsupport/qmlobservertool.cpp b/src/plugins/qtsupport/qmlobservertool.cpp index 9bd94f256d..6dacb5b7ef 100644 --- a/src/plugins/qtsupport/qmlobservertool.cpp +++ b/src/plugins/qtsupport/qmlobservertool.cpp @@ -45,7 +45,46 @@ namespace QtSupport { -static inline QStringList validBinaryFilenames() +static QStringList recursiveFileList(const QDir &dir, const QString &prefix) +{ + QStringList files; + + QString _prefix = prefix; + if (!_prefix.isEmpty() && !_prefix.endsWith(QLatin1Char('/'))) + _prefix.append(QLatin1Char('/')); + + foreach (const QString &fileName, dir.entryList(QDir::Files)) + files << _prefix + fileName; + + foreach (const QString &subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) + files += recursiveFileList(QDir(dir.absoluteFilePath(subDir)), _prefix + subDir); + + return files; +} + +static QStringList installDirectories(const QString &qtInstallData) +{ + const QChar slash = QLatin1Char('/'); + const uint hash = qHash(qtInstallData); + QStringList directories; + directories + << (qtInstallData + QLatin1String("/qtc-qmlobserver/")) + << QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-qmlobserver/") + QString::number(hash))) + slash + << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-qmlobserver/") + QString::number(hash)) + slash; + return directories; +} + +static QString sourcePath() +{ + return Core::ICore::resourcePath() + QLatin1String("/qml/qmlobserver/"); +} + +static QStringList sourceFileNames() +{ + return recursiveFileList(QDir(sourcePath()), QString()); +} + +static QStringList validBinaryFilenames() { return QStringList() << QLatin1String("debug/qmlobserver.exe") @@ -92,7 +131,7 @@ QStringList QmlObserverTool::locationsByInstallData(const QString &qtInstallData QStringList result; QFileInfo fileInfo; const QStringList binFilenames = validBinaryFilenames(); - foreach(const QString &directory, installDirectories(qtInstallData)) { + foreach (const QString &directory, installDirectories(qtInstallData)) { if (getHelperFileInfoFor(binFilenames, directory, &fileInfo)) result << fileInfo.filePath(); } @@ -118,15 +157,14 @@ static inline bool mkpath(const QString &targetDirectory, QString *errorMessage) QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessage) { - const QStringList directories = QmlObserverTool::installDirectories(qtInstallData); + const QStringList directories = installDirectories(qtInstallData); - // Try to find a writeable directory. - foreach(const QString &directory, directories) { - if (!mkpath(directory, errorMessage)) { + // Try to find a writable directory. + foreach (const QString &directory, directories) { + if (!mkpath(directory, errorMessage)) continue; - } else { - errorMessage->clear(); - } + + errorMessage->clear(); if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) { errorMessage->clear(); @@ -139,44 +177,4 @@ QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessag return QString(); } -QStringList QmlObserverTool::recursiveFileList(const QDir &dir, const QString &prefix) -{ - QStringList files; - - QString _prefix = prefix; - if (!_prefix.isEmpty() && !_prefix.endsWith(QLatin1Char('/'))) { - _prefix.append(QLatin1Char('/')); - } - foreach (const QString &fileName, dir.entryList(QDir::Files)) { - files << _prefix + fileName; - } - - foreach (const QString &subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { - files += recursiveFileList(QDir(dir.absoluteFilePath(subDir)), _prefix + subDir); - } - return files; -} - -QStringList QmlObserverTool::installDirectories(const QString &qtInstallData) -{ - const QChar slash = QLatin1Char('/'); - const uint hash = qHash(qtInstallData); - QStringList directories; - directories - << (qtInstallData + QLatin1String("/qtc-qmlobserver/")) - << QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-qmlobserver/") + QString::number(hash))) + slash - << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-qmlobserver/") + QString::number(hash)) + slash; - return directories; -} - -QString QmlObserverTool::sourcePath() -{ - return Core::ICore::resourcePath() + QLatin1String("/qml/qmlobserver/"); -} - -QStringList QmlObserverTool::sourceFileNames() -{ - return recursiveFileList(QDir(sourcePath())); -} - } // namespace |