Commit a9f53ec9 authored by hjk's avatar hjk Committed by hjk
Browse files

analyzer: remove output pane

It's all dockwidgets now.

Change-Id: Ia47ca9331fdfbe12ca11f77c26afc35e73a2fae3
Reviewed-on: http://codereview.qt.nokia.com/776

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 0753c7bd
......@@ -12,7 +12,6 @@ QT += network
SOURCES += \
ianalyzerengine.cpp \
ianalyzeroutputpaneadapter.cpp \
ianalyzertool.cpp \
analyzerplugin.cpp \
analyzerruncontrol.cpp \
......@@ -21,13 +20,11 @@ SOURCES += \
analyzersettings.cpp \
analyzeroptionspage.cpp \
analyzerrunconfigwidget.cpp \
analyzeroutputpane.cpp \
analyzerutils.cpp \
startremotedialog.cpp
HEADERS += \
ianalyzerengine.h \
ianalyzeroutputpaneadapter.h \
ianalyzertool.h \
analyzerbase_global.h \
analyzerconstants.h \
......@@ -39,7 +36,6 @@ HEADERS += \
analyzerstartparameters.h \
analyzeroptionspage.h \
analyzerrunconfigwidget.h \
analyzeroutputpane.h \
analyzerutils.h \
startremotedialog.h
......
......@@ -39,26 +39,25 @@
#include "analyzerruncontrol.h"
#include "analyzerruncontrolfactory.h"
#include "analyzeroptionspage.h"
#include "analyzeroutputpane.h"
#include "analyzerstartparameters.h"
#include "analyzerutils.h"
#include "ianalyzertool.h"
#include "startremotedialog.h"
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h>
#include <coreplugin/imode.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/outputpane.h>
#include <coreplugin/rightpane.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/imode.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h>
......@@ -200,7 +199,6 @@ public:
AnalyzerManager *q;
AnalyzerMode *m_mode;
AnalyzerOutputPane *m_outputpane;
AnalyzerRunControlFactory *m_runControlFactory;
ProjectExplorer::RunControl *m_currentRunControl;
Utils::FancyMainWindow *m_mainWindow;
......@@ -232,7 +230,6 @@ public:
AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
q(qq),
m_mode(0),
m_outputpane(0),
m_runControlFactory(0),
m_currentRunControl(0),
m_mainWindow(0),
......@@ -503,8 +500,6 @@ void AnalyzerManager::AnalyzerManagerPrivate::startTool()
// make sure mode is shown
q->showMode();
if (q->currentTool()->needsOutputPane())
q->popupOutputPane();
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
......@@ -583,16 +578,16 @@ void AnalyzerManager::AnalyzerManagerPrivate::startTool()
// AnalyzerManager ////////////////////////////////////////////////////
AnalyzerManager *AnalyzerManager::m_instance = 0;
AnalyzerManager::AnalyzerManager(AnalyzerOutputPane *op, QObject *parent) :
QObject(parent),
AnalyzerManager::AnalyzerManager(QObject *parent)
: QObject(parent),
d(new AnalyzerManagerPrivate(this))
{
m_instance = this;
d->m_outputpane = op;
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(modeChanged(Core::IMode*)));
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::ProjectExplorerPlugin *pe =
ProjectExplorer::ProjectExplorerPlugin::instance();
connect(pe, SIGNAL(updateRunActions()),
this, SLOT(updateRunActions()));
}
......@@ -652,9 +647,11 @@ void AnalyzerManager::toolSelected(int idx)
foreach (QDockWidget *widget, d->m_toolWidgets.value(oldTool)) {
QAction *toggleViewAction = widget->toggleViewAction();
am->unregisterAction(toggleViewAction, QString("Analyzer." + widget->objectName()));
am->unregisterAction(toggleViewAction,
QString("Analyzer." + widget->objectName()));
d->m_mainWindow->removeDockWidget(widget);
///NOTE: QMainWindow (and FancyMainWindow) just look at @c findChildren<QDockWidget*>()
///NOTE: QMainWindow (and FancyMainWindow) just look at
/// @c findChildren<QDockWidget*>()
///if we don't do this, all kind of havoc might happen, including:
///- improper saveState/restoreState
///- improper list of qdockwidgets in popup menu
......@@ -679,8 +676,6 @@ void AnalyzerManager::toolSelected(int idx)
}
loadToolSettings(newTool);
d->m_outputpane->setTool(newTool);
updateRunActions();
selectingTool = false;
......@@ -704,8 +699,10 @@ void AnalyzerManager::addTool(IAnalyzerTool *tool)
ActionManager *am = Core::ICore::instance()->actionManager();
QString actionId = QString(Constants::ANALYZER_TOOLS) + QString::number(d->m_toolGroup->actions().count());
Core::Command *command = am->registerAction(action, actionId, Core::Context(Core::Constants::C_GLOBAL));
QString actionId = QString(Constants::ANALYZER_TOOLS)
+ QString::number(d->m_toolGroup->actions().count());
Core::Command *command = am->registerAction(action, actionId,
Core::Context(Core::Constants::C_GLOBAL));
d->m_menu->addAction(command, Constants::G_ANALYZER_TOOLS);
d->m_toolGroup->setVisible(d->m_toolGroup->actions().count() > 1);
......@@ -715,11 +712,10 @@ void AnalyzerManager::addTool(IAnalyzerTool *tool)
d->m_toolBox->addItem(tool->displayName());
d->m_toolBox->blockSignals(blocked);
// Populate output pane
d->m_outputpane->setTool(tool);
// populate controls widget
// Populate controls widget.
QWidget *controlWidget = tool->createControlWidget(); // might be 0
d->m_controlsWidget->addWidget(controlWidget ? controlWidget : AnalyzerUtils::createDummyWidget());
d->m_controlsWidget->addWidget(controlWidget
? controlWidget : AnalyzerUtils::createDummyWidget());
d->m_toolBox->setEnabled(d->m_toolBox->count() > 1);
......@@ -841,10 +837,14 @@ void AnalyzerManager::saveToolSettings(IAnalyzerTool *tool)
void AnalyzerManager::updateRunActions()
{
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::ProjectExplorerPlugin *pe =
ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::Project *project = pe->startupProject();
bool startEnabled = !d->m_currentRunControl && pe->canRun(project, Constants::MODE_ANALYZE)
&& currentTool();
bool startEnabled = !d->m_currentRunControl
&& pe->canRun(project, Constants::MODE_ANALYZE)
&& currentTool();
QString disabledReason;
if (d->m_currentRunControl)
disabledReason = tr("An analysis is still in progress.");
......@@ -900,9 +900,4 @@ void AnalyzerManager::showMode()
ModeManager::instance()->activateMode(d->m_mode->id());
}
void AnalyzerManager::popupOutputPane()
{
d->m_outputpane->popup();
}
#include "analyzermanager.moc"
......@@ -62,16 +62,12 @@ class IAnalyzerTool;
class AnalyzerRunControl;
class AnalyzerStartParameters;
namespace Internal {
class AnalyzerOutputPane;
} // namespace Internal
class ANALYZER_EXPORT AnalyzerManager : public QObject
{
Q_OBJECT
public:
explicit AnalyzerManager(Internal::AnalyzerOutputPane *op, QObject *parent = 0);
explicit AnalyzerManager(QObject *parent = 0);
~AnalyzerManager();
static AnalyzerManager *instance();
......@@ -87,9 +83,9 @@ public:
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);
// Dockwidgets are registered to the main window.
QDockWidget *createDockWidget(IAnalyzerTool *tool, const QString &title,
QWidget *widget, Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
Utils::FancyMainWindow *mainWindow() const;
......@@ -102,7 +98,6 @@ public:
AnalyzerRunControl *createAnalyzer(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc = 0);
void showMode();
void popupOutputPane();
public slots:
void startTool();
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** 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.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#include "analyzeroutputpane.h"
#include "analyzerconstants.h"
#include "analyzermanager.h"
#include "analyzerutils.h"
#include "ianalyzertool.h"
#include "ianalyzeroutputpaneadapter.h"
#include <utils/qtcassert.h>
#include <utils/styledbar.h>
#include <QtCore/QVariant>
#include <QtCore/QDebug>
#include <QtGui/QWidget>
#include <QtGui/QStackedLayout>
#include <QtGui/QLabel>
#include <QtGui/QStackedWidget>
enum { debug = 0 };
namespace Analyzer {
namespace Internal {
static const int dummyWidgetIndex = 0;
/*!
\class AnalyzerPane::Internal::AnalyzerOutputPane
\brief Common analysis output pane managing several tools.
Output pane for all tools derived from IAnalyzerTool.
The IAnalyzerOutputPaneAdapter (unless 0) provides
\list
\i Pane widget
\i Optional toolbar widget
\endlist
Both are inserted into a pane stacked layout and a stacked toolbar widget respectively.
The indexes of the stacked widgets/layouts and the adapter list go in sync
(dummy widgets on the toolbar are used to achieve this).
Dummy widgets that are shown in case there is no tool with an output pane
are added at index 0 to the stacks (usage of index 0 is to avoid using
QStackedWidget::insert() when adding adapters, which causes flicker).
Besides the tool-specific toolbar widget, the start/stop buttons and the combo
box of the AnalyzerManager are shown in the toolbar.
The initialization is a bit tricky here, as the sequence of calls to
setTool(), outputWindow()/toolBarWidgets() is basically undefined. The pane widget
should be created on the correct parent when outputWindow()
is called, tools will typically be added before.
\sa AnalyzerPane::Internal::IAnalyzerOutputPaneAdapter
*/
AnalyzerOutputPane::AnalyzerOutputPane(QObject *parent) :
Core::IOutputPane(parent),
m_paneWidget(0),
m_paneStackedLayout(0),
m_toolbarStackedWidget(0),
m_toolBarSeparator(0),
m_delayedCurrentIndex(-1)
{
setObjectName(QLatin1String("AnalyzerOutputPane"));
}
void AnalyzerOutputPane::clearTool()
{
// No tool. Show dummy label, which is the last widget.
if (m_paneWidget) {
m_paneStackedLayout->setCurrentIndex(dummyWidgetIndex);
m_toolbarStackedWidget->setCurrentIndex(dummyWidgetIndex);
emit navigateStateChanged();
}
hide();
}
int AnalyzerOutputPane::currentIndex() const
{
return isInitialized() ? m_paneStackedLayout->currentIndex() : m_delayedCurrentIndex;
}
IAnalyzerOutputPaneAdapter *AnalyzerOutputPane::currentAdapter() const
{
const int index = currentIndex(); // Rule out leading dummy widget
if (index != dummyWidgetIndex && index < m_adapters.size())
return m_adapters.at(index);
return 0;
}
void AnalyzerOutputPane::setCurrentIndex(int i)
{
if (!isInitialized()) {
m_delayedCurrentIndex = i;
} else if (i != currentIndex()) {
// Show up pane widget and optional toolbar widget. Hide
// the toolbar if the toolbar widget is a dummy.
m_paneStackedLayout->setCurrentIndex(i);
m_toolbarStackedWidget->setCurrentIndex(i);
const bool hasToolBarWidget = !m_toolbarStackedWidget->currentWidget()->property(Constants::ANALYZER_DUMMYWIDGET_ID).toBool();
m_toolbarStackedWidget->setVisible(hasToolBarWidget);
m_toolBarSeparator->setVisible(hasToolBarWidget);
navigateStateChanged();
}
}
void AnalyzerOutputPane::addAdapter(IAnalyzerOutputPaneAdapter *adapter)
{
if (m_adapters.isEmpty())
m_adapters.push_back(0); // Index for leading dummy widgets.
m_adapters.push_back(adapter);
connect(adapter, SIGNAL(navigationStatusChanged()), this, SLOT(slotNavigationStatusChanged()));
connect(adapter, SIGNAL(popup(bool)), this, SLOT(slotPopup(bool)));
if (isInitialized())
addToWidgets(adapter);
}
void AnalyzerOutputPane::addToWidgets(IAnalyzerOutputPaneAdapter *adapter)
{
QTC_ASSERT(m_paneWidget, return; )
QWidget *toolPaneWidget = adapter->paneWidget();
QTC_ASSERT(toolPaneWidget, return; )
m_paneStackedLayout->addWidget(toolPaneWidget);
QWidget *toolBarWidget = adapter->toolBarWidget(); // Might be 0
m_toolbarStackedWidget->addWidget(toolBarWidget ? toolBarWidget : AnalyzerUtils::createDummyWidget());
}
void AnalyzerOutputPane::setTool(IAnalyzerTool *tool)
{
if (debug)
qDebug() << "AnalyzerOutputPane::setTool" << tool;
// No tool. show dummy label.
IAnalyzerOutputPaneAdapter *adapter = 0;
if (tool)
adapter = tool->outputPaneAdapter();
// Re-show or add.
if (adapter) {
int index = m_adapters.indexOf(adapter);
if (index == -1) {
addAdapter(adapter);
index = m_adapters.size();
}
setCurrentIndex(index);
if (isInitialized())
popup(false);
} else {
clearTool();
}
}
QWidget *AnalyzerOutputPane::outputWidget(QWidget *parent)
{
if (debug)
qDebug() << "AnalyzerOutputPane::outputWidget";
// Delayed creation of main pane widget. Add a trailing dummy widget
// and add all adapters.
if (!isInitialized())
createWidgets(parent);
return m_paneWidget;
}
void AnalyzerOutputPane::createWidgets(QWidget *paneParent)
{
// Create pane and toolbar stack with leading dummy widget.
m_paneWidget = new QWidget(paneParent);
m_paneStackedLayout = new QStackedLayout(m_paneWidget);
m_paneWidget->setObjectName(objectName() + QLatin1String("Widget"));
m_paneStackedLayout->addWidget(new QLabel(tr("No current analysis tool"))); // placeholder
// Temporarily assign to (wrong) parent to suppress flicker in conjunction with QStackedWidget.
m_toolbarStackedWidget = new QStackedWidget(paneParent);
m_toolbarStackedWidget->setObjectName(objectName() + QLatin1String("ToolBarStackedWidget"));
m_toolbarStackedWidget->addWidget(AnalyzerUtils::createDummyWidget()); // placeholder
m_toolBarSeparator = new Utils::StyledSeparator(paneParent);
m_toolBarSeparator->setObjectName(objectName() + QLatin1String("ToolBarSeparator"));
// Add adapters added before.
const int adapterCount = m_adapters.size();
const int firstAdapter = dummyWidgetIndex + 1;
for (int i = firstAdapter; i < adapterCount; i++)
addToWidgets(m_adapters.at(i));
if (m_delayedCurrentIndex != -1) // setTool was called before initialization
setCurrentIndex(m_delayedCurrentIndex);
else if (adapterCount > firstAdapter) // default: Make last one current
setCurrentIndex(adapterCount - 1);
}
QWidgetList AnalyzerOutputPane::toolBarWidgets() const
{
if (debug)
qDebug() << "AnalyzerOutputPane::toolBarWidget";
QTC_ASSERT(isInitialized(), return QWidgetList(); )
QWidgetList list;
list << m_toolBarSeparator << m_toolbarStackedWidget;
return list;
}
QString AnalyzerOutputPane::displayName() const
{
return tr("Analysis");
}
int AnalyzerOutputPane::priorityInStatusBar() const
{
return -1; // Not visible in status bar.
}
void AnalyzerOutputPane::clearContents()
{
if (IAnalyzerOutputPaneAdapter *adapter = currentAdapter())
adapter->clearContents();
}
void AnalyzerOutputPane::visibilityChanged(bool v)
{
Q_UNUSED(v)
}
void AnalyzerOutputPane::setFocus()
{
if (IAnalyzerOutputPaneAdapter *adapter = currentAdapter())
adapter->setFocus();
}
bool AnalyzerOutputPane::hasFocus()
{
const IAnalyzerOutputPaneAdapter *adapter = currentAdapter();
return adapter ? adapter->hasFocus() : false;
}
bool AnalyzerOutputPane::canFocus()
{
const IAnalyzerOutputPaneAdapter *adapter = currentAdapter();
return adapter ? adapter->canFocus() : false;
}
bool AnalyzerOutputPane::canNavigate()
{
const IAnalyzerOutputPaneAdapter *adapter = currentAdapter();
return adapter ? adapter->canNavigate() : false;
}
bool AnalyzerOutputPane::canNext()
{
const IAnalyzerOutputPaneAdapter *adapter = currentAdapter();
return adapter ? adapter->canNext() : false;
}
bool AnalyzerOutputPane::canPrevious()
{
const IAnalyzerOutputPaneAdapter *adapter = currentAdapter();
return adapter ? adapter->canPrevious() : false;
}
void AnalyzerOutputPane::goToNext()
{
if (IAnalyzerOutputPaneAdapter *adapter = currentAdapter())
adapter->goToNext();
}
void AnalyzerOutputPane::goToPrev()
{
if (IAnalyzerOutputPaneAdapter *adapter = currentAdapter())
adapter->goToPrev();
}
void AnalyzerOutputPane::slotPopup(bool withFocus)
{
popup(withFocus);
}
void AnalyzerOutputPane::slotNavigationStatusChanged()
{
IAnalyzerOutputPaneAdapter *adapter = qobject_cast<IAnalyzerOutputPaneAdapter *>(sender());
const int index = m_adapters.indexOf(adapter);
QTC_ASSERT(adapter != 0 && index != -1, return; )
// Forward navigation status if it is the current pane.
if (index == currentIndex())
navigateStateChanged();
}
} // namespace Internal
} // namespace Analyzer
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** 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.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#ifndef ANALYZEROUTPUTPANE_H
#define ANALYZEROUTPUTPANE_H
#include <coreplugin/ioutputpane.h>
QT_FORWARD_DECLARE_CLASS(QStackedLayout)
QT_FORWARD_DECLARE_CLASS(QStackedWidget)
namespace Utils {
class StyledSeparator;
}
namespace Analyzer {
class IAnalyzerTool;
class IAnalyzerOutputPaneAdapter;
namespace Internal {
class AnalyzerOutputPane : public Core::IOutputPane
{
Q_OBJECT
public:
explicit AnalyzerOutputPane(QObject *parent = 0);
void setTool(IAnalyzerTool *tool);
// IOutputPane
virtual QWidget *outputWidget(QWidget *parent);
virtual QList<QWidget *> toolBarWidgets() const;
virtual QString displayName() const;
virtual int priorityInStatusBar() const;