File indexing completed on 2024-05-19 08:30:31
0001 /* 0002 SPDX-FileCopyrightText: 2005 Adam Treat <treat@kde.org> 0003 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KDEVPLATFORM_PLUGIN_KDEVDOCUMENTVIEW_H 0009 #define KDEVPLATFORM_PLUGIN_KDEVDOCUMENTVIEW_H 0010 0011 #include <QTreeView> 0012 #include <QUrl> 0013 0014 class QSortFilterProxyModel; 0015 class QAction; 0016 class KDevDocumentViewPlugin; 0017 class KDevDocumentModel; 0018 class KDevDocumentViewDelegate; 0019 class KDevDocumentSelection; 0020 class KDevFileItem; 0021 class KDevCategoryItem; 0022 namespace KDevelop 0023 { 0024 class IDocument; 0025 class IProject; 0026 } 0027 0028 0029 class KDevDocumentView: public QTreeView 0030 { 0031 Q_OBJECT 0032 public: 0033 explicit KDevDocumentView( KDevDocumentViewPlugin *plugin, QWidget *parent ); 0034 ~KDevDocumentView() override; 0035 0036 KDevDocumentViewPlugin *plugin() const; 0037 0038 Q_SIGNALS: 0039 void activateURL( const QUrl &url ); 0040 0041 public Q_SLOTS: 0042 void opened( KDevelop::IDocument* document ); 0043 0044 private Q_SLOTS: 0045 void activated( KDevelop::IDocument* document ); 0046 void saved( KDevelop::IDocument* document ); 0047 void closed( KDevelop::IDocument* document ); 0048 void contentChanged( KDevelop::IDocument* document ); 0049 void stateChanged( KDevelop::IDocument* document ); 0050 void documentUrlChanged( KDevelop::IDocument* document ); 0051 void updateCategoryItem( KDevCategoryItem *item ); 0052 void updateProjectPaths(); 0053 0054 void saveSelected(); 0055 void reloadSelected(); 0056 void closeSelected(); 0057 void closeUnselected(); 0058 0059 protected: 0060 void mousePressEvent( QMouseEvent * event ) override; 0061 void contextMenuEvent( QContextMenuEvent * event ) override; 0062 void drawBranches(QPainter* painter, const QRect& rect, 0063 const QModelIndex& index) const override; 0064 0065 private: 0066 template<typename F> void visitItems(F, bool selectedItems); 0067 bool selectedDocHasChanges(); 0068 void updateSelectedDocs(); 0069 void appendActions(QMenu* menu, const QList< QAction* >& actions); 0070 0071 private: 0072 KDevDocumentViewPlugin *m_plugin; 0073 KDevDocumentModel *m_documentModel; 0074 KDevDocumentSelection* m_selectionModel; 0075 QSortFilterProxyModel* m_proxy; 0076 KDevDocumentViewDelegate* m_delegate; 0077 QHash< KDevelop::IDocument*, KDevFileItem* > m_doc2index; 0078 QList<QUrl> m_selectedDocs; // used for ctx menu 0079 QList<QUrl> m_unselectedDocs; // used for ctx menu 0080 0081 friend class KDevDocumentViewPluginFactory; // to connect to the private slots stateChanged and documentUrlChanged 0082 }; 0083 0084 #endif // KDEVPLATFORM_PLUGIN_KDEVDOCUMENTVIEW_H 0085