[kde-doc-english] [ark] /: Detect multi-volume archives and show info in PropertiesDialog

Ragnar Thomsen rthomsen6 at gmail.com
Sat Jul 16 17:51:13 UTC 2016


Git commit 0f4ae19b09680f94e328dd71449604187da7de5b by Ragnar Thomsen.
Committed on 16/07/2016 at 17:46.
Pushed by rthomsen into branch 'master'.

Detect multi-volume archives and show info in PropertiesDialog

Two variables were added to ReadOnlyArchiveInterface: A boolean
describing whether the archive is multi-volume and an int used for
storing number of volumes. Two corresponding Q_PROPERTY's were added to
Archive which fetch the info from ReadOnlyArchiveInterface.

The detection of multi-volume archives was fixed in cli7z.

The information is displayed in PropertiesDialog and will be used when
implementing support for creating multi-volume archives.

GUI:

M  +10   -0    kerfuffle/archive_kerfuffle.cpp
M  +4    -0    kerfuffle/archive_kerfuffle.h
M  +12   -0    kerfuffle/archiveinterface.cpp
M  +5    -0    kerfuffle/archiveinterface.h
M  +1    -0    kerfuffle/propertiesdialog.cpp
M  +32   -18   kerfuffle/propertiesdialog.ui
M  +2    -0    plugins/cli7zplugin/cliplugin.cpp
M  +11   -6    plugins/clirarplugin/cliplugin.cpp
M  +0    -1    plugins/clirarplugin/cliplugin.h

http://commits.kde.org/ark/0f4ae19b09680f94e328dd71449604187da7de5b

diff --git a/kerfuffle/archive_kerfuffle.cpp b/kerfuffle/archive_kerfuffle.cpp
index 01cb8b1..5dc7085 100644
--- a/kerfuffle/archive_kerfuffle.cpp
+++ b/kerfuffle/archive_kerfuffle.cpp
@@ -227,6 +227,16 @@ bool Archive::hasComment() const
     return isValid() ? !comment().isEmpty() : false;
 }
 
+bool Archive::isMultiVolume() const
+{
+    return m_iface->isMultiVolume();
+}
+
+int Archive::numberOfVolumes() const
+{
+    return m_iface->numberOfVolumes();
+}
+
 Archive::EncryptionType Archive::encryptionType()
 {
     if (!isValid()) {
diff --git a/kerfuffle/archive_kerfuffle.h b/kerfuffle/archive_kerfuffle.h
index a510a03..9490e49 100644
--- a/kerfuffle/archive_kerfuffle.h
+++ b/kerfuffle/archive_kerfuffle.h
@@ -151,6 +151,8 @@ class KERFUFFLE_EXPORT Archive : public QObject
     Q_PROPERTY(QMimeType mimeType READ mimeType CONSTANT)
     Q_PROPERTY(bool isReadOnly READ isReadOnly CONSTANT)
     Q_PROPERTY(bool isSingleFolderArchive READ isSingleFolderArchive)
+    Q_PROPERTY(bool isMultiVolume READ isMultiVolume)
+    Q_PROPERTY(bool numberOfVolumes READ numberOfVolumes)
     Q_PROPERTY(EncryptionType encryptionType READ encryptionType)
     Q_PROPERTY(qulonglong numberOfFiles READ numberOfFiles)
     Q_PROPERTY(qulonglong numberOfFolders READ numberOfFolders)
@@ -174,6 +176,8 @@ public:
     bool isReadOnly() const;
     bool isSingleFolderArchive();
     bool hasComment() const;
+    bool isMultiVolume() const;
+    int numberOfVolumes() const;
     EncryptionType encryptionType();
     qulonglong numberOfFiles();
     qulonglong numberOfFolders();
diff --git a/kerfuffle/archiveinterface.cpp b/kerfuffle/archiveinterface.cpp
index ad4ae1e..d0b9767 100644
--- a/kerfuffle/archiveinterface.cpp
+++ b/kerfuffle/archiveinterface.cpp
@@ -41,6 +41,8 @@ ReadOnlyArchiveInterface::ReadOnlyArchiveInterface(QObject *parent, const QVaria
         , m_waitForFinishedSignal(false)
         , m_isHeaderEncryptionEnabled(false)
         , m_isCorrupt(false)
+        , m_isMultiVolume(false)
+        , m_numberOfVolumes(0)
 {
     qCDebug(ARK) << "Created read-only interface for" << args.first().toString();
     m_filename = args.first().toString();
@@ -113,6 +115,16 @@ bool ReadOnlyArchiveInterface::isCorrupt() const
     return m_isCorrupt;
 }
 
+bool ReadOnlyArchiveInterface::isMultiVolume() const
+{
+    return m_isMultiVolume;
+}
+
+int ReadOnlyArchiveInterface::numberOfVolumes() const
+{
+    return m_numberOfVolumes;
+}
+
 ReadWriteArchiveInterface::ReadWriteArchiveInterface(QObject *parent, const QVariantList & args)
         : ReadOnlyArchiveInterface(parent, args)
 {
diff --git a/kerfuffle/archiveinterface.h b/kerfuffle/archiveinterface.h
index ec20537..e61f5d6 100644
--- a/kerfuffle/archiveinterface.h
+++ b/kerfuffle/archiveinterface.h
@@ -62,6 +62,9 @@ public:
      */
     QString password() const;
 
+    bool isMultiVolume() const;
+    int numberOfVolumes() const;
+
     /**
      * Returns whether the file can only be read.
      *
@@ -126,6 +129,8 @@ protected:
     void setCorrupt(bool isCorrupt);
     bool isCorrupt() const;
     QString m_comment;
+    bool m_isMultiVolume;
+    int m_numberOfVolumes;
 
 private:
     QString m_filename;
diff --git a/kerfuffle/propertiesdialog.cpp b/kerfuffle/propertiesdialog.cpp
index 7f3c3e8..d8e81b6 100644
--- a/kerfuffle/propertiesdialog.cpp
+++ b/kerfuffle/propertiesdialog.cpp
@@ -64,6 +64,7 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Archive *archive, qulonglong
     m_ui->lblArchiveType->setText(archive->mimeType().comment());
     m_ui->lblMimetype->setText(archive->mimeType().name());
     m_ui->lblReadOnly->setText(archive->isReadOnly() ?  i18n("yes") : i18n("no"));
+    m_ui->lblMultiVolume->setText(archive->isMultiVolume() ? i18n("yes (%1 volumes)", archive->numberOfVolumes()) : i18n("no"));
     m_ui->lblHasComment->setText(archive->hasComment() ?  i18n("yes") : i18n("no"));
     m_ui->lblNumberOfEntries->setText(i18np("%1 file", "%1 files", numberOfFiles) +
                                       i18np(", %1 folder", ", %1 folders", numberOfFolders));
diff --git a/kerfuffle/propertiesdialog.ui b/kerfuffle/propertiesdialog.ui
index f329441..c5b8e69 100644
--- a/kerfuffle/propertiesdialog.ui
+++ b/kerfuffle/propertiesdialog.ui
@@ -101,98 +101,98 @@
           </property>
          </widget>
         </item>
-        <item row="5" column="0">
+        <item row="6" column="0">
          <widget class="QLabel" name="label_10">
           <property name="text">
            <string>Has comment:</string>
           </property>
          </widget>
         </item>
-        <item row="5" column="1">
+        <item row="6" column="1">
          <widget class="QLabel" name="lblHasComment">
           <property name="text">
            <string/>
           </property>
          </widget>
         </item>
-        <item row="6" column="0">
+        <item row="7" column="0">
          <widget class="QLabel" name="label_3">
           <property name="text">
            <string>Number of entries:</string>
           </property>
          </widget>
         </item>
-        <item row="6" column="1">
+        <item row="7" column="1">
          <widget class="QLabel" name="lblNumberOfEntries">
           <property name="text">
            <string/>
           </property>
          </widget>
         </item>
-        <item row="7" column="0">
+        <item row="8" column="0">
          <widget class="QLabel" name="label_5">
           <property name="text">
            <string>Unpacked size:</string>
           </property>
          </widget>
         </item>
-        <item row="7" column="1">
+        <item row="8" column="1">
          <widget class="QLabel" name="lblUnpackedSize">
           <property name="text">
            <string/>
           </property>
          </widget>
         </item>
-        <item row="8" column="0">
+        <item row="9" column="0">
          <widget class="QLabel" name="label_7">
           <property name="text">
            <string>Packed size:</string>
           </property>
          </widget>
         </item>
-        <item row="8" column="1">
+        <item row="9" column="1">
          <widget class="QLabel" name="lblPackedSize">
           <property name="text">
            <string/>
           </property>
          </widget>
         </item>
-        <item row="9" column="0">
+        <item row="10" column="0">
          <widget class="QLabel" name="label_9">
           <property name="text">
            <string>Compression ratio:</string>
           </property>
          </widget>
         </item>
-        <item row="9" column="1">
+        <item row="10" column="1">
          <widget class="QLabel" name="lblCompressionRatio">
           <property name="text">
            <string/>
           </property>
          </widget>
         </item>
-        <item row="10" column="0">
+        <item row="11" column="0">
          <widget class="QLabel" name="label_6">
           <property name="text">
            <string>Last modified:</string>
           </property>
          </widget>
         </item>
-        <item row="10" column="1">
+        <item row="11" column="1">
          <widget class="QLabel" name="lblLastModified">
           <property name="text">
            <string/>
           </property>
          </widget>
         </item>
-        <item row="11" column="0">
+        <item row="12" column="0">
          <widget class="QLabel" name="label_12">
           <property name="text">
            <string>MD5 hash:</string>
           </property>
          </widget>
         </item>
-        <item row="11" column="1">
+        <item row="12" column="1">
          <widget class="QLabel" name="lblMD5">
           <property name="text">
            <string/>
@@ -205,14 +205,14 @@
           </property>
          </widget>
         </item>
-        <item row="12" column="0">
+        <item row="13" column="0">
          <widget class="QLabel" name="label_13">
           <property name="text">
            <string>SHA-1 hash:</string>
           </property>
          </widget>
         </item>
-        <item row="12" column="1">
+        <item row="13" column="1">
          <widget class="QLabel" name="lblSHA1">
           <property name="text">
            <string/>
@@ -222,14 +222,14 @@
           </property>
          </widget>
         </item>
-        <item row="13" column="0">
+        <item row="14" column="0">
          <widget class="QLabel" name="label_14">
           <property name="text">
            <string>SHA-256 hash:</string>
           </property>
          </widget>
         </item>
-        <item row="13" column="1">
+        <item row="14" column="1">
          <widget class="QLabel" name="lblSHA256">
           <property name="text">
            <string notr="true">nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn</string>
@@ -239,6 +239,20 @@
           </property>
          </widget>
         </item>
+        <item row="5" column="0">
+         <widget class="QLabel" name="label_15">
+          <property name="text">
+           <string>Multi-volume:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="5" column="1">
+         <widget class="QLabel" name="lblMultiVolume">
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
        </layout>
       </item>
       <item>
diff --git a/plugins/cli7zplugin/cliplugin.cpp b/plugins/cli7zplugin/cliplugin.cpp
index 788890e..b154235 100644
--- a/plugins/cli7zplugin/cliplugin.cpp
+++ b/plugins/cli7zplugin/cliplugin.cpp
@@ -159,6 +159,8 @@ bool CliPlugin::readListLine(const QString& line)
                 m_archiveType = ArchiveTypeZip;
             } else if (type == QLatin1String("Rar")) {
                 m_archiveType = ArchiveTypeRar;
+            } else if (type == QLatin1String("Split")) {
+                m_isMultiVolume = true;
             } else {
                 // Should not happen
                 qCWarning(ARK) << "Unsupported archive type";
diff --git a/plugins/clirarplugin/cliplugin.cpp b/plugins/clirarplugin/cliplugin.cpp
index ab31ffb..90b0d4a 100644
--- a/plugins/clirarplugin/cliplugin.cpp
+++ b/plugins/clirarplugin/cliplugin.cpp
@@ -38,7 +38,6 @@ CliPlugin::CliPlugin(QObject *parent, const QVariantList& args)
         , m_parseState(ParseStateTitle)
         , m_isUnrar5(false)
         , m_isPasswordProtected(false)
-        , m_isMultiVolume(false)
         , m_isSolid(false)
         , m_remainingIgnoreLines(1) //The first line of UNRAR output is empty.
         , m_linesComment(0)
@@ -206,9 +205,12 @@ void CliPlugin::handleUnrar5Line(const QString &line) {
         // "Details: " indicates end of header.
         if (line.startsWith(QStringLiteral("Details: "))) {
             ignoreLines(1, ParseStateEntryDetails);
-            if (line.contains(QLatin1String("volume")) && !m_isMultiVolume) {
-                m_isMultiVolume = true;
-                qCDebug(ARK) << "Multi-volume archive detected";
+            if (line.contains(QLatin1String("volume"))) {
+                m_numberOfVolumes++;
+                if (!m_isMultiVolume) {
+                    m_isMultiVolume = true;
+                    qCDebug(ARK) << "Multi-volume archive detected";
+                }
             }
             if (line.contains(QLatin1String("solid")) && !m_isSolid) {
                 m_isSolid = true;
@@ -309,8 +311,11 @@ void CliPlugin::handleUnrar4Line(const QString &line) {
         if (rxCommentEnd.match(line).hasMatch()) {
 
             if (line.startsWith(QLatin1String("Volume")) && !m_isMultiVolume) {
-                m_isMultiVolume = true;
-                qCDebug(ARK) << "Multi-volume archive detected";
+                m_numberOfVolumes++;
+                if (!m_isMultiVolume) {
+                    m_isMultiVolume = true;
+                    qCDebug(ARK) << "Multi-volume archive detected";
+                }
             }
             if (line.startsWith(QLatin1String("Solid archive")) && !m_isSolid) {
                 m_isSolid = true;
diff --git a/plugins/clirarplugin/cliplugin.h b/plugins/clirarplugin/cliplugin.h
index dd98088..8687e19 100644
--- a/plugins/clirarplugin/cliplugin.h
+++ b/plugins/clirarplugin/cliplugin.h
@@ -60,7 +60,6 @@ private:
 
     bool m_isUnrar5;
     bool m_isPasswordProtected;
-    bool m_isMultiVolume;
     bool m_isSolid;
 
     int m_remainingIgnoreLines;


More information about the kde-doc-english mailing list