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 "kateproject.h"
0011 #include "kateprojectviewtree.h"
0012 
0013 #include <QTimer>
0014 
0015 class KLineEdit;
0016 class KateProjectPluginView;
0017 class BranchesDialog;
0018 class QToolButton;
0019 class QStackedWidget;
0020 class FileHistoryWidget;
0021 
0022 /**
0023  * Class representing a view of a project.
0024  * A tree like view of project content.
0025  */
0026 class KateProjectView : public QWidget
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     /**
0032      * construct project view for given project
0033      * @param pluginView our plugin view
0034      * @param project project this view is for
0035      */
0036     KateProjectView(KateProjectPluginView *pluginView, KateProject *project);
0037 
0038     /**
0039      * deconstruct project
0040      */
0041     ~KateProjectView() override;
0042 
0043     /**
0044      * our project.
0045      * @return project
0046      */
0047     KateProject *project() const
0048     {
0049         return m_project;
0050     }
0051 
0052     /**
0053      * Select given file in the view.
0054      * @param file select this file in the view, will be shown if invisible
0055      */
0056     void selectFile(const QString &file);
0057 
0058     /**
0059      * Open the selected document, if any.
0060      */
0061     void openSelectedDocument();
0062 
0063 private Q_SLOTS:
0064     /**
0065      * React on filter change
0066      * @param filterText new filter text
0067      */
0068     void filterTextChanged();
0069 
0070     /**
0071      * On project model change, check if project
0072      * is a git repo and then show/hide the branch
0073      * button accordingly
0074      */
0075     void checkAndRefreshGit();
0076 
0077 private:
0078     /**
0079      * our plugin view
0080      */
0081     KateProjectPluginView *m_pluginView;
0082 
0083     /**
0084      * our project
0085      */
0086     KateProject *m_project;
0087 
0088     /**
0089      * our tree view
0090      */
0091     KateProjectViewTree *m_treeView;
0092 
0093     /**
0094      * filter
0095      */
0096     KLineEdit *m_filter;
0097 
0098     /**
0099      * watches for changes to .git/HEAD
0100      * If this is non-empty, we registered that file in the project watcher
0101      */
0102     QString m_branchChangedWatcherFile;
0103 
0104     /**
0105      * filter timer
0106      */
0107     QTimer m_filterStartTimer;
0108 };