File indexing completed on 2024-06-16 05:00:37

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QDialog>
0010 class QTreeWidget;
0011 class QTreeWidgetItem;
0012 class KArchiveEntry;
0013 class KArchiveDirectory;
0014 class QPushButton;
0015 class KZip;
0016 class QTemporaryDir;
0017 class ShowArchiveStructureDialog : public QDialog
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit ShowArchiveStructureDialog(const QString &filename, QWidget *parent = nullptr);
0022     ~ShowArchiveStructureDialog() override;
0023 
0024     enum File { FullPath = Qt::UserRole + 1 };
0025 
0026 private:
0027     void slotExportAsLogFile();
0028     [[nodiscard]] bool fillTree();
0029     void readConfig();
0030     void writeConfig();
0031     void slotItemClicked(QTreeWidgetItem *item, int column);
0032     void addSubItems(const QString &topLevelPath, QTreeWidgetItem *parent, const KArchiveEntry *entry, int indent, const QString &fullpath = QString());
0033     void slotExtractFile();
0034     void slotOpenFile();
0035 
0036     [[nodiscard]] bool searchArchiveElement(const QString &path, const KArchiveDirectory *topDirectory, const QString &name);
0037     QTreeWidgetItem *addTopItem(const QString &name);
0038     QTreeWidgetItem *addItem(QTreeWidgetItem *parent, const QString &name, const QString &fillFullPath);
0039     const QString mFileName;
0040     QString mLogFile;
0041     QTreeWidget *const mTreeWidget;
0042     QPushButton *const mExtractFile;
0043     QPushButton *const mOpenFile;
0044     KZip *mZip = nullptr;
0045     QTemporaryDir *mTempDir = nullptr;
0046 };