summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <elvis.angelaccio@kde.org>2016-10-17 21:19:13 (GMT)
committerElvis Angelaccio <elvis.angelaccio@kde.org>2016-10-17 21:20:22 (GMT)
commit768117e66f37b240ae845e0f69eb781ad3c4f075 (patch)
tree3ba4e76df9077d963485b983e96a898d16b4f064
parent34a46359d27d472c81a08de712bd1fddd8cfed9a (diff)
Move entryRemoved signal to the read-write interface
Read-only interfaces cannot remove entries, so they should never emit this signal. Differential Revision: D3090
-rw-r--r--kerfuffle/archiveinterface.cpp15
-rw-r--r--kerfuffle/archiveinterface.h8
-rw-r--r--kerfuffle/jobs.cpp6
3 files changed, 19 insertions, 10 deletions
diff --git a/kerfuffle/archiveinterface.cpp b/kerfuffle/archiveinterface.cpp
index b2fa260..d9e7090 100644
--- a/kerfuffle/archiveinterface.cpp
+++ b/kerfuffle/archiveinterface.cpp
@@ -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
diff --git a/kerfuffle/archiveinterface.h b/kerfuffle/archiveinterface.h
index b563758..afb19ed 100644
--- a/kerfuffle/archiveinterface.h
+++ b/kerfuffle/archiveinterface.h
@@ -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
diff --git a/kerfuffle/jobs.cpp b/kerfuffle/jobs.cpp
index aa88baf..cddfbcc 100644
--- a/kerfuffle/jobs.cpp
+++ b/kerfuffle/jobs.cpp
@@ -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()