Commit aea19425 authored by con's avatar con

StatusBarWidget instead of IView, get rid of one level of abstraction.

Merge IView and BaseView into a single class StatusBarWidget.
parent fd73952e
......@@ -56,7 +56,7 @@ SOURCES += mainwindow.cpp \
scriptmanager/scriptmanager.cpp \
scriptmanager/qworkbench_wrapper.cpp \
basemode.cpp \
baseview.cpp \
statusbarwidget.cpp \
coreplugin.cpp \
variablemanager.cpp \
modemanager.cpp \
......@@ -128,7 +128,6 @@ HEADERS += mainwindow.h \
ioutputpane.h \
coreconstants.h \
iversioncontrol.h \
iview.h \
ifilewizardextension.h \
icorelistener.h \
versiondialog.h \
......@@ -138,7 +137,7 @@ HEADERS += mainwindow.h \
scriptmanager/scriptmanager_p.h \
core_global.h \
basemode.h \
baseview.h \
statusbarwidget.h \
coreplugin.h \
variablemanager.h \
modemanager.h \
......
......@@ -46,7 +46,6 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/ieditorfactory.h>
#include <coreplugin/editormanager/iexternaleditor.h>
#include <coreplugin/baseview.h>
#include <coreplugin/imode.h>
#include <coreplugin/settingsdatabase.h>
#include <coreplugin/variablemanager.h>
......@@ -164,7 +163,6 @@ struct EditorManagerPrivate {
QAction *m_gotoOtherSplitAction;
Internal::OpenEditorsWindow *m_windowPopup;
Core::BaseView *m_openEditorsView;
Internal::EditorClosingCoreListener *m_coreListener;
QMap<QString, QVariant> m_editorStates;
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file 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 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef IVIEW_H
#define IVIEW_H
#include "core_global.h"
#include <coreplugin/icontext.h>
namespace Core {
class CORE_EXPORT IView : public IContext
{
Q_OBJECT
public:
enum ViewPosition { First=0, Second=1, Third=2 };
IView(QObject *parent = 0) : IContext(parent) {}
virtual ~IView() {}
virtual const char *uniqueViewName() const = 0;
virtual ViewPosition defaultPosition() const = 0;
};
} // namespace Core
#endif // IVIEW_H
......@@ -60,7 +60,7 @@
#include "navigationwidget.h"
#include "rightpane.h"
#include "editormanager/ieditorfactory.h"
#include "baseview.h"
#include "statusbarwidget.h"
#include "basefilewizard.h"
#include "ioutputpane.h"
......@@ -323,10 +323,9 @@ bool MainWindow::init(QString *errorMessage)
// Add widget to the bottom, we create the view here instead of inside the
// OutputPaneManager, since the ViewManager needs to be initilized before
m_outputView = new Core::BaseView;
m_outputView->setUniqueViewName("OutputWindow");
m_outputView = new Core::StatusBarWidget;
m_outputView->setWidget(OutputPaneManager::instance()->buttonsWidget());
m_outputView->setDefaultPosition(Core::IView::Second);
m_outputView->setPosition(Core::StatusBarWidget::Second);
pm->addObject(m_outputView);
return true;
}
......
......@@ -48,7 +48,7 @@ namespace Core {
class ActionManager;
class BaseMode;
class BaseView;
class StatusBarWidget;
class EditorManager;
class FileManager;
class IContext;
......@@ -195,7 +195,7 @@ private:
FancyTabWidget *m_modeStack;
NavigationWidget *m_navigationWidget;
RightPaneWidget *m_rightPaneWidget;
Core::BaseView *m_outputView;
Core::StatusBarWidget *m_outputView;
VersionDialog *m_versionDialog;
IContext * m_activeContext;
......
......@@ -29,7 +29,6 @@
#include "progressmanager_p.h"
#include "progressview.h"
#include "baseview.h"
#include "coreconstants.h"
#include "icore.h"
#include "uniqueidmanager.h"
......
......@@ -27,65 +27,53 @@
**
**************************************************************************/
#include "baseview.h"
#include "statusbarwidget.h"
#include <QtGui/QWidget>
using namespace Core;
BaseView::BaseView(QObject *parent)
: IView(parent),
m_viewName(""),
StatusBarWidget::StatusBarWidget(QObject *parent)
: IContext(parent),
m_widget(0),
m_context(QList<int>()),
m_defaultPosition(IView::First)
m_defaultPosition(StatusBarWidget::First)
{
}
BaseView::~BaseView()
StatusBarWidget::~StatusBarWidget()
{
delete m_widget;
}
QList<int> BaseView::context() const
QList<int> StatusBarWidget::context() const
{
return m_context;
}
QWidget *BaseView::widget()
QWidget *StatusBarWidget::widget()
{
return m_widget;
}
const char *BaseView::uniqueViewName() const
{
return m_viewName;
}
IView::ViewPosition BaseView::defaultPosition() const
StatusBarWidget::StatusBarPosition StatusBarWidget::position() const
{
return m_defaultPosition;
}
void BaseView::setUniqueViewName(const char *name)
{
m_viewName = name;
}
QWidget *BaseView::setWidget(QWidget *widget)
QWidget *StatusBarWidget::setWidget(QWidget *widget)
{
QWidget *oldWidget = m_widget;
m_widget = widget;
return oldWidget;
}
void BaseView::setContext(const QList<int> &context)
void StatusBarWidget::setContext(const QList<int> &context)
{
m_context = context;
}
void BaseView::setDefaultPosition(IView::ViewPosition position)
void StatusBarWidget::setPosition(StatusBarWidget::StatusBarPosition position)
{
m_defaultPosition = position;
}
......
......@@ -27,40 +27,39 @@
**
**************************************************************************/
#ifndef BASEVIEW_H
#define BASEVIEW_H
#ifndef STATUSBARWIDGET_H
#define STATUSBARWIDGET_H
#include "core_global.h"
#include "iview.h"
#include "icontext.h"
#include <QtCore/QPointer>
namespace Core {
class CORE_EXPORT BaseView : public IView
class CORE_EXPORT StatusBarWidget : public IContext
{
Q_OBJECT
public:
BaseView(QObject *parent = 0);
~BaseView();
enum StatusBarPosition { First=0, Second=1, Third=2 };
StatusBarWidget(QObject *parent = 0);
~StatusBarWidget();
QList<int> context() const;
QWidget *widget();
const char *uniqueViewName() const;
IView::ViewPosition defaultPosition() const;
StatusBarWidget::StatusBarPosition position() const;
void setUniqueViewName(const char *name);
QWidget *setWidget(QWidget *widget);
void setContext(const QList<int> &context);
void setDefaultPosition(IView::ViewPosition position);
void setPosition(StatusBarWidget::StatusBarPosition position);
private:
const char *m_viewName;
QPointer<QWidget> m_widget;
QList<int> m_context;
IView::ViewPosition m_defaultPosition;
StatusBarWidget::StatusBarPosition m_defaultPosition;
};
} // namespace Core
#endif // BASEVIEW_H
#endif // STATUSBARWIDGET_H
......@@ -32,7 +32,7 @@
#include "coreconstants.h"
#include "mainwindow.h"
#include "uniqueidmanager.h"
#include "iview.h"
#include "statusbarwidget.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
......@@ -77,22 +77,21 @@ void ViewManager::init()
void ViewManager::objectAdded(QObject *obj)
{
IView *view = Aggregation::query<IView>(obj);
StatusBarWidget *view = Aggregation::query<StatusBarWidget>(obj);
if (!view)
return;
QWidget *viewWidget = 0;
viewWidget = view->widget();
m_statusBarWidgets.at(view->defaultPosition())->layout()->addWidget(viewWidget);
m_statusBarWidgets.at(view->position())->layout()->addWidget(viewWidget);
m_viewMap.insert(view, viewWidget);
viewWidget->setObjectName(view->uniqueViewName());
m_mainWnd->addContextObject(view);
}
void ViewManager::aboutToRemoveObject(QObject *obj)
{
IView *view = Aggregation::query<IView>(obj);
StatusBarWidget *view = Aggregation::query<StatusBarWidget>(obj);
if (!view)
return;
m_mainWnd->removeContextObject(view);
......@@ -108,14 +107,3 @@ void ViewManager::saveSettings(QSettings *settings)
{
settings->setValue(QLatin1String("ViewGroup_Default"), m_mainWnd->saveState());
}
IView *ViewManager::view(const QString &id)
{
QList<IView *> list =
ExtensionSystem::PluginManager::instance()->getObjects<IView>();
foreach (IView *view, list) {
if (view->uniqueViewName() == id)
return view;
}
return 0;
}
......@@ -43,7 +43,7 @@ QT_END_NAMESPACE
namespace Core {
class IView;
class StatusBarWidget;
namespace Internal {
......@@ -62,13 +62,12 @@ public:
void extensionsInitalized();
void saveSettings(QSettings *settings);
IView * view(const QString & id);
private slots:
void objectAdded(QObject *obj);
void aboutToRemoveObject(QObject *obj);
private:
QMap<Core::IView *, QWidget *> m_viewMap;
QMap<Core::StatusBarWidget *, QWidget *> m_viewMap;
MainWindow *m_mainWnd;
QList<QWidget *> m_statusBarWidgets;
......
......@@ -41,7 +41,7 @@
#include <QtCore/QFuture>
#include <QtCore/QFutureWatcher>
#include <coreplugin/baseview.h>
#include <coreplugin/statusbarwidget.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/settingsdatabase.h>
#include <coreplugin/icore.h>
......@@ -95,12 +95,11 @@ bool LocatorPlugin::initialize(const QStringList &, QString *)
m_locatorWidget = new LocatorWidget(this);
m_locatorWidget->setEnabled(false);
Core::BaseView *view = new Core::BaseView;
view->setUniqueViewName("Locator");
Core::StatusBarWidget *view = new Core::StatusBarWidget;
view->setWidget(m_locatorWidget);
view->setContext(QList<int>() << core->uniqueIDManager()
->uniqueIdentifier(QLatin1String("LocatorWidget")));
view->setDefaultPosition(Core::IView::First);
view->setPosition(Core::StatusBarWidget::First);
addAutoReleasedObject(view);
const QString actionId = QLatin1String("QtCreator.Locate");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment