forked from qt-creator/qt-creator
cleanup interface of Core::Context
This commit is contained in:
@@ -250,7 +250,7 @@ QList<Command *> ActionManagerPrivate::commands() const
|
|||||||
{
|
{
|
||||||
// transform list of CommandPrivate into list of Command
|
// transform list of CommandPrivate into list of Command
|
||||||
QList<Command *> result;
|
QList<Command *> result;
|
||||||
foreach(Command *cmd, m_idCmdMap.values())
|
foreach (Command *cmd, m_idCmdMap.values())
|
||||||
result << cmd;
|
result << cmd;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -262,7 +262,7 @@ QList<ActionContainerPrivate *> ActionManagerPrivate::containers() const
|
|||||||
|
|
||||||
bool ActionManagerPrivate::hasContext(int context) const
|
bool ActionManagerPrivate::hasContext(int context) const
|
||||||
{
|
{
|
||||||
return m_context.d.contains(context);
|
return m_context.contains(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManagerPrivate::setContext(const Context &context)
|
void ActionManagerPrivate::setContext(const Context &context)
|
||||||
@@ -278,8 +278,8 @@ void ActionManagerPrivate::setContext(const Context &context)
|
|||||||
|
|
||||||
bool ActionManagerPrivate::hasContext(const Context &context) const
|
bool ActionManagerPrivate::hasContext(const Context &context) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_context.d.count(); ++i) {
|
for (int i = 0; i < m_context.size(); ++i) {
|
||||||
if (context.d.contains(m_context.d.at(i)))
|
if (context.contains(m_context.at(i)))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -403,7 +403,7 @@ Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QStri
|
|||||||
shortcut->setParent(m_mainWnd);
|
shortcut->setParent(m_mainWnd);
|
||||||
sc->setShortcut(shortcut);
|
sc->setShortcut(shortcut);
|
||||||
|
|
||||||
if (context.d.isEmpty())
|
if (context.isEmpty())
|
||||||
sc->setContext(Context(0));
|
sc->setContext(Context(0));
|
||||||
else
|
else
|
||||||
sc->setContext(context);
|
sc->setContext(context);
|
||||||
|
|||||||
@@ -336,8 +336,8 @@ QString Shortcut::defaultText() const
|
|||||||
|
|
||||||
bool Shortcut::setCurrentContext(const Core::Context &context)
|
bool Shortcut::setCurrentContext(const Core::Context &context)
|
||||||
{
|
{
|
||||||
foreach (int ctxt, m_context.d) {
|
foreach (int ctxt, m_context) {
|
||||||
if (context.d.contains(ctxt)) {
|
if (context.contains(ctxt)) {
|
||||||
if (!m_shortcut->isEnabled()) {
|
if (!m_shortcut->isEnabled()) {
|
||||||
m_shortcut->setEnabled(true);
|
m_shortcut->setEnabled(true);
|
||||||
emit activeStateChanged();
|
emit activeStateChanged();
|
||||||
@@ -487,7 +487,7 @@ static inline QString msgActionWarning(QAction *newAction, int k, QAction *oldAc
|
|||||||
|
|
||||||
void Action::addOverrideAction(QAction *action, const Core::Context &context)
|
void Action::addOverrideAction(QAction *action, const Core::Context &context)
|
||||||
{
|
{
|
||||||
if (context.d.isEmpty()) {
|
if (context.isEmpty()) {
|
||||||
m_contextActionMap.insert(0, action);
|
m_contextActionMap.insert(0, action);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < context.size(); ++i) {
|
for (int i = 0; i < context.size(); ++i) {
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ void DesignMode::updateContext(Core::IMode *newMode, Core::IMode *oldMode)
|
|||||||
|
|
||||||
void DesignMode::setActiveContext(const Context &context)
|
void DesignMode::setActiveContext(const Context &context)
|
||||||
{
|
{
|
||||||
if (d->m_activeContext.d == context.d)
|
if (d->m_activeContext == context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ModeManager::instance()->currentMode() == this)
|
if (ModeManager::instance()->currentMode() == this)
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ void ShortcutSettings::markPossibleCollisions(ShortcutItem *item)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int context, currentItem->m_cmd->context().d) {
|
foreach (int context, currentItem->m_cmd->context()) {
|
||||||
|
|
||||||
// conflict if context is identical, OR if one
|
// conflict if context is identical, OR if one
|
||||||
// of the contexts is the global context
|
// of the contexts is the global context
|
||||||
|
|||||||
@@ -56,7 +56,19 @@ public:
|
|||||||
int size() const { return d.size(); }
|
int size() const { return d.size(); }
|
||||||
bool isEmpty() const { return d.isEmpty(); }
|
bool isEmpty() const { return d.isEmpty(); }
|
||||||
int at(int i) const { return d.at(i); }
|
int at(int i) const { return d.at(i); }
|
||||||
public:
|
|
||||||
|
// FIXME: Make interface slimmer.
|
||||||
|
typedef QList<int>::const_iterator const_iterator;
|
||||||
|
const_iterator begin() const { return d.begin(); }
|
||||||
|
const_iterator end() const { return d.end(); }
|
||||||
|
int indexOf(int c) const { return d.indexOf(c); }
|
||||||
|
void removeAt(int i) { d.removeAt(i); }
|
||||||
|
void prepend(int c) { d.prepend(c); }
|
||||||
|
void add(const Context &c) { d += c.d; }
|
||||||
|
void add(int c) { d.append(c); }
|
||||||
|
bool operator==(const Context &c) { return d == c.d; }
|
||||||
|
|
||||||
|
private:
|
||||||
QList<int> d;
|
QList<int> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1198,21 +1198,21 @@ void MainWindow::writeSettings()
|
|||||||
|
|
||||||
void MainWindow::updateAdditionalContexts(const Context &remove, const Context &add)
|
void MainWindow::updateAdditionalContexts(const Context &remove, const Context &add)
|
||||||
{
|
{
|
||||||
foreach (const int context, remove.d) {
|
foreach (const int context, remove) {
|
||||||
if (context == 0)
|
if (context == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int index = m_additionalContexts.d.indexOf(context);
|
int index = m_additionalContexts.indexOf(context);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
m_additionalContexts.d.removeAt(index);
|
m_additionalContexts.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const int context, add.d) {
|
foreach (const int context, add) {
|
||||||
if (context == 0)
|
if (context == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!m_additionalContexts.d.contains(context))
|
if (!m_additionalContexts.contains(context))
|
||||||
m_additionalContexts.d.prepend(context);
|
m_additionalContexts.prepend(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateContext();
|
updateContext();
|
||||||
@@ -1228,15 +1228,15 @@ void MainWindow::updateContext()
|
|||||||
Context contexts;
|
Context contexts;
|
||||||
|
|
||||||
if (m_activeContext)
|
if (m_activeContext)
|
||||||
contexts.d += m_activeContext->context().d;
|
contexts.add(m_activeContext->context());
|
||||||
|
|
||||||
contexts.d += m_additionalContexts.d;
|
contexts.add(m_additionalContexts);
|
||||||
|
|
||||||
Context uniquecontexts;
|
Context uniquecontexts;
|
||||||
for (int i = 0; i < contexts.d.size(); ++i) {
|
for (int i = 0; i < contexts.size(); ++i) {
|
||||||
const int c = contexts.d.at(i);
|
const int c = contexts.at(i);
|
||||||
if (!uniquecontexts.d.contains(c))
|
if (!uniquecontexts.contains(c))
|
||||||
uniquecontexts.d << c;
|
uniquecontexts.add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_actionManager->setContext(uniquecontexts);
|
m_actionManager->setContext(uniquecontexts);
|
||||||
|
|||||||
@@ -1311,12 +1311,12 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
|
|||||||
Core::Context newContext;
|
Core::Context newContext;
|
||||||
|
|
||||||
if (d->m_currentProject) {
|
if (d->m_currentProject) {
|
||||||
oldContext.d.append(d->m_currentProject->projectManager()->projectContext());
|
oldContext.add(d->m_currentProject->projectManager()->projectContext());
|
||||||
oldContext.d.append(d->m_currentProject->projectManager()->projectLanguage());
|
oldContext.add(d->m_currentProject->projectManager()->projectLanguage());
|
||||||
}
|
}
|
||||||
if (project) {
|
if (project) {
|
||||||
newContext.d.append(project->projectManager()->projectContext());
|
newContext.add(project->projectManager()->projectContext());
|
||||||
newContext.d.append(project->projectManager()->projectLanguage());
|
newContext.add(project->projectManager()->projectLanguage());
|
||||||
}
|
}
|
||||||
|
|
||||||
core->updateAdditionalContexts(oldContext, newContext);
|
core->updateAdditionalContexts(oldContext, newContext);
|
||||||
|
|||||||
@@ -275,8 +275,8 @@ void BauhausPlugin::contextChanged(Core::IContext *context, const Core::Context
|
|||||||
{
|
{
|
||||||
Q_UNUSED(context)
|
Q_UNUSED(context)
|
||||||
|
|
||||||
foreach (int additionalContext, additionalContexts.d) {
|
foreach (int additionalContext, additionalContexts) {
|
||||||
if (m_context->context().d.contains(additionalContext)) {
|
if (m_context->context().contains(additionalContext)) {
|
||||||
m_isActive = true;
|
m_isActive = true;
|
||||||
m_mainWidget->showEditor(m_editorManager->currentEditor());
|
m_mainWidget->showEditor(m_editorManager->currentEditor());
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user