File indexing completed on 2025-01-05 05:22:00

0001 /*
0002  * Copyright (c) 2018 Sune Vuorela <sune@vuorela.dk>
0003  *
0004  * Permission is hereby granted, free of charge, to any person
0005  * obtaining a copy of this software and associated documentation
0006  * files (the "Software"), to deal in the Software without
0007  * restriction, including without limitation the rights to use,
0008  * copy, modify, merge, publish, distribute, sublicense, and/or sell
0009  * copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following
0011  * conditions:
0012  *
0013  * The above copyright notice and this permission notice shall be
0014  * included in all copies or substantial portions of the Software.
0015  *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0017  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
0018  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0019  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
0020  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
0021  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0022  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0023  * OTHER DEALINGS IN THE SOFTWARE.
0024  */
0025 #pragma once
0026 #include <QWidget>
0027 #include <memory>
0028 
0029 class QTreeView;
0030 class QAbstractItemModel;
0031 /**
0032  * Generic pane wrapping a QTreeView
0033  */
0034 class TreePane : public QWidget
0035 {
0036     Q_OBJECT
0037 public:
0038     TreePane(QWidget* parent = nullptr);
0039     /**
0040      * Sets the model to the given object.
0041      * \param model The model
0042      */
0043     void setModel(const std::shared_ptr<QAbstractItemModel>& model);
0044     ~TreePane();
0045 Q_SIGNALS:
0046     /**
0047      * Emitted when a file is selected in this pane.
0048      *
0049      * \param path The selected file
0050      */
0051     void fileSelected(const QString& path);
0052 private:
0053     std::shared_ptr<QAbstractItemModel> m_model;
0054     QTreeView* m_view;
0055 };