File indexing completed on 2024-04-28 05:49:09

0001 /*  This file is part of the Kate project.
0002  *
0003  *  SPDX-FileCopyrightText: 2010 Christoph Cullmann <cullmann@kde.org>
0004  *
0005  *  SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #pragma once
0009 
0010 #include <QTreeView>
0011 
0012 class KateProjectPluginView;
0013 class KateProject;
0014 
0015 /**
0016  * A tree like view of project content.
0017  */
0018 class KateProjectViewTree : public QTreeView
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     /**
0024      * construct project view for given project
0025      * @param pluginView our plugin view
0026      * @param project project this view is for
0027      */
0028     KateProjectViewTree(KateProjectPluginView *pluginView, KateProject *project);
0029 
0030     /**
0031      * deconstruct project
0032      */
0033     ~KateProjectViewTree() override;
0034 
0035     /**
0036      * our project.
0037      * @return project
0038      */
0039     KateProject *project() const
0040     {
0041         return m_project;
0042     }
0043 
0044     /**
0045      * Select given file in the view.
0046      * @param file select this file in the view, will be shown if invisible
0047      */
0048     void selectFile(const QString &file);
0049 
0050     /**
0051      * Open the selected document, if any.
0052      */
0053     void openSelectedDocument();
0054 
0055     /**
0056      * Add a new file
0057      */
0058     void addFile(const QModelIndex &idx, const QString &fileName);
0059 
0060     /**
0061      * Add a new directory
0062      */
0063     void addDirectory(const QModelIndex &idx, const QString &name);
0064 
0065     /**
0066      * remove a file, the function isn't closing document before removing'
0067      */
0068     void removeFile(const QModelIndex &idx, const QString &fullFilePath);
0069 
0070     /**
0071      * Open project terminal at location dirPath
0072      */
0073     void openTerminal(const QString &dirPath);
0074 
0075 private Q_SLOTS:
0076     /**
0077      * item got clicked, do stuff, like open document
0078      * @param index model index of clicked item
0079      */
0080     void slotClicked(const QModelIndex &index);
0081 
0082     /**
0083      * Triggered on model changes.
0084      * This includes the files list, itemForFile mapping!
0085      */
0086     void slotModelChanged();
0087 
0088 protected:
0089     /**
0090      * Create matching context menu.
0091      * @param event context menu event
0092      */
0093     void contextMenuEvent(QContextMenuEvent *event) override;
0094 
0095 private:
0096     /**
0097      * our plugin view
0098      */
0099     KateProjectPluginView *m_pluginView;
0100 
0101     /**
0102      * our project
0103      */
0104     KateProject *m_project;
0105 };