From 21296a64594729a59360131270beaadf61cbced0 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sat, 30 May 2020 14:59:38 +0200 Subject: Allow creation of file using addFile() in ArchiveFileTree. --- src/archivefiletree.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/archivefiletree.cpp') diff --git a/src/archivefiletree.cpp b/src/archivefiletree.cpp index 6ba06924..37d80537 100644 --- a/src/archivefiletree.cpp +++ b/src/archivefiletree.cpp @@ -83,14 +83,6 @@ protected: public: // Overrides: - /** - * @override - */ - std::shared_ptr addFile(QString path) override { - // Cannot add file to an archive. - throw UnsupportedOperationException(QObject::tr("Cannot create file within an archive.")); - } - /** * */ @@ -118,7 +110,9 @@ public: // Overrides: } else { const ArchiveFileEntry& archiveFileEntry = dynamic_cast(*entry); - data[archiveFileEntry.m_Index]->addOutputFileName(path + archiveFileEntry.name()); + if (archiveFileEntry.m_Index != -1) { + data[archiveFileEntry.m_Index]->addOutputFileName(path + archiveFileEntry.name()); + } } } } @@ -135,18 +129,20 @@ public: // Overrides: protected: - /* - * Overriding this to create custom FileTreeEntry with index set to -1. No need to - * override makeFile() since we addFile is overriden. Note that this will not be - * used to create existing tree since we do this manually in doPopulate. + /** + * Overriding makeDirectory and makeFile to create file tree or file entry with index -1. * - * @override */ virtual std::shared_ptr makeDirectory( std::shared_ptr parent, QString name) const override { return std::make_shared(parent, name, -1, std::vector{}); } + virtual std::shared_ptr makeFile( + std::shared_ptr parent, QString name) const override { + return std::make_shared(parent, name, -1); + } + virtual bool doPopulate(std::shared_ptr parent, std::vector>& entries) const override { // Sort by name: -- cgit v1.3.1