core,registry,ui: Do not use absolute file paths

This commit is contained in:
Oleg Shparber 2017-03-26 03:24:04 -04:00
parent ccbb75b1b9
commit 11f10adfe9
4 changed files with 11 additions and 11 deletions

View File

@ -58,7 +58,7 @@ void Extractor::extract(const QString &filePath, const QString &destination, con
QDir destinationDir(destination);
if (!root.isEmpty())
destinationDir = destinationDir.absoluteFilePath(root);
destinationDir = destinationDir.filePath(root);
// TODO: Do not strip root directory in archive if it equals to 'root'
archive_entry *entry;
@ -71,7 +71,7 @@ void Extractor::extract(const QString &filePath, const QString &destination, con
#endif
if (!root.isEmpty())
pathname.remove(0, pathname.indexOf(QLatin1String("/")) + 1);
archive_entry_set_pathname(entry, qPrintable(destinationDir.absoluteFilePath(pathname)));
archive_entry_set_pathname(entry, qPrintable(destinationDir.filePath(pathname)));
archive_read_extract(info.archiveHandle, entry, 0);
}

View File

@ -74,7 +74,7 @@ Docset::Docset(const QString &path) :
// Attempt to find the icon in any supported format
for (const QString &iconFile : dir.entryList({QStringLiteral("icon.*")}, QDir::Files)) {
m_icon = QIcon(dir.absoluteFilePath(iconFile));
m_icon = QIcon(dir.filePath(iconFile));
if (!m_icon.availableSizes().isEmpty())
break;
}
@ -88,9 +88,9 @@ Docset::Docset(const QString &path) :
// /Articles/ConfigFiles.html
Util::Plist plist;
if (dir.exists(QStringLiteral("Info.plist")))
plist.read(dir.absoluteFilePath(QStringLiteral("Info.plist")));
plist.read(dir.filePath(QStringLiteral("Info.plist")));
else if (dir.exists(QStringLiteral("info.plist")))
plist.read(dir.absoluteFilePath(QStringLiteral("info.plist")));
plist.read(dir.filePath(QStringLiteral("info.plist")));
else
return;
@ -122,7 +122,7 @@ Docset::Docset(const QString &path) :
if (!dir.cd(QStringLiteral("Resources")) || !dir.exists(QStringLiteral("docSet.dsidx")))
return;
m_db = new Util::SQLiteDatabase(dir.absoluteFilePath(QStringLiteral("docSet.dsidx")));
m_db = new Util::SQLiteDatabase(dir.filePath(QStringLiteral("docSet.dsidx")));
if (!m_db->isOpen()) {
qWarning("SQL Error: %s", qPrintable(m_db->lastError()));
@ -214,7 +214,7 @@ QString Docset::path() const
QString Docset::documentPath() const
{
return QDir(m_path).absoluteFilePath(QStringLiteral("Contents/Resources/Documents"));
return QDir(m_path).filePath(QStringLiteral("Contents/Resources/Documents"));
}
QIcon Docset::icon() const
@ -484,7 +484,7 @@ QUrl Docset::createPageUrl(const QString &path, const QString &fragment) const
realPath.remove(dashEntryRegExp);
realFragment.remove(dashEntryRegExp);
QUrl url = QUrl::fromLocalFile(QDir(documentPath()).absoluteFilePath(realPath));
QUrl url = QUrl::fromLocalFile(QDir(documentPath()).filePath(realPath));
if (!realFragment.isEmpty()) {
if (realFragment.startsWith(QLatin1String("//apple_ref"))
|| realFragment.startsWith(QLatin1String("//dash_ref"))) {

View File

@ -183,8 +183,8 @@ void DocsetRegistry::addDocsetsFromFolder(const QString &path)
const QDir dir(path);
for (const QFileInfo &subdir : dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs)) {
if (subdir.suffix() == QLatin1String("docset"))
addDocset(subdir.absoluteFilePath());
addDocset(subdir.filePath());
else
addDocsetsFromFolder(subdir.absoluteFilePath());
addDocsetsFromFolder(subdir.filePath());
}
}

View File

@ -487,7 +487,7 @@ void DocsetsDialog::extractionCompleted(const QString &filePath)
const QString docsetName = docsetNameForTmpFilePath(filePath);
const QDir dataDir(m_application->settings()->docsetPath);
const QString docsetPath = dataDir.absoluteFilePath(docsetName + QLatin1String(".docset"));
const QString docsetPath = dataDir.filePath(docsetName + QLatin1String(".docset"));
// Write metadata about docset
Registry::DocsetMetadata metadata = m_availableDocsets.contains(docsetName)