1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
36 #include <coreplugin/core_global.h>
38 #include <QtCore/QList>
39 #include <QtCore/QObject>
47 class CORE_EXPORT Context
52 explicit Context(const char *c1) { add(c1); }
53 Context(const char *c1, const char *c2) { add(c1); add(c2); }
54 Context(const char *c1, const char *c2, const char *c3) { add(c1); add(c2); add(c3); }
55 Context(const char *base, int offset);
56 void add(const char *c);
57 bool contains(const char *c) const;
58 bool contains(int c) const { return d.contains(c); }
59 int size() const { return d.size(); }
60 bool isEmpty() const { return d.isEmpty(); }
61 int at(int i) const { return d.at(i); }
63 // FIXME: Make interface slimmer.
64 typedef QList<int>::const_iterator const_iterator;
65 const_iterator begin() const { return d.begin(); }
66 const_iterator end() const { return d.end(); }
67 int indexOf(int c) const { return d.indexOf(c); }
68 void removeAt(int i) { d.removeAt(i); }
69 void prepend(int c) { d.prepend(c); }
70 void add(const Context &c) { d += c.d; }
71 void add(int c) { d.append(c); }
72 bool operator==(const Context &c) const { return d == c.d; }
78 class CORE_EXPORT IContext : public QObject
82 IContext(QObject *parent = 0) : QObject(parent) {}
83 virtual ~IContext() {}
85 virtual Context context() const = 0;
86 virtual QWidget *widget() = 0;
87 virtual QString contextHelpId() const { return QString(); }
90 class BaseContext : public Core::IContext
93 BaseContext(QWidget *widget, const Context &context, QObject *parent = 0)
94 : Core::IContext(parent),
100 Context context() const { return m_context; }
102 QWidget *widget() { return m_widget; }