Commit 768117e6 authored by Elvis Angelaccio's avatar Elvis Angelaccio
Browse files

Move entryRemoved signal to the read-write interface

Read-only interfaces cannot remove entries, so they should never emit this signal.

Differential Revision: D3090
parent 34a46359
......@@ -49,7 +49,6 @@ ReadOnlyArchiveInterface::ReadOnlyArchiveInterface(QObject *parent, const QVaria
qCDebug(ARK) << "Created read-only interface for" << args.first().toString();
m_filename = args.first().toString();
connect(this, &ReadOnlyArchiveInterface::entry, this, &ReadOnlyArchiveInterface::onEntry);
connect(this, &ReadOnlyArchiveInterface::entryRemoved, this, &ReadOnlyArchiveInterface::onEntryRemoved);
}
ReadOnlyArchiveInterface::~ReadOnlyArchiveInterface()
......@@ -62,12 +61,6 @@ void ReadOnlyArchiveInterface::onEntry(Archive::Entry *archiveEntry)
m_numberOfEntries++;
}
void ReadOnlyArchiveInterface::onEntryRemoved(const QString &path)
{
Q_UNUSED(path)
m_numberOfEntries--;
}
QString ReadOnlyArchiveInterface::filename() const
{
return m_filename;
......@@ -155,6 +148,8 @@ ReadWriteArchiveInterface::ReadWriteArchiveInterface(QObject *parent, const QVar
: ReadOnlyArchiveInterface(parent, args)
{
qCDebug(ARK) << "Created read-write interface for" << args.first().toString();
connect(this, &ReadWriteArchiveInterface::entryRemoved, this, &ReadWriteArchiveInterface::onEntryRemoved);
}
ReadWriteArchiveInterface::~ReadWriteArchiveInterface()
......@@ -280,4 +275,10 @@ int ReadOnlyArchiveInterface::numberOfEntries() const
return m_numberOfEntries;
}
void ReadWriteArchiveInterface::onEntryRemoved(const QString &path)
{
Q_UNUSED(path)
m_numberOfEntries--;
}
} // namespace Kerfuffle
......@@ -162,7 +162,6 @@ signals:
void cancelled();
void error(const QString &message, const QString &details = QString());
void entry(Archive::Entry *archiveEntry);
void entryRemoved(const QString &path);
void progress(double progress);
void info(const QString &info);
void finished(bool result);
......@@ -194,7 +193,6 @@ private:
private slots:
void onEntry(Archive::Entry *archiveEntry);
void onEntryRemoved(const QString &path);
};
class KERFUFFLE_EXPORT ReadWriteArchiveInterface: public ReadOnlyArchiveInterface
......@@ -215,6 +213,12 @@ public:
virtual bool copyFiles(const QVector<Archive::Entry*> &files, Archive::Entry *destination, const CompressionOptions& options) = 0;
virtual bool deleteFiles(const QVector<Archive::Entry*> &files) = 0;
virtual bool addComment(const QString &comment) = 0;
signals:
void entryRemoved(const QString &path);
private slots:
void onEntryRemoved(const QString &path);
};
} // namespace Kerfuffle
......
......@@ -156,11 +156,15 @@ void Job::connectToArchiveInterfaceSignals()
connect(archiveInterface(), &ReadOnlyArchiveInterface::cancelled, this, &Job::onCancelled);
connect(archiveInterface(), &ReadOnlyArchiveInterface::error, this, &Job::onError);
connect(archiveInterface(), &ReadOnlyArchiveInterface::entry, this, &Job::onEntry);
connect(archiveInterface(), &ReadOnlyArchiveInterface::entryRemoved, this, &Job::onEntryRemoved);
connect(archiveInterface(), &ReadOnlyArchiveInterface::progress, this, &Job::onProgress);
connect(archiveInterface(), &ReadOnlyArchiveInterface::info, this, &Job::onInfo);
connect(archiveInterface(), &ReadOnlyArchiveInterface::finished, this, &Job::onFinished);
connect(archiveInterface(), &ReadOnlyArchiveInterface::userQuery, this, &Job::onUserQuery);
auto readWriteInterface = qobject_cast<ReadWriteArchiveInterface*>(archiveInterface());
if (readWriteInterface) {
connect(readWriteInterface, &ReadWriteArchiveInterface::entryRemoved, this, &Job::onEntryRemoved);
}
}
void Job::onCancelled()
......
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