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)
|
||||
: 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;
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::setState(ContainerState state)
|
||||
{
|
||||
m_data |= state;
|
||||
}
|
||||
|
||||
bool ActionContainerPrivate::hasState(ContainerState state) const
|
||||
{
|
||||
return (m_data & state);
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::appendGroup(const QString &group)
|
||||
{
|
||||
int gid = UniqueIDManager::instance()->uniqueIdentifier(group);
|
||||
@@ -198,26 +188,14 @@ void ActionContainerPrivate::addAction(Command *action, const QString &group)
|
||||
return;
|
||||
|
||||
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();
|
||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||
if (!group.isEmpty())
|
||||
grpid = idmanager->uniqueIdentifier(group);
|
||||
if (!m_groups.contains(grpid) && !am->defaultGroups().contains(grpid))
|
||||
qWarning() << "*** addAction(): Unknown group: " << group;
|
||||
int pos = ((grpid << 16) | 0xFFFF);
|
||||
addAction(action, pos, true);
|
||||
}
|
||||
UniqueIDManager *idmanager = UniqueIDManager::instance();
|
||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||
if (!group.isEmpty())
|
||||
grpid = idmanager->uniqueIdentifier(group);
|
||||
if (!m_groups.contains(grpid) && !am->defaultGroups().contains(grpid))
|
||||
qWarning() << "*** addAction(): Unknown group: " << group;
|
||||
int pos = ((grpid << 16) | 0xFFFF);
|
||||
addAction(action, pos, true);
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group)
|
||||
@@ -227,24 +205,14 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group
|
||||
return;
|
||||
|
||||
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();
|
||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||
if (!group.isEmpty())
|
||||
grpid = idmanager->uniqueIdentifier(group);
|
||||
if (!m_groups.contains(grpid) && !am->defaultGroups().contains(grpid))
|
||||
qWarning() << "*** addMenu(): Unknown group: " << group;
|
||||
int pos = ((grpid << 16) | 0xFFFF);
|
||||
addMenu(menu, pos, true);
|
||||
}
|
||||
UniqueIDManager *idmanager = UniqueIDManager::instance();
|
||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||
if (!group.isEmpty())
|
||||
grpid = idmanager->uniqueIdentifier(group);
|
||||
if (!m_groups.contains(grpid) && !am->defaultGroups().contains(grpid))
|
||||
qWarning() << "*** addMenu(): Unknown group: " << group;
|
||||
int pos = ((grpid << 16) | 0xFFFF);
|
||||
addMenu(menu, pos, true);
|
||||
}
|
||||
|
||||
int ActionContainerPrivate::id() const
|
||||
@@ -264,14 +232,7 @@ QMenuBar *ActionContainerPrivate::menuBar() const
|
||||
|
||||
bool ActionContainerPrivate::canAddAction(Command *action) const
|
||||
{
|
||||
if (action->type() != Command::CT_OverridableAction)
|
||||
return false;
|
||||
|
||||
CommandPrivate *cmd = static_cast<CommandPrivate *>(action);
|
||||
if (cmd->stateFlags() & CommandPrivate::CS_Initialized)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return (action->action() != 0);
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::addAction(Command *action, int pos, bool setpos)
|
||||
@@ -444,9 +405,6 @@ bool MenuActionContainer::update()
|
||||
|
||||
bool MenuActionContainer::canBeAddedToMenu() const
|
||||
{
|
||||
if (hasState(ActionContainerPrivate::CS_Initialized))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,22 +41,12 @@ namespace Internal {
|
||||
class ActionContainerPrivate : public Core::ActionContainer
|
||||
{
|
||||
public:
|
||||
enum ContainerState {
|
||||
CS_None = 0x000000,
|
||||
CS_Initialized = 0x010000,
|
||||
CS_PreLocation = 0x020000,
|
||||
CS_UserDefined = 0x040000
|
||||
};
|
||||
|
||||
ActionContainerPrivate(int id);
|
||||
virtual ~ActionContainerPrivate() {}
|
||||
|
||||
void setEmptyAction(EmptyAction ea);
|
||||
bool hasEmptyAction(EmptyAction ea) const;
|
||||
|
||||
void setState(ContainerState state);
|
||||
bool hasState(ContainerState state) const;
|
||||
|
||||
QAction *insertLocation(const QString &group) const;
|
||||
void appendGroup(const QString &group);
|
||||
void addAction(Command *action, const QString &group = QString());
|
||||
|
||||
@@ -335,13 +335,12 @@ Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const
|
||||
OverrideableAction *a = 0;
|
||||
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
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.";
|
||||
return c;
|
||||
}
|
||||
a = static_cast<OverrideableAction *>(c);
|
||||
}
|
||||
if (!a) {
|
||||
} else {
|
||||
a = new OverrideableAction(uid);
|
||||
m_idCmdMap.insert(uid, a);
|
||||
}
|
||||
@@ -381,11 +380,11 @@ Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QStri
|
||||
Shortcut *sc = 0;
|
||||
int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
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.";
|
||||
return c;
|
||||
}
|
||||
sc = static_cast<Shortcut *>(c);
|
||||
} else {
|
||||
sc = new Shortcut(uid);
|
||||
m_idCmdMap.insert(uid, sc);
|
||||
|
||||
@@ -41,10 +41,6 @@
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum Command::CommandType
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum Command::CommandAttribute
|
||||
*/
|
||||
@@ -57,10 +53,6 @@
|
||||
\fn virtual int Command::id() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual CommandType Command::type() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QAction *Command::action() const
|
||||
*/
|
||||
@@ -97,21 +89,11 @@ using namespace Core::Internal;
|
||||
\internal
|
||||
*/
|
||||
|
||||
CommandPrivate::CommandPrivate(CommandType type, int id)
|
||||
: m_type(type), m_id(id)
|
||||
CommandPrivate::CommandPrivate(int 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)
|
||||
{
|
||||
m_defaultKey = key;
|
||||
@@ -137,11 +119,6 @@ int CommandPrivate::id() const
|
||||
return m_id;
|
||||
}
|
||||
|
||||
CommandPrivate::CommandType CommandPrivate::type() const
|
||||
{
|
||||
return (CommandType)(m_type & CT_Mask);
|
||||
}
|
||||
|
||||
QAction *CommandPrivate::action() const
|
||||
{
|
||||
return 0;
|
||||
@@ -154,17 +131,17 @@ QShortcut *CommandPrivate::shortcut() const
|
||||
|
||||
void CommandPrivate::setAttribute(CommandAttribute attr)
|
||||
{
|
||||
m_type |= attr;
|
||||
m_attributes |= attr;
|
||||
}
|
||||
|
||||
void CommandPrivate::removeAttribute(CommandAttribute attr)
|
||||
{
|
||||
m_type &= ~attr;
|
||||
m_attributes &= ~attr;
|
||||
}
|
||||
|
||||
bool CommandPrivate::hasAttribute(CommandAttribute attr) const
|
||||
{
|
||||
return (m_type & attr);
|
||||
return (m_attributes & attr);
|
||||
}
|
||||
|
||||
QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
|
||||
@@ -183,7 +160,7 @@ QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
|
||||
...
|
||||
*/
|
||||
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)
|
||||
: CommandPrivate(type, id), m_action(0)
|
||||
Action::Action(int id)
|
||||
: CommandPrivate(id), m_action(0)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -385,7 +362,7 @@ QKeySequence Action::keySequence() const
|
||||
...
|
||||
*/
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,12 +42,6 @@ class CORE_EXPORT Command : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum CommandType {
|
||||
CT_Shortcut = 0x0001,
|
||||
CT_OverridableAction = 0x0002,
|
||||
CT_Mask = 0x00FF
|
||||
};
|
||||
|
||||
enum CommandAttribute {
|
||||
CA_Hide = 0x0100,
|
||||
CA_UpdateText = 0x0200,
|
||||
@@ -64,7 +58,6 @@ public:
|
||||
virtual QString defaultText() const = 0;
|
||||
|
||||
virtual int id() const = 0;
|
||||
virtual CommandType type() const = 0;
|
||||
|
||||
virtual QAction *action() const = 0;
|
||||
virtual QShortcut *shortcut() const = 0;
|
||||
|
||||
@@ -45,19 +45,9 @@ class CommandPrivate : public Core::Command
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum CommandState {
|
||||
CS_PreLocation = 0x020000,
|
||||
CS_LocationChanged = 0x040000,
|
||||
CS_Initialized = 0x080000,
|
||||
CS_Mask = 0xFF0000
|
||||
};
|
||||
|
||||
CommandPrivate(CommandType type, int id);
|
||||
CommandPrivate(int id);
|
||||
virtual ~CommandPrivate() {}
|
||||
|
||||
void setStateFlags(int state);
|
||||
int stateFlags() const;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
@@ -67,7 +57,6 @@ public:
|
||||
QString defaultText() const;
|
||||
|
||||
int id() const;
|
||||
CommandType type() const;
|
||||
|
||||
QAction *action() const;
|
||||
QShortcut *shortcut() const;
|
||||
@@ -82,7 +71,7 @@ public:
|
||||
|
||||
protected:
|
||||
QString m_category;
|
||||
int m_type;
|
||||
int m_attributes;
|
||||
int m_id;
|
||||
QKeySequence m_defaultKey;
|
||||
QString m_defaultText;
|
||||
@@ -121,7 +110,7 @@ class Action : public CommandPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Action(CommandType type, int id);
|
||||
Action(int id);
|
||||
|
||||
QString name() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user