/* This file is part of KArchiveManager Copyright (C) 2018 Ivailo Monev This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2, as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KARCHIVEMANAGER_H #define KARCHIVEMANAGER_H #include #include #include #include class KArchiveModelPrivate; /*! Custom item model for displaying archives in tree views (@p QTreeView) Example: \code QTreeView view; KArchiveModel model; KArchive archive("/home/joe/archive.tar.gz"); view.setModel(model); model.loadArchive(&archive); \endcode @todo sorting by column values is borked */ class KArchiveModel : public QStandardItemModel { Q_OBJECT public: KArchiveModel(QObject *parent = nullptr); ~KArchiveModel(); //! @brief Load archive into the model bool loadArchive(const KArchive *archive); //! @brief Get path for index, propagates to parents to retrieve the full path QString path(const QModelIndex &index) const; /*! @brief Get paths for index, propagates to childs to retrieve all sub-paths. Usefull for obtaining the selected item paths for add, remove and extract operations */ QStringList paths(const QModelIndex &index) const; /*! @brief Get parent directory for index. Usefull for obtaining the current dir for add operations */ QString dir(const QModelIndex &index) const; Q_SIGNALS: //! @brief Signals load was started void loadStarted(); //! @brief Signals load was finished void loadFinished(); private Q_SLOTS: void slotLoadFinished(); private: KArchiveModelPrivate *d; }; #endif // KARCHIVEMANAGER_H