forked from qt-creator/qt-creator
Remove unused/unnecessary code.
This commit is contained in:
@@ -153,7 +153,7 @@ using namespace Core::Internal;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ActionContainerPrivate::ActionContainerPrivate(int id)
|
ActionContainerPrivate::ActionContainerPrivate(int id)
|
||||||
: m_data(CS_None), m_id(id)
|
: m_data(0), m_id(id)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -168,16 +168,6 @@ bool ActionContainerPrivate::hasEmptyAction(EmptyAction ea) const
|
|||||||
return (m_data & EA_Mask) == ea;
|
return (m_data & EA_Mask) == ea;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionContainerPrivate::setState(ContainerState state)
|
|
||||||
{
|
|
||||||
m_data |= state;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ActionContainerPrivate::hasState(ContainerState state) const
|
|
||||||
{
|
|
||||||
return (m_data & state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionContainerPrivate::appendGroup(const QString &group)
|
void ActionContainerPrivate::appendGroup(const QString &group)
|
||||||
{
|
{
|
||||||
int gid = UniqueIDManager::instance()->uniqueIdentifier(group);
|
int gid = UniqueIDManager::instance()->uniqueIdentifier(group);
|
||||||
@@ -198,17 +188,6 @@ void ActionContainerPrivate::addAction(Command *action, const QString &group)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
||||||
Action *a = static_cast<Action *>(action);
|
|
||||||
if (a->stateFlags() & CommandPrivate::CS_PreLocation) {
|
|
||||||
QList<CommandLocation> locs = a->locations();
|
|
||||||
for (int i=0; i<locs.size(); ++i) {
|
|
||||||
if (ActionContainer *aci = am->actionContainer(locs.at(i).m_container)) {
|
|
||||||
ActionContainerPrivate *ac = static_cast<ActionContainerPrivate *>(aci);
|
|
||||||
ac->addAction(action, locs.at(i).m_position, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a->setStateFlags(a->stateFlags() | CommandPrivate::CS_Initialized);
|
|
||||||
} else {
|
|
||||||
UniqueIDManager *idmanager = UniqueIDManager::instance();
|
UniqueIDManager *idmanager = UniqueIDManager::instance();
|
||||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||||
if (!group.isEmpty())
|
if (!group.isEmpty())
|
||||||
@@ -217,7 +196,6 @@ void ActionContainerPrivate::addAction(Command *action, const QString &group)
|
|||||||
qWarning() << "*** addAction(): Unknown group: " << group;
|
qWarning() << "*** addAction(): Unknown group: " << group;
|
||||||
int pos = ((grpid << 16) | 0xFFFF);
|
int pos = ((grpid << 16) | 0xFFFF);
|
||||||
addAction(action, pos, true);
|
addAction(action, pos, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group)
|
void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group)
|
||||||
@@ -227,15 +205,6 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
||||||
MenuActionContainer *mc = static_cast<MenuActionContainer *>(menu);
|
|
||||||
if (mc->hasState(ActionContainerPrivate::CS_PreLocation)) {
|
|
||||||
CommandLocation loc = mc->location();
|
|
||||||
if (ActionContainer *aci = am->actionContainer(loc.m_container)) {
|
|
||||||
ActionContainerPrivate *ac = static_cast<ActionContainerPrivate *>(aci);
|
|
||||||
ac->addMenu(menu, loc.m_position, false);
|
|
||||||
}
|
|
||||||
mc->setState(ActionContainerPrivate::CS_Initialized);
|
|
||||||
} else {
|
|
||||||
UniqueIDManager *idmanager = UniqueIDManager::instance();
|
UniqueIDManager *idmanager = UniqueIDManager::instance();
|
||||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||||
if (!group.isEmpty())
|
if (!group.isEmpty())
|
||||||
@@ -244,7 +213,6 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group
|
|||||||
qWarning() << "*** addMenu(): Unknown group: " << group;
|
qWarning() << "*** addMenu(): Unknown group: " << group;
|
||||||
int pos = ((grpid << 16) | 0xFFFF);
|
int pos = ((grpid << 16) | 0xFFFF);
|
||||||
addMenu(menu, pos, true);
|
addMenu(menu, pos, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionContainerPrivate::id() const
|
int ActionContainerPrivate::id() const
|
||||||
@@ -264,14 +232,7 @@ QMenuBar *ActionContainerPrivate::menuBar() const
|
|||||||
|
|
||||||
bool ActionContainerPrivate::canAddAction(Command *action) const
|
bool ActionContainerPrivate::canAddAction(Command *action) const
|
||||||
{
|
{
|
||||||
if (action->type() != Command::CT_OverridableAction)
|
return (action->action() != 0);
|
||||||
return false;
|
|
||||||
|
|
||||||
CommandPrivate *cmd = static_cast<CommandPrivate *>(action);
|
|
||||||
if (cmd->stateFlags() & CommandPrivate::CS_Initialized)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionContainerPrivate::addAction(Command *action, int pos, bool setpos)
|
void ActionContainerPrivate::addAction(Command *action, int pos, bool setpos)
|
||||||
@@ -444,9 +405,6 @@ bool MenuActionContainer::update()
|
|||||||
|
|
||||||
bool MenuActionContainer::canBeAddedToMenu() const
|
bool MenuActionContainer::canBeAddedToMenu() const
|
||||||
{
|
{
|
||||||
if (hasState(ActionContainerPrivate::CS_Initialized))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,22 +41,12 @@ namespace Internal {
|
|||||||
class ActionContainerPrivate : public Core::ActionContainer
|
class ActionContainerPrivate : public Core::ActionContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ContainerState {
|
|
||||||
CS_None = 0x000000,
|
|
||||||
CS_Initialized = 0x010000,
|
|
||||||
CS_PreLocation = 0x020000,
|
|
||||||
CS_UserDefined = 0x040000
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainerPrivate(int id);
|
ActionContainerPrivate(int id);
|
||||||
virtual ~ActionContainerPrivate() {}
|
virtual ~ActionContainerPrivate() {}
|
||||||
|
|
||||||
void setEmptyAction(EmptyAction ea);
|
void setEmptyAction(EmptyAction ea);
|
||||||
bool hasEmptyAction(EmptyAction ea) const;
|
bool hasEmptyAction(EmptyAction ea) const;
|
||||||
|
|
||||||
void setState(ContainerState state);
|
|
||||||
bool hasState(ContainerState state) const;
|
|
||||||
|
|
||||||
QAction *insertLocation(const QString &group) const;
|
QAction *insertLocation(const QString &group) const;
|
||||||
void appendGroup(const QString &group);
|
void appendGroup(const QString &group);
|
||||||
void addAction(Command *action, const QString &group = QString());
|
void addAction(Command *action, const QString &group = QString());
|
||||||
|
|||||||
@@ -335,13 +335,12 @@ Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const
|
|||||||
OverrideableAction *a = 0;
|
OverrideableAction *a = 0;
|
||||||
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||||
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
||||||
if (c->type() != Command::CT_OverridableAction) {
|
a = qobject_cast<OverrideableAction *>(c);
|
||||||
|
if (!a) {
|
||||||
qWarning() << "registerAction: id" << id << "is registered with a different command type.";
|
qWarning() << "registerAction: id" << id << "is registered with a different command type.";
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
a = static_cast<OverrideableAction *>(c);
|
} else {
|
||||||
}
|
|
||||||
if (!a) {
|
|
||||||
a = new OverrideableAction(uid);
|
a = new OverrideableAction(uid);
|
||||||
m_idCmdMap.insert(uid, a);
|
m_idCmdMap.insert(uid, a);
|
||||||
}
|
}
|
||||||
@@ -381,11 +380,11 @@ Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QStri
|
|||||||
Shortcut *sc = 0;
|
Shortcut *sc = 0;
|
||||||
int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||||
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
||||||
if (c->type() != Command::CT_Shortcut) {
|
sc = qobject_cast<Shortcut *>(c);
|
||||||
|
if (!sc) {
|
||||||
qWarning() << "registerShortcut: id" << id << "is registered with a different command type.";
|
qWarning() << "registerShortcut: id" << id << "is registered with a different command type.";
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
sc = static_cast<Shortcut *>(c);
|
|
||||||
} else {
|
} else {
|
||||||
sc = new Shortcut(uid);
|
sc = new Shortcut(uid);
|
||||||
m_idCmdMap.insert(uid, sc);
|
m_idCmdMap.insert(uid, sc);
|
||||||
|
|||||||
@@ -41,10 +41,6 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\enum Command::CommandType
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\enum Command::CommandAttribute
|
\enum Command::CommandAttribute
|
||||||
*/
|
*/
|
||||||
@@ -57,10 +53,6 @@
|
|||||||
\fn virtual int Command::id() const
|
\fn virtual int Command::id() const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn virtual CommandType Command::type() const
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn virtual QAction *Command::action() const
|
\fn virtual QAction *Command::action() const
|
||||||
*/
|
*/
|
||||||
@@ -97,21 +89,11 @@ using namespace Core::Internal;
|
|||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CommandPrivate::CommandPrivate(CommandType type, int id)
|
CommandPrivate::CommandPrivate(int id)
|
||||||
: m_type(type), m_id(id)
|
: m_attributes(0), m_id(id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandPrivate::setStateFlags(int state)
|
|
||||||
{
|
|
||||||
m_type |= (state & CS_Mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CommandPrivate::stateFlags() const
|
|
||||||
{
|
|
||||||
return (m_type & CS_Mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandPrivate::setDefaultKeySequence(const QKeySequence &key)
|
void CommandPrivate::setDefaultKeySequence(const QKeySequence &key)
|
||||||
{
|
{
|
||||||
m_defaultKey = key;
|
m_defaultKey = key;
|
||||||
@@ -137,11 +119,6 @@ int CommandPrivate::id() const
|
|||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandPrivate::CommandType CommandPrivate::type() const
|
|
||||||
{
|
|
||||||
return (CommandType)(m_type & CT_Mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *CommandPrivate::action() const
|
QAction *CommandPrivate::action() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@@ -154,17 +131,17 @@ QShortcut *CommandPrivate::shortcut() const
|
|||||||
|
|
||||||
void CommandPrivate::setAttribute(CommandAttribute attr)
|
void CommandPrivate::setAttribute(CommandAttribute attr)
|
||||||
{
|
{
|
||||||
m_type |= attr;
|
m_attributes |= attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandPrivate::removeAttribute(CommandAttribute attr)
|
void CommandPrivate::removeAttribute(CommandAttribute attr)
|
||||||
{
|
{
|
||||||
m_type &= ~attr;
|
m_attributes &= ~attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandPrivate::hasAttribute(CommandAttribute attr) const
|
bool CommandPrivate::hasAttribute(CommandAttribute attr) const
|
||||||
{
|
{
|
||||||
return (m_type & attr);
|
return (m_attributes & attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
|
QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
|
||||||
@@ -183,7 +160,7 @@ QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
|
|||||||
...
|
...
|
||||||
*/
|
*/
|
||||||
Shortcut::Shortcut(int id)
|
Shortcut::Shortcut(int id)
|
||||||
: CommandPrivate(CT_Shortcut, id), m_shortcut(0)
|
: CommandPrivate(id), m_shortcut(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -293,8 +270,8 @@ bool Shortcut::isActive() const
|
|||||||
/*!
|
/*!
|
||||||
...
|
...
|
||||||
*/
|
*/
|
||||||
Action::Action(CommandType type, int id)
|
Action::Action(int id)
|
||||||
: CommandPrivate(type, id), m_action(0)
|
: CommandPrivate(id), m_action(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -385,7 +362,7 @@ QKeySequence Action::keySequence() const
|
|||||||
...
|
...
|
||||||
*/
|
*/
|
||||||
OverrideableAction::OverrideableAction(int id)
|
OverrideableAction::OverrideableAction(int id)
|
||||||
: Action(CT_OverridableAction, id), m_currentAction(0), m_active(false),
|
: Action(id), m_currentAction(0), m_active(false),
|
||||||
m_contextInitialized(false)
|
m_contextInitialized(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,6 @@ class CORE_EXPORT Command : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum CommandType {
|
|
||||||
CT_Shortcut = 0x0001,
|
|
||||||
CT_OverridableAction = 0x0002,
|
|
||||||
CT_Mask = 0x00FF
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CommandAttribute {
|
enum CommandAttribute {
|
||||||
CA_Hide = 0x0100,
|
CA_Hide = 0x0100,
|
||||||
CA_UpdateText = 0x0200,
|
CA_UpdateText = 0x0200,
|
||||||
@@ -64,7 +58,6 @@ public:
|
|||||||
virtual QString defaultText() const = 0;
|
virtual QString defaultText() const = 0;
|
||||||
|
|
||||||
virtual int id() const = 0;
|
virtual int id() const = 0;
|
||||||
virtual CommandType type() const = 0;
|
|
||||||
|
|
||||||
virtual QAction *action() const = 0;
|
virtual QAction *action() const = 0;
|
||||||
virtual QShortcut *shortcut() const = 0;
|
virtual QShortcut *shortcut() const = 0;
|
||||||
|
|||||||
@@ -45,19 +45,9 @@ class CommandPrivate : public Core::Command
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum CommandState {
|
CommandPrivate(int id);
|
||||||
CS_PreLocation = 0x020000,
|
|
||||||
CS_LocationChanged = 0x040000,
|
|
||||||
CS_Initialized = 0x080000,
|
|
||||||
CS_Mask = 0xFF0000
|
|
||||||
};
|
|
||||||
|
|
||||||
CommandPrivate(CommandType type, int id);
|
|
||||||
virtual ~CommandPrivate() {}
|
virtual ~CommandPrivate() {}
|
||||||
|
|
||||||
void setStateFlags(int state);
|
|
||||||
int stateFlags() const;
|
|
||||||
|
|
||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
|
|
||||||
void setDefaultKeySequence(const QKeySequence &key);
|
void setDefaultKeySequence(const QKeySequence &key);
|
||||||
@@ -67,7 +57,6 @@ public:
|
|||||||
QString defaultText() const;
|
QString defaultText() const;
|
||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
CommandType type() const;
|
|
||||||
|
|
||||||
QAction *action() const;
|
QAction *action() const;
|
||||||
QShortcut *shortcut() const;
|
QShortcut *shortcut() const;
|
||||||
@@ -82,7 +71,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_category;
|
QString m_category;
|
||||||
int m_type;
|
int m_attributes;
|
||||||
int m_id;
|
int m_id;
|
||||||
QKeySequence m_defaultKey;
|
QKeySequence m_defaultKey;
|
||||||
QString m_defaultText;
|
QString m_defaultText;
|
||||||
@@ -121,7 +110,7 @@ class Action : public CommandPrivate
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Action(CommandType type, int id);
|
Action(int id);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user