summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladyslav Batyrenko <mvlabat@gmail.com>2016-07-17 11:16:47 (GMT)
committerVladyslav Batyrenko <mvlabat@gmail.com>2016-07-17 11:17:46 (GMT)
commite1bc57bc626e5664bf2e808a0d2839a6dd7cb51b (patch)
tree866d9bfa0e829838df49cc4182a0674e18d905a7
parenta530116b619aed62d519188adc44e7588cada063 (diff)
[GSoC] Refactor ArchiveInterface API with entries metadata
- Refactor fileRootNodePair into Archive::Entry - Make ArchiveInterface API receive Archive::Entry See: https://phabricator.kde.org/T2566
-rw-r--r--app/batchextract.cpp2
-rw-r--r--autotests/kerfuffle/archivetest.cpp140
-rw-r--r--autotests/kerfuffle/data/archive-deepsinglehierarchy.json10
-rw-r--r--autotests/kerfuffle/data/archive-emptysinglefolder.json2
-rw-r--r--autotests/kerfuffle/data/archive-malicious.json20
-rw-r--r--autotests/kerfuffle/data/archive-multiplefolders.json8
-rw-r--r--autotests/kerfuffle/data/archive-nodir-manyfiles.json4
-rw-r--r--autotests/kerfuffle/data/archive-onetopfolder.json4
-rw-r--r--autotests/kerfuffle/data/archive-password.json6
-rw-r--r--autotests/kerfuffle/data/archive-singlefile.json2
-rw-r--r--autotests/kerfuffle/data/archive-unorderedsinglefolder.json8
-rw-r--r--autotests/kerfuffle/data/archive001.json8
-rw-r--r--autotests/kerfuffle/data/archive002.json8
-rw-r--r--autotests/kerfuffle/jobstest.cpp103
-rw-r--r--autotests/kerfuffle/jsonarchiveinterface.cpp21
-rw-r--r--autotests/kerfuffle/jsonarchiveinterface.h6
-rw-r--r--autotests/kerfuffle/jsonparser.cpp8
-rw-r--r--autotests/kerfuffle/jsonparser.h6
-rw-r--r--autotests/plugins/cli7zplugin/cli7ztest.cpp35
-rw-r--r--autotests/plugins/clirarplugin/clirartest.cpp35
-rw-r--r--autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp61
-rw-r--r--autotests/plugins/clizipplugin/cliziptest.cpp28
-rw-r--r--kerfuffle/addtoarchive.cpp21
-rw-r--r--kerfuffle/addtoarchive.h5
-rw-r--r--kerfuffle/archive_kerfuffle.cpp37
-rw-r--r--kerfuffle/archive_kerfuffle.h50
-rw-r--r--kerfuffle/archiveentry.cpp100
-rw-r--r--kerfuffle/archiveentry.h27
-rw-r--r--kerfuffle/archiveinterface.cpp9
-rw-r--r--kerfuffle/archiveinterface.h12
-rw-r--r--kerfuffle/cliinterface.cpp57
-rw-r--r--kerfuffle/cliinterface.h21
-rw-r--r--kerfuffle/jobs.cpp70
-rw-r--r--kerfuffle/jobs.h24
-rw-r--r--part/archivemodel.cpp139
-rw-r--r--part/archivemodel.h19
-rw-r--r--part/infopanel.cpp8
-rw-r--r--part/part.cpp47
-rw-r--r--part/part.h6
-rw-r--r--plugins/cli7zplugin/cliplugin.cpp10
-rw-r--r--plugins/cliplugin-example/cliplugin.cpp4
-rw-r--r--plugins/clirarplugin/cliplugin.cpp8
-rw-r--r--plugins/cliunarchiverplugin/cliplugin.cpp28
-rw-r--r--plugins/cliunarchiverplugin/cliplugin.h3
-rw-r--r--plugins/clizipplugin/cliplugin.cpp4
-rw-r--r--plugins/libarchive/libarchiveplugin.cpp47
-rw-r--r--plugins/libarchive/libarchiveplugin.h7
-rw-r--r--plugins/libarchive/readwritelibarchiveplugin.cpp25
-rw-r--r--plugins/libarchive/readwritelibarchiveplugin.h4
-rw-r--r--plugins/libsinglefileplugin/singlefileplugin.cpp6
-rw-r--r--plugins/libsinglefileplugin/singlefileplugin.h3
51 files changed, 677 insertions, 649 deletions
diff --git a/app/batchextract.cpp b/app/batchextract.cpp
index 7c56f31..112793d 100644
--- a/app/batchextract.cpp
+++ b/app/batchextract.cpp
@@ -92,7 +92,7 @@ void BatchExtract::addExtraction(Kerfuffle::Archive* archive)
Kerfuffle::ExtractionOptions options;
options[QStringLiteral("PreservePaths")] = preservePaths();
- Kerfuffle::ExtractJob *job = archive->copyFiles(QVariantList(), destination, options);
+ Kerfuffle::ExtractJob *job = archive->copyFiles(QList<Kerfuffle::Archive::Entry*>(), destination, options);
qCDebug(ARK) << QString(QStringLiteral("Registering job from archive %1, to %2, preservePaths %3")).arg(archive->fileName(), destination, QString::number(preservePaths()));
diff --git a/autotests/kerfuffle/archivetest.cpp b/autotests/kerfuffle/archivetest.cpp
index 2ff8820..2e04fe2 100644
--- a/autotests/kerfuffle/archivetest.cpp
+++ b/autotests/kerfuffle/archivetest.cpp
@@ -213,7 +213,7 @@ void ArchiveTest::testProperties()
void ArchiveTest::testExtraction_data()
{
QTest::addColumn<QString>("archivePath");
- QTest::addColumn<QVariantList>("entriesToExtract");
+ QTest::addColumn<QList<Archive::Entry*>>("entriesToExtract");
QTest::addColumn<ExtractionOptions>("extractionOptions");
QTest::addColumn<int>("expectedExtractedEntriesCount");
@@ -227,16 +227,16 @@ void ArchiveTest::testExtraction_data()
QString archivePath = QFINDTESTDATA("data/simplearchive.tar.gz");
QTest::newRow("extract the whole simplearchive.tar.gz")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 4;
archivePath = QFINDTESTDATA("data/simplearchive.tar.gz");
QTest::newRow("extract selected entries from a tar.gz, without paths")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -244,9 +244,9 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.gz");
QTest::newRow("extract selected entries from a tar.gz, preserve paths")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< optionsPreservePaths
<< 3;
@@ -254,9 +254,9 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.gz");
QTest::newRow("extract selected entries from a tar.gz, drag-and-drop")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir/")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir/"))
}
<< dragAndDropOptions
<< 2;
@@ -264,16 +264,16 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/one_toplevel_folder.zip");
QTest::newRow("extract the whole one_toplevel_folder.zip")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 9;
archivePath = QFINDTESTDATA("data/one_toplevel_folder.zip");
QTest::newRow("extract selected entries from a zip, without paths")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")),
+ new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B"))
}
<< ExtractionOptions()
<< 2;
@@ -281,9 +281,9 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/one_toplevel_folder.zip");
QTest::newRow("extract selected entries from a zip, preserve paths")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")),
+ new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B"))
}
<< optionsPreservePaths
<< 4;
@@ -291,11 +291,11 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/one_toplevel_folder.zip");
QTest::newRow("extract selected entries from a zip, drag-and-drop")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A/"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/C/"), QStringLiteral("A/B/"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/C/test1.txt"), QStringLiteral("A/B/"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/C/test2.txt"), QStringLiteral("A/B/")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A/")),
+ new Archive::Entry(this, QStringLiteral("A/B/C/"), QStringLiteral("A/B/")),
+ new Archive::Entry(this, QStringLiteral("A/B/C/test1.txt"), QStringLiteral("A/B/")),
+ new Archive::Entry(this, QStringLiteral("A/B/C/test2.txt"), QStringLiteral("A/B/"))
}
<< dragAndDropOptions
<< 4;
@@ -303,16 +303,16 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/one_toplevel_folder.7z");
QTest::newRow("extract the whole one_toplevel_folder.7z")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 9;
archivePath = QFINDTESTDATA("data/one_toplevel_folder.7z");
QTest::newRow("extract selected entries from a 7z, without paths")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")),
+ new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B"))
}
<< ExtractionOptions()
<< 2;
@@ -320,9 +320,9 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/one_toplevel_folder.7z");
QTest::newRow("extract selected entries from a 7z, preserve paths")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")),
+ new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B"))
}
<< optionsPreservePaths
<< 4;
@@ -330,30 +330,30 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/one_toplevel_folder.7z");
QTest::newRow("extract selected entries from a 7z, drag-and-drop")
<< archivePath
- << QVariantList {QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/test2.txt"), QStringLiteral("A/B/")))}
+ << QList<Archive::Entry*> {new Archive::Entry(this, QStringLiteral("A/B/test2.txt"), QStringLiteral("A/B/"))}
<< dragAndDropOptions
<< 1;
archivePath = QFINDTESTDATA("data/empty_folders.zip");
QTest::newRow("zip with empty folders")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 5;
archivePath = QFINDTESTDATA("data/empty_folders.tar.gz");
QTest::newRow("tar with empty folders")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 5;
archivePath = QFINDTESTDATA("data/simplearchive.tar.bz2");
QTest::newRow("extract selected entries from a bzip2-compressed tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -361,16 +361,16 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.bz2");
QTest::newRow("extract all entries from a bzip2-compressed tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/simplearchive.tar.xz");
QTest::newRow("extract selected entries from a xz-compressed tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -378,16 +378,16 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.xz");
QTest::newRow("extract all entries from a xz-compressed tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/simplearchive.tar.lzma");
QTest::newRow("extract selected entries from a lzma-compressed tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -395,16 +395,16 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.lzma");
QTest::newRow("extract all entries from a lzma-compressed tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/simplearchive.tar.Z");
QTest::newRow("extract selected entries from a compress (.Z)-compressed tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -412,16 +412,16 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.Z");
QTest::newRow("extract all entries from a compress (.Z)-compressed tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/simplearchive.tar.lz");
QTest::newRow("extract selected entries from a lzipped tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -429,16 +429,16 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.lz");
QTest::newRow("extract all entries from a lzipped tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
archivePath = QFINDTESTDATA("data/simplearchive.tar.lzo");
QTest::newRow("extract selected entries from a lzop-compressed tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -446,7 +446,7 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.lzo");
QTest::newRow("extract all entries from a lzop-compressed tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
@@ -455,9 +455,9 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.lrz");
QTest::newRow("extract selected entries from a lrzip-compressed tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -465,7 +465,7 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.lrz");
QTest::newRow("extract all entries from a lrzip-compressed tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
} else {
@@ -477,9 +477,9 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.lz4");
QTest::newRow("extract selected entries from a lz4-compressed tarball without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file3.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir2/file22.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -487,7 +487,7 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.tar.lz4");
QTest::newRow("extract all entries from a lz4-compressed tarball with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 7;
} else {
@@ -497,9 +497,9 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.xar");
QTest::newRow("extract selected entries from a xar archive without path")
<< archivePath
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("dir1/file11.txt"), QString())),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("file4.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("dir1/file11.txt"), QString()),
+ new Archive::Entry(this, QStringLiteral("file4.txt"), QString())
}
<< ExtractionOptions()
<< 2;
@@ -507,7 +507,7 @@ void ArchiveTest::testExtraction_data()
archivePath = QFINDTESTDATA("data/simplearchive.xar");
QTest::newRow("extract all entries from a xar archive with path")
<< archivePath
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 6;
}
@@ -527,7 +527,7 @@ void ArchiveTest::testExtraction()
QSKIP("Could not create a temporary directory for extraction. Skipping test.", SkipSingle);
}
- QFETCH(QVariantList, entriesToExtract);
+ QFETCH(QList<Archive::Entry*>, entriesToExtract);
QFETCH(ExtractionOptions, extractionOptions);
auto extractionJob = archive->copyFiles(entriesToExtract, destDir.path(), extractionOptions);
diff --git a/autotests/kerfuffle/data/archive-deepsinglehierarchy.json b/autotests/kerfuffle/data/archive-deepsinglehierarchy.json
index 9aa8c0c..c6f6a63 100644
--- a/autotests/kerfuffle/data/archive-deepsinglehierarchy.json
+++ b/autotests/kerfuffle/data/archive-deepsinglehierarchy.json
@@ -1,20 +1,20 @@
[
{
- "fileName": "aDir/",
+ "fullPath": "aDir/",
"isDirectory": true
},
{
- "fileName": "aDir/b.txt"
+ "fullPath": "aDir/b.txt"
},
{
- "fileName": "aDir/aDirInside/",
+ "fullPath": "aDir/aDirInside/",
"isDirectory": true
},
{
- "fileName": "aDir/aDirInside/anotherDir/",
+ "fullPath": "aDir/aDirInside/anotherDir/",
"isDirectory": true
},
{
- "fileName": "aDir/aDirInside/anotherDir/file.txt"
+ "fullPath": "aDir/aDirInside/anotherDir/file.txt"
}
]
diff --git a/autotests/kerfuffle/data/archive-emptysinglefolder.json b/autotests/kerfuffle/data/archive-emptysinglefolder.json
index e6c95a2..46d5451 100644
--- a/autotests/kerfuffle/data/archive-emptysinglefolder.json
+++ b/autotests/kerfuffle/data/archive-emptysinglefolder.json
@@ -1,6 +1,6 @@
[
{
- "fileName": "aDir/",
+ "fullPath": "aDir/",
"isDirectory": true
}
]
diff --git a/autotests/kerfuffle/data/archive-malicious.json b/autotests/kerfuffle/data/archive-malicious.json
index d576a57..696e001 100644
--- a/autotests/kerfuffle/data/archive-malicious.json
+++ b/autotests/kerfuffle/data/archive-malicious.json
@@ -1,24 +1,24 @@
[
{
- "FileName": "aDir/",
- "IsDirectory": true
+ "fullPath": "aDir/",
+ "isDirectory": true
},
{
- "FileName": "aDir/b.txt"
+ "fullPath": "aDir/b.txt"
},
{
- "FileName": "anotherDir/",
- "IsDirectory": true
+ "fullPath": "anotherDir/",
+ "isDirectory": true
},
{
- "FileName": "anotherDir/..",
- "IsDirectory": true
+ "fullPath": "anotherDir/..",
+ "isDirectory": true
},
{
- "FileName": "anotherDir/../..",
- "IsDirectory": true
+ "fullPath": "anotherDir/../..",
+ "isDirectory": true
},
{
- "FileName": "anotherDir/../../file.txt"
+ "fullPath": "anotherDir/../../file.txt"
}
]
diff --git a/autotests/kerfuffle/data/archive-multiplefolders.json b/autotests/kerfuffle/data/archive-multiplefolders.json
index 47b0caf..c5ee946 100644
--- a/autotests/kerfuffle/data/archive-multiplefolders.json
+++ b/autotests/kerfuffle/data/archive-multiplefolders.json
@@ -1,16 +1,16 @@
[
{
- "fileName": "aDir/",
+ "fullPath": "aDir/",
"isDirectory": true
},
{
- "fileName": "aDir/b.txt"
+ "fullPath": "aDir/b.txt"
},
{
- "fileName": "anotherDir/",
+ "fullPath": "anotherDir/",
"isDirectory": true
},
{
- "fileName": "anotherDir/file.txt"
+ "fullPath": "anotherDir/file.txt"
}
]
diff --git a/autotests/kerfuffle/data/archive-nodir-manyfiles.json b/autotests/kerfuffle/data/archive-nodir-manyfiles.json
index 9f89f94..c8afc56 100644
--- a/autotests/kerfuffle/data/archive-nodir-manyfiles.json
+++ b/autotests/kerfuffle/data/archive-nodir-manyfiles.json
@@ -1,8 +1,8 @@
[
{
- "fileName": "a.txt"
+ "fullPath": "a.txt"
},
{
- "fileName": "file.txt"
+ "fullPath": "file.txt"
}
]
diff --git a/autotests/kerfuffle/data/archive-onetopfolder.json b/autotests/kerfuffle/data/archive-onetopfolder.json
index ca025e9..e9c557b 100644
--- a/autotests/kerfuffle/data/archive-onetopfolder.json
+++ b/autotests/kerfuffle/data/archive-onetopfolder.json
@@ -1,9 +1,9 @@
[
{
- "fileName": "aDir/",
+ "fullPath": "aDir/",
"isDirectory": true
},
{
- "fileName": "aDir/b.txt"
+ "fullPath": "aDir/b.txt"
}
]
diff --git a/autotests/kerfuffle/data/archive-password.json b/autotests/kerfuffle/data/archive-password.json
index 73fd1c1..520b713 100644
--- a/autotests/kerfuffle/data/archive-password.json
+++ b/autotests/kerfuffle/data/archive-password.json
@@ -1,13 +1,13 @@
[
{
- "fileName": "foo.txt",
+ "fullPath": "foo.txt",
"isPasswordProtected": true
},
{
- "fileName": "bar.txt"
+ "fullPath": "bar.txt"
},
{
- "fileName": "aDirectory/",
+ "fullPath": "aDirectory/",
"isDirectory": true
}
]
diff --git a/autotests/kerfuffle/data/archive-singlefile.json b/autotests/kerfuffle/data/archive-singlefile.json
index 8573c43..df1f4a5 100644
--- a/autotests/kerfuffle/data/archive-singlefile.json
+++ b/autotests/kerfuffle/data/archive-singlefile.json
@@ -1,5 +1,5 @@
[
{
- "fileName": "a.txt"
+ "fullPath": "a.txt"
}
] \ No newline at end of file
diff --git a/autotests/kerfuffle/data/archive-unorderedsinglefolder.json b/autotests/kerfuffle/data/archive-unorderedsinglefolder.json
index 60ce54d..6cf288b 100644
--- a/autotests/kerfuffle/data/archive-unorderedsinglefolder.json
+++ b/autotests/kerfuffle/data/archive-unorderedsinglefolder.json
@@ -1,16 +1,16 @@
[
{
- "fileName": "aDir/anotherDir/bar.txt"
+ "fullPath": "aDir/anotherDir/bar.txt"
},
{
- "fileName": "aDir/foo.txt"
+ "fullPath": "aDir/foo.txt"
},
{
- "fileName": "aDir/anotherDir/",
+ "fullPath": "aDir/anotherDir/",
"isDirectory": true
},
{
- "fileName": "aDir/",
+ "fullPath": "aDir/",
"isDirectory": true
}
]
diff --git a/autotests/kerfuffle/data/archive001.json b/autotests/kerfuffle/data/archive001.json
index 3efc558..0a6130a 100644
--- a/autotests/kerfuffle/data/archive001.json
+++ b/autotests/kerfuffle/data/archive001.json
@@ -1,15 +1,15 @@
[
{
- "fileName": "a.txt"
+ "fullPath": "a.txt"
},
{
- "fileName": "aDir/",
+ "fullPath": "aDir/",
"isDirectory": true
},
{
- "fileName": "aDir/b.txt"
+ "fullPath": "aDir/b.txt"
},
{
- "fileName": "c.txt"
+ "fullPath": "c.txt"
}
]
diff --git a/autotests/kerfuffle/data/archive002.json b/autotests/kerfuffle/data/archive002.json
index c401919..f81b433 100644
--- a/autotests/kerfuffle/data/archive002.json
+++ b/autotests/kerfuffle/data/archive002.json
@@ -1,18 +1,18 @@
[
{
- "fileName": "a.txt",
+ "fullPath": "a.txt",
"size": 5
},
{
- "fileName": "aDir/",
+ "fullPath": "aDir/",
"isDirectory": true
},
{
- "fileName": "aDir/b.txt",
+ "fullPath": "aDir/b.txt",
"size": 954
},
{
- "fileName": "c.txt",
+ "fullPath": "c.txt",
"size": 45000
}
]
diff --git a/autotests/kerfuffle/jobstest.cpp b/autotests/kerfuffle/jobstest.cpp
index d9dd0c9..8a24962 100644
--- a/autotests/kerfuffle/jobstest.cpp
+++ b/autotests/kerfuffle/jobstest.cpp
@@ -209,7 +209,7 @@ void JobsTest::testListJob()
QCOMPARE(archiveEntries.size(), expectedEntryNames.size());
for (int i = 0; i < archiveEntries.size(); i++) {
- QCOMPARE(archiveEntries.at(i)->property("fileName").toString(), expectedEntryNames.at(i));
+ QCOMPARE(archiveEntries.at(i)->property("fullPath").toString(), expectedEntryNames.at(i));
}
listJob->deleteLater();
@@ -218,7 +218,7 @@ void JobsTest::testListJob()
void JobsTest::testExtractJobAccessors()
{
JSONArchiveInterface *iface = createArchiveInterface(QFINDTESTDATA("data/archive001.json"));
- ExtractJob *job = new ExtractJob(QVariantList(), QStringLiteral("/tmp/some-dir"), ExtractionOptions(), iface);
+ ExtractJob *job = new ExtractJob(QList<Archive::Entry*>(), QStringLiteral("/tmp/some-dir"), ExtractionOptions(), iface);
ExtractionOptions defaultOptions;
defaultOptions[QStringLiteral("PreservePaths")] = false;
@@ -237,7 +237,7 @@ void JobsTest::testExtractJobAccessors()
options[QStringLiteral("foo")] = QLatin1String("bar");
options[QStringLiteral("pi")] = 3.14f;
- job = new ExtractJob(QVariantList(), QStringLiteral("/root"), options, iface);
+ job = new ExtractJob(QList<Archive::Entry*>(), QStringLiteral("/root"), options, iface);
QCOMPARE(job->destinationDirectory(), QLatin1String("/root"));
QCOMPARE(job->extractionOptions(), options);
@@ -253,7 +253,7 @@ void JobsTest::testExtractJobAccessors()
void JobsTest::testTempExtractJob()
{
JSONArchiveInterface *iface = createArchiveInterface(QFINDTESTDATA("data/archive-malicious.json"));
- PreviewJob *job = new PreviewJob(QStringLiteral("anotherDir/../../file.txt"), false, iface);
+ PreviewJob *job = new PreviewJob(new Archive::Entry(this, QStringLiteral("anotherDir/../../file.txt")), false, iface);
QVERIFY(job->validatedFilePath().endsWith(QLatin1String("anotherDir/file.txt")));
QVERIFY(job->extractionOptions()[QStringLiteral("PreservePaths")].toBool());
@@ -270,21 +270,39 @@ void JobsTest::testTempExtractJob()
void JobsTest::testRemoveEntries_data()
{
QTest::addColumn<QString>("jsonArchive");
- QTest::addColumn<QStringList>("entries");
- QTest::addColumn<QVariantList>("entriesToDelete");
+ QTest::addColumn<QList<Archive::Entry*>>("entries");
+ QTest::addColumn<QList<Archive::Entry*>>("entriesToDelete");
QTest::newRow("archive001.json") << QFINDTESTDATA("data/archive001.json")
- << QStringList {QStringLiteral("a.txt"), QStringLiteral("aDir/"), QStringLiteral("aDir/b.txt"), QStringLiteral("c.txt")}
- << QVariantList {QStringLiteral("c.txt")};
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("a.txt")),
+ new Archive::Entry(this, QStringLiteral("aDir/")),
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt")),
+ new Archive::Entry(this, QStringLiteral("c.txt"))
+ }
+ << QList<Archive::Entry*> {new Archive::Entry(this, QStringLiteral("c.txt"))};
QTest::newRow("archive001.json") << QFINDTESTDATA("data/archive001.json")
- << QStringList {QStringLiteral("a.txt"), QStringLiteral("aDir/"), QStringLiteral("aDir/b.txt"), QStringLiteral("c.txt")}
- << QVariantList {QStringLiteral("a.txt"), QStringLiteral("c.txt")};
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("a.txt")),
+ new Archive::Entry(this, QStringLiteral("aDir/")),
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt")),
+ new Archive::Entry(this, QStringLiteral("c.txt"))
+ }
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("a.txt")),
+ new Archive::Entry(this, QStringLiteral("c.txt"))
+ };
// Error test: if we delete non-existent entries, the archive must not change.
QTest::newRow("archive001.json") << QFINDTESTDATA("data/archive001.json")
- << QStringList {QStringLiteral("a.txt"), QStringLiteral("aDir/"), QStringLiteral("aDir/b.txt"), QStringLiteral("c.txt")}
- << QVariantList {QStringLiteral("foo.txt")};
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("a.txt")),
+ new Archive::Entry(this, QStringLiteral("aDir/")),
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt")),
+ new Archive::Entry(this, QStringLiteral("c.txt"))
+ }
+ << QList<Archive::Entry*> {new Archive::Entry(this, QStringLiteral("foo.txt"))};
}
void JobsTest::testRemoveEntries()
@@ -293,12 +311,13 @@ void JobsTest::testRemoveEntries()
JSONArchiveInterface *iface = createArchiveInterface(jsonArchive);
QVERIFY(iface);
- QFETCH(QStringList, entries);
- QFETCH(QVariantList, entriesToDelete);
+ QFETCH(QList<Archive::Entry*>, entries);
+ QFETCH(QList<Archive::Entry*>, entriesToDelete);
+ QStringList fullPathsToDelete = iface->entryFullPaths(entriesToDelete);
- QStringList expectedRemainingEntries;
- Q_FOREACH (const QString& entry, entries) {
- if (!entriesToDelete.contains(entry)) {
+ QList<Archive::Entry*> expectedRemainingEntries;
+ Q_FOREACH (Archive::Entry *entry, entries) {
+ if (!fullPathsToDelete.contains(entry->property("fullPath").toString())) {
expectedRemainingEntries.append(entry);
}
}
@@ -310,7 +329,7 @@ void JobsTest::testRemoveEntries()
QCOMPARE(remainingEntries.size(), expectedRemainingEntries.size());
for (int i = 0; i < remainingEntries.size(); i++) {
- QCOMPARE(remainingEntries.at(i)->property("fileName").toString(), expectedRemainingEntries.at(i));
+ QCOMPARE(*remainingEntries.at(i), *expectedRemainingEntries.at(i));
}
iface->deleteLater();
@@ -319,21 +338,41 @@ void JobsTest::testRemoveEntries()
void JobsTest::testAddEntries_data()
{
QTest::addColumn<QString>("jsonArchive");
- QTest::addColumn<QStringList>("originalEntries");
- QTest::addColumn<QStringList>("entriesToAdd");
+ QTest::addColumn<QList<Archive::Entry*>>("originalEntries");
+ QTest::addColumn<QList<Archive::Entry*>>("entriesToAdd");
QTest::newRow("archive001.json") << QFINDTESTDATA("data/archive001.json")
- << QStringList {QStringLiteral("a.txt"), QStringLiteral("aDir/"), QStringLiteral("aDir/b.txt"), QStringLiteral("c.txt")}
- << QStringList {QStringLiteral("foo.txt")};
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("a.txt")),
+ new Archive::Entry(this, QStringLiteral("aDir/")),
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt")),
+ new Archive::Entry(this, QStringLiteral("c.txt"))
+ }
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("foo.txt"))
+ };
QTest::newRow("archive001.json") << QFINDTESTDATA("data/archive001.json")
- << QStringList {QStringLiteral("a.txt"), QStringLiteral("aDir/"), QStringLiteral("aDir/b.txt"), QStringLiteral("c.txt")}
- << QStringList {QStringLiteral("foo.txt"), QStringLiteral("bar.txt")};
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("a.txt")),
+ new Archive::Entry(this, QStringLiteral("aDir/")),
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt")),
+ new Archive::Entry(this, QStringLiteral("c.txt"))
+ }
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("foo.txt")),
+ new Archive::Entry(this, QStringLiteral("bar.txt"))
+ };
// Error test: if we add an already existent entry, the archive must not change.
QTest::newRow("archive001.json") << QFINDTESTDATA("data/archive001.json")
- << QStringList {QStringLiteral("a.txt"), QStringLiteral("aDir/"), QStringLiteral("aDir/b.txt"), QStringLiteral("c.txt")}
- << QStringList {QStringLiteral("c.txt")};
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("a.txt")),
+ new Archive::Entry(this, QStringLiteral("aDir/")),
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt")),
+ new Archive::Entry(this, QStringLiteral("c.txt"))
+ }
+ << QList<Archive::Entry*> {new Archive::Entry(this, QStringLiteral("c.txt"))};
}
void JobsTest::testAddEntries()
@@ -342,19 +381,23 @@ void JobsTest::testAddEntries()
JSONArchiveInterface *iface = createArchiveInterface(jsonArchive);
QVERIFY(iface);
- QFETCH(QStringList, originalEntries);
+ QFETCH(QList<Archive::Entry*>, originalEntries);
+ QStringList originalFullPaths = QStringList();
+ Q_FOREACH (Archive::Entry *entry, originalEntries) {
+ originalFullPaths.append(entry->property("fullPath").toString());
+ }
auto currentEntries = listEntries(iface);
QCOMPARE(currentEntries.size(), originalEntries.size());
- QFETCH(QStringList, entriesToAdd);
+ QFETCH(QList<Archive::Entry*>, entriesToAdd);
AddJob *addJob = new AddJob(entriesToAdd, CompressionOptions(), iface);
startAndWaitForResult(addJob);
currentEntries = listEntries(iface);
int expectedEntriesCount = originalEntries.size();
- Q_FOREACH (const QString& entry, entriesToAdd) {
- if (!originalEntries.contains(entry)) {
+ Q_FOREACH (Archive::Entry *entry, entriesToAdd) {
+ if (!originalFullPaths.contains(entry->property("fullPath").toString())) {
expectedEntriesCount++;
}
}
diff --git a/autotests/kerfuffle/jsonarchiveinterface.cpp b/autotests/kerfuffle/jsonarchiveinterface.cpp
index 07b6d1c..c0f2e21 100644
--- a/autotests/kerfuffle/jsonarchiveinterface.cpp
+++ b/autotests/kerfuffle/jsonarchiveinterface.cpp
@@ -64,25 +64,26 @@ bool JSONArchiveInterface::open()
return !m_archive.isEmpty();
}
-bool JSONArchiveInterface::addFiles(const QStringList& files, const Kerfuffle::CompressionOptions& options)
+bool JSONArchiveInterface::addFiles(const QList<Kerfuffle::Archive::Entry*> &files, const Kerfuffle::CompressionOptions& options)
{
Q_UNUSED(options)
- foreach (const QString& file, files) {
- if (m_archive.contains(file)) {
+ foreach (const Kerfuffle::Archive::Entry *entry, files) {
+ const QString &path = entry->property("fullPath").toString();
+ if (m_archive.contains(path)) {
return false;
}
- Kerfuffle::Archive::Entry *e = new Kerfuffle::Archive::Entry(NULL);
- e->setProperty("fileName", file);
+ Kerfuffle::Archive::Entry *e = new Kerfuffle::Archive::Entry(Q_NULLPTR);
+ e->setProperty("fullPath", path);
- m_archive[file] = e;
+ m_archive[path] = e;
}
return true;
}
-bool JSONArchiveInterface::copyFiles(const QList<QVariant>& files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options)
+bool JSONArchiveInterface::copyFiles(const QList<Kerfuffle::Archive::Entry*>& files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options)
{
Q_UNUSED(files)
Q_UNUSED(destinationDirectory)
@@ -91,10 +92,10 @@ bool JSONArchiveInterface::copyFiles(const QList<QVariant>& files, const QString
return true;
}
-bool JSONArchiveInterface::deleteFiles(const QList<QVariant>& files)
+bool JSONArchiveInterface::deleteFiles(const QList<Kerfuffle::Archive::Entry*>& files)
{
- foreach (const QVariant& file, files) {
- const QString fileName = file.toString();
+ foreach (const Kerfuffle::Archive::Entry *file, files) {
+ const QString &fileName = file->property("fullPath").toString();
if (m_archive.contains(fileName)) {
m_archive.remove(fileName);
emit entryRemoved(fileName);
diff --git a/autotests/kerfuffle/jsonarchiveinterface.h b/autotests/kerfuffle/jsonarchiveinterface.h
index 49d2c28..aaacce6 100644
--- a/autotests/kerfuffle/jsonarchiveinterface.h
+++ b/autotests/kerfuffle/jsonarchiveinterface.h
@@ -55,9 +55,9 @@ public:
virtual bool list() Q_DECL_OVERRIDE;
virtual bool open() Q_DECL_OVERRIDE;
- virtual bool addFiles(const QStringList& files, const Kerfuffle::CompressionOptions& options) Q_DECL_OVERRIDE;
- virtual bool copyFiles(const QList<QVariant>& files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options) Q_DECL_OVERRIDE;
- virtual bool deleteFiles(const QList<QVariant>& files) Q_DECL_OVERRIDE;
+ virtual bool addFiles(const QList<Kerfuffle::Archive::Entry*>& files, const Kerfuffle::CompressionOptions& options) Q_DECL_OVERRIDE;
+ virtual bool copyFiles(const QList<Kerfuffle::Archive::Entry*>& files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options) Q_DECL_OVERRIDE;
+ virtual bool deleteFiles(const QList<Kerfuffle::Archive::Entry*>& files) Q_DECL_OVERRIDE;
virtual bool addComment(const QString& comment) Q_DECL_OVERRIDE;
virtual bool testArchive() Q_DECL_OVERRIDE;
diff --git a/autotests/kerfuffle/jsonparser.cpp b/autotests/kerfuffle/jsonparser.cpp
index f9e5751..492808f 100644
--- a/autotests/kerfuffle/jsonparser.cpp
+++ b/autotests/kerfuffle/jsonparser.cpp
@@ -59,11 +59,11 @@ JSONParser::JSONArchive JSONParser::createJSONArchive(const QVariant &json)
foreach (const QVariant &entry, json.toList()) {
const QVariantMap entryMap = entry.toMap();
- if (!entryMap.contains(QStringLiteral("fileName"))) {
+ if (!entryMap.contains(QStringLiteral("fullPath"))) {
continue;
}
- Kerfuffle::Archive::Entry *e = new Kerfuffle::Archive::Entry(Q_NULLPTR);
+ Kerfuffle::Archive::Entry *e = new Kerfuffle::Archive::Entry();
QVariantMap::const_iterator entryIterator = entryMap.constBegin();
for (; entryIterator != entryMap.constEnd(); ++entryIterator) {
@@ -75,8 +75,8 @@ JSONParser::JSONArchive JSONParser::createJSONArchive(const QVariant &json)
}
}
- const QString fileName = entryMap[QStringLiteral("fileName")].toString();
- archive[fileName] = e;
+ const QString fullPath = entryMap[QStringLiteral("fullPath")].toString();
+ archive[fullPath] = e;
}
return archive;
diff --git a/autotests/kerfuffle/jsonparser.h b/autotests/kerfuffle/jsonparser.h
index 8f02ff8..dc0e80a 100644
--- a/autotests/kerfuffle/jsonparser.h
+++ b/autotests/kerfuffle/jsonparser.h
@@ -45,8 +45,8 @@
* Example file:
* @code
* [
- * { "FileName": "foo", "IsPasswordProtected": true },
- * { "FileName": "aDir/", "IsDirectory": true }
+ * { "fullPath": "foo", "IsPasswordProtected": true },
+ * { "fullPath": "aDir/", "IsDirectory": true }
* ]
* @endcode
*
@@ -68,7 +68,7 @@ private:
* Parses each entry in the QVariant obtained from parsing a JSON file and
* creates a @c JSONArchive from them.
*
- * If an entry does not have a "FileName" key, it is ignored. Keys which do
+ * If an entry does not have a "fullPath" key, it is ignored. Keys which do
* not correspond to a value in the EntryMetaDataType enum are ignored.
*
* @return A new @c JSONArchive corresponding to the parsed JSON file. If a
diff --git a/autotests/plugins/cli7zplugin/cli7ztest.cpp b/autotests/plugins/cli7zplugin/cli7ztest.cpp
index 4c9ecab..c3eb15e 100644
--- a/autotests/plugins/cli7zplugin/cli7ztest.cpp
+++ b/autotests/plugins/cli7zplugin/cli7ztest.cpp
@@ -140,8 +140,9 @@ void Cli7zTest::testList_data()
void Cli7zTest::testList()
{
+ qRegisterMetaType<Archive::Entry*>("Archive::Entry*");
CliPlugin *plugin = new CliPlugin(this, {QStringLiteral("dummy.7z")});
- QSignalSpy signalSpy(plugin, SIGNAL(entry(ArchiveEntry)));
+ QSignalSpy signalSpy(plugin, &CliPlugin::entry);
QFETCH(QString, outputTextFile);
QFETCH(int, expectedEntriesCount);
@@ -159,10 +160,10 @@ void Cli7zTest::testList()
QFETCH(int, someEntryIndex);
QVERIFY(someEntryIndex < signalSpy.count());
- Archive::Entry *entry = signalSpy.at(someEntryIndex).at(0).value<Archive::Entry *>();
+ Archive::Entry *entry = signalSpy.at(someEntryIndex).at(0).value<Archive::Entry*>();
QFETCH(QString, expectedName);
- QCOMPARE(entry->property("fileName").toString(), expectedName);
+ QCOMPARE(entry->property("fullPath").toString(), expectedName);
QFETCH(bool, isDirectory);
QCOMPARE(entry->isDir(), isDirectory);
@@ -291,16 +292,16 @@ void Cli7zTest::testAddArgs()
void Cli7zTest::testExtractArgs_data()
{
QTest::addColumn<QString>("archiveName");
- QTest::addColumn<QVariantList>("files");
+ QTest::addColumn<QList<Archive::Entry*>>("files");
QTest::addColumn<bool>("preservePaths");
QTest::addColumn<QString>("password");
QTest::addColumn<QStringList>("expectedArgs");
QTest::newRow("preserve paths, encrypted")
<< QStringLiteral("/tmp/foo.7z")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< true << QStringLiteral("1234")
<< QStringList {
@@ -313,9 +314,9 @@ void Cli7zTest::testExtractArgs_data()
QTest::newRow("preserve paths, unencrypted")
<< QStringLiteral("/tmp/foo.7z")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< true << QString()
<< QStringList {
@@ -327,9 +328,9 @@ void Cli7zTest::testExtractArgs_data()
QTest::newRow("without paths, encrypted")
<< QStringLiteral("/tmp/foo.7z")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< false << QStringLiteral("1234")
<< QStringList {
@@ -342,9 +343,9 @@ void Cli7zTest::testExtractArgs_data()
QTest::newRow("without paths, unencrypted")
<< QStringLiteral("/tmp/foo.7z")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< false << QString()
<< QStringList {
@@ -366,7 +367,7 @@ void Cli7zTest::testExtractArgs()
QStringLiteral("$Archive"),
QStringLiteral("$Files") };
- QFETCH(QVariantList, files);
+ QFETCH(QList<Archive::Entry*>, files);
QFETCH(bool, preservePaths);
QFETCH(QString, password);
diff --git a/autotests/plugins/clirarplugin/clirartest.cpp b/autotests/plugins/clirarplugin/clirartest.cpp
index 47b78c0..014a7af 100644
--- a/autotests/plugins/clirarplugin/clirartest.cpp
+++ b/autotests/plugins/clirarplugin/clirartest.cpp
@@ -169,8 +169,9 @@ void CliRarTest::testList_data()
void CliRarTest::testList()
{
+ qRegisterMetaType<Archive::Entry*>("Archive::Entry*");
CliPlugin *rarPlugin = new CliPlugin(this, {QStringLiteral("dummy.rar")});
- QSignalSpy signalSpy(rarPlugin, SIGNAL(entry(ArchiveEntry)));
+ QSignalSpy signalSpy(rarPlugin, &CliPlugin::entry);
QFETCH(QString, outputTextFile);
QFETCH(int, expectedEntriesCount);
@@ -188,10 +189,10 @@ void CliRarTest::testList()
QFETCH(int, someEntryIndex);
QVERIFY(someEntryIndex < signalSpy.count());
- Archive::Entry *entry = signalSpy.at(someEntryIndex).at(0).value<Archive::Entry *>();
+ Archive::Entry *entry = signalSpy.at(someEntryIndex).at(0).value<Archive::Entry*>();
QFETCH(QString, expectedName);
- QCOMPARE(entry->property("fileName").toString(), expectedName);
+ QCOMPARE(entry->property("fullPath").toString(), expectedName);
QFETCH(bool, isDirectory);
QCOMPARE(entry->isDir(), isDirectory);
@@ -325,16 +326,16 @@ void CliRarTest::testAddArgs()
void CliRarTest::testExtractArgs_data()
{
QTest::addColumn<QString>("archiveName");
- QTest::addColumn<QVariantList>("files");
+ QTest::addColumn<QList<Archive::Entry*>>("files");
QTest::addColumn<bool>("preservePaths");
QTest::addColumn<QString>("password");
QTest::addColumn<QStringList>("expectedArgs");
QTest::newRow("preserve paths, encrypted")
<< QStringLiteral("/tmp/foo.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< true << QStringLiteral("1234")
<< QStringList {
@@ -349,9 +350,9 @@ void CliRarTest::testExtractArgs_data()
QTest::newRow("preserve paths, unencrypted")
<< QStringLiteral("/tmp/foo.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< true << QString()
<< QStringList {
@@ -365,9 +366,9 @@ void CliRarTest::testExtractArgs_data()
QTest::newRow("without paths, encrypted")
<< QStringLiteral("/tmp/foo.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< false << QStringLiteral("1234")
<< QStringList {
@@ -382,9 +383,9 @@ void CliRarTest::testExtractArgs_data()
QTest::newRow("without paths, unencrypted")
<< QStringLiteral("/tmp/foo.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< false << QString()
<< QStringList {
@@ -410,7 +411,7 @@ void CliRarTest::testExtractArgs()
QStringLiteral("$Archive"),
QStringLiteral("$Files") };
- QFETCH(QVariantList, files);
+ QFETCH(QList<Archive::Entry*>, files);
QFETCH(bool, preservePaths);
QFETCH(QString, password);
diff --git a/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp b/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp
index a913b1a..1c7675d 100644
--- a/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp
+++ b/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp
@@ -122,22 +122,23 @@ void CliUnarchiverTest::testList_data()
QTest::newRow("archive with one top-level folder")
<< QFINDTESTDATA("data/one_toplevel_folder.json") << 9
- << 6 << QStringLiteral("A/B/C/") << true << false << (qulonglong) 0 << (qulonglong) 0 << QStringLiteral("2015-12-21 16:57:20 +0100");
+ << 6 << QStringLiteral("A/B/C/") << true << false << (qulonglong) 0 << (qulonglong) 0 << QStringLiteral("2015-12-21T16:57:20+01:00");
QTest::newRow("archive with multiple top-level entries")
<< QFINDTESTDATA("data/multiple_toplevel_entries.json") << 12
- << 4 << QStringLiteral("data/A/B/test1.txt") << false << false << (qulonglong) 7 << (qulonglong) 7 << QStringLiteral("2015-12-21 16:56:28 +0100");
+ << 4 << QStringLiteral("data/A/B/test1.txt") << false << false << (qulonglong) 7 << (qulonglong) 7 << QStringLiteral("2015-12-21T16:56:28+01:00");
QTest::newRow("archive with encrypted entries")
<< QFINDTESTDATA("data/encrypted_entries.json") << 9
- << 5 << QStringLiteral("A/test1.txt") << false << true << (qulonglong) 7 << (qulonglong) 32 << QStringLiteral("2015-12-21 16:56:28 +0100");
+ << 5 << QStringLiteral("A/test1.txt") << false << true << (qulonglong) 7 << (qulonglong) 32 << QStringLiteral("2015-12-21T16:56:28+01:00");
QTest::newRow("huge archive")
<< QFINDTESTDATA("data/huge_archive.json") << 250
- << 8 << QStringLiteral("PsycOPacK/Base Dictionnaries/att800") << false << false << (qulonglong) 593687 << (qulonglong) 225219 << QStringLiteral("2011-08-14 03:10:10 +0200");
+ << 8 << QStringLiteral("PsycOPacK/Base Dictionnaries/att800") << false << false << (qulonglong) 593687 << (qulonglong) 225219 << QStringLiteral("2011-08-14T03:10:10+02:00");
}
void CliUnarchiverTest::testList()
{
+ qRegisterMetaType<Archive::Entry*>("Archive::Entry*");
CliPlugin *unarPlugin = new CliPlugin(this, {QStringLiteral("dummy.rar")});
- QSignalSpy signalSpy(unarPlugin, SIGNAL(entry(ArchiveEntry)));
+ QSignalSpy signalSpy(unarPlugin, &CliPlugin::entry);
QFETCH(QString, jsonFilePath);
QFETCH(int, expectedEntriesCount);
@@ -152,10 +153,10 @@ void CliUnarchiverTest::testList()
QFETCH(int, someEntryIndex);
QVERIFY(someEntryIndex < signalSpy.count());
- Archive::Entry *entry = signalSpy.at(someEntryIndex).at(0).value<Archive::Entry *>();
+ Archive::Entry *entry = signalSpy.at(someEntryIndex).at(0).value<Archive::Entry*>();
QFETCH(QString, expectedName);
- QCOMPARE(entry->property("fileName").toString(), expectedName);
+ QCOMPARE(entry->property("fullPath").toString(), expectedName);
QFETCH(bool, isDirectory);
QCOMPARE(entry->isDir(), isDirectory);
@@ -222,7 +223,7 @@ void CliUnarchiverTest::testListArgs()
void CliUnarchiverTest::testExtraction_data()
{
QTest::addColumn<QString>("archivePath");
- QTest::addColumn<QVariantList>("entriesToExtract");
+ QTest::addColumn<QList<Archive::Entry*>>("entriesToExtract");
QTest::addColumn<ExtractionOptions>("extractionOptions");
QTest::addColumn<int>("expectedExtractedEntriesCount");
@@ -237,42 +238,42 @@ void CliUnarchiverTest::testExtraction_data()
QTest::newRow("extract the whole multiple_toplevel_entries.rar")
<< QFINDTESTDATA("data/multiple_toplevel_entries.rar")
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 12;
QTest::newRow("extract selected entries from a rar, without paths")
<< QFINDTESTDATA("data/one_toplevel_folder.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")),
+ new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B"))
}
<< options
<< 2;
QTest::newRow("extract selected entries from a rar, preserve paths")
<< QFINDTESTDATA("data/one_toplevel_folder.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")),
+ new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B"))
}
<< optionsPreservePaths
<< 4;
QTest::newRow("extract selected entries from a rar, drag-and-drop")
<< QFINDTESTDATA("data/one_toplevel_folder.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/C/"), QStringLiteral("A/B/"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/test2.txt"), QStringLiteral("A/"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/C/test1.txt"), QStringLiteral("A/B/"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("A/B/C/test2.txt"), QStringLiteral("A/B/")))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("A/B/C/"), QStringLiteral("A/B/")),
+ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A/")),
+ new Archive::Entry(this, QStringLiteral("A/B/C/test1.txt"), QStringLiteral("A/B/")),
+ new Archive::Entry(this, QStringLiteral("A/B/C/test2.txt"), QStringLiteral("A/B/"))
}
<< dragAndDropOptions
<< 4;
QTest::newRow("rar with empty folders")
<< QFINDTESTDATA("data/empty_folders.rar")
- << QVariantList()
+ << QList<Archive::Entry*>()
<< optionsPreservePaths
<< 5;
}
@@ -298,7 +299,7 @@ void CliUnarchiverTest::testExtraction()
QSKIP("Could not create a temporary directory for extraction. Skipping test.", SkipSingle);
}
- QFETCH(QVariantList, entriesToExtract);
+ QFETCH(QList<Archive::Entry*>, entriesToExtract);
QFETCH(ExtractionOptions, extractionOptions);
auto extractionJob = archive->copyFiles(entriesToExtract, destDir.path(), extractionOptions);
@@ -324,15 +325,15 @@ void CliUnarchiverTest::testExtraction()
void CliUnarchiverTest::testExtractArgs_data()
{
QTest::addColumn<QString>("archiveName");
- QTest::addColumn<QVariantList>("files");
+ QTest::addColumn<QList<Archive::Entry*>>("files");
QTest::addColumn<QString>("password");
QTest::addColumn<QStringList>("expectedArgs");
QTest::newRow("encrypted, multiple files")
<< QStringLiteral("/tmp/foo.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< QStringLiteral("1234")
<< QStringList {
@@ -346,9 +347,9 @@ void CliUnarchiverTest::testExtractArgs_data()
QTest::newRow("unencrypted, multiple files")
<< QStringLiteral("/tmp/foo.rar")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< QString()
<< QStringList {
@@ -370,7 +371,7 @@ void CliUnarchiverTest::testExtractArgs()
QStringLiteral("$Files"),
QStringLiteral("$PasswordSwitch") };
- QFETCH(QVariantList, files);
+ QFETCH(QList<Archive::Entry*>, files);
QFETCH(QString, password);
QStringList replacedArgs = plugin->substituteCopyVariables(extractArgs, files, false, password);
diff --git a/autotests/plugins/clizipplugin/cliziptest.cpp b/autotests/plugins/clizipplugin/cliziptest.cpp
index 5f066d8..7cb1881 100644
--- a/autotests/plugins/clizipplugin/cliziptest.cpp
+++ b/autotests/plugins/clizipplugin/cliziptest.cpp
@@ -117,16 +117,16 @@ void CliZipTest::testAddArgs()
void CliZipTest::testExtractArgs_data()
{
QTest::addColumn<QString>("archiveName");
- QTest::addColumn<QVariantList>("files");
+ QTest::addColumn<QList<Archive::Entry*>>("files");
QTest::addColumn<bool>("preservePaths");
QTest::addColumn<QString>("password");
QTest::addColumn<QStringList>("expectedArgs");
QTest::newRow("preserve paths, encrypted")
<< QStringLiteral("/tmp/foo.zip")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< true << QStringLiteral("1234")
<< QStringList {
@@ -138,9 +138,9 @@ void CliZipTest::testExtractArgs_data()
QTest::newRow("preserve paths, unencrypted")
<< QStringLiteral("/tmp/foo.zip")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< true << QString()
<< QStringList {
@@ -151,9 +151,9 @@ void CliZipTest::testExtractArgs_data()
QTest::newRow("without paths, encrypted")
<< QStringLiteral("/tmp/foo.zip")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< false << QStringLiteral("1234")
<< QStringList {
@@ -166,9 +166,9 @@ void CliZipTest::testExtractArgs_data()
QTest::newRow("without paths, unencrypted")
<< QStringLiteral("/tmp/foo.zip")
- << QVariantList {
- QVariant::fromValue(fileRootNodePair(QStringLiteral("aDir/b.txt"), QStringLiteral("aDir"))),
- QVariant::fromValue(fileRootNodePair(QStringLiteral("c.txt"), QString()))
+ << QList<Archive::Entry*> {
+ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")),
+ new Archive::Entry(this, QStringLiteral("c.txt"), QString())
}
<< false << QString()
<< QStringList {
@@ -190,7 +190,7 @@ void CliZipTest::testExtractArgs()
QStringLiteral("$Archive"),
QStringLiteral("$Files") };
- QFETCH(QVariantList, files);
+ QFETCH(QList<Archive::Entry*>, files);
QFETCH(bool, preservePaths);
QFETCH(QString, password);
diff --git a/kerfuffle/addtoarchive.cpp b/kerfuffle/addtoarchive.cpp
index 0f0fa1c..49c0aea 100644
--- a/kerfuffle/addtoarchive.cpp
+++ b/kerfuffle/addtoarchive.cpp
@@ -113,7 +113,9 @@ bool AddToArchive::showAddDialog()
bool AddToArchive::addInput(const QUrl &url)
{
- m_inputs << url.toDisplayString(QUrl::PreferLocalFile);
+ Archive::Entry *entry = new Archive::Entry();
+ entry->setFullPath(url.toDisplayString(QUrl::PreferLocalFile));
+ m_entries << entry;
if (m_firstPath.isEmpty()) {
QString firstEntry = url.toDisplayString(QUrl::PreferLocalFile);
@@ -134,7 +136,7 @@ void AddToArchive::slotStartJob()
{
Kerfuffle::CompressionOptions options;
- if (m_inputs.isEmpty()) {
+ if (m_entries.isEmpty()) {
KMessageBox::error(NULL, i18n("No input files were given."));
emitResult();
return;
@@ -157,7 +159,7 @@ void AddToArchive::slotStartJob()
return;
}
- const QString base = detectBaseName(m_inputs);
+ const QString base = detectBaseName(m_entries);
QString finalName = base + QLatin1Char( '.' ) + m_autoFilenameSuffix;
@@ -205,17 +207,16 @@ void AddToArchive::slotStartJob()
const QDir stripDir(m_firstPath);
- for (int i = 0; i < m_inputs.size(); ++i) {
- m_inputs[i] = stripDir.absoluteFilePath(m_inputs.at(i));
+ foreach (Archive::Entry *entry, m_entries) {
+ entry->setFullPath(stripDir.absoluteFilePath(entry->property("fullPath").toString()));
}
-
options[QStringLiteral( "GlobalWorkDir" )] = stripDir.path();
qCDebug(ARK) << "Setting GlobalWorkDir to " << stripDir.path();
}
Kerfuffle::AddJob *job =
- archive->addFiles(m_inputs, options);
+ archive->addFiles(m_entries, options);
KIO::getJobTracker()->registerJob(job);
@@ -235,13 +236,13 @@ void AddToArchive::slotFinished(KJob *job)
emitResult();
}
-QString AddToArchive::detectBaseName(const QStringList &paths) const
+QString AddToArchive::detectBaseName(const QList<Archive::Entry*> &entries) const
{
- QFileInfo fileInfo = QFileInfo(paths.first());
+ QFileInfo fileInfo = QFileInfo(entries.first()->property("fullPath").toString());
QDir parentDir = fileInfo.dir();
QString base = parentDir.absolutePath() + QLatin1Char('/');
- if (paths.size() > 1) {
+ if (entries.size() > 1) {
if (!parentDir.isRoot()) {
// Use directory name for the new archive.
base += parentDir.dirName();
diff --git a/kerfuffle/addtoarchive.h b/kerfuffle/addtoarchive.h
index b6766dc..460e9f8 100644
--- a/kerfuffle/addtoarchive.h
+++ b/kerfuffle/addtoarchive.h
@@ -30,6 +30,7 @@
#define ADDTOARCHIVE_H
#include "kerfuffle_export.h"
+#include "archive_kerfuffle.h"
#include <KJob>
@@ -60,7 +61,7 @@ public:
bool showAddDialog();
void setPreservePaths(bool value);
void setChangeToFirstPath(bool value);
- QString detectBaseName(const QStringList &paths) const;
+ QString detectBaseName(const QList<Archive::Entry*> &entries) const;
public slots:
bool addInput(const QUrl &url);
@@ -82,7 +83,7 @@ private:
QString m_firstPath;
QString m_mimeType;
QString m_password;
- QStringList m_inputs;
+ QList<Archive::Entry*> m_entries;
bool m_changeToFirstPath;
bool m_enableHeaderEncryption;
};
diff --git a/kerfuffle/archive_kerfuffle.cpp b/kerfuffle/archive_kerfuffle.cpp
index 47cdb16..14cca8b 100644
--- a/kerfuffle/archive_kerfuffle.cpp
+++ b/kerfuffle/archive_kerfuffle.cpp
@@ -27,18 +27,12 @@
#include "archive_kerfuffle.h"
#include "archiveentry.h"
-#include "ark_debug.h"
#include "archiveinterface.h"
#include "jobs.h"
#include "mimetypes.h"
#include "pluginmanager.h"
-#include <QByteArray>
-#include <QDebug>
#include <QEventLoop>
-#include <QFile>
-#include <QFileInfo>
-#include <QMimeDatabase>
#include <KPluginFactory>
#include <KPluginLoader>
@@ -46,12 +40,6 @@
namespace Kerfuffle
{
-QDebug operator<<(QDebug d, const fileRootNodePair &pair)
-{
- d.nospace() << "fileRootNodePair(" << pair.file << "," << pair.rootNode << ")";
- return d.space();
-}
-
Archive *Archive::create(const QString &fileName, QObject *parent)
{
return create(fileName, QString(), parent);
@@ -135,9 +123,6 @@ Archive::Archive(ReadOnlyArchiveInterface *archiveInterface, bool isReadOnly, QO
Q_ASSERT(archiveInterface);
archiveInterface->setParent(this);
- QMetaType::registerComparators<fileRootNodePair>();
- QMetaType::registerDebugStreamOperator<fileRootNodePair>();
-
connect(m_iface, &ReadOnlyArchiveInterface::entry, this, &Archive::onNewEntry);
}
@@ -315,23 +300,23 @@ ListJob* Archive::list()
return job;
}
-DeleteJob* Archive::deleteFiles(const QList<QVariant> & files)
+DeleteJob* Archive::deleteFiles(QList<Archive::Entry*> &entries)
{
if (!isValid()) {
return Q_NULLPTR;
}
- qCDebug(ARK) << "Going to delete files" << files;
+ qCDebug(ARK) << "Going to delete entries" << entries;
if (m_iface->isReadOnly()) {
return 0;
}
- DeleteJob *newJob = new DeleteJob(files, static_cast<ReadWriteArchiveInterface*>(m_iface));
+ DeleteJob *newJob = new DeleteJob(entries, static_cast<ReadWriteArchiveInterface*>(m_iface));
return newJob;
}
-AddJob* Archive::addFiles(const QStringList & files, const CompressionOptions& options)
+AddJob* Archive::addFiles(QList<Archive::Entry*> &files, const CompressionOptions& options)
{
if (!isValid()) {
return Q_NULLPTR;
@@ -350,7 +335,7 @@ AddJob* Archive::addFiles(const QStringList & files, const CompressionOptions& o
return newJob;
}
-ExtractJob* Archive::copyFiles(const QList<QVariant>& files, const QString& destinationDir, const ExtractionOptions& options)
+ExtractJob* Archive::copyFiles(const QList<Archive::Entry*> &files, const QString& destinationDir, const ExtractionOptions& options)
{
if (!isValid()) {
return Q_NULLPTR;
@@ -365,33 +350,33 @@ ExtractJob* Archive::copyFiles(const QList<QVariant>& files, const QString& dest
return newJob;
}
-PreviewJob *Archive::preview(const QString &file)
+PreviewJob *Archive::preview(Archive::Entry *entry)
{
if (!isValid()) {
return Q_NULLPTR;
}
- PreviewJob *job = new PreviewJob(file, (encryptionType() != Unencrypted), m_iface);
+ PreviewJob *job = new PreviewJob(entry, (encryptionType() != Unencrypted), m_iface);
return job;
}
-OpenJob *Archive::open(const QString &file)
+OpenJob *Archive::open(Archive::Entry *entry)
{
if (!isValid()) {
return Q_NULLPTR;
}
- OpenJob *job = new OpenJob(file, (encryptionType() != Unencrypted), m_iface);
+ OpenJob *job = new OpenJob(entry, (encryptionType() != Unencrypted), m_iface);
return job;
}
-OpenWithJob *Archive::openWith(const QString &file)
+OpenWithJob *Archive::openWith(Archive::Entry *entry)
{
if (!isValid()) {
return Q_NULLPTR;
}
- OpenWithJob *job = new OpenWithJob(file, (encryptionType() != Unencrypted), m_iface);
+ OpenWithJob *job = new OpenWithJob(entry, (encryptionType() != Unencrypted), m_iface);
return job;
}
diff --git a/kerfuffle/archive_kerfuffle.h b/kerfuffle/archive_kerfuffle.h
index 112d638..856b2b8 100644
--- a/kerfuffle/archive_kerfuffle.h
+++ b/kerfuffle/archive_kerfuffle.h
@@ -68,43 +68,6 @@ Rar, etc), followed by the property name used
typedef QHash<QString, QVariant> CompressionOptions;
typedef QHash<QString, QVariant> ExtractionOptions;
-/**
- * Stores a filename and rootnode pair. This is used to cut an individual
- * rootnode from the path of each file, e.g. when drag'n'drop extracting a
- * selection of files.
- */
-struct fileRootNodePair
-{
- QString file;
- QString rootNode;
-
- fileRootNodePair()
- {}
-
- fileRootNodePair(const QString &f)
- : file(f)
- {}
-
- fileRootNodePair(const QString &f, const QString &n)
- : file(f),
- rootNode(n)
- {}
-
- // Required to compare QVariants with this type.
- bool operator==(const fileRootNodePair &right) const
- {
- if (file == right.file)
- return true;
- else
- return false;
- }
- bool operator<(const fileRootNodePair &) const
- {
- return false;
- }
-};
-QDebug operator<<(QDebug d, const fileRootNodePair &pair);
-
class KERFUFFLE_EXPORT Archive : public QObject
{
Q_OBJECT
@@ -172,7 +135,7 @@ public:
*/
ListJob* list();
- DeleteJob* deleteFiles(const QList<QVariant> & files);
+ DeleteJob* deleteFiles(QList<Archive::Entry*> &entries);
CommentJob* addComment(const QString &comment);
TestJob* testArchive();
@@ -188,13 +151,13 @@ public:
* archive root where the files will be added under
*
*/
- AddJob* addFiles(const QStringList & files, const CompressionOptions& options = CompressionOptions());
+ AddJob* addFiles(QList<Archive::Entry*> &files, const CompressionOptions& options = CompressionOptions());
- ExtractJob* copyFiles(const QList<QVariant> &files, const QString &destinationDir, const ExtractionOptions &options = ExtractionOptions());
+ ExtractJob* copyFiles(const QList<Archive::Entry*> &files, const QString &destinationDir, const ExtractionOptions &options = ExtractionOptions());
- PreviewJob* preview(const QString &file);
- OpenJob* open(const QString &file);
- OpenWithJob* openWith(const QString &file);
+ PreviewJob* preview(Archive::Entry *entry);
+ OpenJob* open(Archive::Entry *entry);
+ OpenWithJob* openWith(Archive::Entry *entry);
/**
* @param password The password to encrypt the archive with.
@@ -229,6 +192,5 @@ private:
} // namespace Kerfuffle
Q_DECLARE_METATYPE(Kerfuffle::Archive::EncryptionType)
-Q_DECLARE_METATYPE(Kerfuffle::fileRootNodePair)
#endif // ARCHIVE_H
diff --git a/kerfuffle/archiveentry.cpp b/kerfuffle/archiveentry.cpp
index 5a7ef15..6c03fa6 100644
--- a/kerfuffle/archiveentry.cpp
+++ b/kerfuffle/archiveentry.cpp
@@ -5,11 +5,18 @@
#include "archiveentry.h"
namespace Kerfuffle {
-Archive::Entry::Entry(Entry *parent)
- : compressedSizeIsSet(true)
- , m_parent(parent)
+Archive::Entry::Entry(QObject *parent, QString fullPath, QString rootNode)
+ : QObject(parent)
+ , rootNode(rootNode)
+ , compressedSizeIsSet(true)
+ , m_parent(qobject_cast<Entry*>(parent))
+ , m_size(0)
+ , m_compressedSize(0)
+ , m_isDirectory(false)
+ , m_isPasswordProtected(false)
{
- clearMetaData();
+ if (!fullPath.isEmpty())
+ setFullPath(fullPath);
}
Archive::Entry::~Entry()
@@ -17,15 +24,21 @@ Archive::Entry::~Entry()
clear();
}
-QList<Archive::Entry*> Archive::Entry::entries()
+QVector<Archive::Entry*> Archive::Entry::entries()
{
Q_ASSERT(isDir());
return m_entries;
}
+const QVector<Archive::Entry*> Archive::Entry::entries() const {
+ Q_ASSERT(isDir());
+ return m_entries;
+}
+
void Archive::Entry::setEntryAt(int index, Entry *value)
{
Q_ASSERT(isDir());
+ Q_ASSERT(index < m_entries.count());
m_entries[index] = value;
}
@@ -38,6 +51,7 @@ void Archive::Entry::appendEntry(Entry *entry)
void Archive::Entry::removeEntryAt(int index)
{
Q_ASSERT(isDir());
+ Q_ASSERT(index < m_entries.count());
delete m_entries.takeAt(index);
}
@@ -51,37 +65,29 @@ void Archive::Entry::setParent(Archive::Entry *parent)
m_parent = parent;
}
-int Archive::Entry::row() const
+void Archive::Entry::setFullPath(const QString &fullPath)
{
- if (getParent()) {
- return getParent()->entries().indexOf(const_cast<Archive::Entry*>(this));
- }
- return 0;
+ m_fullPath = fullPath;
+ const QStringList pieces = m_fullPath.split(QLatin1Char( '/' ), QString::SkipEmptyParts);
+ m_name = pieces.isEmpty() ? QString() : pieces.last();
}
-bool Archive::Entry::isDir() const
+void Archive::Entry::setIsDirectory(const bool isDirectory)
{
- return m_isDirectory;
+ m_isDirectory = isDirectory;
}
-void Archive::Entry::processNameAndIcon()
+int Archive::Entry::row() const
{
- const QStringList pieces = m_fileName.split(QLatin1Char( '/' ), QString::SkipEmptyParts);
- m_name = pieces.isEmpty() ? QString() : pieces.last();
-
- QMimeDatabase db;
- if (isDir()) {
- m_icon = QIcon::fromTheme(db.mimeTypeForName(QStringLiteral("inode/directory")).iconName()).pixmap(IconSize(KIconLoader::Small),
- IconSize(KIconLoader::Small));
- } else {
- m_icon = QIcon::fromTheme(db.mimeTypeForFile(m_fileName).iconName()).pixmap(IconSize(KIconLoader::Small),
- IconSize(KIconLoader::Small));
+ if (getParent()) {
+ return getParent()->entries().indexOf(const_cast<Archive::Entry*>(this));
}
+ return 0;
}
-QPixmap Archive::Entry::icon() const
+bool Archive::Entry::isDir() const
{
- return m_icon;
+ return m_isDirectory;
}
QString Archive::Entry::name() const
@@ -116,25 +122,6 @@ Archive::Entry *Archive::Entry::findByPath(const QStringList & pieces, int index
return 0;
}
-void Archive::Entry::clearMetaData()
-{
- m_fileName.clear();
- m_permissions.clear();
- m_owner.clear();
- m_group.clear();
- m_size = 0;
- m_compressedSize = 0;
- m_link.clear();
- m_ratio.clear();
- m_CRC.clear();
- m_method.clear();
- m_version.clear();
- m_timestamp = QDateTime();
- m_isDirectory = false;
- m_comment.clear();
- m_isPasswordProtected = false;
-}
-
void Archive::Entry::returnDirEntries(QList<Entry *> *store)
{
foreach(Entry *entry, m_entries) {
@@ -153,4 +140,29 @@ void Archive::Entry::clear()
}
}
+bool Archive::Entry::operator==(const Archive::Entry &right) const
+{
+ return m_fullPath == right.m_fullPath;
+}
+
+QDebug operator<<(QDebug d, const Kerfuffle::Archive::Entry &entry)
+{
+ d.nospace() << "Entry(" << entry.property("fullPath");
+ if (!entry.rootNode.isEmpty()) {
+ d.nospace() << "," << entry.rootNode;
+ }
+ d.nospace() << ")";
+ return d.space();
+}
+
+QDebug operator<<(QDebug d, const Kerfuffle::Archive::Entry *entry)
+{
+ d.nospace() << "Entry(" << entry->property("fullPath");
+ if (!entry->rootNode.isEmpty()) {
+ d.nospace() << "," << entry->rootNode;
+ }
+ d.nospace() << ")";
+ return d.space();
+}
+
}
diff --git a/kerfuffle/archiveentry.h b/kerfuffle/archiveentry.h
index d6a7a4f..3561780 100644
--- a/kerfuffle/archiveentry.h
+++ b/kerfuffle/archiveentry.h
@@ -30,7 +30,8 @@ class Archive::Entry : public QObject
* Please notice that not all archive formats support all the properties
* below, so set those that are available.
*/
- Q_PROPERTY(QString fileName MEMBER m_fileName)
+ Q_PROPERTY(QString fullPath MEMBER m_fullPath WRITE setFullPath)
+ Q_PROPERTY(QString name READ name)
Q_PROPERTY(QString permissions MEMBER m_permissions)
Q_PROPERTY(QString owner MEMBER m_owner)
Q_PROPERTY(QString group MEMBER m_group)
@@ -42,42 +43,44 @@ class Archive::Entry : public QObject
Q_PROPERTY(QString method MEMBER m_method)
Q_PROPERTY(QString version MEMBER m_version)
Q_PROPERTY(QDateTime timestamp MEMBER m_timestamp)
- Q_PROPERTY(bool isDirectory MEMBER m_isDirectory)
+ Q_PROPERTY(bool isDirectory MEMBER m_isDirectory WRITE setIsDirectory)
Q_PROPERTY(QString comment MEMBER m_comment)
Q_PROPERTY(bool isPasswordProtected MEMBER m_isPasswordProtected)
public:
- Entry(Entry *parent);
+ explicit Entry(QObject *parent = Q_NULLPTR, QString fullPath = QString(), QString rootNode = QString());
~Entry();
- QList<Entry*> entries();
+ QVector<Entry*> entries();
+ const QVector<Entry*> entries() const;
void setEntryAt(int index, Entry *value);
void appendEntry(Entry *entry);
void removeEntryAt(int index);
Entry *getParent() const;
void setParent(Entry *parent);
+ void setFullPath(const QString &fullPath);
+ void setIsDirectory(const bool isDirectory);
int row() const;
bool isDir() const;
- void processNameAndIcon();
- QPixmap icon() const;
QString name() const;
Entry *find(const QString & name);
Entry *findByPath(const QStringList & pieces, int index = 0);
- void clearMetaData();
void returnDirEntries(QList<Entry *> *store);
void clear();
+ bool operator==(const Archive::Entry &right) const;
+
public:
+ QString rootNode;
bool compressedSizeIsSet;
private:
- QList<Entry*> m_entries;
- QPixmap m_icon;
+ QVector<Entry*> m_entries;
QString m_name;
Entry *m_parent;
- QString m_fileName;
+ QString m_fullPath;
QString m_permissions;
QString m_owner;
QString m_group;
@@ -94,7 +97,11 @@ private:
bool m_isPasswordProtected;
};
+QDebug KERFUFFLE_EXPORT operator<<(QDebug d, const Kerfuffle::Archive::Entry &entry);
+QDebug KERFUFFLE_EXPORT operator<<(QDebug d, const Kerfuffle::Archive::Entry *entry);
+
}
+Q_DECLARE_METATYPE(Kerfuffle::Archive::Entry*)
#endif //ARK_ENTRY_H
diff --git a/kerfuffle/archiveinterface.cpp b/kerfuffle/archiveinterface.cpp
index ad4ae1e..971ec4f 100644
--- a/kerfuffle/archiveinterface.cpp
+++ b/kerfuffle/archiveinterface.cpp
@@ -133,6 +133,15 @@ void ReadOnlyArchiveInterface::setWaitForFinishedSignal(bool value)
m_waitForFinishedSignal = value;
}
+QStringList ReadOnlyArchiveInterface::entryFullPaths(const QList<Archive::Entry *> &entries) const
+{
+ QStringList filesList;
+ foreach (const Archive::Entry *file, entries) {
+ filesList << file->property("fullPath").toString();
+ }
+ return filesList;
+}
+
bool ReadOnlyArchiveInterface::isHeaderEncryptionEnabled() const
{
return m_isHeaderEncryptionEnabled;
diff --git a/kerfuffle/archiveinterface.h b/kerfuffle/archiveinterface.h
index 0afffa6..ee924ca 100644
--- a/kerfuffle/archiveinterface.h
+++ b/kerfuffle/archiveinterface.h
@@ -31,6 +31,7 @@
#include "archive_kerfuffle.h"
#include "archive_entry.h"
#include "kerfuffle_export.h"
+#include "kerfuffle/archiveentry.h"
#include <QObject>
#include <QStringList>
@@ -96,9 +97,14 @@ public:
* @note If returning false, make sure to emit the error() signal beforewards to notify
* the user of the error condition.
*/
- virtual bool copyFiles(const QList<QVariant> &files, const QString &destinationDirectory, const ExtractionOptions &options) = 0;
+ virtual bool copyFiles(const QList<Archive::Entry*> &files, const QString &destinationDirectory, const ExtractionOptions &options) = 0;
bool waitForFinishedSignal();
+ /**
+ * @return The list of filenames retrieved from the list of entries.
+ */
+ QStringList entryFullPaths(const QList<Archive::Entry *> &entries) const;
+
virtual bool doKill();
virtual bool doSuspend();
virtual bool doResume();
@@ -147,8 +153,8 @@ public:
//see archive.h for a list of what the compressionoptions might
//contain
- virtual bool addFiles(const QStringList & files, const CompressionOptions& options) = 0;
- virtual bool deleteFiles(const QList<QVariant> & files) = 0;
+ virtual bool addFiles(const QList<Archive::Entry*> &files, const CompressionOptions& options) = 0;
+ virtual bool deleteFiles(const QList<Archive::Entry*> &files) = 0;
virtual bool addComment(const QString &comment) = 0;
};
diff --git a/kerfuffle/cliinterface.cpp b/kerfuffle/cliinterface.cpp
index f72b3ea..cecb263 100644
--- a/kerfuffle/cliinterface.cpp
+++ b/kerfuffle/cliinterface.cpp
@@ -109,7 +109,7 @@ bool CliInterface::list()
return true;
}
-bool CliInterface::copyFiles(const QVariantList &files, const QString &destinationDirectory, const ExtractionOptions &options)
+bool CliInterface::copyFiles(const QList<Archive::Entry*> &files, const QString &destinationDirectory, const ExtractionOptions &options)
{
qCDebug(ARK) << Q_FUNC_INFO << "to" << destinationDirectory;
@@ -164,7 +164,7 @@ bool CliInterface::copyFiles(const QVariantList &files, const QString &destinati
return true;
}
-bool CliInterface::addFiles(const QStringList & files, const CompressionOptions& options)
+bool CliInterface::addFiles(const QList<Archive::Entry*> &files, const CompressionOptions& options)
{
cacheParameterList();
@@ -189,14 +189,10 @@ bool CliInterface::addFiles(const QStringList & files, const CompressionOptions&
isHeaderEncryptionEnabled(),
compLevel);
- if (!runProcess(m_param.value(AddProgram).toStringList(), args)) {
- return false;
- }
-
- return true;
+ return runProcess(m_param.value(AddProgram).toStringList(), args);
}
-bool CliInterface::deleteFiles(const QList<QVariant> & files)
+bool CliInterface::deleteFiles(const QList<Archive::Entry*> &files)
{
cacheParameterList();
m_operationMode = Delete;
@@ -209,11 +205,7 @@ bool CliInterface::deleteFiles(const QList<QVariant> & files)
files,
password());
- if (!runProcess(m_param.value(DeleteProgram).toStringList(), args)) {
- return false;
- }
-
- return true;
+ return runProcess(m_param.value(DeleteProgram).toStringList(), args);
}
bool CliInterface::testArchive()
@@ -224,11 +216,7 @@ bool CliInterface::testArchive()
const auto args = substituteTestVariables(m_param.value(TestArgs).toStringList());
- if (!runProcess(m_param.value(TestProgram).toStringList(), args)) {
- return false;
- }
-
- return true;
+ return runProcess(m_param.value(TestProgram).toStringList(), args);
}
bool CliInterface::runProcess(const QStringList& programNames, const QStringList& arguments)
@@ -298,8 +286,9 @@ void CliInterface::processFinished(int exitCode, QProcess::ExitStatus exitStatus
}
if (m_operationMode == Delete) {
- foreach(const QVariant& v, m_removedFiles) {
- emit entryRemoved(v.toString());
+ QStringList removedFullPaths = entryFullPaths(m_removedFiles);
+ foreach (const QString &fullPath, removedFullPaths) {
+ emit entryRemoved(fullPath);
}
}
@@ -387,7 +376,7 @@ void CliInterface::copyProcessFinished(int exitCode, QProcess::ExitStatus exitSt
emit finished(true);
}
-bool CliInterface::moveDroppedFilesToDest(const QVariantList &files, const QString &finalDest)
+bool CliInterface::moveDroppedFilesToDest(const QList<Archive::Entry*> &files, const QString &finalDest)
{
// Move extracted files from a QTemporaryDir to the final destination.
@@ -397,10 +386,10 @@ bool CliInterface::moveDroppedFilesToDest(const QVariantList &files, const QStri
bool overwriteAll = false;
bool skipAll = false;
- foreach (const QVariant& file, files) {
+ foreach (const Archive::Entry *file, files) {
- QFileInfo relEntry(file.value<fileRootNodePair>().file.remove(file.value<fileRootNodePair>().rootNode));
- QFileInfo absSourceEntry(QDir::current().absolutePath() + QLatin1Char('/') + file.value<fileRootNodePair>().file);
+ QFileInfo relEntry(file->property("fullPath").toString().remove(file->rootNode));
+ QFileInfo absSourceEntry(QDir::current().absolutePath() + QLatin1Char('/') + file->property("fullPath").toString());
QFileInfo absDestEntry(finalDestDir.path() + QLatin1Char('/') + relEntry.filePath());
if (absSourceEntry.isDir()) {
@@ -596,7 +585,7 @@ QStringList CliInterface::substituteListVariables(const QStringList &listArgs, c
return args;
}
-QStringList CliInterface::substituteCopyVariables(const QStringList &extractArgs, const QVariantList &files, bool preservePaths, const QString &password)
+QStringList CliInterface::substituteCopyVariables(const QStringList &extractArgs, const QList<Archive::Entry*> &entries, bool preservePaths, const QString &password)
{
// Required if we call this function from unit tests.
cacheParameterList();
@@ -621,7 +610,7 @@ QStringList CliInterface::substituteCopyVariables(const QStringList &extractArgs
}
if (arg == QLatin1String("$Files")) {
- args << copyFilesList(files);
+ args << copyFilesList(entries);
continue;
}
@@ -635,7 +624,7 @@ QStringList CliInterface::substituteCopyVariables(const QStringList &extractArgs
return args;
}
-QStringList CliInterface::substituteAddVariables(const QStringList &addArgs, const QStringList &files, const QString &password, bool encryptHeader, int compLevel)
+QStringList CliInterface::substituteAddVariables(const QStringList &addArgs, const QList<Archive::Entry*> &entries, const QString &password, bool encryptHeader, int compLevel)
{
// Required if we call this function from unit tests.
cacheParameterList();
@@ -660,7 +649,7 @@ QStringList CliInterface::substituteAddVariables(const QStringList &addArgs, con
}
if (arg == QLatin1String("$Files")) {
- args << files;
+ args << entryFullPaths(entries);
continue;
}
@@ -674,7 +663,7 @@ QStringList CliInterface::substituteAddVariables(const QStringList &addArgs, con
return args;
}
-QStringList CliInterface::substituteDeleteVariables(const QStringList &deleteArgs, const QVariantList &files, const QString &password)
+QStringList CliInterface::substituteDeleteVariables(const QStringList &deleteArgs, const QList<Archive::Entry*> &entries, const QString &password)
{
cacheParameterList();
@@ -693,8 +682,8 @@ QStringList CliInterface::substituteDeleteVariables(const QStringList &deleteArg
}
if (arg == QLatin1String("$Files")) {
- foreach (const QVariant& file, files) {
- args << escapeFileName(file.toString());
+ foreach (const Archive::Entry *e, entries) {
+ args << escapeFileName(e->property("fullPath").toString());
}
continue;
}
@@ -827,11 +816,11 @@ QString CliInterface::compressionLevelSwitch(int level) const
return compLevelSwitch;
}
-QStringList CliInterface::copyFilesList(const QVariantList& files) const
+QStringList CliInterface::copyFilesList(const QList<Archive::Entry*> &entries) const
{
QStringList filesList;
- foreach (const QVariant& f, files) {
- filesList << escapeFileName(f.value<fileRootNodePair>().file);
+ foreach (const Archive::Entry *e, entries) {
+ filesList << escapeFileName(e->property("fullPath").toString());
}
return filesList;
diff --git a/kerfuffle/cliinterface.h b/kerfuffle/cliinterface.h
index 2aae7c6..c152981 100644
--- a/kerfuffle/cliinterface.h
+++ b/kerfuffle/cliinterface.h
@@ -29,6 +29,7 @@
#define CLIINTERFACE_H
#include "archiveinterface.h"
+#include "archiveentry.h"
#include "kerfuffle_export.h"
#include <QProcess>
@@ -282,9 +283,9 @@ public:
virtual ~CliInterface();
virtual bool list() Q_DECL_OVERRIDE;
- virtual bool copyFiles(const QList<QVariant>& files, const QString& destinationDirectory, const ExtractionOptions& options) Q_DECL_OVERRIDE;
- virtual bool addFiles(const QStringList & files, const CompressionOptions& options) Q_DECL_OVERRIDE;
- virtual bool deleteFiles(const QList<QVariant> & files) Q_DECL_OVERRIDE;
+ virtual bool copyFiles(const QList<Archive::Entry*> &files, const QString& destinationDirectory, const ExtractionOptions& options) Q_DECL_OVERRIDE;
+ virtual bool addFiles(const QList<Archive::Entry*> &files, const CompressionOptions& options) Q_DECL_OVERRIDE;
+ virtual bool deleteFiles(const QList<Archive::Entry*> &files) Q_DECL_OVERRIDE;
virtual bool addComment(const QString &comment) Q_DECL_OVERRIDE;
virtual bool testArchive() Q_DECL_OVERRIDE;
@@ -309,9 +310,9 @@ public:
bool moveToDestination(const QDir &tempDir, const QDir &destDir, bool preservePaths);
QStringList substituteListVariables(const QStringList &listArgs, const QString &password);
- QStringList substituteCopyVariables(const QStringList &extractArgs, const QVariantList &files, bool preservePaths, const QString &password);
- QStringList substituteAddVariables(const QStringList &addArgs, const QStringList &files, const QString &password, bool encryptHeader, int compLevel);
- QStringList substituteDeleteVariables(const QStringList &deleteArgs, const QVariantList &files, const QString &password);
+ QStringList substituteCopyVariables(const QStringList &extractArgs, const QList<Archive::Entry*> &entries, bool preservePaths, const QString &password);
+ QStringList substituteAddVariables(const QStringList &addArgs, const QList<Archive::Entry*> &entries, const QString &password, bool encryptHeader, int compLevel);
+ QStringList substituteDeleteVariables(const QStringList &deleteArgs, const QList<Archive::Entry*> &entries, const QString &password);
QStringList substituteCommentVariables(const QStringList &commentArgs, const QString &commentFile);
QStringList substituteTestVariables(const QStringList &testArgs);
@@ -338,7 +339,7 @@ public:
/**
* @return The list of selected files to extract.
*/
- QStringList copyFilesList(const QVariantList& files) const;
+ QStringList copyFilesList(const QList<Archive::Entry*> &files) const;
protected:
@@ -409,7 +410,7 @@ private:
*/
void writeToProcess(const QByteArray& data);
- bool moveDroppedFilesToDest(const QVariantList &files, const QString &finalDest);
+ bool moveDroppedFilesToDest(const QList<Archive::Entry*> &files, const QString &finalDest);
/**
* @return Whether @p dir is an empty directory.
@@ -428,7 +429,7 @@ private:
KPtyProcess *m_process;
#endif
- QVariantList m_removedFiles;
+ QList<Archive::Entry*> m_removedFiles;
bool m_listEmptyLines;
bool m_abortingOperation;
QString m_storedFileName;
@@ -438,7 +439,7 @@ private:
QString m_extractDestDir;
QTemporaryDir *m_extractTempDir;
QTemporaryFile *m_commentTempFile;
- QVariantList m_copiedFiles;
+ QList<Archive::Entry*> m_copiedFiles;
private slots:
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
diff --git a/kerfuffle/jobs.cpp b/kerfuffle/jobs.cpp
index 33427f1..8a2043b 100644
--- a/kerfuffle/jobs.cpp
+++ b/kerfuffle/jobs.cpp
@@ -88,6 +88,9 @@ Job::Job(ReadOnlyArchiveInterface *interface)
Job::~Job()
{
+ qDeleteAll(m_archiveEntries);
+ m_archiveEntries.clear();
+
if (d->isRunning()) {
d->wait();
}
@@ -248,8 +251,8 @@ void ListJob::onNewEntry(const Archive::Entry *entry)
if (m_isSingleFolderArchive) {
// RPM filenames have the ./ prefix, and "." would be detected as the subfolder name, so we remove it.
- const QString fileName = entry->property("fileName").toString().replace(QRegularExpression(QStringLiteral("^\\./")), QString());
- const QString basePath = fileName.split(QLatin1Char('/')).at(0);
+ const QString fullPath = entry->property("fullPath").toString().replace(QRegularExpression(QStringLiteral("^\\./")), QString());
+ const QString basePath = fullPath.split(QLatin1Char('/')).at(0);
if (m_basePath.isEmpty()) {
m_basePath = basePath;
@@ -272,9 +275,9 @@ QString ListJob::subfolderName() const
return m_subfolderName;
}
-ExtractJob::ExtractJob(const QVariantList& files, const QString& destinationDir, const ExtractionOptions& options, ReadOnlyArchiveInterface *interface)
+ExtractJob::ExtractJob(const QList<Archive::Entry*> &entries, const QString &destinationDir, const ExtractionOptions &options, ReadOnlyArchiveInterface *interface)
: Job(interface)
- , m_files(files)
+ , m_entries(entries)
, m_destinationDir(destinationDir)
, m_options(options)
{
@@ -285,10 +288,10 @@ ExtractJob::ExtractJob(const QVariantList& files, const QString& destinationDir,
void ExtractJob::doWork()
{
QString desc;
- if (m_files.count() == 0) {
+ if (m_entries.count() == 0) {
desc = i18n("Extracting all files");
} else {
- desc = i18np("Extracting one file", "Extracting %1 files", m_files.count());
+ desc = i18np("Extracting one file", "Extracting %1 files", m_entries.count());
}
emit description(this, desc);
@@ -302,11 +305,11 @@ void ExtractJob::doWork()
connectToArchiveInterfaceSignals();
qCDebug(ARK) << "Starting extraction with selected files:"
- << m_files
+ << m_entries
<< "Destination dir:" << m_destinationDir
<< "Options:" << m_options;
- bool ret = archiveInterface()->copyFiles(m_files, m_destinationDir, m_options);
+ bool ret = archiveInterface()->copyFiles(m_entries, m_destinationDir, m_options);
if (!archiveInterface()->waitForFinishedSignal()) {
onFinished(ret);
@@ -337,9 +340,9 @@ ExtractionOptions ExtractJob::extractionOptions() const
return m_options;
}
-TempExtractJob::TempExtractJob(const QString &file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
+TempExtractJob::TempExtractJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
: Job(interface)
- , m_file(file)
+ , m_entry(entry)
, m_passwordProtectedHint(passwordProtectedHint)
{
}
@@ -347,7 +350,7 @@ TempExtractJob::TempExtractJob(const QString &file, bool passwordProtectedHint,
QString TempExtractJob::validatedFilePath() const
{
- QString path = extractionDir() + QLatin1Char('/') + m_file;
+ QString path = extractionDir() + QLatin1Char('/') + m_entry->property("fullPath").toString();
// Make sure a maliciously crafted archive with parent folders named ".." do
// not cause the previewed file path to be located outside the temporary
@@ -375,17 +378,17 @@ void TempExtractJob::doWork()
connectToArchiveInterfaceSignals();
- qCDebug(ARK) << "Extracting:" << m_file;
+ qCDebug(ARK) << "Extracting:" << m_entry;
- bool ret = archiveInterface()->copyFiles({ QVariant::fromValue(fileRootNodePair(m_file)) }, extractionDir(), extractionOptions());
+ bool ret = archiveInterface()->copyFiles({ m_entry }, extractionDir(), extractionOptions());
if (!archiveInterface()->waitForFinishedSignal()) {
onFinished(ret);
}
}
-PreviewJob::PreviewJob(const QString& file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
- : TempExtractJob(file, passwordProtectedHint, interface)
+PreviewJob::PreviewJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
+ : TempExtractJob(entry, passwordProtectedHint, interface)
{
qCDebug(ARK) << "PreviewJob started";
}
@@ -395,8 +398,8 @@ QString PreviewJob::extractionDir() const
return m_tmpExtractDir.path();
}
-OpenJob::OpenJob(const QString& file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
- : TempExtractJob(file, passwordProtectedHint, interface)
+OpenJob::OpenJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
+ : TempExtractJob(entry, passwordProtectedHint, interface)
{
qCDebug(ARK) << "OpenJob started";
@@ -413,15 +416,15 @@ QString OpenJob::extractionDir() const
return m_tmpExtractDir->path();
}
-OpenWithJob::OpenWithJob(const QString& file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
- : OpenJob(file, passwordProtectedHint, interface)
+OpenWithJob::OpenWithJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface)
+ : OpenJob(entry, passwordProtectedHint, interface)
{
qCDebug(ARK) << "OpenWithJob started";
}
-AddJob::AddJob(const QStringList& files, const CompressionOptions& options , ReadWriteArchiveInterface *interface)
+AddJob::AddJob(QList<Archive::Entry*> &entries, const CompressionOptions& options , ReadWriteArchiveInterface *interface)
: Job(interface)
- , m_files(files)
+ , m_entries(entries)
, m_options(options)
{
qCDebug(ARK) << "AddJob started";
@@ -429,9 +432,9 @@ AddJob::AddJob(const QStringList& files, const CompressionOptions& options , Rea
void AddJob::doWork()
{
- qCDebug(ARK) << "AddJob: going to add" << m_files.count() << "file(s)";
+ qCDebug(ARK) << "AddJob: going to add" << m_entries.count() << "file(s)";
- emit description(this, i18np("Adding a file", "Adding %1 files", m_files.count()));
+ emit description(this, i18np("Adding a file", "Adding %1 files", m_entries.count()));
ReadWriteArchiveInterface *m_writeInterface =
qobject_cast<ReadWriteArchiveInterface*>(archiveInterface());
@@ -447,21 +450,22 @@ void AddJob::doWork()
}
// The file paths must be relative to GlobalWorkDir.
- QStringList relativeFiles;
- foreach (const QString& file, m_files) {
+ foreach (Archive::Entry *entry, m_entries) {
// #191821: workDir must be used instead of QDir::current()
// so that symlinks aren't resolved automatically
- QString relativePath = workDir.relativeFilePath(file);
+ const QString &fullPath = entry->property("fullPath").toString();
+ QString relativePath = workDir.relativeFilePath(fullPath);
- if (file.endsWith(QLatin1Char('/'))) {
+ if (fullPath.endsWith(QLatin1Char('/'))) {
relativePath += QLatin1Char('/');
}
- relativeFiles << relativePath;
+ qCDebug(ARK) << entry->property("fullPath") << entry->isDir() << relativePath;
+ entry->setFullPath(relativePath);
}
connectToArchiveInterfaceSignals();
- bool ret = m_writeInterface->addFiles(relativeFiles, m_options);
+ bool ret = m_writeInterface->addFiles(m_entries, m_options);
if (!archiveInterface()->waitForFinishedSignal()) {
onFinished(ret);
@@ -477,15 +481,15 @@ void AddJob::onFinished(bool result)
Job::onFinished(result);
}
-DeleteJob::DeleteJob(const QVariantList& files, ReadWriteArchiveInterface *interface)
+DeleteJob::DeleteJob(QList<Archive::Entry*> &entries, ReadWriteArchiveInterface *interface)
: Job(interface)
- , m_files(files)
+ , m_entries(entries)
{
}
void DeleteJob::doWork()
{
- emit description(this, i18np("Deleting a file from the archive", "Deleting %1 files", m_files.count()));
+ emit description(this, i18np("Deleting a file from the archive", "Deleting %1 files", m_entries.count()));
ReadWriteArchiveInterface *m_writeInterface =
qobject_cast<ReadWriteArchiveInterface*>(archiveInterface());
@@ -493,7 +497,7 @@ void DeleteJob::doWork()
Q_ASSERT(m_writeInterface);
connectToArchiveInterfaceSignals();
- bool ret = m_writeInterface->deleteFiles(m_files);
+ bool ret = m_writeInterface->deleteFiles(m_entries);
if (!archiveInterface()->waitForFinishedSignal()) {
onFinished(ret);
diff --git a/kerfuffle/jobs.h b/kerfuffle/jobs.h
index 67a75d1..3279bff 100644
--- a/kerfuffle/jobs.h
+++ b/kerfuffle/jobs.h
@@ -31,6 +31,7 @@
#include "kerfuffle_export.h"
#include "archiveinterface.h"
#include "archive_kerfuffle.h"
+#include "archiveentry.h"
#include "queries.h"
#include <KJob>
@@ -57,6 +58,7 @@ protected:
virtual void emitResult();
ReadOnlyArchiveInterface *archiveInterface();
+ QList<Archive::Entry*> m_archiveEntries;
void connectToArchiveInterfaceSignals();
@@ -122,7 +124,7 @@ class KERFUFFLE_EXPORT ExtractJob : public Job
Q_OBJECT
public:
- ExtractJob(const QVariantList& files, const QString& destinationDir, const ExtractionOptions& options, ReadOnlyArchiveInterface *interface);
+ ExtractJob(const QList<Archive::Entry*> &entries, const QString& destinationDir, const ExtractionOptions& options, ReadOnlyArchiveInterface *interface);
QString destinationDirectory() const;
ExtractionOptions extractionOptions() const;
@@ -134,7 +136,7 @@ private:
// TODO: Maybe this should be a method if ExtractionOptions were a class?
void setDefaultOptions();
- QVariantList m_files;
+ QList<Archive::Entry*> m_entries;
QString m_destinationDir;
ExtractionOptions m_options;
};
@@ -149,7 +151,7 @@ class KERFUFFLE_EXPORT TempExtractJob : public Job
Q_OBJECT
public:
- TempExtractJob(const QString& file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
+ TempExtractJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
/**
* @return The absolute path of the extracted file.
@@ -165,7 +167,7 @@ public slots:
private:
virtual QString extractionDir() const = 0;
- QString m_file;
+ Archive::Entry *m_entry;
bool m_passwordProtectedHint;
};
@@ -178,7 +180,7 @@ class KERFUFFLE_EXPORT PreviewJob : public TempExtractJob
Q_OBJECT
public:
- PreviewJob(const QString& file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
+ PreviewJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
private:
QString extractionDir() const Q_DECL_OVERRIDE;
@@ -195,7 +197,7 @@ class KERFUFFLE_EXPORT OpenJob : public TempExtractJob
Q_OBJECT
public:
- OpenJob(const QString& file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
+ OpenJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
/**
* @return The temporary dir used for the extraction.
@@ -214,7 +216,7 @@ class KERFUFFLE_EXPORT OpenWithJob : public OpenJob
Q_OBJECT
public:
- OpenWithJob(const QString& file, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
+ OpenWithJob(Archive::Entry *entry, bool passwordProtectedHint, ReadOnlyArchiveInterface *interface);
};
class KERFUFFLE_EXPORT AddJob : public Job
@@ -222,7 +224,7 @@ class KERFUFFLE_EXPORT AddJob : public Job
Q_OBJECT
public:
- AddJob(const QStringList& files, const CompressionOptions& options, ReadWriteArchiveInterface *interface);
+ AddJob(QList<Archive::Entry*> &files, const CompressionOptions& options, ReadWriteArchiveInterface *interface);
public slots:
virtual void doWork() Q_DECL_OVERRIDE;
@@ -232,7 +234,7 @@ protected slots:
private:
QString m_oldWorkingDir;
- QStringList m_files;
+ QList<Archive::Entry*> m_entries;
CompressionOptions m_options;
};
@@ -241,13 +243,13 @@ class KERFUFFLE_EXPORT DeleteJob : public Job
Q_OBJECT
public:
- DeleteJob(const QVariantList& files, ReadWriteArchiveInterface *interface);
+ DeleteJob(QList<Archive::Entry*> &files, ReadWriteArchiveInterface *interface);
public slots:
virtual void doWork() Q_DECL_OVERRIDE;
private:
- QVariantList m_files;
+ QList<Archive::Entry*> m_entries;
};
class KERFUFFLE_EXPORT CommentJob : public Job
diff --git a/part/archivemodel.cpp b/part/archivemodel.cpp
index b7c9e12..5489153 100644
--- a/part/archivemodel.cpp
+++ b/part/archivemodel.cpp
@@ -22,8 +22,6 @@
*/
#include "archivemodel.h"
-#include "ark_debug.h"
-#include "kerfuffle/archiveentry.h"
#include "kerfuffle/jobs.h"
#include <KLocalizedString>
@@ -47,7 +45,7 @@ Q_GLOBAL_STATIC(QStringList, s_previousPieces)
* and for determining data displaying order in part's view.
*/
enum EntryMetaDataType {
- FileName, /**< The entry's file name */
+ FullPath, /**< The entry's file name */
Size, /**< The entry's original size */
CompressedSize, /**< The compressed size for the entry */
Permissions, /**< The entry's permissions */
@@ -66,7 +64,7 @@ enum EntryMetaDataType {
*/
static QMap<int, QString> initializePropertiesList() {
QMap<int, QString> propertiesList = QMap<int, QString>();
- propertiesList.insert(FileName, QStringLiteral("fileName"));
+ propertiesList.insert(FullPath, QStringLiteral("fullPath"));
propertiesList.insert(Size, QStringLiteral("size"));
propertiesList.insert(CompressedSize, QStringLiteral("compressedSize"));
propertiesList.insert(Permissions, QStringLiteral("permissions"));
@@ -129,7 +127,7 @@ protected:
const QVariant &rightEntryMetaData = rightEntry->property(propertiesList[column].toStdString().c_str());
switch (m_sortColumn) {
- case FileName:
+ case FullPath:
return leftEntry->name() < rightEntry->name();
case Size:
case CompressedSize:
@@ -150,16 +148,14 @@ private:
ArchiveModel::ArchiveModel(const QString &dbusPathName, QObject *parent)
: QAbstractItemModel(parent)
- , m_rootEntry(new Archive::Entry(Q_NULLPTR))
+ , m_rootEntry()
, m_dbusPathName(dbusPathName)
{
- m_rootEntry->setProperty("isDirectory", true);
+ m_rootEntry.setProperty("isDirectory", true);
}
ArchiveModel::~ArchiveModel()
{
- delete m_rootEntry;
- m_rootEntry = 0;
}
QVariant ArchiveModel::data(const QModelIndex &index, int role) const
@@ -171,7 +167,7 @@ QVariant ArchiveModel::data(const QModelIndex &index, int role) const
//TODO: complete the columns
int column = m_showColumns.at(index.column());
switch (column) {
- case FileName:
+ case FullPath:
return entry->name();
case Size:
if (entry->isDir()) {
@@ -220,7 +216,7 @@ QVariant ArchiveModel::data(const QModelIndex &index, int role) const
}
case Qt::DecorationRole:
if (index.column() == 0) {
- return entry->icon();
+ return *m_entryIcons.value(entry->property("fullPath").toString());
}
return QVariant();
case Qt::FontRole: {
@@ -258,7 +254,7 @@ QVariant ArchiveModel::headerData(int section, Qt::Orientation, int role) const
int columnId = m_showColumns.at(section);
switch (columnId) {
- case FileName:
+ case FullPath:
return i18nc("Name of a file inside an archive", "Name");
case Size:
return i18nc("Uncompressed size of a file inside an archive", "Size");
@@ -294,13 +290,15 @@ QVariant ArchiveModel::headerData(int section, Qt::Orientation, int role) const
QModelIndex ArchiveModel::index(int row, int column, const QModelIndex &parent) const
{
if (hasIndex(row, column, parent)) {
- Archive::Entry *parentEntry = parent.isValid() ? static_cast<Archive::Entry*>(parent.internalPointer()) : m_rootEntry;
+ const Archive::Entry *parentEntry = parent.isValid()
+ ? static_cast<Archive::Entry*>(parent.internalPointer())
+ : &m_rootEntry;
Q_ASSERT(parentEntry->isDir());
- Archive::Entry *item = parentEntry->entries().value(row, 0);
- if (item) {
- return createIndex(row, column, item);
+ const Archive::Entry *item = parentEntry->entries().value(row, Q_NULLPTR);
+ if (item != Q_NULLPTR) {
+ return createIndex(row, column, const_cast<Archive::Entry*>(item));
}
}
@@ -312,7 +310,7 @@ QModelIndex ArchiveModel::parent(const QModelIndex &index) const
if (index.isValid()) {
Archive::Entry *item = static_cast<Archive::Entry*>(index.internalPointer());
Q_ASSERT(item);
- if (item->getParent() && (item->getParent() != m_rootEntry)) {
+ if (item->getParent() && (item->getParent() != &m_rootEntry)) {
return createIndex(item->getParent()->row(), 0, item->getParent());
}
}
@@ -336,7 +334,7 @@ int ArchiveModel::childCount(const QModelIndex &index, int &dirs, int &files) co
Archive::Entry *item = static_cast<Archive::Entry*>(index.internalPointer());
Q_ASSERT(item);
if (item->isDir()) {
- const QList<Archive::Entry*> entries = static_cast<Archive::Entry*>(item)->entries();
+ const QVector<Archive::Entry*> entries = item->entries();
foreach(const Archive::Entry *entry, entries) {
if (entry->isDir()) {
dirs++;
@@ -354,10 +352,12 @@ int ArchiveModel::childCount(const QModelIndex &index, int &dirs, int &files) co
int ArchiveModel::rowCount(const QModelIndex &parent) const
{
if (parent.column() <= 0) {
- Archive::Entry *parentEntry = parent.isValid() ? static_cast<Archive::Entry*>(parent.internalPointer()) : m_rootEntry;
+ const Archive::Entry *parentEntry = parent.isValid()
+ ? static_cast<Archive::Entry*>(parent.internalPointer())
+ : &m_rootEntry;
if (parentEntry && parentEntry->isDir()) {
- return static_cast<Archive::Entry*>(parentEntry)->entries().count();
+ return parentEntry->entries().count();
}
}
return 0;
@@ -377,8 +377,8 @@ void ArchiveModel::sort(int column, Qt::SortOrder order)
emit layoutAboutToBeChanged();
QList<Archive::Entry*> dirEntries;
- m_rootEntry->returnDirEntries(&dirEntries);
- dirEntries.append(m_rootEntry);
+ m_rootEntry.returnDirEntries(&dirEntries);
+ dirEntries.append(&m_rootEntry);
const ArchiveModelSorter modelSorter(m_showColumns.at(column), order);
@@ -504,7 +504,7 @@ QString ArchiveModel::cleanFileName(const QString& fileName)
Archive::Entry *ArchiveModel::parentFor(const Archive::Entry *entry)
{
- QStringList pieces = entry->property("fileName").toString().split(QLatin1Char( '/' ), QString::SkipEmptyParts);
+ QStringList pieces = entry->property("fullPath").toString().split(QLatin1Char( '/' ), QString::SkipEmptyParts);
if (pieces.isEmpty()) {
return Q_NULLPTR;
}
@@ -531,7 +531,7 @@ Archive::Entry *ArchiveModel::parentFor(const Archive::Entry *entry)
}
}
- Archive::Entry *parent = m_rootEntry;
+ Archive::Entry *parent = &m_rootEntry;
foreach(const QString &piece, pieces) {
Archive::Entry *entry = parent->find(piece);
@@ -541,17 +541,15 @@ Archive::Entry *ArchiveModel::parentFor(const Archive::Entry *entry)
// and then delete the existing one (see ArchiveModel::newEntry).
entry = new Archive::Entry(parent);
- entry->setProperty("fileName", (parent == m_rootEntry)
+ entry->setProperty("fullPath", (parent == &m_rootEntry)
? piece
- : parent->property("fileName").toString() + QLatin1Char( '/' ) + piece);
+ : parent->property("fullPath").toString() + QLatin1Char( '/' ) + piece);
entry->setProperty("isDirectory", true);
- entry->processNameAndIcon();
insertEntry(entry);
}
if (!entry->isDir()) {
Archive::Entry *e = new Archive::Entry(parent);
copyEntryMetaData(e, entry);
- e->processNameAndIcon();
// Maybe we have both a file and a directory of the same name.
// We avoid removing previous entries unless necessary.
insertEntry(e);
@@ -568,7 +566,7 @@ Archive::Entry *ArchiveModel::parentFor(const Archive::Entry *entry)
QModelIndex ArchiveModel::indexForEntry(Archive::Entry *entry)
{
Q_ASSERT(entry);
- if (entry != m_rootEntry) {
+ if (entry != &m_rootEntry) {
Q_ASSERT(entry->getParent());
Q_ASSERT(entry->getParent()->isDir());
return createIndex(entry->row(), 0, entry);
@@ -583,18 +581,15 @@ void ArchiveModel::slotEntryRemoved(const QString & path)
return;
}
- Archive::Entry *entry = m_rootEntry->findByPath(entryFileName.split(QLatin1Char( '/' ), QString::SkipEmptyParts));
+ Archive::Entry *entry = m_rootEntry.findByPath(entryFileName.split(QLatin1Char( '/' ), QString::SkipEmptyParts));
if (entry) {
Archive::Entry *parent = entry->getParent();
QModelIndex index = indexForEntry(entry);
Q_UNUSED(index);
beginRemoveRows(indexForEntry(parent), entry->row(), entry->row());
-
- //delete parent->entries()[ metaData->row() ];
- //parent->entries()[ metaData->row() ] = 0;
+ delete m_entryIcons.take(parent->entries().at(entry->row())->property("fullPath").toString());
parent->removeEntryAt(entry->row());
-
endRemoveRows();
}
}
@@ -620,7 +615,7 @@ void ArchiveModel::slotNewEntry(Archive::Entry *entry)
void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behaviour)
{
- if (receivedEntry->property("fileName").toString().isEmpty()) {
+ if (receivedEntry->property("fullPath").toString().isEmpty()) {
qCDebug(ARK) << "Weird, received empty entry (no filename) - skipping";
return;
}
@@ -649,26 +644,23 @@ void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behav
//#194241: Filenames such as "./file" should be displayed as "file"
//#241967: Entries called "/" should be ignored
//#355839: Entries called "//" should be ignored
- QString entryFileName = cleanFileName(receivedEntry->property("fileName").toString());
+ QString entryFileName = cleanFileName(receivedEntry->property("fullPath").toString());
if (entryFileName.isEmpty()) { // The entry contains only "." or "./"
return;
}
- receivedEntry->setProperty("fileName", entryFileName);
+ receivedEntry->setProperty("fullPath", entryFileName);
/// 1. Skip already created entries
- if (m_rootEntry) {
- Archive::Entry *existing = m_rootEntry->findByPath(entryFileName.split(QLatin1Char( '/' )));
- if (existing) {
- qCDebug(ARK) << "Refreshing entry for" << entryFileName;
-
- existing->setProperty("fileName", entryFileName);
- // Multi-volume files are repeated at least in RAR archives.
- // In that case, we need to sum the compressed size for each volume
- qulonglong currentCompressedSize = existing->property("compressedSize").toULongLong();
- existing->setProperty("compressedSize", currentCompressedSize + receivedEntry->property("compressedSize").toULongLong());
- existing->processNameAndIcon();
- return;
- }
+ Archive::Entry *existing = m_rootEntry.findByPath(entryFileName.split(QLatin1Char( '/' )));
+ if (existing) {
+ qCDebug(ARK) << "Refreshing entry for" << entryFileName;
+
+ existing->setProperty("fullPath", entryFileName);
+ // Multi-volume files are repeated at least in RAR archives.
+ // In that case, we need to sum the compressed size for each volume
+ qulonglong currentCompressedSize = existing->property("compressedSize").toULongLong();
+ existing->setProperty("compressedSize", currentCompressedSize + receivedEntry->property("compressedSize").toULongLong());
+ return;
}
/// 2. Find Parent Entry, creating missing direcotry ArchiveEntries in the process
@@ -680,12 +672,10 @@ void ArchiveModel::newEntry(Archive::Entry *receivedEntry, InsertBehaviour behav
Archive::Entry *entry = parent->find(name);
if (entry) {
copyEntryMetaData(entry, receivedEntry);
- entry->setProperty("fileName", entryFileName);
- entry->processNameAndIcon();
+ entry->setProperty("fullPath", entryFileName);
delete receivedEntry;
} else {
receivedEntry->setParent(parent);
- receivedEntry->processNameAndIcon();
insertEntry(receivedEntry, behaviour);
}
}
@@ -708,7 +698,7 @@ void ArchiveModel::slotLoadingFinished(KJob *job)
void ArchiveModel::copyEntryMetaData(Archive::Entry *destinationEntry, const Archive::Entry *sourceEntry)
{
- destinationEntry->setProperty("fileName", sourceEntry->property("fileName"));
+ destinationEntry->setProperty("fullPath", sourceEntry->property("fullPath"));
destinationEntry->setProperty("permissions", sourceEntry->property("permissions"));
destinationEntry->setProperty("owner", sourceEntry->property("owner"));
destinationEntry->setProperty("group", sourceEntry->property("group"));
@@ -737,6 +727,18 @@ void ArchiveModel::insertEntry(Archive::Entry *entry, InsertBehaviour behaviour)
if (behaviour == NotifyViews) {
endInsertRows();
}
+
+ // Save an icon for each newly added entry.
+ QMimeDatabase db;
+ const QPixmap *pixmap;
+ if (entry->isDir()) {
+ pixmap = new QPixmap(QIcon::fromTheme(db.mimeTypeForName(QStringLiteral("inode/directory")).iconName()).pixmap(IconSize(KIconLoader::Small),
+ IconSize(KIconLoader::Small)));
+ } else {
+ pixmap = new QPixmap(QIcon::fromTheme(db.mimeTypeForFile(entry->property("fullPath").toString()).iconName()).pixmap(IconSize(KIconLoader::Small),
+ IconSize(KIconLoader::Small)));
+ }
+ m_entryIcons.insert(entry->property("fullPath").toString(), pixmap);
}
Kerfuffle::Archive* ArchiveModel::archive() const
@@ -748,7 +750,7 @@ KJob* ArchiveModel::setArchive(Kerfuffle::Archive *archive)
{
m_archive.reset(archive);
- m_rootEntry->clear();
+ m_rootEntry.clear();
s_previousMatch = Q_NULLPTR;
s_previousPieces->clear();
@@ -773,14 +775,14 @@ KJob* ArchiveModel::setArchive(Kerfuffle::Archive *archive)
return job;
}
-ExtractJob* ArchiveModel::extractFile(const QVariant& fileName, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options) const
+ExtractJob* ArchiveModel::extractFile(Archive::Entry *file, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options) const
{
- QList<QVariant> files;
- files << QVariant::fromValue(fileRootNodePair(fileName.toString()));
+ QList<Archive::Entry*> files;
+ files << file;
return extractFiles(files, destinationDir, options);
}
-ExtractJob* ArchiveModel::extractFiles(const QList<QVariant>& files, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options) const
+ExtractJob* ArchiveModel::extractFiles(const QList<Archive::Entry*>& files, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options) const
{
Q_ASSERT(m_archive);
ExtractJob *newJob = m_archive->copyFiles(files, destinationDir, options);
@@ -788,7 +790,7 @@ ExtractJob* ArchiveModel::extractFiles(const QList<QVariant>& files, const QStri
return newJob;
}
-Kerfuffle::PreviewJob *ArchiveModel::preview(const QString& file) const
+Kerfuffle::PreviewJob *ArchiveModel::preview(Archive::Entry *file) const
{
Q_ASSERT(m_archive);
PreviewJob *job = m_archive->preview(file);
@@ -796,7 +798,7 @@ Kerfuffle::PreviewJob *ArchiveModel::preview(const QString& file) const
return job;
}
-OpenJob *ArchiveModel::open(const QString& file) const
+OpenJob *ArchiveModel::open(Archive::Entry *file) const
{
Q_ASSERT(m_archive);
OpenJob *job = m_archive->open(file);
@@ -804,7 +806,7 @@ OpenJob *ArchiveModel::open(const QString& file) const
return job;
}
-OpenWithJob *ArchiveModel::openWith(const QString& file) const
+OpenWithJob *ArchiveModel::openWith(Archive::Entry *file) const
{
Q_ASSERT(m_archive);
OpenWithJob *job = m_archive->openWith(file);
@@ -812,14 +814,14 @@ OpenWithJob *ArchiveModel::openWith(const QString& file) const
return job;
}
-AddJob* ArchiveModel::addFiles(const QStringList & filenames, const CompressionOptions& options)
+AddJob* ArchiveModel::addFiles(QList<Archive::Entry*> &entries, const CompressionOptions& options)
{
if (!m_archive) {
return Q_NULLPTR;
}
if (!m_archive->isReadOnly()) {
- AddJob *job = m_archive->addFiles(filenames, options);
+ AddJob *job = m_archive->addFiles(entries, options);
connect(job, &AddJob::newEntry, this, &ArchiveModel::slotNewEntry);
connect(job, &AddJob::userQuery, this, &ArchiveModel::slotUserQuery);
@@ -829,11 +831,11 @@ AddJob* ArchiveModel::addFiles(const QStringList & filenames, const CompressionO
return Q_NULLPTR;
}
-DeleteJob* ArchiveModel::deleteFiles(const QList<QVariant> & files)
+DeleteJob* ArchiveModel::deleteFiles(QList<Archive::Entry*> entries)
{
Q_ASSERT(m_archive);
if (!m_archive->isReadOnly()) {
- DeleteJob *job = m_archive->deleteFiles(files);
+ DeleteJob *job = m_archive->deleteFiles(entries);
connect(job, &DeleteJob::entryRemoved, this, &ArchiveModel::slotEntryRemoved);
connect(job, &DeleteJob::finished, this, &ArchiveModel::slotCleanupEmptyDirs);
@@ -869,7 +871,7 @@ void ArchiveModel::slotCleanupEmptyDirs()
Archive::Entry *entry = entryForIndex(node);
if (!hasChildren(node)) {
- if (!entry->property("fileName").toString().isEmpty()) {
+ if (entry->property("fullPath").toString().isEmpty()) {
nodesToDelete << node;
}
} else {
@@ -883,7 +885,8 @@ void ArchiveModel::slotCleanupEmptyDirs()
Archive::Entry *rawEntry = static_cast<Archive::Entry*>(node.internalPointer());
qCDebug(ARK) << "Delete with parent entries " << rawEntry->getParent()->entries() << " and row " << rawEntry->row();
beginRemoveRows(parent(node), rawEntry->row(), rawEntry->row());
- rawEntry->getParent()->removeEntryAt(rawEntry->row());
+ delete m_entryIcons.take(rawEntry->getParent()->entries().at(rawEntry->row())->property("fullPath").toString());
+ rawEntry->getParent()->removeEntryAt(rawEntry->row());
endRemoveRows();
}
}
diff --git a/part/archivemodel.h b/part/archivemodel.h
index a922731..395ef80 100644
--- a/part/archivemodel.h
+++ b/part/archivemodel.h
@@ -26,7 +26,7 @@
#include <QScopedPointer>
#include <kjobtrackerinterface.h>
-#include "kerfuffle/archive_kerfuffle.h"
+#include "kerfuffle/archiveentry.h"
using Kerfuffle::Archive;
@@ -66,15 +66,15 @@ public:
Archive::Entry *entryForIndex(const QModelIndex &index);
int childCount(const QModelIndex &index, int &dirs, int &files) const;
- Kerfuffle::ExtractJob* extractFile(const QVariant& fileName, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options = Kerfuffle::ExtractionOptions()) const;
- Kerfuffle::ExtractJob* extractFiles(const QList<QVariant>& files, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options = Kerfuffle::ExtractionOptions()) const;
+ Kerfuffle::ExtractJob* extractFile(Archive::Entry *file, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options = Kerfuffle::ExtractionOptions()) const;
+ Kerfuffle::ExtractJob* extractFiles(const QList<Archive::Entry*>& files, const QString& destinationDir, const Kerfuffle::ExtractionOptions& options = Kerfuffle::ExtractionOptions()) const;
- Kerfuffle::PreviewJob* preview(const QString& file) const;
- Kerfuffle::OpenJob* open(const QString& file) const;
- Kerfuffle::OpenWithJob* openWith(const QString& file) const;
+ Kerfuffle::PreviewJob* preview(Archive::Entry *file) const;
+ Kerfuffle::OpenJob* open(Archive::Entry *file) const;
+ Kerfuffle::OpenWithJob* openWith(Archive::Entry *file) const;
- Kerfuffle::AddJob* addFiles(const QStringList & paths, const Kerfuffle::CompressionOptions& options = Kerfuffle::CompressionOptions());
- Kerfuffle::DeleteJob* deleteFiles(const QList<QVariant> & files);
+ Kerfuffle::AddJob* addFiles(QList<Archive::Entry*> &entries, const Kerfuffle::CompressionOptions& options = Kerfuffle::CompressionOptions());
+ Kerfuffle::DeleteJob* deleteFiles(QList<Archive::Entry*> entries);
/**
* @param password The password to encrypt the archive with.
@@ -125,7 +125,8 @@ private:
QList<Kerfuffle::Archive::Entry*> m_newArchiveEntries; // holds entries from opening a new archive until it's totally open
QList<int> m_showColumns;
QScopedPointer<Kerfuffle::Archive> m_archive;
- Archive::Entry *m_rootEntry;
+ Archive::Entry m_rootEntry;
+ QHash<QString, const QPixmap*> m_entryIcons;
QString m_dbusPathName;
};
diff --git a/part/infopanel.cpp b/part/infopanel.cpp
index 55a8a56..d46f0e1 100644
--- a/part/infopanel.cpp
+++ b/part/infopanel.cpp
@@ -100,7 +100,7 @@ void InfoPanel::setIndex(const QModelIndex& index)
if (entry->isDir()) {
mimeType = db.mimeTypeForName(QStringLiteral("inode/directory"));
} else {
- mimeType = db.mimeTypeForFile(entry->property("fileName").toString(), QMimeDatabase::MatchExtension);
+ mimeType = db.mimeTypeForFile(entry->property("fullPath").toString(), QMimeDatabase::MatchExtension);
}
iconLabel->setPixmap(getDesktopIconForName(mimeType.iconName()));
@@ -120,8 +120,8 @@ void InfoPanel::setIndex(const QModelIndex& index)
}
}
- const QStringList nameParts = entry->property("fileName").toString().split(QLatin1Char( '/' ), QString::SkipEmptyParts);
- const QString name = (nameParts.count() > 0) ? nameParts.last() : entry->property("fileName").toString();
+ const QStringList nameParts = entry->property("fullPath").toString().split(QLatin1Char( '/' ), QString::SkipEmptyParts);
+ const QString name = (nameParts.count() > 0) ? nameParts.last() : entry->property("fullPath").toString();
fileName->setText(name);
showMetaDataFor(index);
@@ -171,7 +171,7 @@ void InfoPanel::showMetaDataFor(const QModelIndex &index)
if (entry->isDir()) {
mimeType = db.mimeTypeForName(QStringLiteral("inode/directory"));
} else {
- mimeType = db.mimeTypeForFile(entry->property("fileName").toString(), QMimeDatabase::MatchExtension);
+ mimeType = db.mimeTypeForFile(entry->property("fullPath").toString(), QMimeDatabase::MatchExtension);
}
m_typeLabel->setText(i18n("<b>Type:</b> %1", mimeType.comment()));
diff --git a/part/part.cpp b/part/part.cpp
index fb486f0..e2ed178 100644
--- a/part/part.cpp
+++ b/part/part.cpp
@@ -30,7 +30,6 @@
#include "dnddbusinterfaceadaptor.h"
#include "infopanel.h"
#include "jobtracker.h"
-#include "kerfuffle/archiveentry.h"
#include "kerfuffle/extractiondialog.h"
#include "kerfuffle/extractionsettingspage.h"
#include "kerfuffle/jobs.h"
@@ -588,7 +587,7 @@ void Part::slotQuickExtractFiles(QAction *triggeredAction)
Kerfuffle::ExtractionOptions options;
options[QStringLiteral("PreservePaths")] = true;
- QList<QVariant> files = filesAndRootNodesForIndexes(m_view->selectionModel()->selectedRows());
+ QList<Archive::Entry*> files = filesAndRootNodesForIndexes(m_view->selectionModel()->selectedRows());
ExtractJob *job = m_model->extractFiles(files, finalDestinationDirectory, options);
registerJob(job);
@@ -793,7 +792,7 @@ void Part::slotLoadingFinished(KJob *job)
displayMsgWidget(KMessageWidget::Warning, xi18nc("@info", "The archive is empty or Ark could not open its content."));
} else if (m_model->rowCount() == 1) {
if (m_model->archive()->mimeType().inherits(QStringLiteral("application/x-cd-image")) &&
- m_model->entryForIndex(m_model->index(0, 0))->property("fileName").toString() == QLatin1String("README.TXT")) {
+ m_model->entryForIndex(m_model->index(0, 0))->property("fullPath").toString() == QLatin1String("README.TXT")) {
qCWarning(ARK) << "Detected ISO image with UDF filesystem";
displayMsgWidget(KMessageWidget::Warning, xi18nc("@info", "Ark does not currently support ISO files with UDF filesystem."));
}
@@ -841,7 +840,7 @@ void Part::slotOpenEntry(int mode)
qCDebug(ARK) << "Opening with mode" << mode;
QModelIndex index = m_view->selectionModel()->currentIndex();
- const Archive::Entry *entry = m_model->entryForIndex(index);
+ Archive::Entry *entry = m_model->entryForIndex(index);
// Don't open directories.
if (entry->isDir()) {
@@ -855,17 +854,16 @@ void Part::slotOpenEntry(int mode)
}
// Extract the entry.
- if (!entry->property("fileName").toString().isEmpty()) {
+ if (!entry->property("fullPath").toString().isEmpty()) {
m_openFileMode = static_cast<OpenFileMode>(mode);
KJob *job = Q_NULLPTR;
if (m_openFileMode == Preview) {
- job = m_model->preview(entry->property("fileName").toString());
+ job = m_model->preview(entry);
connect(job, &KJob::result, this, &Part::slotPreviewExtractedEntry);
} else {
- const QString file = entry->property("fileName").toString();
- job = (m_openFileMode == OpenFile) ? m_model->open(file) : m_model->openWith(file);
+ job = (m_openFileMode == OpenFile) ? m_model->open(entry) : m_model->openWith(entry);
connect(job, &KJob::result, this, &Part::slotOpenExtractedEntry);
}
@@ -1027,7 +1025,7 @@ void Part::slotShowExtractionDialog()
updateQuickExtractMenu(m_extractArchiveAction);
updateQuickExtractMenu(m_extractAction);
- QVariantList files;
+ QList<Archive::Entry*> files;
// If the user has chosen to extract only selected entries, fetch these
// from the QTreeView.
@@ -1078,21 +1076,21 @@ QModelIndexList Part::addChildren(const QModelIndexList &list) const
return ret;
}
-QList<QVariant> Part::filesForIndexes(const QModelIndexList& list) const
+QList<Archive::Entry*> Part::filesForIndexes(const QModelIndexList& list) const
{
- QVariantList ret;
+ QList<Archive::Entry*> ret;
foreach(const QModelIndex& index, list) {
- const Archive::Entry *entry = m_model->entryForIndex(index);
- ret << entry->property("fileName").toString();
+ ret << m_model->entryForIndex(index);
}
return ret;
}
-QList<QVariant> Part::filesAndRootNodesForIndexes(const QModelIndexList& list) const
+QList<Kerfuffle::Archive::Entry*> Part::filesAndRootNodesForIndexes(const QModelIndexList& list) const
{
- QVariantList fileList;
+ QList<Kerfuffle::Archive::Entry*> fileList;
+ QStringList fullPathsList;
foreach (const QModelIndex& index, list) {
@@ -1109,15 +1107,17 @@ QList<QVariant> Part::filesAndRootNodesForIndexes(const QModelIndexList& list) c
// Fetch the root node for the unselected parent.
const QString rootFileName =
- m_model->entryForIndex(selectionRoot)->property("fileName").toString();
+ m_model->entryForIndex(selectionRoot)->property("fullPath").toString();
// Append index with root node to fileList.
QModelIndexList alist = QModelIndexList() << index;
- foreach (const QVariant &file, filesForIndexes(alist)) {
- QVariant v = QVariant::fromValue(fileRootNodePair(file.toString(), rootFileName));
- if (!fileList.contains(v)) {
- fileList.append(v);
+ foreach (Archive::Entry *entry, filesForIndexes(alist)) {
+ const QString fullPath = entry->property("fullPath").toString();
+ if (!fullPathsList.contains(fullPath)) {
+ entry->rootNode = rootFileName;
+ fileList.append(entry);
+ fullPathsList.append(fullPath);
}
}
}
@@ -1207,7 +1207,10 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const QString& path)
options[QStringLiteral("CompressionLevel")] = arguments().metaData()[QStringLiteral("compressionLevel")];
}
- AddJob *job = m_model->addFiles(cleanFilesToAdd, options);
+ foreach (const QString& file, cleanFilesToAdd) {
+ m_jobTempEntries.push_back(new Archive::Entry(Q_NULLPTR, file));
+ }
+ AddJob *job = m_model->addFiles(m_jobTempEntries, options);
if (!job) {
return;
}
@@ -1246,6 +1249,8 @@ void Part::slotAddDir()
void Part::slotAddFilesDone(KJob* job)
{
+ qDeleteAll(m_jobTempEntries);
+ m_jobTempEntries.clear();
if (job->error() && job->error() != KJob::KilledJobError) {
KMessageBox::error(widget(), job->errorString());
}
diff --git a/part/part.h b/part/part.h
index aa52074..a11b92d 100644
--- a/part/part.h
+++ b/part/part.h
@@ -24,6 +24,7 @@
#define PART_H
#include "interface.h"
+#include "kerfuffle/archiveentry.h"
#include <KParts/Part>
#include <KParts/ReadWritePart>
@@ -138,8 +139,8 @@ private:
void setupActions();
bool isSingleFolderArchive() const;
QString detectSubfolder() const;
- QList<QVariant> filesForIndexes(const QModelIndexList& list) const;
- QList<QVariant> filesAndRootNodesForIndexes(const QModelIndexList& list) const;
+ QList<Kerfuffle::Archive::Entry*> filesForIndexes(const QModelIndexList& list) const;
+ QList<Kerfuffle::Archive::Entry*> filesAndRootNodesForIndexes(const QModelIndexList& list) const;
QModelIndexList addChildren(const QModelIndexList &list) const;
void registerJob(KJob *job);
void displayMsgWidget(KMessageWidget::MessageType type, const QString& msg);
@@ -164,6 +165,7 @@ private:
QList<QTemporaryDir*> m_tmpOpenDirList;
bool m_busy;
OpenFileMode m_openFileMode;
+ QList<Kerfuffle::Archive::Entry*> m_jobTempEntries;
KAbstractWidgetJobTracker *m_jobTracker;
KParts::StatusBarExtension *m_statusBarExtension;
diff --git a/plugins/cli7zplugin/cliplugin.cpp b/plugins/cli7zplugin/cliplugin.cpp
index cbb794a..85b5227 100644
--- a/plugins/cli7zplugin/cliplugin.cpp
+++ b/plugins/cli7zplugin/cliplugin.cpp
@@ -188,13 +188,13 @@ bool CliPlugin::readListLine(const QString& line)
if (m_isFirstInformationEntry) {
m_isFirstInformationEntry = false;
- m_currentArchiveEntry = new Archive::Entry(Q_NULLPTR);
+ m_currentArchiveEntry = new Archive::Entry();
m_currentArchiveEntry->compressedSizeIsSet = false;
}
if (line.startsWith(QStringLiteral("Path = "))) {
const QString entryFilename =
QDir::fromNativeSeparators(line.mid(7).trimmed());
- m_currentArchiveEntry->setProperty("fileName", entryFilename);
+ m_currentArchiveEntry->setProperty("fullPath", entryFilename);
} else if (line.startsWith(QStringLiteral("Size = "))) {
m_currentArchiveEntry->setProperty("size", line.mid(7).trimmed());
} else if (line.startsWith(QStringLiteral("Packed Size = "))) {
@@ -214,10 +214,10 @@ bool CliPlugin::readListLine(const QString& line)
m_currentArchiveEntry->setProperty("isDirectory", isDirectory);
if (isDirectory) {
const QString directoryName =
- m_currentArchiveEntry->property("fileName").toString();
+ m_currentArchiveEntry->property("fullPath").toString();
if (!directoryName.endsWith(QLatin1Char('/'))) {
const bool isPasswordProtected = (line.at(12) == QLatin1Char('+'));
- m_currentArchiveEntry->setProperty("fileName", QString(directoryName + QLatin1Char('/')));
+ m_currentArchiveEntry->setProperty("fullPath", QString(directoryName + QLatin1Char('/')));
m_currentArchiveEntry->setProperty("isPasswordProtected", isPasswordProtected);
}
}
@@ -233,7 +233,7 @@ bool CliPlugin::readListLine(const QString& line)
} else if (line.startsWith(QStringLiteral("Block = ")) ||
line.startsWith(QStringLiteral("Version = "))) {
m_isFirstInformationEntry = true;
- if (!m_currentArchiveEntry->property("fileName").toString().isEmpty()) {
+ if (!m_currentArchiveEntry->property("fullPath").toString().isEmpty()) {
emit entry(m_currentArchiveEntry);
}
else {
diff --git a/plugins/cliplugin-example/cliplugin.cpp b/plugins/cliplugin-example/cliplugin.cpp
index fa21fbb..29b2bac 100644
--- a/plugins/cliplugin-example/cliplugin.cpp
+++ b/plugins/cliplugin-example/cliplugin.cpp
@@ -127,8 +127,8 @@ bool CliPlugin::readListLine(const QString &line)
}
qCDebug(ARK) << m_entryFilename << " : " << fileprops;
- Archive::Entry *e = new Archive::Entry(Q_NULLPTR);
- e->setProperty("fileName", m_entryFilename);
+ Archive::Entry *e = new Archive::Entry();
+ e->setProperty("fullPath", m_entryFilename);
e->setProperty("size", fileprops[ 0 ]);
e->setProperty("compressedSize", fileprops[ 1 ]);
e->setProperty("ratio", fileprops[ 2 ]);
diff --git a/plugins/clirarplugin/cliplugin.cpp b/plugins/clirarplugin/cliplugin.cpp
index 545bed0..b56ec41 100644
--- a/plugins/clirarplugin/cliplugin.cpp
+++ b/plugins/clirarplugin/cliplugin.cpp
@@ -250,7 +250,7 @@ void CliPlugin::handleUnrar5Line(const QString &line) {
void CliPlugin::handleUnrar5Entry() {
- Archive::Entry *e = new Archive::Entry(Q_NULLPTR);
+ Archive::Entry *e = new Archive::Entry();
QString compressionRatio = m_unrar5Details.value(QStringLiteral("ratio"));
compressionRatio.chop(1); // Remove the '%'
@@ -281,7 +281,7 @@ void CliPlugin::handleUnrar5Entry() {
m_isPasswordProtected = m_unrar5Details.value(QStringLiteral("flags")).contains(QStringLiteral("encrypted"));
e->setProperty("isPasswordProtected", m_isPasswordProtected);
- e->setProperty("fileName", m_unrar5Details.value(QStringLiteral("name")));
+ e->setProperty("fullPath", m_unrar5Details.value(QStringLiteral("name")));
e->setProperty("size", m_unrar5Details.value(QStringLiteral("size")));
e->setProperty("compressedSize", m_unrar5Details.value(QStringLiteral("packed size")));
e->setProperty("permissions", m_unrar5Details.value(QStringLiteral("attributes")));
@@ -452,7 +452,7 @@ void CliPlugin::handleUnrar4Line(const QString &line) {
void CliPlugin::handleUnrar4Entry() {
- Archive::Entry *e = new Archive::Entry(NULL);
+ Archive::Entry *e = new Archive::Entry(Q_NULLPTR);
QDateTime ts = QDateTime::fromString(QString(m_unrar4Details.at(4) + QLatin1Char(' ') + m_unrar4Details.at(5)),
QStringLiteral("dd-MM-yy hh:mm"));
@@ -489,7 +489,7 @@ void CliPlugin::handleUnrar4Entry() {
// TODO:
// - Permissions differ depending on the system the entry was added
// to the archive.
- e->setProperty("fileName", m_unrar4Details.at(0));
+ e->setProperty("fullPath", m_unrar4Details.at(0));
e->setProperty("size", m_unrar4Details.at(1));
e->setProperty("compressedSize", m_unrar4Details.at(2));
e->setProperty("permissions", m_unrar4Details.at(6));
diff --git a/plugins/cliunarchiverplugin/cliplugin.cpp b/plugins/cliunarchiverplugin/cliplugin.cpp
index 7e3e4ff..4a8ab87 100644
--- a/plugins/cliunarchiverplugin/cliplugin.cpp
+++ b/plugins/cliunarchiverplugin/cliplugin.cpp
@@ -21,8 +21,6 @@
*/
#include "cliplugin.h"
-#include "ark_debug.h"
-#include "kerfuffle/kerfuffle_export.h"
#include <QJsonArray>
#include <QJsonParseError>
@@ -78,7 +76,7 @@ bool CliPlugin::list()
return true;
}
-bool CliPlugin::copyFiles(const QList<QVariant> &files, const QString &destinationDirectory, const ExtractionOptions &options)
+bool CliPlugin::copyFiles(const QList<Archive::Entry*> &files, const QString &destinationDirectory, const ExtractionOptions &options)
{
ExtractionOptions newOptions = options;
@@ -187,28 +185,28 @@ void CliPlugin::readJsonOutput()
const QJsonArray entries = json.value(QStringLiteral("lsarContents")).toArray();
foreach (const QJsonValue& value, entries) {
- const QJsonObject currentEntry = value.toObject();
+ const QJsonObject currentEntryJson = value.toObject();
- m_currentEntry->clearMetaData();
+ Archive::Entry *currentEntry = new Archive::Entry(this);
- QString filename = currentEntry.value(QStringLiteral("XADFileName")).toString();
+ QString filename = currentEntryJson.value(QStringLiteral("XADFileName")).toString();
- m_currentEntry->setProperty("isDirectory", !currentEntry.value(QStringLiteral("XADIsDirectory")).isUndefined());
- if (m_currentEntry->isDir()) {
+ currentEntry->setProperty("isDirectory", !currentEntryJson.value(QStringLiteral("XADIsDirectory")).isUndefined());
+ if (currentEntry->isDir()) {
filename += QLatin1Char('/');
}
- m_currentEntry->setProperty("fileName", filename);
+ currentEntry->setProperty("fullPath", filename);
// FIXME: archives created from OSX (i.e. with the __MACOSX folder) list each entry twice, the 2nd time with size 0
- m_currentEntry->setProperty("size", currentEntry.value(QStringLiteral("XADFileSize")));
- m_currentEntry->setProperty("compressedSize", currentEntry.value(QStringLiteral("XADCompressedSize")));
- m_currentEntry->setProperty("timestamp", currentEntry.value(QStringLiteral("XADLastModificationDate")).toVariant());
- m_currentEntry->setProperty("size", currentEntry.value(QStringLiteral("XADFileSize")));
- m_currentEntry->setProperty("isPasswordProtected", (currentEntry.value(QStringLiteral("XADIsEncrypted")).toInt() == 1));
+ currentEntry->setProperty("size", currentEntryJson.value(QStringLiteral("XADFileSize")));
+ currentEntry->setProperty("compressedSize", currentEntryJson.value(QStringLiteral("XADCompressedSize")));
+ currentEntry->setProperty("timestamp", currentEntryJson.value(QStringLiteral("XADLastModificationDate")).toVariant());
+ currentEntry->setProperty("size", currentEntryJson.value(QStringLiteral("XADFileSize")));
+ currentEntry->setProperty("isPasswordProtected", (currentEntryJson.value(QStringLiteral("XADIsEncrypted")).toInt() == 1));
// TODO: missing fields
- emit entry(m_currentEntry);
+ emit entry(currentEntry);
}
}
diff --git a/plugins/cliunarchiverplugin/cliplugin.h b/plugins/cliunarchiverplugin/cliplugin.h
index 0923c48..0358771 100644
--- a/plugins/cliunarchiverplugin/cliplugin.h
+++ b/plugins/cliunarchiverplugin/cliplugin.h
@@ -35,7 +35,7 @@ public:
virtual ~CliPlugin();
virtual bool list() Q_DECL_OVERRIDE;
- virtual bool copyFiles(const QList<QVariant> &files, const QString &destinationDirectory, const Kerfuffle::ExtractionOptions &options) Q_DECL_OVERRIDE;
+ virtual bool copyFiles(const QList<Kerfuffle::Archive::Entry*> &files, const QString &destinationDirectory, const Kerfuffle::ExtractionOptions &options) Q_DECL_OVERRIDE;
virtual void resetParsing() Q_DECL_OVERRIDE;
virtual Kerfuffle::ParameterList parameterList() const Q_DECL_OVERRIDE;
virtual bool readListLine(const QString &line) Q_DECL_OVERRIDE;
@@ -57,7 +57,6 @@ private:
void readJsonOutput();
- Kerfuffle::Archive::Entry *m_currentEntry;
QString m_jsonOutput;
};
diff --git a/plugins/clizipplugin/cliplugin.cpp b/plugins/clizipplugin/cliplugin.cpp
index bf61f94..e12b5b7 100644
--- a/plugins/clizipplugin/cliplugin.cpp
+++ b/plugins/clizipplugin/cliplugin.cpp
@@ -162,7 +162,7 @@ bool CliPlugin::readListLine(const QString &line)
case ParseStateEntry:
QRegularExpressionMatch rxMatch = entryPattern.match(line);
if (rxMatch.hasMatch()) {
- Archive::Entry *e = new Archive::Entry(Q_NULLPTR);
+ Archive::Entry *e = new Archive::Entry();
e->setProperty("permissions", rxMatch.captured(1));
// #280354: infozip may not show the right attributes for a given directory, so an entry
@@ -180,7 +180,7 @@ bool CliPlugin::readListLine(const QString &line)
QTime::fromString(rxMatch.captured(9), QStringLiteral("hhmmss")));
e->setProperty("timestamp", ts);
- e->setProperty("fileName", rxMatch.captured(10));
+ e->setProperty("fullPath", rxMatch.captured(10));
emit entry(e);
}
break;
diff --git a/plugins/libarchive/libarchiveplugin.cpp b/plugins/libarchive/libarchiveplugin.cpp
index ad7685c..4ac0659 100644
--- a/plugins/libarchive/libarchiveplugin.cpp
+++ b/plugins/libarchive/libarchiveplugin.cpp
@@ -26,20 +26,11 @@
*/
#include "libarchiveplugin.h"
-#include "ark_debug.h"
-#include "kerfuffle/kerfuffle_export.h"
-#include "kerfuffle/archiveentry.h"
#include "kerfuffle/queries.h"
-#include <archive_entry.h>
-
#include <KLocalizedString>
-#include <QDateTime>
#include <QDirIterator>
-#include <QFile>
-#include <QList>
-#include <QSaveFile>
LibarchivePlugin::LibarchivePlugin(QObject *parent, const QVariantList & args)
: ReadWriteArchiveInterface(parent, args)
@@ -117,14 +108,14 @@ bool LibarchivePlugin::list()
return archive_read_close(arch_reader.data()) == ARCHIVE_OK;
}
-bool LibarchivePlugin::addFiles(const QStringList &files, const CompressionOptions &options)
+bool LibarchivePlugin::addFiles(const QList<Archive::Entry*> &files, const CompressionOptions &options)
{
Q_UNUSED(files)
Q_UNUSED(options)
return false;
}
-bool LibarchivePlugin::deleteFiles(const QList<QVariant> &files)
+bool LibarchivePlugin::deleteFiles(const QList<Archive::Entry*> &files)
{
Q_UNUSED(files)
return false;
@@ -147,7 +138,7 @@ bool LibarchivePlugin::doKill()
return true;
}
-bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& destinationDirectory, const ExtractionOptions& options)
+bool LibarchivePlugin::copyFiles(const QList<Archive::Entry*>& files, const QString& destinationDirectory, const ExtractionOptions& options)
{
qCDebug(ARK) << "Changing current directory to " << destinationDirectory;
QDir::setCurrent(destinationDirectory);
@@ -159,7 +150,8 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
// To avoid traversing the entire archive when extracting a limited set of
// entries, we maintain a list of remaining entries and stop when it's
// empty.
- QVariantList remainingFiles = files;
+ QStringList fullPaths = entryFullPaths(files);
+ QStringList remainingFiles = entryFullPaths(files);
ArchiveRead arch(archive_read_new());
@@ -256,12 +248,12 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
// Should the entry be extracted?
if (extractAll ||
- remainingFiles.contains(QVariant::fromValue(fileRootNodePair(entryName))) ||
+ remainingFiles.contains(entryName) ||
entryName == fileBeingRenamed) {
// Find the index of entry.
if (entryName != fileBeingRenamed) {
- index = files.indexOf(QVariant::fromValue(fileRootNodePair(entryName)));
+ index = fullPaths.indexOf(entryName);
}
if (!extractAll && index == -1) {
// If entry is not found in files, skip entry.
@@ -286,14 +278,15 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
entryFI = QFileInfo(fileWithoutPath);
// OR, if the file has a rootNode attached, remove it from file path.
- } else if (!extractAll && removeRootNode && entryName != fileBeingRenamed &&
- !files.at(index).value<fileRootNodePair>().rootNode.isEmpty()) {
-
- //qCDebug(ARK) << "Removing" << files.at(index).value<fileRootNodePair>().rootNode << "from" << entryName;
-
- const QString truncatedFilename(entryName.remove(0, files.at(index).value<fileRootNodePair>().rootNode.size()));
- archive_entry_copy_pathname(entry, QFile::encodeName(truncatedFilename).constData());
- entryFI = QFileInfo(truncatedFilename);
+ } else if (!extractAll && removeRootNode && entryName != fileBeingRenamed) {
+ const QString &rootNode = files.at(index)->rootNode;
+ if (!rootNode.isEmpty()) {
+ //qCDebug(ARK) << "Removing" << files.at(index).value<fileRootNodePair>().rootNode << "from" << entryName;
+
+ const QString truncatedFilename(entryName.remove(0, rootNode.size()));
+ archive_entry_copy_pathname(entry, QFile::encodeName(truncatedFilename).constData());
+ entryFI = QFileInfo(truncatedFilename);
+ }
}
// Check if the file about to be written already exists.
@@ -396,7 +389,7 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
archive_entry_clear(entry);
no_entries++;
- remainingFiles.removeOne(QVariant::fromValue(fileRootNodePair(entryName)));
+ remainingFiles.removeOne(entryName);
} else {
@@ -416,12 +409,12 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
void LibarchivePlugin::emitEntryFromArchiveEntry(struct archive_entry *aentry)
{
- Archive::Entry *e = new Archive::Entry(NULL);
+ Archive::Entry *e = new Archive::Entry(Q_NULLPTR);
#ifdef _MSC_VER
- e->fileName = QDir::fromNativeSeparators(QString::fromUtf16((ushort*)archive_entry_pathname_w(aentry)));
+ e->setProperty("fullPath", QDir::fromNativeSeparators(QString::fromUtf16((ushort*)archive_entry_pathname_w(aentry))));
#else
- e->setProperty("fileName", QDir::fromNativeSeparators(QString::fromWCharArray(archive_entry_pathname_w(aentry))));
+ e->setProperty("fullPath", QDir::fromNativeSeparators(QString::fromWCharArray(archive_entry_pathname_w(aentry))));
#endif
const QString owner = QString::fromLatin1(archive_entry_uname(aentry));
diff --git a/plugins/libarchive/libarchiveplugin.h b/plugins/libarchive/libarchiveplugin.h
index 77a319a..9661efa 100644
--- a/plugins/libarchive/libarchiveplugin.h
+++ b/plugins/libarchive/libarchiveplugin.h
@@ -28,6 +28,7 @@
#define LIBARCHIVEPLUGIN_H
#include "kerfuffle/archiveinterface.h"
+#include "kerfuffle/archiveentry.h"
#include <archive.h>
@@ -45,10 +46,10 @@ public:
virtual bool list() Q_DECL_OVERRIDE;
virtual bool doKill() Q_DECL_OVERRIDE;
- virtual bool copyFiles(const QVariantList& files, const QString& destinationDirectory, const ExtractionOptions& options) Q_DECL_OVERRIDE;
+ virtual bool copyFiles(const QList<Archive::Entry*>& files, const QString& destinationDirectory, const ExtractionOptions& options) Q_DECL_OVERRIDE;
- virtual bool addFiles(const QStringList& files, const CompressionOptions& options) Q_DECL_OVERRIDE;
- virtual bool deleteFiles(const QList<QVariant>& files) Q_DECL_OVERRIDE;
+ virtual bool addFiles(const QList<Archive::Entry*>& files, const CompressionOptions& options) Q_DECL_OVERRIDE;
+ virtual bool deleteFiles(const QList<Archive::Entry*>& files) Q_DECL_OVERRIDE;
virtual bool addComment(const QString& comment) Q_DECL_OVERRIDE;
virtual bool testArchive() Q_DECL_OVERRIDE;
diff --git a/plugins/libarchive/readwritelibarchiveplugin.cpp b/plugins/libarchive/readwritelibarchiveplugin.cpp
index 565bea9..dd13b3a 100644
--- a/plugins/libarchive/readwritelibarchiveplugin.cpp
+++ b/plugins/libarchive/readwritelibarchiveplugin.cpp
@@ -26,9 +26,6 @@
*/
#include "readwritelibarchiveplugin.h"
-#include "ark_debug.h"
-
-#include <archive_entry.h>
#include <KLocalizedString>
#include <KPluginFactory>
@@ -48,7 +45,7 @@ ReadWriteLibarchivePlugin::~ReadWriteLibarchivePlugin()
{
}
-bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const CompressionOptions& options)
+bool ReadWriteLibarchivePlugin::addFiles(const QList<Archive::Entry*>& files, const CompressionOptions& options)
{
qCDebug(ARK) << "Adding" << files.size() << "entries with CompressionOptions" << options;
@@ -220,20 +217,21 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
// First write the new files.
qCDebug(ARK) << "Writing new entries";
int no_entries = 0;
- foreach(const QString& selectedFile, files) {
+ foreach(Archive::Entry *selectedFile, files) {
if (m_abortOperation) {
break;
}
- if (!writeFile(selectedFile, arch_writer.data())) {
+ if (!writeFile(selectedFile->property("fullPath").toString(), arch_writer.data())) {
return false;
}
no_entries++;
// For directories, write all subfiles/folders.
- if (QFileInfo(selectedFile).isDir()) {
- QDirIterator it(selectedFile,
+ const QString &fullPath = selectedFile->property("fullPath").toString();
+ if (QFileInfo(fullPath).isDir()) {
+ QDirIterator it(fullPath,
QDir::AllEntries | QDir::Readable |
QDir::Hidden | QDir::NoDotAndDotDot,
QDirIterator::Subdirectories);
@@ -320,7 +318,7 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
return true;
}
-bool ReadWriteLibarchivePlugin::deleteFiles(const QVariantList& files)
+bool ReadWriteLibarchivePlugin::deleteFiles(const QList<Archive::Entry*>& files)
{
qCDebug(ARK) << "Deleting" << files.size() << "entries";
@@ -403,13 +401,14 @@ bool ReadWriteLibarchivePlugin::deleteFiles(const QVariantList& files)
// Copy old elements from previous archive to new archive.
int no_entries = 0;
+ QStringList filePaths = entryFullPaths(files);
while (archive_read_next_header(arch_reader.data(), &entry) == ARCHIVE_OK) {
- const QString entryName = QFile::decodeName(archive_entry_pathname(entry));
+ QString file = QFile::decodeName(archive_entry_pathname(entry));
- if (files.contains(entryName)) {
+ if (filePaths.contains(file)) {
archive_read_data_skip(arch_reader.data());
- emit entryRemoved(entryName);
+ emit entryRemoved(file);
no_entries++;
continue;
}
@@ -427,7 +426,7 @@ bool ReadWriteLibarchivePlugin::deleteFiles(const QVariantList& files)
qCCritical(ARK) << "archive_write_header() has returned" << returnCode
<< "with errno" << archive_errno(arch_writer.data());
emit error(xi18nc("@info", "Compression failed while processing:<nl/>"
- "<filename>%1</filename><nl/><nl/>Operation aborted.", entryName));
+ "<filename>%1</filename><nl/><nl/>Operation aborted.", file));
return false;
default:
qCDebug(ARK) << "archive_writer_header() has returned" << returnCode
diff --git a/plugins/libarchive/readwritelibarchiveplugin.h b/plugins/libarchive/readwritelibarchiveplugin.h
index c46482a..1fb9938 100644
--- a/plugins/libarchive/readwritelibarchiveplugin.h
+++ b/plugins/libarchive/readwritelibarchiveplugin.h
@@ -42,8 +42,8 @@ public:
explicit ReadWriteLibarchivePlugin(QObject *parent, const QVariantList& args);
~ReadWriteLibarchivePlugin();
- bool addFiles(const QStringList& files, const CompressionOptions& options) Q_DECL_OVERRIDE;
- bool deleteFiles(const QVariantList& files) Q_DECL_OVERRIDE;
+ bool addFiles(const QList<Archive::Entry*>& files, const CompressionOptions& options) Q_DECL_OVERRIDE;
+ bool deleteFiles(const QList<Archive::Entry*>& files) Q_DECL_OVERRIDE;
private:
bool writeFile(const QString& relativeName, struct archive* arch);
diff --git a/plugins/libsinglefileplugin/singlefileplugin.cpp b/plugins/libsinglefileplugin/singlefileplugin.cpp
index 2c1eb04..fa7d2f0 100644
--- a/plugins/libsinglefileplugin/singlefileplugin.cpp
+++ b/plugins/libsinglefileplugin/singlefileplugin.cpp
@@ -44,7 +44,7 @@ LibSingleFileInterface::~LibSingleFileInterface()
{
}
-bool LibSingleFileInterface::copyFiles(const QList<QVariant>& files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options)
+bool LibSingleFileInterface::copyFiles(const QList<Kerfuffle::Archive::Entry*> &files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options)
{
Q_UNUSED(files)
Q_UNUSED(options)
@@ -105,8 +105,8 @@ bool LibSingleFileInterface::list()
{
qCDebug(ARK) << "Listing archive contents";
- Kerfuffle::Archive::Entry *e = new Kerfuffle::Archive::Entry(Q_NULLPTR);
- e->setProperty("fileName", uncompressedFileName());
+ Kerfuffle::Archive::Entry *e = new Kerfuffle::Archive::Entry();
+ e->setProperty("fullPath", uncompressedFileName());
emit entry(e);
return true;
diff --git a/plugins/libsinglefileplugin/singlefileplugin.h b/plugins/libsinglefileplugin/singlefileplugin.h
index bbc32ca..29d2a92 100644
--- a/plugins/libsinglefileplugin/singlefileplugin.h
+++ b/plugins/libsinglefileplugin/singlefileplugin.h
@@ -27,6 +27,7 @@
#define SINGLEFILEPLUGIN_H
#include "kerfuffle/archiveinterface.h"
+#include "kerfuffle/archiveentry.h"
class LibSingleFileInterface : public Kerfuffle::ReadOnlyArchiveInterface
{
@@ -38,7 +39,7 @@ public:
virtual bool list() Q_DECL_OVERRIDE;
virtual bool testArchive() Q_DECL_OVERRIDE;
- virtual bool copyFiles(const QList<QVariant>& files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options) Q_DECL_OVERRIDE;
+ virtual bool copyFiles(const QList<Kerfuffle::Archive::Entry*> &files, const QString& destinationDirectory, const Kerfuffle::ExtractionOptions& options) Q_DECL_OVERRIDE;
protected:
const QString uncompressedFileName() const;