Files
qt-creator/src/plugins/coreplugin/imode.cpp
hjk cf7f898db3 Core: Keep track of modes in the ModeManager directly
... instead of having the indirection of the global object pool.

ModeManagerPrivate has been maintaining the list of instantiated
modes by tracking (all...) pool object additions / removals. This
can be achieved more directly by calling functions from the
IMode base constructor/destructor.

The pattern used deviates a bit from the otherwise used 'static
QList<Foo *> allFoos();' acessor pattern as there is some sorting
logic etc. associated each time a mode is appended.
Sticking to the preexisting structure seemed less effort for now.

Change-Id: Ic1b4e641e155f949248890acc48cafbe74025115
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-24 10:12:50 +00:00

54 lines
1.6 KiB
C++

/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "imode.h"
#include "modemanager.h"
using namespace Core;
IMode::IMode(QObject *parent) : IContext(parent)
{
ModeManager::instance()->addMode(this);
}
IMode::~IMode()
{
ModeManager::instance()->removeMode(this);
delete m_menu;
}
void IMode::setEnabled(bool enabled)
{
if (m_isEnabled == enabled)
return;
m_isEnabled = enabled;
emit enabledStateChanged(m_isEnabled);
}
bool IMode::isEnabled() const
{
return m_isEnabled;
}