From d9f97aa179d3441943ee7e258333bf228fa67a5d Mon Sep 17 00:00:00 2001
From: con <qtc-committer@nokia.com>
Date: Wed, 14 Jan 2009 12:58:06 +0100
Subject: [PATCH] Fixes:    - Command --> CommandPrivate

Details:  - Preparation for ICommand rename
---
 .../actionmanager/actioncontainer.cpp         |  10 +-
 .../actionmanager/actionmanager.cpp           |  10 +-
 .../actionmanager/actionmanager_p.h           |   6 +-
 .../coreplugin/actionmanager/command.cpp      | 111 ++++--------------
 .../actionmanager/{command.h => command_p.h}  |  16 +--
 .../coreplugin/actionmanager/commandsfile.cpp |   2 +-
 src/plugins/coreplugin/coreplugin.pro         |   2 +-
 .../coreplugin/dialogs/shortcutsettings.cpp   |  10 +-
 .../coreplugin/dialogs/shortcutsettings.h     |   1 -
 9 files changed, 53 insertions(+), 115 deletions(-)
 rename src/plugins/coreplugin/actionmanager/{command.h => command_p.h} (94%)

diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp
index 9c478fae5ff..124711fe37a 100644
--- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp
+++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp
@@ -34,7 +34,7 @@
 #include "actioncontainer_p.h"
 #include "actionmanager_p.h"
 
-#include "command.h"
+#include "command_p.h"
 #include "coreimpl.h"
 
 #include "coreconstants.h"
@@ -171,7 +171,7 @@ void ActionContainerPrivate::addAction(ICommand *action, const QString &group)
 
     ActionManagerPrivate *am = ActionManagerPrivate::instance();
     Action *a = static_cast<Action *>(action);
-    if (a->stateFlags() & Command::CS_PreLocation) {
+    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)) {
@@ -179,7 +179,7 @@ void ActionContainerPrivate::addAction(ICommand *action, const QString &group)
                 ac->addAction(action, locs.at(i).m_position, false);
             }
         }
-        a->setStateFlags(a->stateFlags() | Command::CS_Initialized);
+        a->setStateFlags(a->stateFlags() | CommandPrivate::CS_Initialized);
     } else {
         UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager();
         int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
@@ -239,8 +239,8 @@ bool ActionContainerPrivate::canAddAction(ICommand *action) const
     if (action->type() != ICommand::CT_OverridableAction)
         return false;
 
-    Command *cmd = static_cast<Command *>(action);
-    if (cmd->stateFlags() & Command::CS_Initialized)
+    CommandPrivate *cmd = static_cast<CommandPrivate *>(action);
+    if (cmd->stateFlags() & CommandPrivate::CS_Initialized)
         return false;
 
     return true;
diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp
index 6b359304324..cf8791dab1d 100644
--- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp
+++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp
@@ -34,7 +34,7 @@
 #include "actionmanager_p.h"
 #include "mainwindow.h"
 #include "actioncontainer_p.h"
-#include "command.h"
+#include "command_p.h"
 #include "uniqueidmanager.h"
 
 #include <coreplugin/coreconstants.h>
@@ -233,7 +233,7 @@ QList<int> ActionManagerPrivate::defaultGroups() const
     return m_defaultGroups;
 }
 
-QList<Command *> ActionManagerPrivate::commands() const
+QList<CommandPrivate *> ActionManagerPrivate::commands() const
 {
     return m_idCmdMap.values();
 }
@@ -322,7 +322,7 @@ ICommand *ActionManagerPrivate::registerOverridableAction(QAction *action, const
 {
     OverrideableAction *a = 0;
     const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
-    if (Command *c = m_idCmdMap.value(uid, 0)) {
+    if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
         if (c->type() != ICommand::CT_OverridableAction) {
             qWarning() << "registerAction: id" << id << "is registered with a different command type.";
             return c;
@@ -368,7 +368,7 @@ ICommand *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QStr
 {
     Shortcut *sc = 0;
     int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
-    if (Command *c = m_idCmdMap.value(uid, 0)) {
+    if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
         if (c->type() != ICommand::CT_Shortcut) {
             qWarning() << "registerShortcut: id" << id << "is registered with a different command type.";
             return c;
@@ -476,7 +476,7 @@ void ActionManagerPrivate::saveSettings(QSettings *settings)
     const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
     for (IdCmdMap::const_iterator j = m_idCmdMap.constBegin(); j != cmdcend; ++j) {
         const int id = j.key();
-        Command *cmd = j.value();
+        CommandPrivate *cmd = j.value();
         QKeySequence key = cmd->keySequence();
         if (key != cmd->defaultKeySequence()) {
             const QString sid = m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(id);
diff --git a/src/plugins/coreplugin/actionmanager/actionmanager_p.h b/src/plugins/coreplugin/actionmanager/actionmanager_p.h
index c0712d38475..2fedcd5395c 100644
--- a/src/plugins/coreplugin/actionmanager/actionmanager_p.h
+++ b/src/plugins/coreplugin/actionmanager/actionmanager_p.h
@@ -58,7 +58,7 @@ namespace Internal {
 
 class ActionContainerPrivate;
 class MainWindow;
-class Command;
+class CommandPrivate;
 
 class ActionManagerPrivate : public Core::ActionManager
 {
@@ -74,7 +74,7 @@ public:
     void saveSettings(QSettings *settings);
     QList<int> defaultGroups() const;
 
-    QList<Command *> commands() const;
+    QList<CommandPrivate *> commands() const;
     QList<ActionContainerPrivate *> containers() const;
 
     bool hasContext(int context) const;
@@ -104,7 +104,7 @@ private:
     static ActionManagerPrivate* m_instance;
     QList<int> m_defaultGroups;
 
-    typedef QHash<int, Command *> IdCmdMap;
+    typedef QHash<int, CommandPrivate *> IdCmdMap;
     IdCmdMap m_idCmdMap;
 
     typedef QHash<int, ActionContainerPrivate *> IdContainerMap;
diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp
index 90931a8bb14..242e9559758 100644
--- a/src/plugins/coreplugin/actionmanager/command.cpp
+++ b/src/plugins/coreplugin/actionmanager/command.cpp
@@ -35,7 +35,7 @@
 #include <QtGui/QAction>
 #include <QtGui/QShortcut>
 
-#include "command.h"
+#include "command_p.h"
 
 /*!
     \class Core::ICommand
@@ -105,170 +105,111 @@
 using namespace Core::Internal;
 
 /*!
-    \class Command
-    \ingroup qwb
-    \inheaderfile command.h
-*/
-
-/*!
-    \enum Command::CommandState
+    \class CommandPrivate
+    \inheaderfile command_p.h
+    \internal
 */
 
-/*!
-    \fn Command::Command(CommandType type, int id)
-*/
-Command::Command(CommandType type, int id)
+CommandPrivate::CommandPrivate(CommandType type, int id)
     : m_type(type), m_id(id)
 {
 }
 
-/*!
-    \fn virtual Command::~Command()
-*/
-
-/*!
-    ...
-*/
-void Command::setStateFlags(int state)
+void CommandPrivate::setStateFlags(int state)
 {
     m_type |= (state & CS_Mask);
 }
 
-/*!
-    ...
-*/
-int Command::stateFlags() const
+int CommandPrivate::stateFlags() const
 {
     return (m_type & CS_Mask);
 }
 
-/*!
-    \fn virtual QString Command::name() const
-*/
-
-/*!
-    ...
-*/
-void Command::setCategory(const QString &name)
+void CommandPrivate::setCategory(const QString &name)
 {
     m_category = name;
 }
 
-/*!
-    ...
-*/
-QString Command::category() const
+QString CommandPrivate::category() const
 {
     if (m_category.isEmpty())
         return QObject::tr("Other");
     return m_category;
 }
 
-/*!
-    ...
-*/
-void Command::setDefaultKeySequence(const QKeySequence &key)
+void CommandPrivate::setDefaultKeySequence(const QKeySequence &key)
 {
     m_defaultKey = key;
 }
 
-/*!
-    ...
-*/
-QKeySequence Command::defaultKeySequence() const
+QKeySequence CommandPrivate::defaultKeySequence() const
 {
     return m_defaultKey;
 }
 
-void Command::setDefaultText(const QString &text)
+void CommandPrivate::setDefaultText(const QString &text)
 {
     m_defaultText = text;
 }
 
-QString Command::defaultText() const
+QString CommandPrivate::defaultText() const
 {
     return m_defaultText;
 }
 
-/*!
-    ...
-*/
-int Command::id() const
+int CommandPrivate::id() const
 {
     return m_id;
 }
 
-/*!
-    ...
-*/
-Command::CommandType Command::type() const
+CommandPrivate::CommandType CommandPrivate::type() const
 {
     return (CommandType)(m_type & CT_Mask);
 }
 
-/*!
-    ...
-*/
-QAction *Command::action() const
+QAction *CommandPrivate::action() const
 {
     return 0;
 }
 
-/*!
-    ...
-*/
-QShortcut *Command::shortcut() const
+QShortcut *CommandPrivate::shortcut() const
 {
     return 0;
 }
 
-/*!
-    ...
-*/
-void Command::setAttribute(CommandAttribute attr)
+void CommandPrivate::setAttribute(CommandAttribute attr)
 {
     m_type |= attr;
 }
 
-/*!
-    ...
-*/
-void Command::removeAttribute(CommandAttribute attr)
+void CommandPrivate::removeAttribute(CommandAttribute attr)
 {
     m_type &= ~attr;
 }
 
-/*!
-    ...
-*/
-bool Command::hasAttribute(CommandAttribute attr) const
+bool CommandPrivate::hasAttribute(CommandAttribute attr) const
 {
     return (m_type & attr);
 }
 
-QString Command::stringWithAppendedShortcut(const QString &str) const
+QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
 {
     return QString("%1 <span style=\"color: gray; font-size: small\">%2</span>").arg(str).arg(
             keySequence().toString(QKeySequence::NativeText));
 }
 
-/*!
-    \fn virtual bool Command::setCurrentContext(const QList<int> &context) = 0
-*/
-
 // ---------- Shortcut ------------
 
 /*!
     \class Shortcut
     \ingroup qwb
-    \inheaderfile command.h
 */
 
 /*!
     ...
 */
 Shortcut::Shortcut(int id)
-    : Command(CT_Shortcut, id), m_shortcut(0)
+    : CommandPrivate(CT_Shortcut, id), m_shortcut(0)
 {
 
 }
@@ -322,7 +263,7 @@ QList<int> Shortcut::context() const
 void Shortcut::setDefaultKeySequence(const QKeySequence &key)
 {
     setKeySequence(key);
-    Command::setDefaultKeySequence(key);
+    CommandPrivate::setDefaultKeySequence(key);
 }
 
 void Shortcut::setKeySequence(const QKeySequence &key)
@@ -374,14 +315,13 @@ bool Shortcut::isActive() const
 /*!
     \class Action
     \ingroup qwb
-    \inheaderfile command.h
 */
 
 /*!
     ...
 */
 Action::Action(CommandType type, int id)
-    : Command(type, id), m_action(0)
+    : CommandPrivate(type, id), m_action(0)
 {
 
 }
@@ -439,7 +379,7 @@ QList<CommandLocation> Action::locations() const
 void Action::setDefaultKeySequence(const QKeySequence &key)
 {
     setKeySequence(key);
-    Command::setDefaultKeySequence(key);
+    CommandPrivate::setDefaultKeySequence(key);
 }
 
 void Action::setKeySequence(const QKeySequence &key)
@@ -467,7 +407,6 @@ QKeySequence Action::keySequence() const
 /*!
     \class OverrideableAction
     \ingroup qwb
-    \inheaderfile command.h
 */
 
 /*!
diff --git a/src/plugins/coreplugin/actionmanager/command.h b/src/plugins/coreplugin/actionmanager/command_p.h
similarity index 94%
rename from src/plugins/coreplugin/actionmanager/command.h
rename to src/plugins/coreplugin/actionmanager/command_p.h
index f68bd247463..49640371c7f 100644
--- a/src/plugins/coreplugin/actionmanager/command.h
+++ b/src/plugins/coreplugin/actionmanager/command_p.h
@@ -31,8 +31,8 @@
 **
 ***************************************************************************/
 
-#ifndef COMMAND_H
-#define COMMAND_H
+#ifndef COMMAND_P_H
+#define COMMAND_P_H
 
 #include "icommand.h"
 #include "actionmanager_p.h"
@@ -45,7 +45,7 @@
 namespace Core {
 namespace Internal {
 
-class Command : public Core::ICommand
+class CommandPrivate : public Core::ICommand
 {
     Q_OBJECT
 public:
@@ -56,8 +56,8 @@ public:
         CS_Mask             = 0xFF0000
     };
 
-    Command(CommandType type, int id);
-    virtual ~Command() {}
+    CommandPrivate(CommandType type, int id);
+    virtual ~CommandPrivate() {}
 
     void setStateFlags(int state);
     int stateFlags() const;
@@ -95,7 +95,7 @@ protected:
     QString m_defaultText;
 };
 
-class Shortcut : public Command
+class Shortcut : public CommandPrivate
 {
     Q_OBJECT
 public:
@@ -124,7 +124,7 @@ private:
     QString m_defaultText;
 };
 
-class Action : public Command
+class Action : public CommandPrivate
 {
     Q_OBJECT
 public:
@@ -176,4 +176,4 @@ private:
 } // namespace Internal
 } // namespace Core
 
-#endif // COMMAND_H
+#endif // COMMAND_P_H
diff --git a/src/plugins/coreplugin/actionmanager/commandsfile.cpp b/src/plugins/coreplugin/actionmanager/commandsfile.cpp
index 6b8e906d33e..abdecf43660 100644
--- a/src/plugins/coreplugin/actionmanager/commandsfile.cpp
+++ b/src/plugins/coreplugin/actionmanager/commandsfile.cpp
@@ -34,7 +34,7 @@
 #include "coreimpl.h"
 #include "commandsfile.h"
 #include "shortcutsettings.h"
-#include "command.h"
+#include "command_p.h"
 
 #include <coreplugin/uniqueidmanager.h>
 
diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro
index b93a44ec542..8fefddbc2d1 100644
--- a/src/plugins/coreplugin/coreplugin.pro
+++ b/src/plugins/coreplugin/coreplugin.pro
@@ -102,7 +102,7 @@ HEADERS += mainwindow.h \
     actionmanager/actionmanager.h \
     actionmanager/icommand.h \
     actionmanager/actionmanager_p.h \
-    actionmanager/command.h \
+    actionmanager/command_p.h \
     actionmanager/actioncontainer_p.h \
     actionmanager/commandsfile.h \
     dialogs/saveitemsdialog.h \
diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
index d4f1abb438e..b093e5cf328 100644
--- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
+++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
@@ -34,7 +34,7 @@
 #include "shortcutsettings.h"
 #include "ui_shortcutsettings.h"
 #include "actionmanager_p.h"
-#include "command.h"
+#include "command_p.h"
 #include "coreconstants.h"
 #include "coreimpl.h"
 #include "commandsfile.h"
@@ -285,10 +285,10 @@ void ShortcutSettings::initialize()
     UniqueIDManager *uidm =
         CoreImpl::instance()->uniqueIDManager();
 
-    QList<Command *> cmds = m_am->commands();
+    QList<CommandPrivate *> cmds = m_am->commands();
     for (int i = 0; i < cmds.size(); ++i) {
-        Command *c = cmds.at(i);
-        if (c->hasAttribute(Command::CA_NonConfigureable))
+        CommandPrivate *c = cmds.at(i);
+        if (c->hasAttribute(CommandPrivate::CA_NonConfigureable))
             continue;
         if (c->action() && c->action()->isSeparator())
             continue;
@@ -313,7 +313,7 @@ void ShortcutSettings::initialize()
         item->setText(0, uidm->stringForUniqueIdentifier(c->id()));
 
         if (c->action()) {
-            QString text = c->hasAttribute(Command::CA_UpdateText) && !c->defaultText().isNull() ? c->defaultText() : c->action()->text();
+            QString text = c->hasAttribute(CommandPrivate::CA_UpdateText) && !c->defaultText().isNull() ? c->defaultText() : c->action()->text();
             s->m_key = c->action()->shortcut();
             item->setText(1, text);
         } else {
diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.h b/src/plugins/coreplugin/dialogs/shortcutsettings.h
index b0c4bbfbeae..49f83b3cdcc 100644
--- a/src/plugins/coreplugin/dialogs/shortcutsettings.h
+++ b/src/plugins/coreplugin/dialogs/shortcutsettings.h
@@ -52,7 +52,6 @@ class ICommand;
 namespace Internal {
 
 class ActionManagerPrivate;
-class Command;
 class MainWindow;
 
 struct ShortcutItem
-- 
GitLab