Commit 0cc448f7 authored by Mike McQuaid's avatar Mike McQuaid Committed by hjk

Add analyzer base plugin.

Merge-request: 260
Reviewed-by: default avatarhjk <qtc-committer@nokia.com>
parent 3b703588
<plugin name=\"AnalyzerBase\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2011 Nokia Corporation</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</license>
<category>Code Analyzer</category>
<description>Code Analyzer Base Plugin</description>
<url>http://qt.nokia.com</url>
<dependencyList>
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
include(analyzerbase_dependencies.pri)
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
LIBS *= -l$$qtLibraryName(AnalyzerBase)
TEMPLATE = lib
TARGET = AnalyzerBase
DEFINES += ANALYZER_LIBRARY
include(../../qtcreatorplugin.pri)
include(analyzerbase_dependencies.pri)
QT += network
# AnalyzerBase files
SOURCES += \
ianalyzerengine.cpp \
ianalyzertool.cpp \
analyzerplugin.cpp \
analyzerruncontrol.cpp \
analyzermanager.cpp \
analyzersettings.cpp \
analyzeroptionspage.cpp \
analyzerrunconfigwidget.cpp
HEADERS += \
ianalyzerengine.h \
ianalyzertool.h \
analyzerbase_global.h \
analyzerconstants.h \
analyzerplugin.h \
analyzerruncontrol.h \
analyzermanager.h \
analyzersettings.h \
analyzeroptionspage.h \
analyzerrunconfigwidget.h
RESOURCES += \
analyzerbase.qrc
<RCC>
<qresource prefix="/">
<file>images/analyzer_mode.png</file>
<file>images/analyzer_category.png</file>
<file>images/analyzer_start_small.png</file>
</qresource>
</RCC>
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/projectexplorer/projectexplorer.pri)
\ No newline at end of file
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANALYZERBASE_GLOBAL_H
#define ANALYZERBASE_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(ANALYZER_LIBRARY)
# define ANALYZER_EXPORT Q_DECL_EXPORT
#else
# define ANALYZER_EXPORT Q_DECL_IMPORT
#endif
#endif // ANALYZERBASE_GLOBAL_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANALYZERCONSTANTS_H
#define ANALYZERCONSTANTS_H
#include <QtGlobal>
namespace Analyzer {
namespace Constants {
// modes and their priorities
const char * const MODE_ANALYZE = "Analyzer.Mode.Analyze";
const int P_MODE_ANALYZE = 60;
// context
const char * const C_ANALYZEMODE = "Analyzer.AnalyzeMode";
// menu
const char * const M_TOOLS_ANALYZER = "Analyzer.Tools.Menu";
const char * const START = "Analyzer.Start";
const char * const STOP = "Analyzer.Stop";
// options dialog
const char * const ANALYZER_SETTINGS_CATEGORY = "T.Analyzer";
const char * const ANALYZER_SETTINGS_TR_CATEGORY =
QT_TRANSLATE_NOOP("Analyzer", "Analyzer");
const char * const ANALYZER_SETTINGS_CATEGORY_ICON =
":/images/analyzer_category.png";
const char * const ANALYZERTASK_ID = "Analyzer.TaskId";
} // namespace Constants
} // namespace Analyzer
#endif // ANALYZERCONSTANTS_H
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Author: Andreas Hartmetz, KDAB (andreas.hartmetz@kdab.com)
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANALYZERMANAGER_H
#define ANALYZERMANAGER_H
#include "analyzerbase_global.h"
#include "analyzerconstants.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/imode.h>
#include <QObject>
#include <QIcon>
QT_BEGIN_NAMESPACE
class QAction;
class QDockWidget;
QT_END_NAMESPACE
namespace Core {
class IMode;
}
namespace Utils {
class FancyMainWindow;
}
namespace Analyzer {
class IAnalyzerTool;
namespace Internal {
class AnalyzerRunControl;
class DockWidgetEventFilter : public QObject
{
Q_OBJECT
public:
explicit DockWidgetEventFilter(QObject *parent = 0) : QObject(parent) {}
signals:
void widgetResized();
protected:
virtual bool eventFilter(QObject *obj, QEvent *event);
};
class AnalyzerMode : public Core::IMode
{
Q_OBJECT
public:
AnalyzerMode(QObject *parent = 0)
: Core::IMode(parent)
, m_widget(0)
{}
~AnalyzerMode()
{
// Make sure the editor manager does not get deleted.
if (m_widget) {
delete m_widget;
m_widget = 0;
}
Core::EditorManager::instance()->setParent(0);
}
QString displayName() const { return tr("Analyze"); }
QIcon icon() const { return QIcon(":/images/analyzer_mode.png"); }
int priority() const { return Constants::P_MODE_ANALYZE; }
QWidget *widget() { return m_widget; }
QString id() const { return QLatin1String(Constants::MODE_ANALYZE); }
QString type() const { return Core::Constants::MODE_EDIT_TYPE; }
Core::Context context() const
{
return Core::Context(Core::Constants::C_EDITORMANAGER, Constants::C_ANALYZEMODE,
Core::Constants::C_NAVIGATION_PANE);
}
QString contextHelpId() const { return QString(); }
void setWidget(QWidget *widget) { m_widget = widget; }
private:
QWidget *m_widget;
};
}
using Analyzer::Internal::AnalyzerRunControl;
class ANALYZER_EXPORT AnalyzerManager : public QObject
{
Q_OBJECT
public:
explicit AnalyzerManager(QObject *parent = 0);
~AnalyzerManager();
static AnalyzerManager *instance();
void shutdown();
/**
* Register a tool and initialize it.
*/
void addTool(Analyzer::IAnalyzerTool *tool);
IAnalyzerTool *currentTool() const;
QList<IAnalyzerTool *> tools() const;
// dockwidgets are registered to the main window
QDockWidget *createDockWidget(IAnalyzerTool *tool, const QString &title, QWidget *widget,
Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
/**
* Add the given @p widget into this mode's toolbar.
*
* It will be shown whenever this tool is selected by the user.
*
* @Note The manager will take ownership of @p widget.
*/
void setToolbar(Analyzer::IAnalyzerTool *tool, QWidget *widget);
Utils::FancyMainWindow *mainWindow() const;
void selectTool(IAnalyzerTool* tool);
private slots:
void startTool();
void stopTool();
void handleToolFinished();
void toolSelected(int);
void toolSelected(QAction *);
void modeChanged(Core::IMode *mode);
void runControlCreated(AnalyzerRunControl *);
void buildQueueFinished(bool success);
void resetLayout();
void saveToolSettings(IAnalyzerTool *tool);
void loadToolSettings(IAnalyzerTool *tool);
void updateRunActions();
private:
class AnalyzerManagerPrivate;
friend class AnalyzerManagerPrivate;
AnalyzerManagerPrivate *const d;
static AnalyzerManager *m_instance;
};
} // namespace Analyzer
#endif // ANALYZERMANAGER_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "analyzerconstants.h"
#include "analyzeroptionspage.h"
#include "analyzersettings.h"
#include <QCoreApplication>
#include <QLatin1String>
#include <QWidget>
#include <QDebug>
#include <QIcon>
#include <coreplugin/icore.h>
using namespace Analyzer;
using namespace Analyzer::Internal;
AnalyzerOptionsPage::AnalyzerOptionsPage(AbstractAnalyzerSubConfig *config, QObject *parent) :
Core::IOptionsPage(parent),
m_config(config)
{
}
QString AnalyzerOptionsPage::id() const
{
return m_config->id();
}
QString AnalyzerOptionsPage::displayName() const
{
return m_config->displayName();
}
QString AnalyzerOptionsPage::category() const
{
return QLatin1String(Constants::ANALYZER_SETTINGS_CATEGORY);
}
QString AnalyzerOptionsPage::displayCategory() const
{
return QCoreApplication::tr("Analyzer", Constants::ANALYZER_SETTINGS_TR_CATEGORY);
}
QIcon AnalyzerOptionsPage::categoryIcon() const
{
return QIcon(QLatin1String(Constants::ANALYZER_SETTINGS_CATEGORY_ICON));
}
QWidget *AnalyzerOptionsPage::createPage(QWidget *parent)
{
return m_config->createConfigWidget(parent);
}
void AnalyzerOptionsPage::apply()
{
AnalyzerGlobalSettings::instance()->writeSettings();
}
void AnalyzerOptionsPage::finish()
{
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANALYZER_INTERNAL_ANALYZEROPTIONSPAGE_H
#define ANALYZER_INTERNAL_ANALYZEROPTIONSPAGE_H
#include <coreplugin/dialogs/ioptionspage.h>
namespace Analyzer {
class AbstractAnalyzerSubConfig;
namespace Internal {
class AnalyzerOptionsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
explicit AnalyzerOptionsPage(AbstractAnalyzerSubConfig *config, QObject *parent = 0);
// IOptionsPage implementation
QString id() const;
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
void finish();
private:
AbstractAnalyzerSubConfig *m_config;
};
} // namespace Internal
} // namespace Analyzer
#endif // ANALYZER_INTERNAL_ANALYZEROPTIONSPAGE_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "analyzerplugin.h"
#include "analyzerconstants.h"
#include "analyzermanager.h"
#include <coreplugin/imode.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/task.h>
#include <projectexplorer/taskhub.h>
#include <QtPlugin>
#include <QMessageBox>
#include <QMainWindow>
#include <QApplication>
using namespace Analyzer;
using namespace Analyzer::Internal;