2008-12-02 12:01:29 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-01-13 19:21:51 +01:00
|
|
|
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
|
** Non-Open Source Usage
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Licensees may use this file in accordance with the Qt Beta Version
|
|
|
|
|
** License Agreement, Agreement version 2.2 provided with the Software or,
|
|
|
|
|
** alternatively, in accordance with the terms contained in a written
|
2008-12-02 14:17:16 +01:00
|
|
|
** agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
|
** Public License versions 2.0 or 3.0 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
|
|
|
|
** of this file. Please review the following information to ensure GNU
|
|
|
|
|
** General Public Licensing requirements will be met:
|
|
|
|
|
**
|
|
|
|
|
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
|
|
|
|
** http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2008-12-02 14:17:16 +01:00
|
|
|
** rights. These rights are described in the Nokia Qt GPL Exception
|
2008-12-16 17:20:00 +01:00
|
|
|
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
|
***************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "baseview.h"
|
|
|
|
|
|
2009-01-14 15:08:46 +01:00
|
|
|
#include <QtGui/QWidget>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class BaseView
|
|
|
|
|
\mainclass
|
|
|
|
|
\ingroup qwb
|
|
|
|
|
\inheaderfile baseview.h
|
|
|
|
|
\brief A base implementation of IView.
|
|
|
|
|
|
|
|
|
|
The BaseView class can be used directly for most IView implementations.
|
|
|
|
|
It has setter functions for the views properties, and a convenience constructor
|
|
|
|
|
for the most important ones.
|
|
|
|
|
|
|
|
|
|
The ownership of the widget is given to the BaseView, so when the BaseView is destroyed it
|
|
|
|
|
deletes its widget.
|
|
|
|
|
|
|
|
|
|
A typical use case is to do the following in the init method of a plugin:
|
|
|
|
|
\code
|
|
|
|
|
bool MyPlugin::init(QString *error_message)
|
|
|
|
|
{
|
|
|
|
|
[...]
|
|
|
|
|
addObject(new Core::BaseView("myplugin.myview",
|
|
|
|
|
new MyWidget,
|
|
|
|
|
QList<int>() << myContextId,
|
|
|
|
|
Qt::LeftDockWidgetArea,
|
|
|
|
|
this));
|
|
|
|
|
[...]
|
|
|
|
|
}
|
|
|
|
|
\endcode
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn BaseView::BaseView()
|
|
|
|
|
|
|
|
|
|
Creates a View with empty view name, no widget, empty context, NoDockWidgetArea,
|
|
|
|
|
no menu group and empty default shortcut. You should use the setter functions
|
|
|
|
|
to give the view a meaning.
|
|
|
|
|
*/
|
|
|
|
|
BaseView::BaseView(QObject *parent)
|
|
|
|
|
: IView(parent),
|
|
|
|
|
m_viewName(""),
|
|
|
|
|
m_widget(0),
|
|
|
|
|
m_context(QList<int>()),
|
|
|
|
|
m_defaultPosition(IView::First)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn BaseView::BaseView(const char *name, QWidget *widget, const QList<int> &context, Qt::DockWidgetArea position, QObject *parent)
|
|
|
|
|
|
|
|
|
|
Creates a view with the given properties.
|
|
|
|
|
|
|
|
|
|
\a name
|
|
|
|
|
\a widget
|
|
|
|
|
\a context
|
|
|
|
|
\a position
|
|
|
|
|
\a parent
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
BaseView::BaseView(const char *name, QWidget *widget, const QList<int> &context, IView::ViewPosition position, QObject *parent)
|
|
|
|
|
: IView(parent),
|
|
|
|
|
m_viewName(name),
|
|
|
|
|
m_widget(widget),
|
|
|
|
|
m_context(context),
|
|
|
|
|
m_defaultPosition(position)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn BaseView::~BaseView()
|
|
|
|
|
*/
|
|
|
|
|
BaseView::~BaseView()
|
|
|
|
|
{
|
|
|
|
|
delete m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn const QList<int> &BaseView::context() const
|
|
|
|
|
*/
|
|
|
|
|
QList<int> BaseView::context() const
|
|
|
|
|
{
|
|
|
|
|
return m_context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QWidget *BaseView::widget()
|
|
|
|
|
*/
|
|
|
|
|
QWidget *BaseView::widget()
|
|
|
|
|
{
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn const char *BaseView::uniqueViewName() const
|
|
|
|
|
*/
|
|
|
|
|
const char *BaseView::uniqueViewName() const
|
|
|
|
|
{
|
|
|
|
|
return m_viewName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn IView::ViewPosition BaseView::defaultPosition() const
|
|
|
|
|
*/
|
|
|
|
|
IView::ViewPosition BaseView::defaultPosition() const
|
|
|
|
|
{
|
|
|
|
|
return m_defaultPosition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void BaseView::setUniqueViewName(const char *name)
|
|
|
|
|
|
|
|
|
|
\a name
|
|
|
|
|
*/
|
|
|
|
|
void BaseView::setUniqueViewName(const char *name)
|
|
|
|
|
{
|
|
|
|
|
m_viewName = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QWidget *BaseView::setWidget(QWidget *widget)
|
|
|
|
|
|
|
|
|
|
The BaseView takes the ownership of the \a widget. The previously
|
|
|
|
|
set widget (if existent) is not deleted but returned, and responsibility
|
|
|
|
|
for deleting it moves to the caller of this method.
|
|
|
|
|
*/
|
|
|
|
|
QWidget *BaseView::setWidget(QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
QWidget *oldWidget = m_widget;
|
|
|
|
|
m_widget = widget;
|
|
|
|
|
return oldWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void BaseView::setContext(const QList<int> &context)
|
|
|
|
|
|
|
|
|
|
\a context
|
|
|
|
|
*/
|
|
|
|
|
void BaseView::setContext(const QList<int> &context)
|
|
|
|
|
{
|
|
|
|
|
m_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void BaseView::setDefaultPosition(IView::ViewPosition position)
|
|
|
|
|
|
|
|
|
|
\a position
|
|
|
|
|
*/
|
|
|
|
|
void BaseView::setDefaultPosition(IView::ViewPosition position)
|
|
|
|
|
{
|
|
|
|
|
m_defaultPosition = position;
|
|
|
|
|
}
|
|
|
|
|
|