[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kbibtex] src: Prefer 'const QSharedPointer<const Entry> &' over raw pointer 'const Entry *'
From: Thomas Fischer <null () kde ! org>
Date: 2017-03-31 21:56:22
Message-ID: E1cu4Ws-0004Se-Gx () code ! kde ! org
[Download RAW message or body]
Git commit 1eb5a767289751acf2aae885e93fa9e4d3829423 by Thomas Fischer.
Committed on 31/03/2017 at 19:47.
Pushed by thomasfischer into branch 'master'.
Prefer 'const QSharedPointer<const Entry> &' over raw pointer 'const Entry *'
M +1 -1 src/gui/field/fieldlistedit.cpp
M +1 -1 src/gui/file/sortfilterfilemodel.cpp
M +1 -1 src/io/fileexporterpdf.cpp
M +2 -2 src/io/fileinfo.cpp
M +3 -2 src/io/fileinfo.h
M +1 -1 src/parts/part.cpp
M +1 -1 src/program/docklets/documentpreview.cpp
https://commits.kde.org/kbibtex/1eb5a767289751acf2aae885e93fa9e4d3829423
diff --git a/src/gui/field/fieldlistedit.cpp b/src/gui/field/fieldlistedit.cpp
index 2b7b90c9..354df7c1 100644
--- a/src/gui/field/fieldlistedit.cpp
+++ b/src/gui/field/fieldlistedit.cpp
@@ -332,7 +332,7 @@ void FieldListEdit::dropEvent(QDropEvent *event)
if (file != nullptr && !entry.isNull() && d->fieldKey == \
QStringLiteral("^external")) { /// handle "external" list differently
- const QList<QUrl> urlList = FileInfo::entryUrls(entry.data(), \
QUrl(file->property(File::Url).toUrl()), FileInfo::TestExistenceNo); + \
const QList<QUrl> urlList = FileInfo::entryUrls(entry, \
QUrl(file->property(File::Url).toUrl()), FileInfo::TestExistenceNo); Value v;
for (const QUrl &url : urlList) {
v.append(QSharedPointer<VerbatimText>(new \
VerbatimText(url.url(QUrl::PreferLocalFile))));
diff --git a/src/gui/file/sortfilterfilemodel.cpp \
b/src/gui/file/sortfilterfilemodel.cpp index fad845a4..f738357d 100644
--- a/src/gui/file/sortfilterfilemodel.cpp
+++ b/src/gui/file/sortfilterfilemodel.cpp
@@ -196,7 +196,7 @@ bool SortFilterFileModel::filterAcceptsRow(int source_row, const \
QModelIndex &so
/// Test associated PDF files
if (m_filterQuery.searchPDFfiles && m_filterQuery.field.isEmpty()) {///< not \
filtering for any specific field
- const auto entryUrlList = FileInfo::entryUrls(entry.data(), \
fileSourceModel()->bibliographyFile()->property(File::Url, QUrl()).toUrl(), \
FileInfo::TestExistenceYes); + const auto entryUrlList = \
FileInfo::entryUrls(entry, fileSourceModel()->bibliographyFile()->property(File::Url, \
QUrl()).toUrl(), FileInfo::TestExistenceYes); for (const QUrl &url : entryUrlList) {
if (url.isLocalFile() && \
url.fileName().endsWith(QStringLiteral(".pdf"))) {
// FIXME if you have a large collection of PDF files and the \
text version
diff --git a/src/io/fileexporterpdf.cpp b/src/io/fileexporterpdf.cpp
index 340f2104..dafd556c 100644
--- a/src/io/fileexporterpdf.cpp
+++ b/src/io/fileexporterpdf.cpp
@@ -208,7 +208,7 @@ void FileExporterPDF::fillEmbeddedFileList(const \
QSharedPointer<const Element> e
const QSharedPointer<const Entry> entry = element.dynamicCast<const Entry>();
if (!entry.isNull()) {
const QString title = PlainTextValue::text(entry->value(Entry::ftTitle));
- const QList<QUrl> urlList = FileInfo::entryUrls(entry.data(), \
bibtexfile->property(File::Url).toUrl(), FileInfo::TestExistenceYes); + const \
QList<QUrl> urlList = FileInfo::entryUrls(entry, \
bibtexfile->property(File::Url).toUrl(), FileInfo::TestExistenceYes); for (const \
QUrl &url : urlList) { if (!url.isLocalFile()) continue;
const QString filename = url.url(QUrl::PreferLocalFile);
diff --git a/src/io/fileinfo.cpp b/src/io/fileinfo.cpp
index 4a507ae9..41ded3ab 100644
--- a/src/io/fileinfo.cpp
+++ b/src/io/fileinfo.cpp
@@ -181,10 +181,10 @@ void FileInfo::urlsInText(const QString &text, TestExistence \
testExistence, cons }
}
-QList<QUrl> FileInfo::entryUrls(const Entry *entry, const QUrl &bibTeXUrl, \
TestExistence testExistence) +QList<QUrl> FileInfo::entryUrls(const \
QSharedPointer<const Entry> &entry, const QUrl &bibTeXUrl, TestExistence \
testExistence) {
QList<QUrl> result;
- if (entry == nullptr || entry->isEmpty())
+ if (entry.isNull() || entry->isEmpty())
return result;
if (entry->contains(Entry::ftDOI)) {
diff --git a/src/io/fileinfo.h b/src/io/fileinfo.h
index 1e73cbb5..7128f2b7 100644
--- a/src/io/fileinfo.h
+++ b/src/io/fileinfo.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2004-2014 by Thomas Fischer <fischer@unix-ag.uni-kl.de> *
+ * Copyright (C) 2004-2017 by Thomas Fischer <fischer@unix-ag.uni-kl.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -24,6 +24,7 @@
#include <QUrl>
#include <QMimeDatabase>
#include <QMimeType>
+#include <QSharedPointer>
class Entry;
@@ -82,7 +83,7 @@ public:
* @param testExistence shall be tested for file existence?
* @return list of found URLs/filenames (duplicates are avoided)
*/
- static QList<QUrl> entryUrls(const Entry *entry, const QUrl &bibTeXUrl, \
TestExistence testExistence); + static QList<QUrl> entryUrls(const \
QSharedPointer<const Entry> &entry, const QUrl &bibTeXUrl, TestExistence \
testExistence);
/**
* Load the given PDF file and return the contained plain text.
diff --git a/src/parts/part.cpp b/src/parts/part.cpp
index acb0f28d..1d311295 100644
--- a/src/parts/part.cpp
+++ b/src/parts/part.cpp
@@ -664,7 +664,7 @@ public:
/// Test and continue if there was an Entry to retrieve
if (!entry.isNull()) {
/// Get list of URLs associated with this entry
- const QList<QUrl> urlList = FileInfo::entryUrls(entry.data(), \
partWidget->fileView()->fileModel()->bibliographyFile()->property(File::Url).toUrl(), \
FileInfo::TestExistenceYes); + const QList<QUrl> urlList = \
FileInfo::entryUrls(entry, \
partWidget->fileView()->fileModel()->bibliographyFile()->property(File::Url).toUrl(), \
FileInfo::TestExistenceYes); if (!urlList.isEmpty()) {
/// Memorize first action, necessary to set menu title
QAction *firstAction = nullptr;
diff --git a/src/program/docklets/documentpreview.cpp \
b/src/program/docklets/documentpreview.cpp index 39c4d02a..9b28c2ac 100644
--- a/src/program/docklets/documentpreview.cpp
+++ b/src/program/docklets/documentpreview.cpp
@@ -321,7 +321,7 @@ public:
/// do not load external reference if widget is hidden
if (isVisible()) {
- const QList<QUrl> urlList = FileInfo::entryUrls(entry.data(), baseUrl, \
FileInfo::TestExistenceYes); + const QList<QUrl> urlList = \
FileInfo::entryUrls(entry, baseUrl, FileInfo::TestExistenceYes); for (const QUrl \
&url : urlList) { bool isLocal = KBibTeX::isLocalOrRelative(url);
anyRemote |= !isLocal;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic