Commit 9dd40fc3 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix cppcheck warnings

parent 447794d6
Pipeline #84040 passed with stage
in 12 minutes and 3 seconds
......@@ -209,11 +209,11 @@ void ImportAddressbookJobInterface::restoreResources()
const KArchiveEntry *dataResouceEntry =
mArchiveDirectory->entry(dataFile);
if (dataResouceEntry->isFile()) {
const auto file =
const auto fileEntry =
static_cast<const KArchiveFile *>(dataResouceEntry);
// TODO adapt directory name too
extractZipFile(
file, copyToDirName, newUrlInfo.path(),
fileEntry, copyToDirName, newUrlInfo.path(),
value.akonadiConfigFile.contains(
QLatin1String("akonadi_contacts_resource_")));
}
......
......@@ -152,10 +152,10 @@ void ImportAlarmJobInterface::restoreResources()
bool isDirResource = value.akonadiConfigFile.contains(
QLatin1String("akonadi_kalarm_dir_resource_"));
if (dataResouceEntry->isFile()) {
const auto file =
const auto fileEntry =
static_cast<const KArchiveFile *>(dataResouceEntry);
// TODO adapt directory name too
extractZipFile(file, copyToDirName, newUrlInfo.path(),
extractZipFile(fileEntry, copyToDirName, newUrlInfo.path(),
isDirResource);
}
settings.insert(QStringLiteral("Path"), newUrl);
......
......@@ -66,17 +66,17 @@ void GenerateListFileFromArchive::addSubItems(const QString &topLevelPath, const
const QString space = QString(indent * 2, QLatin1Char(' '));
const QStringList lst = dir->entries();
for (const QString &entryName : lst) {
const KArchiveEntry *entry = dir->entry(entryName);
if (entry) {
if (entry->isDirectory()) {
const auto dirEntry = static_cast<const KArchiveDirectory *>(entry);
const KArchiveEntry *archiveEntry = dir->entry(entryName);
if (archiveEntry) {
if (archiveEntry->isDirectory()) {
const auto dirEntry = static_cast<const KArchiveDirectory *>(archiveEntry);
// mListFile += space + dirEntry->name();
addSubItems(
topLevelPath, entry, indent,
topLevelPath, archiveEntry, indent,
(fullpath.isEmpty() ? QString() : fullpath + QLatin1Char('/')) +
dirEntry->name());
} else if (entry->isFile()) {
const auto file = static_cast<const KArchiveFile *>(entry);
} else if (archiveEntry->isFile()) {
const auto file = static_cast<const KArchiveFile *>(archiveEntry);
const QString fileFullPath =
topLevelPath +
(fullpath.isEmpty() ? QString() : fullpath + QLatin1Char('/')) +
......
......@@ -18,8 +18,8 @@
TestExportFile::TestExportFile(QObject *parent)
: QObject(parent)
, mTemporaryFile(QDir::tempPath() + QStringLiteral("/archive.zip"))
{
mTemporaryFile = QDir::tempPath() + QStringLiteral("/archive.zip");
mArchiveStorage = new ArchiveStorage(mTemporaryFile, this);
Q_ASSERT(mArchiveStorage->openArchive(true));
}
......
......@@ -306,11 +306,11 @@ void ImportCalendarJobInterface::restoreResources()
bool isDirResource = value.akonadiConfigFile.contains(
QLatin1String("akonadi_icaldir_resource_"));
if (dataResouceEntry->isFile()) {
const auto file =
const auto fileEntry =
static_cast<const KArchiveFile *>(dataResouceEntry);
// TODO adapt directory name too
extractZipFile(
file, copyToDirName, newUrlInfo.path(),
fileEntry, copyToDirName, newUrlInfo.path(),
value.akonadiConfigFile.contains(
QLatin1String("akonadi_icaldir_resource_")));
}
......@@ -320,10 +320,10 @@ void ImportCalendarJobInterface::restoreResources()
if (!agentConfigFile.isEmpty()) {
const KArchiveEntry *akonadiAgentConfigEntry = mArchiveDirectory->entry(agentConfigFile);
if (akonadiAgentConfigEntry->isFile()) {
const auto file = static_cast<const KArchiveFile *>(
const auto fileEntry = static_cast<const KArchiveFile *>(
akonadiAgentConfigEntry);
copyArchiveFileTo(file, copyToDirName);
resourceName = file->name();
copyArchiveFileTo(fileEntry, copyToDirName);
resourceName = fileEntry->name();
filename = Utils::akonadiAgentName(
copyToDirName + QLatin1Char('/') + resourceName);
}
......
......@@ -106,12 +106,12 @@ void ImportMailJobInterface::storeMailArchiveResource(const KArchiveDirectory *d
if (entry && entry->isDirectory()) {
const auto resourceDir =
static_cast<const KArchiveDirectory *>(entry);
const QStringList lst = resourceDir->entries();
if (lst.count() >= 2) {
const QStringList lstResourceDirEntries = resourceDir->entries();
if (lstResourceDirEntries.count() >= 2) {
const QString archPath(prefix + QLatin1Char('/') + entryName +
QLatin1Char('/'));
ResourceFiles files;
for (const QString &name : lst) {
for (const QString &name : lstResourceDirEntries) {
if (name.endsWith(QLatin1String("rc")) &&
(name.contains(QLatin1String("akonadi_mbox_resource_")) ||
name.contains(
......@@ -129,7 +129,7 @@ void ImportMailJobInterface::storeMailArchiveResource(const KArchiveDirectory *d
mListResourceFile.append(files);
} else {
qCDebug(PIMDATAEXPORTERCORE_LOG)
<< " Problem in archive. number of file " << lst.count();
<< " Problem in archive. number of file " << lstResourceDirEntries.count();
}
}
}
......@@ -533,10 +533,10 @@ void ImportMailJobInterface::restoreMails()
const KArchiveEntry *akonadiAgentConfigEntry =
mArchiveDirectory->entry(agentConfigFile);
if (akonadiAgentConfigEntry->isFile()) {
const auto file =
const auto fileEntry =
static_cast<const KArchiveFile *>(akonadiAgentConfigEntry);
copyArchiveFileTo(file, copyToDirName);
resourceName = file->name();
copyArchiveFileTo(fileEntry, copyToDirName);
resourceName = fileEntry->name();
filename = Utils::akonadiAgentName(
copyToDirName + QLatin1Char('/') + resourceName);
}
......@@ -613,10 +613,10 @@ void ImportMailJobInterface::restoreMails()
const QString mailFile = value.akonadiResources;
const KArchiveEntry *dataResouceEntry = mArchiveDirectory->entry(mailFile);
if (dataResouceEntry && dataResouceEntry->isFile()) {
const auto file =
const auto fileEntry =
static_cast<const KArchiveFile *>(dataResouceEntry);
// TODO Fix me not correct zip filename.
extractZipFile(file, copyToDirName, newUrl);
extractZipFile(fileEntry, copyToDirName, newUrl);
}
listResourceToSync << newResource;
} else {
......@@ -1149,8 +1149,8 @@ void ImportMailJobInterface::copyArchiveMailAgentConfigGroup(const KSharedConfig
KConfigGroup newGroup(archiveConfigDestination, archiveGroupPattern + QString::number(id));
oldGroup.copyTo(&newGroup);
newGroup.writeEntry(QStringLiteral("saveCollectionId"), id);
QUrl path = newGroup.readEntry("storePath", QUrl());
if (!QDir(path.path()).exists()) {
QUrl storePath = newGroup.readEntry("storePath", QUrl());
if (!QDir(storePath.path()).exists()) {
newGroup.writeEntry(QStringLiteral("storePath"), QUrl::fromLocalFile(QDir::homePath()));
}
}
......
......@@ -195,10 +195,10 @@ void ImportNotesJobInterface::restoreResources()
if (!agentConfigFile.isEmpty()) {
const KArchiveEntry *akonadiAgentConfigEntry = mArchiveDirectory->entry(agentConfigFile);
if (akonadiAgentConfigEntry->isFile()) {
const auto file = static_cast<const KArchiveFile *>(
const auto fileEntry = static_cast<const KArchiveFile *>(
akonadiAgentConfigEntry);
copyArchiveFileTo(file, copyToDirName);
resourceName = file->name();
copyArchiveFileTo(fileEntry, copyToDirName);
resourceName = fileEntry->name();
filename = Utils::akonadiAgentName(
copyToDirName + QLatin1Char('/') + resourceName);
}
......
......@@ -222,10 +222,10 @@ void ShowArchiveStructureDialog::addSubItems(const QString &topLevelPath, QTreeW
const QString space = QString(indent * 2, QLatin1Char(' '));
const QStringList lst = dir->entries();
for (const QString &entryName : lst) {
const KArchiveEntry *entry = dir->entry(entryName);
if (entry) {
if (entry->isDirectory()) {
const auto dirEntry = static_cast<const KArchiveDirectory *>(entry);
const KArchiveEntry *archiveEntry = dir->entry(entryName);
if (archiveEntry) {
if (archiveEntry->isDirectory()) {
const auto dirEntry = static_cast<const KArchiveDirectory *>(archiveEntry);
QTreeWidgetItem *newTopItem =
addItem(parent, dirEntry->name(), QString());
QFont font(newTopItem->font(0));
......@@ -233,11 +233,11 @@ void ShowArchiveStructureDialog::addSubItems(const QString &topLevelPath, QTreeW
mLogFile += space + dirEntry->name() + QLatin1Char('\n');
newTopItem->setFont(0, font);
addSubItems(
topLevelPath, newTopItem, entry, indent,
topLevelPath, newTopItem, archiveEntry, indent,
(fullpath.isEmpty() ? QString() : fullpath + QLatin1Char('/')) +
dirEntry->name());
} else if (entry->isFile()) {
const auto file = static_cast<const KArchiveFile *>(entry);
} else if (archiveEntry->isFile()) {
const auto file = static_cast<const KArchiveFile *>(archiveEntry);
const QString fileFullPath =
topLevelPath +
(fullpath.isEmpty() ? QString() : fullpath + QLatin1Char('/')) +
......
......@@ -12,9 +12,9 @@
LogWidget::LogWidget(QWidget *parent)
: QWidget(parent)
, mCustomLogWidget(new PimCommon::CustomLogWidget(this))
{
auto layout = new QHBoxLayout(this);
mCustomLogWidget = new PimCommon::CustomLogWidget(this);
layout->addWidget(mCustomLogWidget);
}
......
......@@ -28,6 +28,6 @@ public:
Q_REQUIRED_RESULT bool isEmpty() const;
private:
PimCommon::CustomLogWidget *mCustomLogWidget = nullptr;
PimCommon::CustomLogWidget *const mCustomLogWidget;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment