diff options
Diffstat (limited to 'src/plugins/coreplugin/icontext.h')
-rw-r--r-- | src/plugins/coreplugin/icontext.h | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/plugins/coreplugin/icontext.h b/src/plugins/coreplugin/icontext.h index f4559f1a20..82fc88c2fb 100644 --- a/src/plugins/coreplugin/icontext.h +++ b/src/plugins/coreplugin/icontext.h @@ -38,10 +38,8 @@ #include <QtCore/QList> #include <QtCore/QObject> - -QT_BEGIN_NAMESPACE -class QWidget; -QT_END_NAMESPACE +#include <QtCore/QPointer> +#include <QtGui/QWidget> namespace Core { @@ -80,31 +78,28 @@ class CORE_EXPORT IContext : public QObject { Q_OBJECT public: - IContext(QObject *parent = 0) : QObject(parent) {} - virtual ~IContext() {} + IContext(QObject *parent = 0) : QObject(parent), m_widget(0) {} - virtual Context context() const = 0; - virtual QWidget *widget() = 0; + virtual Context context() const { return m_context; } + virtual QWidget *widget() const { return m_widget; } virtual QString contextHelpId() const { return QString(); } + + virtual void setContext(const Context &context) { m_context = context; } + virtual void setWidget(QWidget *widget) { m_widget = widget; } +protected: + Context m_context; + QPointer<QWidget> m_widget; }; class BaseContext : public Core::IContext { public: BaseContext(QWidget *widget, const Context &context, QObject *parent = 0) - : Core::IContext(parent), - m_widget(widget), - m_context(context) + : Core::IContext(parent) { + setWidget(widget); + setContext(context); } - - Context context() const { return m_context; } - - QWidget *widget() { return m_widget; } - -private: - QWidget *m_widget; - Context m_context; }; } // namespace Core |