OSDN Git Service

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