File indexing completed on 2024-04-28 04:34:23

0001 /***************************************************************************
0002  *   Copyright 2009 Sandro Andrade <sandroandrade@kde.org>                 *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU Library General Public License as       *
0006  *   published by the Free Software Foundation; either version 2 of the    *
0007  *   License, or (at your option) any later version.                       *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU Library General Public     *
0015  *   License along with this program; if not, write to the                 *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0018  ***************************************************************************/
0019 
0020 #ifndef KDEVCONTROLFLOWGRAPHVIEWPLUGIN_H
0021 #define KDEVCONTROLFLOWGRAPHVIEWPLUGIN_H
0022 
0023 #include <QVariant>
0024 #include <QList>
0025 
0026 #include <interfaces/iplugin.h>
0027 #include <interfaces/istatus.h>
0028 
0029 #include "controlflowgraphfiledialog.h"
0030 
0031 class KDevControlFlowGraphViewFactory;
0032 class QAction;
0033 
0034 namespace KDevelop
0035 {
0036     class IProject;
0037     class IDocument;
0038     class ParseJob;
0039     class ContextMenuExtension;
0040 }
0041 
0042 namespace KTextEditor
0043 {
0044     class View;
0045     class Document;
0046     class Cursor;
0047 }
0048 
0049 class ControlFlowGraphView;
0050 class DUChainControlFlow;
0051 class DotControlFlowGraph;
0052 class ControlFlowGraphFileDialog;
0053 
0054 using namespace KDevelop;
0055 
0056 class KDevControlFlowGraphViewPlugin : public KDevelop::IPlugin, public KDevelop::IStatus
0057 {
0058     Q_OBJECT
0059     Q_INTERFACES(KDevelop::IStatus)
0060 public:
0061     explicit KDevControlFlowGraphViewPlugin(QObject *, const QVariantList & = QVariantList());
0062     virtual ~KDevControlFlowGraphViewPlugin();
0063 
0064     virtual QString statusName() const;
0065     virtual void unload();
0066 
0067     void registerToolView(ControlFlowGraphView *view);
0068     void unRegisterToolView(ControlFlowGraphView *view);
0069     QPointer<ControlFlowGraphFileDialog> exportControlFlowGraph(ControlFlowGraphFileDialog::OpeningMode mode = ControlFlowGraphFileDialog::ConfigurationButtons);
0070 
0071     KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context);
0072     void generateControlFlowGraph();
0073     void generateClassControlFlowGraph();
0074     void generateProjectControlFlowGraph();
0075     void requestAbort();
0076 public Q_SLOTS:
0077     void projectOpened(KDevelop::IProject* project);
0078     void projectClosed(KDevelop::IProject* project);
0079     void parseJobFinished(KDevelop::ParseJob* parseJob);
0080     void textDocumentCreated(KDevelop::IDocument *document);
0081     void viewCreated(KTextEditor::Document *document, KTextEditor::View *view);
0082     void viewDestroyed(QObject *object);
0083     void focusIn(KTextEditor::View *view);
0084     void cursorPositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &cursor);
0085 
0086     void refreshActiveToolView();
0087     void slotExportControlFlowGraph(bool value);
0088     void slotExportClassControlFlowGraph(bool value);
0089     void slotExportProjectControlFlowGraph(bool value);
0090     void setActiveToolView(ControlFlowGraphView *activeToolView);
0091     void generationDone(KJob *job);
0092     void exportGraph();
0093 Q_SIGNALS:
0094     // Implementations of IStatus signals
0095     void clearMessage(KDevelop::IStatus*);
0096     void showMessage(KDevelop::IStatus*, const QString &message, int timeout = 0);
0097     void hideProgress(KDevelop::IStatus*);
0098     void showProgress(KDevelop::IStatus*, int minimum, int maximum, int value);
0099     void showErrorMessage(const QString&, int);
0100 private:
0101     void configureDuchainControlFlow(DUChainControlFlow *duchainControlFlow, DotControlFlowGraph *dotControlFlowGraph, ControlFlowGraphFileDialog *fileDialog);
0102 
0103     ControlFlowGraphView *activeToolView();
0104     KDevControlFlowGraphViewFactory *m_toolViewFactory;
0105     QList<ControlFlowGraphView *> m_toolViews;
0106     ControlFlowGraphView *m_activeToolView;
0107     QAction *m_exportControlFlowGraph;
0108     QAction *m_exportClassControlFlowGraph;
0109     QAction *m_exportProjectControlFlowGraph;
0110     
0111     IndexedDeclaration m_ideclaration;
0112     IProject *m_project;
0113     
0114     QPointer<DUChainControlFlow> m_duchainControlFlow;
0115     QPointer<DotControlFlowGraph> m_dotControlFlowGraph;
0116 
0117     ControlFlowGraphFileDialog *m_fileDialog;
0118 
0119     bool m_abort;
0120 };
0121 
0122 #endif