OSDN Git Service

62d8f7b1270224a7d2a071c99630ac27ee7c6866
[qt-creator-jp/qt-creator-jp.git] / src / plugins / analyzerbase / analyzerplugin.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
8 **
9 ** Contact: Nokia Corporation (qt-info@nokia.com)
10 **
11 ** No Commercial Usage
12 **
13 ** This file contains pre-release code and may not be distributed.
14 ** You may use this file in accordance with the terms and conditions
15 ** contained in the Technology Preview License Agreement accompanying
16 ** this package.
17 **
18 ** GNU Lesser General Public License Usage
19 **
20 ** Alternatively, this file may be used under the terms of the GNU Lesser
21 ** General Public License version 2.1 as published by the Free Software
22 ** Foundation and appearing in the file LICENSE.LGPL included in the
23 ** packaging of this file.  Please review the following information to
24 ** ensure the GNU Lesser General Public License version 2.1 requirements
25 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
26 **
27 ** In addition, as a special exception, Nokia gives you certain additional
28 ** rights.  These rights are described in the Nokia Qt LGPL Exception
29 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
30 **
31 ** If you have questions regarding the use of this file, please contact
32 ** Nokia at qt-info@nokia.com.
33 **
34 **************************************************************************/
35
36 #include "analyzerplugin.h"
37 #include "analyzerconstants.h"
38 #include "analyzermanager.h"
39 #include "analyzeroutputpane.h"
40
41 #include <coreplugin/imode.h>
42 #include <coreplugin/coreconstants.h>
43 #include <coreplugin/editormanager/editormanager.h>
44
45 #include <extensionsystem/pluginmanager.h>
46 #include <projectexplorer/task.h>
47 #include <projectexplorer/taskhub.h>
48
49 #include <QtCore/QtPlugin>
50 #include <QtGui/QMessageBox>
51 #include <QtGui/QMainWindow>
52 #include <QtGui/QApplication>
53
54 using namespace Analyzer;
55 using namespace Analyzer::Internal;
56
57
58 AnalyzerPlugin *AnalyzerPlugin::m_instance = 0;
59
60
61 // AnalyzerPluginPrivate ////////////////////////////////////////////////////
62 class AnalyzerPlugin::AnalyzerPluginPrivate
63 {
64 public:
65     AnalyzerPluginPrivate(AnalyzerPlugin *qq):
66         q(qq),
67         m_manager(0)
68     {}
69
70     void initialize(const QStringList &arguments, QString *errorString);
71
72     AnalyzerPlugin *q;
73     AnalyzerManager *m_manager;
74 };
75
76 void AnalyzerPlugin::AnalyzerPluginPrivate::initialize(const QStringList &arguments, QString *errorString)
77 {
78     Q_UNUSED(arguments)
79     Q_UNUSED(errorString)
80     AnalyzerOutputPane *outputPane =  new AnalyzerOutputPane;
81     q->addAutoReleasedObject(outputPane);
82     m_manager = new AnalyzerManager(outputPane, q);
83 }
84
85
86 // AnalyzerPlugin ////////////////////////////////////////////////////
87 AnalyzerPlugin::AnalyzerPlugin()
88     : d(new AnalyzerPluginPrivate(this))
89 {
90     m_instance = this;
91 }
92
93 AnalyzerPlugin::~AnalyzerPlugin()
94 {
95     // Unregister objects from the plugin manager's object pool
96     // Delete members
97     delete d;
98     m_instance = 0;
99 }
100
101 bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorString)
102 {
103     // Register objects in the plugin manager's object pool
104     // Load settings
105     // connect to other plugins' signals
106     // "In the initialize method, a plugin can be sure that the plugins it
107     //  depends on have initialized their members."
108
109     Q_UNUSED(arguments)
110     Q_UNUSED(errorString)
111
112     d->initialize(arguments, errorString);
113
114     // Task integration
115     ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
116     ProjectExplorer::TaskHub *hub = pm->getObject<ProjectExplorer::TaskHub>();
117     //: Category under which Analyzer tasks are listed in build issues view
118     hub->addCategory(QLatin1String(Constants::ANALYZERTASK_ID), tr("Analyzer"));
119
120     ///TODO: select last used tool or default tool
121 //     d->m_manager->selectTool(memcheckTool);
122
123     return true;
124 }
125
126 void AnalyzerPlugin::extensionsInitialized()
127 {
128     // Retrieve objects from the plugin manager's object pool
129     // "In the extensionsInitialized method, a plugin can be sure that all
130     //  plugins that depend on it are completely initialized."
131 }
132
133 ExtensionSystem::IPlugin::ShutdownFlag AnalyzerPlugin::aboutToShutdown()
134 {
135     d->m_manager->shutdown();
136     // Save settings
137     // Disconnect from signals that are not needed during shutdown
138     // Hide UI (if you add UI that is not in the main window directly)
139     return SynchronousShutdown;
140 }
141
142 AnalyzerPlugin *AnalyzerPlugin::instance()
143 {
144     return m_instance;
145 }
146
147 Q_EXPORT_PLUGIN(AnalyzerPlugin)