Commit c7e8b51d authored by hjk's avatar hjk
Browse files

core: use a class derived from QList<int> instead of a QList<int> for Core::Context

A mostly mechanical change.

Reviewed-By: con
parent a54fc1f6
......@@ -33,13 +33,14 @@
#include "debugger_global.h"
#include <QtCore/QObject>
#include <QtCore/QMultiHash>
QT_FORWARD_DECLARE_CLASS(QDockWidget);
#include <QtCore/QMultiHash>
namespace Core {
class ActionContainer;
class Command;
class Context;
class BaseMode;
class IMode;
}
......@@ -68,7 +69,7 @@ public:
static DebuggerUISwitcher *instance();
// debuggable languages are registered with this function.
void addLanguage(const QString &langName, const QList<int> &context);
void addLanguage(const QString &langName, const Core::Context &context);
// debugger toolbars are registered with this function
void setToolbar(const QString &langName, QWidget *widget);
......
......@@ -43,7 +43,7 @@ enum { debug = 0 };
namespace Designer {
namespace Internal {
DesignerContext::DesignerContext(const QList<int> contexts,
DesignerContext::DesignerContext(const Core::Context &contexts,
QWidget *widget,
QObject *parent) :
Core::IContext(parent),
......@@ -52,7 +52,7 @@ DesignerContext::DesignerContext(const QList<int> contexts,
{
}
QList<int> DesignerContext::context() const
Core::Context DesignerContext::context() const
{
return m_context;
}
......
......@@ -44,16 +44,16 @@ class DesignerContext : public Core::IContext
{
Q_DISABLE_COPY(DesignerContext)
public:
explicit DesignerContext(const QList<int> contexts,
explicit DesignerContext(const Core::Context &contexts,
QWidget *widget,
QObject *parent = 0);
virtual QList<int> context() const;
virtual Core::Context context() const;
virtual QWidget *widget();
virtual QString contextHelpId() const;
private:
const QList<int> m_context;
const Core::Context m_context;
QWidget *m_widget;
};
......
......@@ -119,7 +119,7 @@ static inline QIcon designerIcon(const QString &iconName)
// Create a menu separator
static inline QAction *createSeparator(QObject *parent,
Core::ActionManager *am,
const QList<int> &context,
const Core::Context &context,
Core::ActionContainer *container,
const QString &name = QString(),
const QString &group = QString())
......@@ -220,7 +220,7 @@ FormEditorW::~FormEditorW()
// Add an actioon to toggle the view state of a dock window
void FormEditorW::addDockViewAction(Core::ActionManager *am,
Core::ActionContainer *viewMenu,
int index, const QList<int> &context,
int index, const Core::Context &context,
const QString &title, const QString &id)
{
if (const QDockWidget *dw = m_editorWidget->designerDockWidgets()[index]) {
......@@ -334,7 +334,9 @@ void FormEditorW::fullInit()
Core::UniqueIDManager *idMan = Core::UniqueIDManager::instance();
int editorManagerContext = idMan->uniqueIdentifier(QLatin1String(Core::Constants::C_EDITORMANAGER));
m_context = new DesignerContext(QList<int>() << m_contexts << editorManagerContext, m_modeWidget, this);
Core::Context designerContexts = m_contexts;
designerContexts.append(Core::Context(editorManagerContext));
m_context = new DesignerContext(designerContexts, m_modeWidget, this);
m_core->addContextObject(m_context);
m_designMode->registerDesignWidget(m_modeWidget, QStringList(QLatin1String(FORM_MIMETYPE)), m_contexts);
......@@ -625,7 +627,7 @@ void FormEditorW::bindShortcut(Core::Command *command, QAction *action)
// Create an action to activate a designer tool
QAction *FormEditorW::createEditModeAction(QActionGroup *ag,
const QList<int> &context,
const Core::Context &context,
Core::ActionManager *am,
Core::ActionContainer *medit,
const QString &actionName,
......@@ -651,7 +653,7 @@ QAction *FormEditorW::createEditModeAction(QActionGroup *ag,
// Create a tool action
Core::Command *FormEditorW::addToolAction(QAction *a, Core::ActionManager *am,
const QList<int> &context, const QString &name,
const Core::Context &context, const QString &name,
Core::ActionContainer *c1, const QString &keySequence)
{
Core::Command *command = am->registerAction(a, name, context);
......
......@@ -30,11 +30,13 @@
#ifndef FORMEDITORW_H
#define FORMEDITORW_H
#include "designerconstants.h"
#include "coreplugin/icontext.h"
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QMap>
#include "designerconstants.h"
QT_BEGIN_NAMESPACE
......@@ -136,11 +138,11 @@ private:
void setupActions();
void setupViewActions();
inline void addDockViewAction(Core::ActionManager *am,
Core::ActionContainer *viewMenu,
int index,
const QList<int> &context,
const QString &title, const QString &id);
void addDockViewAction(Core::ActionManager *am,
Core::ActionContainer *viewMenu,
int index,
const Core::Context &context,
const QString &title, const QString &id);
Core::ActionContainer *createPreviewStyleMenu(Core::ActionManager *am,
QActionGroup *actionGroup);
......@@ -148,7 +150,7 @@ private:
void critical(const QString &errorMessage);
void bindShortcut(Core::Command *command, QAction *action);
QAction *createEditModeAction(QActionGroup *ag,
const QList<int> &context,
const Core::Context &context,
Core::ActionManager *am,
Core::ActionContainer *medit,
const QString &actionName,
......@@ -157,7 +159,7 @@ private:
const QString &iconName = QString(),
const QString &keySequence = QString());
Core::Command *addToolAction(QAction *a, Core::ActionManager *am,
const QList<int> &context, const QString &name,
const Core::Context &context, const QString &name,
Core::ActionContainer *c1, const QString &keySequence = QString());
QToolBar *createEditorToolBar() const;
......@@ -184,7 +186,7 @@ private:
QSignalMapper *m_shortcutMapper;
DesignerContext *m_context;
QList<int> m_contexts;
Core::Context m_contexts;
QStringList m_toolActionIds;
QWidget *m_modeWidget;
......
......@@ -53,13 +53,14 @@
namespace Designer {
struct FormWindowEditorPrivate {
struct FormWindowEditorPrivate
{
explicit FormWindowEditorPrivate(Internal::DesignerXmlEditor *editor,
QDesignerFormWindowInterface *form);
TextEditor::PlainTextEditorEditable m_textEditable;
Internal::FormWindowFile m_file;
QList<int> m_context;
Core::Context m_context;
};
FormWindowEditorPrivate::FormWindowEditorPrivate(Internal::DesignerXmlEditor *editor,
......@@ -221,7 +222,7 @@ bool FormWindowEditor::restoreState(const QByteArray &state)
return d->m_textEditable.restoreState(state);
}
QList<int> FormWindowEditor::context() const
Core::Context FormWindowEditor::context() const
{
return d->m_context;
}
......
......@@ -91,7 +91,7 @@ public:
virtual QString preferredMode() const;
// IContext
virtual QList<int> context() const;
virtual Core::Context context() const;
virtual QWidget *widget();
// For uic code model support
......
......@@ -587,8 +587,7 @@ bool FakeVimPluginPrivate::initialize()
Core::ActionManager *actionManager = Core::ICore::instance()->actionManager();
QTC_ASSERT(actionManager, return false);
QList<int> globalcontext;
globalcontext << Core::Constants::C_GLOBAL_ID;
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
m_fakeVimOptionsPage = new FakeVimOptionPage;
q->addObject(m_fakeVimOptionsPage);
......
......@@ -41,6 +41,7 @@
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <extensionsystem/pluginmanager.h>
......@@ -191,7 +192,7 @@ void FindPlugin::setupMenu()
mfind->appendGroup(Constants::G_FIND_FILTERS);
mfind->appendGroup(Constants::G_FIND_FLAGS);
mfind->appendGroup(Constants::G_FIND_ACTIONS);
QList<int> globalcontext = QList<int>() << Core::Constants::C_GLOBAL_ID;
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Command *cmd;
QAction *separator;
separator = new QAction(this);
......@@ -219,7 +220,7 @@ void FindPlugin::setupFilterMenuItems()
QList<IFindFilter*> findInterfaces =
ExtensionSystem::PluginManager::instance()->getObjects<IFindFilter>();
Core::Command *cmd;
QList<int> globalcontext = QList<int>() << Core::Constants::C_GLOBAL_ID;
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::ActionContainer *mfindadvanced = am->actionContainer(Constants::M_FIND_ADVANCED);
d->m_filterActions.clear();
......
......@@ -32,6 +32,7 @@
#include "textfindconstants.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
......@@ -129,10 +130,8 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
// need to make sure QStringList is registered as metatype
QMetaTypeId<QStringList>::qt_metatype_id();
//register actions
QList<int> globalcontext;
globalcontext << Core::Constants::C_GLOBAL_ID;
// register actions
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND);
Core::Command *cmd;
......
......@@ -111,7 +111,7 @@ ProjectFilesEditable::ProjectFilesEditable(ProjectFilesEditor *editor)
ProjectFilesEditable::~ProjectFilesEditable()
{ }
QList<int> ProjectFilesEditable::context() const
Core::Context ProjectFilesEditable::context() const
{
return m_context;
}
......
......@@ -79,7 +79,7 @@ public:
ProjectFilesEditable(ProjectFilesEditor *editor);
virtual ~ProjectFilesEditable();
virtual QList<int> context() const;
virtual Core::Context context() const;
virtual QString id() const;
virtual bool duplicateSupported() const;
......@@ -88,7 +88,7 @@ public:
virtual bool isTemporary() const { return false; }
private:
QList<int> m_context;
Core::Context m_context;
};
class ProjectFilesEditor: public TextEditor::BaseTextEditor
......
......@@ -174,7 +174,7 @@ static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
};
static Core::Command *createSeparator(Core::ActionManager *am,
const QList<int> &context,
const Core::Context &context,
const QString &id,
QObject *parent)
{
......@@ -187,7 +187,7 @@ static Core::Command *createSeparator(Core::ActionManager *am,
ParameterActionCommandPair
GitPlugin::createParameterAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context,
const QString &id, const Core::Context &context,
bool addToLocator)
{
Utils::ParameterAction *action = new Utils::ParameterAction(defaultText, parameterText,
......@@ -205,7 +205,7 @@ ParameterActionCommandPair
ParameterActionCommandPair
GitPlugin::createFileAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator,
const QString &id, const Core::Context &context, bool addToLocator,
const char *pluginSlot)
{
const ParameterActionCommandPair rc = createParameterAction(am, ac, defaultText, parameterText, id, context, addToLocator);
......@@ -218,7 +218,7 @@ ParameterActionCommandPair
ParameterActionCommandPair
GitPlugin::createProjectAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator,
const QString &id, const Core::Context &context, bool addToLocator,
const char *pluginSlot)
{
const ParameterActionCommandPair rc = createParameterAction(am, ac, defaultText, parameterText, id, context, addToLocator);
......@@ -231,7 +231,7 @@ ParameterActionCommandPair
ActionCommandPair
GitPlugin::createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context, bool addToLocator)
const Core::Context &context, bool addToLocator)
{
QAction *action = new QAction(text, this);
Core::Command *command = am->registerAction(action, id, context);
......@@ -246,7 +246,7 @@ ActionCommandPair
ActionCommandPair
GitPlugin::createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context, bool addToLocator,
const Core::Context &context, bool addToLocator,
const char *pluginSlot)
{
const ActionCommandPair rc = createRepositoryAction(am, ac, text, id, context, addToLocator);
......@@ -259,7 +259,7 @@ ActionCommandPair
ActionCommandPair
GitPlugin::createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context, bool addToLocator,
const Core::Context &context, bool addToLocator,
GitClientMemberFunc func)
{
// Set the member func as data and connect to generic slot
......@@ -282,7 +282,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_core = Core::ICore::instance();
m_gitClient = new GitClient(this);
// Create the globalcontext list to register actions accordingly
QList<int> globalcontext;
Core::Context globalcontext;
globalcontext << m_core->uniqueIDManager()->uniqueIdentifier(Core::Constants::C_GLOBAL);
// Create the settings Page
......@@ -493,7 +493,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
}
// Submit editor
QList<int> submitContext;
Core::Context submitContext;
submitContext.push_back(m_core->uniqueIDManager()->uniqueIdentifier(QLatin1String(Constants::C_GITSUBMITEDITOR)));
m_submitCurrentAction = new QAction(VCSBase::VCSBaseSubmitEditor::submitIcon(), tr("Commit"), this);
Core::Command *command = actionManager->registerAction(m_submitCurrentAction, Constants::SUBMIT_CURRENT, submitContext);
......
......@@ -53,6 +53,7 @@ namespace Core {
class IEditorFactory;
class ICore;
class Command;
class Context;
class ActionManager;
class ActionContainer;
}
......@@ -135,36 +136,36 @@ private:
inline ParameterActionCommandPair
createParameterAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator);
const QString &id, const Core::Context &context, bool addToLocator);
inline ParameterActionCommandPair
createFileAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator,
const QString &id, const Core::Context &context, bool addToLocator,
const char *pluginSlot);
inline ParameterActionCommandPair
createProjectAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator);
const QString &id, const Core::Context &context, bool addToLocator);
inline ParameterActionCommandPair
createProjectAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator,
const QString &id, const Core::Context &context, bool addToLocator,
const char *pluginSlot);
inline ActionCommandPair createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context, bool addToLocator);
const Core::Context &context, bool addToLocator);
inline ActionCommandPair createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context,
const Core::Context &context,
bool addToLocator, const char *pluginSlot);
inline ActionCommandPair createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context,
const Core::Context &context,
bool addToLocator, GitClientMemberFunc);
bool isCommitEditorOpen() const;
......
......@@ -120,10 +120,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
Q_UNUSED(arguments)
Q_UNUSED(error)
m_core = Core::ICore::instance();
QList<int> globalcontext;
globalcontext << Core::Constants::C_GLOBAL_ID;
QList<int> modecontext;
modecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP);
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context modecontext(m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP));
const QString &locale = qApp->property("qtc_locale").toString();
if (!locale.isEmpty()) {
......@@ -304,7 +302,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
this, SLOT(modeChanged(Core::IMode*)));
addAutoReleasedObject(m_mode = new HelpMode(m_splitter, m_centralWidget));
m_mode->setContext(QList<int>() << modecontext);
m_mode->setContext(modecontext);
return true;
}
......@@ -343,9 +341,8 @@ void HelpPlugin::aboutToShutdown()
void HelpPlugin::setupUi()
{
// side bar widgets and shortcuts
QList<int> modecontext;
Core::ActionManager *am = m_core->actionManager();
modecontext << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP);
Core::Context modecontext(m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_MODE_HELP));
IndexWindow *indexWindow = new IndexWindow();
indexWindow->setWindowTitle(tr(SB_INDEX));
......@@ -523,12 +520,12 @@ void HelpPlugin::createRightPaneContextViewer()
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
agg->add(m_helpViewerForSideBar);
agg->add(new HelpViewerFindSupport(m_helpViewerForSideBar));
m_core->addContextObject(new Core::BaseContext(m_helpViewerForSideBar, QList<int>()
<< m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR), this));
m_core->addContextObject(new Core::BaseContext(m_helpViewerForSideBar,Core::Context(
m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR)), this));
QAction *copy = new QAction(this);
Core::Command *cmd = m_core->actionManager()->registerAction(copy, Core::Constants::COPY,
QList<int>() << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR));
Core::Context(m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_HELP_SIDEBAR)));
copy->setText(cmd->action()->text());
copy->setIcon(cmd->action()->icon());
......
......@@ -51,7 +51,7 @@ namespace Internal {
struct ImageViewerPrivate
{
QList<int> context;
Core::Context context;
QString displayName;
ImageViewerFile *file;
ImageView *imageView;
......@@ -109,7 +109,7 @@ ImageViewer::~ImageViewer()
delete d_ptr->toolbar;
}
QList<int> ImageViewer::context() const
Core::Context ImageViewer::context() const
{
return d_ptr->context;
}
......
......@@ -52,7 +52,7 @@ public:
explicit ImageViewer(QWidget *parent = 0);
~ImageViewer();
QList<int> context() const;
Core::Context context() const;
QWidget *widget();
bool createNew(const QString &contents = QString());
......
......@@ -57,7 +57,7 @@ struct ImageViewerActionHandlerPrivate
QPointer<QAction> actionBackground;
QPointer<QAction> actionOutline;
QList<int> context;
Core::Context context;
QPointer<QSignalMapper> signalMapper;
};
......@@ -126,7 +126,7 @@ void ImageViewerActionHandler::createActions()
}
QAction *ImageViewerActionHandler::registerNewAction(int actionId, const QString &id,
const QString &title, const QList<int> &context, const QKeySequence &key)
const QString &title, const Core::Context &context, const QKeySequence &key)
{
Core::ActionManager *actionManager = Core::ICore::instance()->actionManager();
Core::Command *command = 0;
......
......@@ -31,11 +31,15 @@
#ifndef IMAGEVIEWERACTIONHANDLER_H
#define IMAGEVIEWERACTIONHANDLER_H
#include <QObject>
#include "coreplugin/icontext.h"
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
QT_FORWARD_DECLARE_CLASS(QAction)
QT_FORWARD_DECLARE_CLASS(QKeySequence)
QT_BEGIN_NAMESPACE
class QAction;
class QKeySequence;
QT_END_NAMESPACE
namespace ImageViewer {
namespace Internal {
......@@ -65,7 +69,7 @@ protected:
\return Created and registered action, 0 if something goes wrong
*/
QAction *registerNewAction(int actionId, const QString &id, const QString &title,
const QList<int> &context, const QKeySequence &key);
const Core::Context &context, const QKeySequence &key);
private:
QScopedPointer<struct ImageViewerActionHandlerPrivate> d_ptr;
......
......@@ -106,14 +106,14 @@ bool LocatorPlugin::initialize(const QStringList &, QString *)
m_locatorWidget->setEnabled(false);
Core::StatusBarWidget *view = new Core::StatusBarWidget;
view->setWidget(m_locatorWidget);
view->setContext(QList<int>() << core->uniqueIDManager()
->uniqueIdentifier(QLatin1String("LocatorWidget")));
view->setContext(Core::Context(core->uniqueIDManager()
->uniqueIdentifier(QLatin1String("LocatorWidget"))));
view->setPosition(Core::StatusBarWidget::First);
addAutoReleasedObject(view);
const QString actionId = QLatin1String("QtCreator.Locate");
QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
Core::Command *cmd = core->actionManager()->registerAction(action, actionId, QList<int>() << Core::Constants::C_GLOBAL_ID);
Core::Command *cmd = core->actionManager()->registerAction(action, actionId, Core::Context(Core::Constants::C_GLOBAL_ID));
cmd->setDefaultKeySequence(QKeySequence("Ctrl+K"));
connect(action, SIGNAL(triggered()), this, SLOT(openLocator()));
......
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