Commit 0f4ae19b authored by Ragnar Thomsen's avatar Ragnar Thomsen

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:
parent 07269ec7
......@@ -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()) {
......
......@@ -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();
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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));
......
......@@ -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>
......
......@@ -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";
......
......@@ -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;
......
......@@ -60,7 +60,6 @@ private:
bool m_isUnrar5;
bool m_isPasswordProtected;
bool m_isMultiVolume;
bool m_isSolid;
int m_remainingIgnoreLines;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment