Commit 60103868 authored by con's avatar con
Browse files

Remove one level of the Command class hierarchy.

Remove the historical separation of "Action" and "OverridableAction".
The latter is now merged into the former.
parent e172eccb
......@@ -323,9 +323,9 @@ ActionContainer *ActionManagerPrivate::createMenuBar(const QString &id)
Command *ActionManagerPrivate::registerAction(QAction *action, const QString &id, const QList<int> &context)
{
OverrideableAction *a = 0;
Action *a = 0;
Command *c = registerOverridableAction(action, id, false);
a = static_cast<OverrideableAction *>(c);
a = static_cast<Action *>(c);
if (a)
a->addOverrideAction(action, context);
return a;
......@@ -333,16 +333,16 @@ Command *ActionManagerPrivate::registerAction(QAction *action, const QString &id
Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
{
OverrideableAction *a = 0;
Action *a = 0;
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
a = qobject_cast<OverrideableAction *>(c);
a = qobject_cast<Action *>(c);
if (!a) {
qWarning() << "registerAction: id" << id << "is registered with a different command type.";
return c;
}
} else {
a = new OverrideableAction(uid);
a = new Action(uid);
m_idCmdMap.insert(uid, a);
}
......
......@@ -352,7 +352,11 @@ bool Shortcut::isActive() const
\internal
*/
Action::Action(int id)
: CommandPrivate(id), m_action(0)
: CommandPrivate(id),
m_action(0),
m_currentAction(0),
m_active(false),
m_contextInitialized(false)
{
}
......@@ -416,25 +420,7 @@ QKeySequence Action::keySequence() const
return m_action->shortcut();
}
// ---------- OverrideableAction ------------
/*!
\class OverrideableAction
\internal
*/
OverrideableAction::OverrideableAction(int id)
: Action(id), m_currentAction(0), m_active(false),
m_contextInitialized(false)
{
}
void OverrideableAction::setAction(QAction *action)
{
Action::setAction(action);
}
bool OverrideableAction::setCurrentContext(const QList<int> &context)
bool Action::setCurrentContext(const QList<int> &context)
{
m_context = context;
......@@ -488,7 +474,7 @@ static inline QString msgActionWarning(QAction *newAction, int k, QAction *oldAc
return msg;
}
void OverrideableAction::addOverrideAction(QAction *action, const QList<int> &context)
void Action::addOverrideAction(QAction *action, const QList<int> &context)
{
if (context.isEmpty()) {
m_contextActionMap.insert(0, action);
......@@ -502,7 +488,7 @@ void OverrideableAction::addOverrideAction(QAction *action, const QList<int> &co
}
}
void OverrideableAction::actionChanged()
void Action::actionChanged()
{
if (hasAttribute(CA_UpdateIcon)) {
m_action->setIcon(m_currentAction->icon());
......@@ -525,7 +511,7 @@ void OverrideableAction::actionChanged()
m_action->setVisible(m_currentAction->isVisible());
}
bool OverrideableAction::isActive() const
bool Action::isActive() const
{
return m_active;
}
......@@ -124,30 +124,21 @@ public:
void setLocations(const QList<CommandLocation> &locations);
QList<CommandLocation> locations() const;
protected:
void updateToolTipWithKeySequence();
QAction *m_action;
QList<CommandLocation> m_locations;
QString m_toolTip;
};
class OverrideableAction : public Action
{
Q_OBJECT
public:
OverrideableAction(int id);
void setAction(QAction *action);
bool setCurrentContext(const QList<int> &context);
void addOverrideAction(QAction *action, const QList<int> &context);
bool isActive() const;
void addOverrideAction(QAction *action, const QList<int> &context);
protected:
void updateToolTipWithKeySequence();
private slots:
void actionChanged();
private:
QAction *m_action;
QList<CommandLocation> m_locations;
QString m_toolTip;
QPointer<QAction> m_currentAction;
QList<int> m_context;
QMap<int, QPointer<QAction> > m_contextActionMap;
......
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