mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6106 Apply clang-format on AppFwk
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
@@ -50,55 +49,43 @@
|
||||
class UndoRedoWrapper : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
explicit UndoRedoWrapper(caf::CmdExecuteCommand* executeCommand)
|
||||
explicit UndoRedoWrapper( caf::CmdExecuteCommand* executeCommand )
|
||||
{
|
||||
m_executeCommand = executeCommand;
|
||||
|
||||
setText(m_executeCommand->name());
|
||||
setText( m_executeCommand->name() );
|
||||
}
|
||||
|
||||
~UndoRedoWrapper() override
|
||||
{
|
||||
delete m_executeCommand;
|
||||
}
|
||||
~UndoRedoWrapper() override { delete m_executeCommand; }
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void undo() override
|
||||
{
|
||||
m_executeCommand->undo();
|
||||
}
|
||||
void undo() override { m_executeCommand->undo(); }
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void redo() override
|
||||
{
|
||||
m_executeCommand->redo();
|
||||
}
|
||||
|
||||
void redo() override { m_executeCommand->redo(); }
|
||||
|
||||
private:
|
||||
caf::CmdExecuteCommand* m_executeCommand;
|
||||
};
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdExecCommandManager::CmdExecCommandManager()
|
||||
{
|
||||
m_commandFeatureInterface = nullptr;
|
||||
|
||||
|
||||
m_undoStack = new QUndoStack();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdExecCommandManager* CmdExecCommandManager::instance()
|
||||
{
|
||||
@@ -107,38 +94,38 @@ CmdExecCommandManager* CmdExecCommandManager::instance()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::activateCommandSystem()
|
||||
{
|
||||
if (!m_commandFeatureInterface)
|
||||
if ( !m_commandFeatureInterface )
|
||||
{
|
||||
m_commandFeatureInterface = new CmdUiCommandSystemImpl;
|
||||
}
|
||||
|
||||
PdmUiCommandSystemProxy::instance()->setCommandInterface(m_commandFeatureInterface);
|
||||
PdmUiCommandSystemProxy::instance()->setCommandInterface( m_commandFeatureInterface );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::deactivateCommandSystem()
|
||||
{
|
||||
PdmUiCommandSystemProxy::instance()->setCommandInterface(nullptr);
|
||||
PdmUiCommandSystemProxy::instance()->setCommandInterface( nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::enableUndoCommandSystem(bool enable)
|
||||
void CmdExecCommandManager::enableUndoCommandSystem( bool enable )
|
||||
{
|
||||
this->activateCommandSystem();
|
||||
|
||||
m_commandFeatureInterface->enableUndoFeature(enable);
|
||||
m_commandFeatureInterface->enableUndoFeature( enable );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QUndoStack* CmdExecCommandManager::undoStack()
|
||||
{
|
||||
@@ -146,52 +133,53 @@ QUndoStack* CmdExecCommandManager::undoStack()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::processExecuteCommand(CmdExecuteCommand* executeCommand)
|
||||
void CmdExecCommandManager::processExecuteCommand( CmdExecuteCommand* executeCommand )
|
||||
{
|
||||
if (isUndoEnabledForCurrentCommand(executeCommand))
|
||||
if ( isUndoEnabledForCurrentCommand( executeCommand ) )
|
||||
{
|
||||
// Transfer ownership of execute command to wrapper object
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper(executeCommand);
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper( executeCommand );
|
||||
|
||||
m_undoStack->push(undoRedoWrapper);
|
||||
m_undoStack->push( undoRedoWrapper );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Execute command and delete the execute command
|
||||
|
||||
|
||||
executeCommand->redo();
|
||||
delete executeCommand;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::processExecuteCommandsAsMacro(const QString& macroName, std::vector<CmdExecuteCommand*>& commands)
|
||||
void CmdExecCommandManager::processExecuteCommandsAsMacro( const QString& macroName,
|
||||
std::vector<CmdExecuteCommand*>& commands )
|
||||
{
|
||||
if (commands.size() == 0)
|
||||
if ( commands.size() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUndoEnabledForCurrentCommand(commands[0]))
|
||||
if ( isUndoEnabledForCurrentCommand( commands[0] ) )
|
||||
{
|
||||
m_undoStack->beginMacro(macroName);
|
||||
for (size_t i = 0; i < commands.size(); i++)
|
||||
m_undoStack->beginMacro( macroName );
|
||||
for ( size_t i = 0; i < commands.size(); i++ )
|
||||
{
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper(commands[i]);
|
||||
m_undoStack->push(undoRedoWrapper);
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper( commands[i] );
|
||||
m_undoStack->push( undoRedoWrapper );
|
||||
}
|
||||
m_undoStack->endMacro();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < commands.size(); i++)
|
||||
for ( size_t i = 0; i < commands.size(); i++ )
|
||||
{
|
||||
CmdExecuteCommand* executeCommand = commands[i];
|
||||
if (executeCommand)
|
||||
if ( executeCommand )
|
||||
{
|
||||
executeCommand->redo();
|
||||
delete executeCommand;
|
||||
@@ -201,17 +189,17 @@ void CmdExecCommandManager::processExecuteCommandsAsMacro(const QString& macroNa
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdExecCommandManager::isUndoEnabledForCurrentCommand(CmdExecuteCommand* command)
|
||||
bool CmdExecCommandManager::isUndoEnabledForCurrentCommand( CmdExecuteCommand* command )
|
||||
{
|
||||
bool useUndo = false;
|
||||
|
||||
if (dynamic_cast<CmdFieldChangeExec*>(command) && m_commandFeatureInterface->disableUndoForFieldChange())
|
||||
if ( dynamic_cast<CmdFieldChangeExec*>( command ) && m_commandFeatureInterface->disableUndoForFieldChange() )
|
||||
{
|
||||
useUndo = false;
|
||||
}
|
||||
else if (m_commandFeatureInterface && m_commandFeatureInterface->isUndoEnabled())
|
||||
else if ( m_commandFeatureInterface && m_commandFeatureInterface->isUndoEnabled() )
|
||||
{
|
||||
useUndo = true;
|
||||
}
|
||||
@@ -219,5 +207,4 @@ bool CmdExecCommandManager::isUndoEnabledForCurrentCommand(CmdExecuteCommand* co
|
||||
return useUndo;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QPointer>
|
||||
@@ -44,45 +43,44 @@
|
||||
class QUndoStack;
|
||||
class QString;
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class CmdExecuteCommand;
|
||||
class CmdUiCommandSystemImpl;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class CmdExecCommandManager
|
||||
{
|
||||
public:
|
||||
static CmdExecCommandManager* instance();
|
||||
|
||||
CmdExecCommandManager(const CmdExecCommandManager&) = delete;
|
||||
CmdExecCommandManager& operator=(const CmdExecCommandManager&) = delete;
|
||||
CmdExecCommandManager( const CmdExecCommandManager& ) = delete;
|
||||
CmdExecCommandManager& operator=( const CmdExecCommandManager& ) = delete;
|
||||
|
||||
// When the undoFeature is enabled, execute commands are inserted in the undo stack
|
||||
// The application can use the QUndoStack to display/modify execute commands wrapped in QUndoCommand objects
|
||||
void enableUndoCommandSystem(bool enable);
|
||||
void enableUndoCommandSystem( bool enable );
|
||||
QUndoStack* undoStack();
|
||||
|
||||
// If undo system is enabled, the PdmExecuteCommand is wrapped in a QUndoCommand and inserted in the QUndoStack.
|
||||
// If undo is not possible (undo system not enabled, or pdm object has disabled undo),
|
||||
// the PdmExecuteCommand is executed and deleted
|
||||
void processExecuteCommand(CmdExecuteCommand* executeCommand);
|
||||
void processExecuteCommandsAsMacro(const QString& macroName, std::vector<CmdExecuteCommand*>& commands);
|
||||
void processExecuteCommand( CmdExecuteCommand* executeCommand );
|
||||
void processExecuteCommandsAsMacro( const QString& macroName, std::vector<CmdExecuteCommand*>& commands );
|
||||
|
||||
private:
|
||||
CmdExecCommandManager();
|
||||
|
||||
// Creates the object (CmdUiCommandSystemImpl) used to communicate from UI editors to advanced parts of the command system
|
||||
// This includes support for undo system and default command features for add/delete of items in PdmChildArrayFieldHandle
|
||||
// and creation of field changed commands so a change in an editor can be put into undo/redo
|
||||
// CmdUiCommandSystemImpl is a requirement for using the undo system
|
||||
// Creates the object (CmdUiCommandSystemImpl) used to communicate from UI editors to advanced parts of the command
|
||||
// system This includes support for undo system and default command features for add/delete of items in
|
||||
// PdmChildArrayFieldHandle and creation of field changed commands so a change in an editor can be put into
|
||||
// undo/redo CmdUiCommandSystemImpl is a requirement for using the undo system
|
||||
void activateCommandSystem();
|
||||
void deactivateCommandSystem();
|
||||
|
||||
bool isUndoEnabledForCurrentCommand(CmdExecuteCommand* command);
|
||||
bool isUndoEnabledForCurrentCommand( CmdExecuteCommand* command );
|
||||
|
||||
friend class CmdExecCommandSystemActivator;
|
||||
friend class CmdExecCommandSystemDeactivator;
|
||||
@@ -99,15 +97,9 @@ private:
|
||||
class CmdExecCommandSystemDeactivator
|
||||
{
|
||||
public:
|
||||
CmdExecCommandSystemDeactivator()
|
||||
{
|
||||
CmdExecCommandManager::instance()->deactivateCommandSystem();
|
||||
}
|
||||
CmdExecCommandSystemDeactivator() { CmdExecCommandManager::instance()->deactivateCommandSystem(); }
|
||||
|
||||
~CmdExecCommandSystemDeactivator()
|
||||
{
|
||||
CmdExecCommandManager::instance()->activateCommandSystem();
|
||||
}
|
||||
~CmdExecCommandSystemDeactivator() { CmdExecCommandManager::instance()->activateCommandSystem(); }
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
@@ -116,15 +108,9 @@ public:
|
||||
class CmdExecCommandSystemActivator
|
||||
{
|
||||
public:
|
||||
CmdExecCommandSystemActivator()
|
||||
{
|
||||
CmdExecCommandManager::instance()->activateCommandSystem();
|
||||
}
|
||||
CmdExecCommandSystemActivator() { CmdExecCommandManager::instance()->activateCommandSystem(); }
|
||||
|
||||
~CmdExecCommandSystemActivator()
|
||||
{
|
||||
CmdExecCommandManager::instance()->deactivateCommandSystem();
|
||||
}
|
||||
~CmdExecCommandSystemActivator() { CmdExecCommandManager::instance()->deactivateCommandSystem(); }
|
||||
};
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,38 +34,31 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class NotificationCenter;
|
||||
class PdmObjectHandle;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
explicit CmdExecuteCommand(NotificationCenter* notificationCenter)
|
||||
{
|
||||
m_notificationCenter = notificationCenter;
|
||||
}
|
||||
explicit CmdExecuteCommand( NotificationCenter* notificationCenter ) { m_notificationCenter = notificationCenter; }
|
||||
|
||||
virtual ~CmdExecuteCommand() { };
|
||||
virtual ~CmdExecuteCommand(){};
|
||||
|
||||
virtual QString name() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual void undo() = 0;
|
||||
|
||||
protected:
|
||||
NotificationCenter* m_notificationCenter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -46,112 +46,110 @@
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeature::CmdFeature()
|
||||
: m_triggerModelChange(true)
|
||||
: m_triggerModelChange( true )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeature::~CmdFeature()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* CmdFeature::action()
|
||||
{
|
||||
return this->actionWithCustomText(QString(""));
|
||||
return this->actionWithCustomText( QString( "" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* CmdFeature::actionWithCustomText(const QString& customText)
|
||||
QAction* CmdFeature::actionWithCustomText( const QString& customText )
|
||||
{
|
||||
return actionWithUserData(customText, QVariant());
|
||||
return actionWithUserData( customText, QVariant() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* CmdFeature::actionWithUserData(const QString& customText, const QVariant& userData)
|
||||
QAction* CmdFeature::actionWithUserData( const QString& customText, const QVariant& userData )
|
||||
{
|
||||
QAction* action = nullptr;
|
||||
|
||||
std::map<QString, QAction*>::iterator it;
|
||||
it = m_customTextToActionMap.find(customText);
|
||||
it = m_customTextToActionMap.find( customText );
|
||||
|
||||
if (it != m_customTextToActionMap.end() && it->second != NULL)
|
||||
if ( it != m_customTextToActionMap.end() && it->second != NULL )
|
||||
{
|
||||
action = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
action = new QAction(this);
|
||||
action = new QAction( this );
|
||||
|
||||
connect(action, SIGNAL(triggered(bool)), SLOT(actionTriggered(bool)));
|
||||
m_customTextToActionMap[customText]= action;
|
||||
connect( action, SIGNAL( triggered( bool ) ), SLOT( actionTriggered( bool ) ) );
|
||||
m_customTextToActionMap[customText] = action;
|
||||
}
|
||||
|
||||
if (!userData.isNull())
|
||||
if ( !userData.isNull() )
|
||||
{
|
||||
action->setData(userData);
|
||||
action->setData( userData );
|
||||
}
|
||||
|
||||
if (dynamic_cast<QApplication*>(QCoreApplication::instance()))
|
||||
if ( dynamic_cast<QApplication*>( QCoreApplication::instance() ) )
|
||||
{
|
||||
this->setupActionLook(action);
|
||||
this->setupActionLook( action );
|
||||
}
|
||||
if (!customText.isEmpty())
|
||||
if ( !customText.isEmpty() )
|
||||
{
|
||||
action->setText(customText);
|
||||
action->setText( customText );
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeature::refreshEnabledState()
|
||||
{
|
||||
std::map<QString, QAction*>::iterator it;
|
||||
bool isEnabled = this->isCommandEnabled();
|
||||
bool isEnabled = this->isCommandEnabled();
|
||||
|
||||
for (it = m_customTextToActionMap.begin(); it != m_customTextToActionMap.end(); ++it)
|
||||
for ( it = m_customTextToActionMap.begin(); it != m_customTextToActionMap.end(); ++it )
|
||||
{
|
||||
it->second->setEnabled(isEnabled);
|
||||
it->second->setEnabled( isEnabled );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeature::refreshCheckedState()
|
||||
{
|
||||
std::map<QString, QAction*>::iterator it;
|
||||
bool isChecked = this->isCommandChecked();
|
||||
bool isChecked = this->isCommandChecked();
|
||||
|
||||
for (it = m_customTextToActionMap.begin(); it != m_customTextToActionMap.end(); ++it)
|
||||
for ( it = m_customTextToActionMap.begin(); it != m_customTextToActionMap.end(); ++it )
|
||||
{
|
||||
QAction* act = it->second;
|
||||
if (act->isCheckable())
|
||||
if ( act->isCheckable() )
|
||||
{
|
||||
it->second->setChecked(isChecked);
|
||||
it->second->setChecked( isChecked );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdFeature::canFeatureBeExecuted()
|
||||
{
|
||||
@@ -161,32 +159,32 @@ bool CmdFeature::canFeatureBeExecuted()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeature::applyShortcutWithHintToAction(QAction* action, const QKeySequence& keySequence)
|
||||
void CmdFeature::applyShortcutWithHintToAction( QAction* action, const QKeySequence& keySequence )
|
||||
{
|
||||
action->setShortcut(keySequence);
|
||||
action->setShortcut( keySequence );
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) )
|
||||
// Qt made keyboard shortcuts in context menus platform dependent in Qt 5.10
|
||||
// With no global way of removing it.
|
||||
action->setShortcutVisibleInContextMenu(true);
|
||||
action->setShortcutVisibleInContextMenu( true );
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeature::actionTriggered(bool isChecked)
|
||||
void CmdFeature::actionTriggered( bool isChecked )
|
||||
{
|
||||
this->onActionTriggered(isChecked);
|
||||
this->onActionTriggered( isChecked );
|
||||
|
||||
if (m_triggerModelChange)
|
||||
if ( m_triggerModelChange )
|
||||
{
|
||||
caf::PdmUiModelChangeDetector::instance()->setModelChanged();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdFeature::isCommandChecked()
|
||||
{
|
||||
@@ -194,7 +192,7 @@ bool CmdFeature::isCommandChecked()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeature::disableModelChangeContribution()
|
||||
{
|
||||
@@ -207,8 +205,8 @@ void CmdFeature::disableModelChangeContribution()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QVariant CmdFeature::userData() const
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
CAF_ASSERT(action);
|
||||
QAction* action = qobject_cast<QAction*>( sender() );
|
||||
CAF_ASSERT( action );
|
||||
|
||||
return action->data();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafFactory.h"
|
||||
@@ -50,17 +49,19 @@ class QKeySequence;
|
||||
class QString;
|
||||
|
||||
#define CAF_CMD_HEADER_INIT \
|
||||
public: \
|
||||
public: \
|
||||
static const std::string& idNameStatic()
|
||||
|
||||
#define CAF_CMD_SOURCE_INIT(ClassName, CommandIdName)\
|
||||
const std::string& ClassName::idNameStatic() { static std::string id = CommandIdName; return id;} \
|
||||
CAF_FACTORY_REGISTER(caf::CmdFeature, ClassName, std::string, ClassName::idNameStatic())
|
||||
#define CAF_CMD_SOURCE_INIT( ClassName, CommandIdName ) \
|
||||
const std::string& ClassName::idNameStatic() \
|
||||
{ \
|
||||
static std::string id = CommandIdName; \
|
||||
return id; \
|
||||
} \
|
||||
CAF_FACTORY_REGISTER( caf::CmdFeature, ClassName, std::string, ClassName::idNameStatic() )
|
||||
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class CmdExecuteCommand;
|
||||
|
||||
//==================================================================================================
|
||||
@@ -77,33 +78,31 @@ public:
|
||||
CmdFeature();
|
||||
~CmdFeature() override;
|
||||
|
||||
QAction* action();
|
||||
QAction* actionWithCustomText(const QString& customText);
|
||||
QAction* actionWithUserData(const QString& customText, const QVariant& userData);
|
||||
void refreshEnabledState();
|
||||
void refreshCheckedState();
|
||||
QAction* action();
|
||||
QAction* actionWithCustomText( const QString& customText );
|
||||
QAction* actionWithUserData( const QString& customText, const QVariant& userData );
|
||||
void refreshEnabledState();
|
||||
void refreshCheckedState();
|
||||
|
||||
bool canFeatureBeExecuted();
|
||||
bool canFeatureBeExecuted();
|
||||
|
||||
static void applyShortcutWithHintToAction(QAction* action, const QKeySequence& keySequence);
|
||||
static void applyShortcutWithHintToAction( QAction* action, const QKeySequence& keySequence );
|
||||
|
||||
public slots:
|
||||
void actionTriggered(bool isChecked);
|
||||
void actionTriggered( bool isChecked );
|
||||
|
||||
protected:
|
||||
virtual void onActionTriggered(bool isChecked) = 0;
|
||||
virtual void setupActionLook(QAction* actionToSetup) = 0;
|
||||
virtual bool isCommandEnabled() = 0;
|
||||
virtual bool isCommandChecked();
|
||||
|
||||
void disableModelChangeContribution();
|
||||
const QVariant userData() const;
|
||||
virtual void onActionTriggered( bool isChecked ) = 0;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) = 0;
|
||||
virtual bool isCommandEnabled() = 0;
|
||||
virtual bool isCommandChecked();
|
||||
|
||||
void disableModelChangeContribution();
|
||||
const QVariant userData() const;
|
||||
|
||||
private:
|
||||
std::map<QString, QAction*> m_customTextToActionMap;
|
||||
bool m_triggerModelChange;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,46 +34,43 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafCmdSelectionHelper.h"
|
||||
#include "cafFactory.h"
|
||||
#include "cafFactory.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QKeySequence>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
typedef Factory<CmdFeature, std::string> CommandFeatureFactory;
|
||||
typedef Factory<CmdFeature, std::string> CommandFeatureFactory;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureManager::CmdFeatureManager()
|
||||
{
|
||||
// Make sure all command features are created. The command feature is registered
|
||||
// in the command factory, and instantiated when required. This will enable possibility
|
||||
// of searching through all command features instead of having to use the string keys to
|
||||
// of searching through all command features instead of having to use the string keys to
|
||||
// be sure all command features are present.
|
||||
std::vector<std::string> keys = CommandFeatureFactory::instance()->allKeys();
|
||||
for (size_t i = 0; i < keys.size(); i++)
|
||||
for ( size_t i = 0; i < keys.size(); i++ )
|
||||
{
|
||||
createFeature(keys[i]);
|
||||
createFeature( keys[i] );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureManager::~CmdFeatureManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureManager* CmdFeatureManager::instance()
|
||||
{
|
||||
@@ -85,99 +82,101 @@ CmdFeatureManager* CmdFeatureManager::instance()
|
||||
/// Get action for the specified command.
|
||||
/// The action is owned by the PdmCommandItemManager
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* CmdFeatureManager::action(const QString& commandId)
|
||||
QAction* CmdFeatureManager::action( const QString& commandId )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature(commandId.toStdString());
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature( commandId.toStdString() );
|
||||
|
||||
QAction* act = featurePair.first->action();
|
||||
QAction* act = featurePair.first->action();
|
||||
m_actionToFeatureIdxMap[act] = featurePair.second;
|
||||
|
||||
return act;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get action for the specified command, with custom action text
|
||||
/// Get action for the specified command, with custom action text
|
||||
/// The action is owned by the PdmCommandItemManager
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* CmdFeatureManager::action(const QString& commandId, const QString& customActionText)
|
||||
QAction* CmdFeatureManager::action( const QString& commandId, const QString& customActionText )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature(commandId.toStdString());
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature( commandId.toStdString() );
|
||||
|
||||
QAction* act = featurePair.first->actionWithCustomText(customActionText);
|
||||
QAction* act = featurePair.first->actionWithCustomText( customActionText );
|
||||
m_actionToFeatureIdxMap[act] = featurePair.second;
|
||||
|
||||
return act;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get action for the specified command, with custom action text
|
||||
/// Get action for the specified command, with custom action text
|
||||
/// The action is owned by the PdmCommandItemManager
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* CmdFeatureManager::actionWithUserData(const QString& commandId, const QString& customActionText, const QVariant& userData)
|
||||
QAction* CmdFeatureManager::actionWithUserData( const QString& commandId,
|
||||
const QString& customActionText,
|
||||
const QVariant& userData )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature(commandId.toStdString());
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature( commandId.toStdString() );
|
||||
|
||||
QAction* act = featurePair.first->actionWithUserData(customActionText, userData);
|
||||
QAction* act = featurePair.first->actionWithUserData( customActionText, userData );
|
||||
m_actionToFeatureIdxMap[act] = featurePair.second;
|
||||
|
||||
return act;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<CmdFeature*, size_t> CmdFeatureManager::createFeature(const std::string& commandId)
|
||||
std::pair<CmdFeature*, size_t> CmdFeatureManager::createFeature( const std::string& commandId )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = this->findExistingCmdFeature(commandId);
|
||||
std::pair<CmdFeature*, size_t> featurePair = this->findExistingCmdFeature( commandId );
|
||||
|
||||
if (featurePair.first)
|
||||
if ( featurePair.first )
|
||||
{
|
||||
return featurePair;
|
||||
}
|
||||
|
||||
CmdFeature* feature = CommandFeatureFactory::instance()->create(commandId);
|
||||
CAF_ASSERT(feature); // The command ID is not known in the factory
|
||||
|
||||
feature->setParent(this);
|
||||
CmdFeature* feature = CommandFeatureFactory::instance()->create( commandId );
|
||||
CAF_ASSERT( feature ); // The command ID is not known in the factory
|
||||
|
||||
feature->setParent( this );
|
||||
size_t index = m_commandFeatures.size();
|
||||
m_commandFeatures.push_back(feature);
|
||||
m_commandFeatures.push_back( feature );
|
||||
m_commandIdToFeatureIdxMap[commandId] = index;
|
||||
|
||||
return std::make_pair(feature, index);
|
||||
return std::make_pair( feature, index );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<CmdFeature*, size_t> CmdFeatureManager::findExistingCmdFeature(const std::string& commandId)
|
||||
std::pair<CmdFeature*, size_t> CmdFeatureManager::findExistingCmdFeature( const std::string& commandId )
|
||||
{
|
||||
std::map<std::string, size_t>::const_iterator it;
|
||||
it = m_commandIdToFeatureIdxMap.find(commandId);
|
||||
it = m_commandIdToFeatureIdxMap.find( commandId );
|
||||
|
||||
if (it != m_commandIdToFeatureIdxMap.end())
|
||||
if ( it != m_commandIdToFeatureIdxMap.end() )
|
||||
{
|
||||
size_t itemIndex = it->second;
|
||||
|
||||
CmdFeature* item = m_commandFeatures[itemIndex];
|
||||
item->refreshEnabledState();
|
||||
|
||||
return std::make_pair(item, itemIndex);
|
||||
return std::make_pair( item, itemIndex );
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::make_pair(static_cast<CmdFeature*>(nullptr), -1);
|
||||
return std::make_pair( static_cast<CmdFeature*>( nullptr ), -1 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::CmdFeature* CmdFeatureManager::commandFeature(const std::string& commandId) const
|
||||
caf::CmdFeature* CmdFeatureManager::commandFeature( const std::string& commandId ) const
|
||||
{
|
||||
std::map<std::string, size_t>::const_iterator it;
|
||||
it = m_commandIdToFeatureIdxMap.find(commandId);
|
||||
it = m_commandIdToFeatureIdxMap.find( commandId );
|
||||
|
||||
if (it != m_commandIdToFeatureIdxMap.end())
|
||||
if ( it != m_commandIdToFeatureIdxMap.end() )
|
||||
{
|
||||
size_t itemIndex = it->second;
|
||||
|
||||
@@ -190,17 +189,17 @@ caf::CmdFeature* CmdFeatureManager::commandFeature(const std::string& commandId)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeatureManager::refreshStates(const QStringList& commandIdList)
|
||||
void CmdFeatureManager::refreshStates( const QStringList& commandIdList )
|
||||
{
|
||||
if (commandIdList.size() == 0)
|
||||
if ( commandIdList.size() == 0 )
|
||||
{
|
||||
for (size_t i = 0; i < m_commandFeatures.size(); i++)
|
||||
for ( size_t i = 0; i < m_commandFeatures.size(); i++ )
|
||||
{
|
||||
CmdFeature* cmdFeature = m_commandFeatures[i];
|
||||
|
||||
if (cmdFeature)
|
||||
if ( cmdFeature )
|
||||
{
|
||||
cmdFeature->refreshEnabledState();
|
||||
cmdFeature->refreshCheckedState();
|
||||
@@ -209,11 +208,11 @@ void CmdFeatureManager::refreshStates(const QStringList& commandIdList)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < commandIdList.size(); i++)
|
||||
for ( int i = 0; i < commandIdList.size(); i++ )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = findExistingCmdFeature(commandIdList.at(i).toStdString());
|
||||
std::pair<CmdFeature*, size_t> featurePair = findExistingCmdFeature( commandIdList.at( i ).toStdString() );
|
||||
|
||||
if (featurePair.first)
|
||||
if ( featurePair.first )
|
||||
{
|
||||
featurePair.first->refreshEnabledState();
|
||||
featurePair.first->refreshCheckedState();
|
||||
@@ -223,24 +222,24 @@ void CmdFeatureManager::refreshStates(const QStringList& commandIdList)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeatureManager::refreshEnabledState(const QStringList& commandIdList)
|
||||
void CmdFeatureManager::refreshEnabledState( const QStringList& commandIdList )
|
||||
{
|
||||
if (commandIdList.size() == 0)
|
||||
if ( commandIdList.size() == 0 )
|
||||
{
|
||||
for (size_t i = 0; i < m_commandFeatures.size(); i++)
|
||||
for ( size_t i = 0; i < m_commandFeatures.size(); i++ )
|
||||
{
|
||||
m_commandFeatures[i]->refreshEnabledState();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < commandIdList.size(); i++)
|
||||
for ( int i = 0; i < commandIdList.size(); i++ )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = findExistingCmdFeature(commandIdList.at(i).toStdString());
|
||||
std::pair<CmdFeature*, size_t> featurePair = findExistingCmdFeature( commandIdList.at( i ).toStdString() );
|
||||
|
||||
if (featurePair.first)
|
||||
if ( featurePair.first )
|
||||
{
|
||||
featurePair.first->refreshEnabledState();
|
||||
}
|
||||
@@ -249,24 +248,24 @@ void CmdFeatureManager::refreshEnabledState(const QStringList& commandIdList)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeatureManager::refreshCheckedState(const QStringList& commandIdList)
|
||||
void CmdFeatureManager::refreshCheckedState( const QStringList& commandIdList )
|
||||
{
|
||||
if (commandIdList.size() == 0)
|
||||
if ( commandIdList.size() == 0 )
|
||||
{
|
||||
for (size_t i = 0; i < m_commandFeatures.size(); i++)
|
||||
for ( size_t i = 0; i < m_commandFeatures.size(); i++ )
|
||||
{
|
||||
m_commandFeatures[i]->refreshCheckedState();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < commandIdList.size(); i++)
|
||||
for ( int i = 0; i < commandIdList.size(); i++ )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = findExistingCmdFeature(commandIdList.at(i).toStdString());
|
||||
std::pair<CmdFeature*, size_t> featurePair = findExistingCmdFeature( commandIdList.at( i ).toStdString() );
|
||||
|
||||
if (featurePair.first)
|
||||
if ( featurePair.first )
|
||||
{
|
||||
featurePair.first->refreshCheckedState();
|
||||
}
|
||||
@@ -275,32 +274,31 @@ void CmdFeatureManager::refreshCheckedState(const QStringList& commandIdList)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeature* CmdFeatureManager::getCommandFeature(const std::string& commandId)
|
||||
CmdFeature* CmdFeatureManager::getCommandFeature( const std::string& commandId )
|
||||
{
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature(commandId);
|
||||
std::pair<CmdFeature*, size_t> featurePair = createFeature( commandId );
|
||||
|
||||
return featurePair.first;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingSubString(const std::string& subString) const
|
||||
std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingSubString( const std::string& subString ) const
|
||||
{
|
||||
std::vector<CmdFeature*> matches;
|
||||
|
||||
std::vector<std::string> keys = CommandFeatureFactory::instance()->allKeys();
|
||||
for (size_t i = 0; i < keys.size(); i++)
|
||||
for ( size_t i = 0; i < keys.size(); i++ )
|
||||
{
|
||||
if (keys[i].find(subString) != std::string::npos)
|
||||
if ( keys[i].find( subString ) != std::string::npos )
|
||||
{
|
||||
caf::CmdFeature* cmdFeature = commandFeature(keys[i]);
|
||||
if (cmdFeature)
|
||||
caf::CmdFeature* cmdFeature = commandFeature( keys[i] );
|
||||
if ( cmdFeature )
|
||||
{
|
||||
matches.push_back(cmdFeature);
|
||||
matches.push_back( cmdFeature );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,19 +309,19 @@ std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingSubString(con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingKeyboardShortcut(const QKeySequence& keySequence) const
|
||||
std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingKeyboardShortcut( const QKeySequence& keySequence ) const
|
||||
{
|
||||
std::vector<CmdFeature*> matches;
|
||||
|
||||
std::vector<std::string> keys = CommandFeatureFactory::instance()->allKeys();
|
||||
for (size_t i = 0; i < keys.size(); i++)
|
||||
for ( size_t i = 0; i < keys.size(); i++ )
|
||||
{
|
||||
caf::CmdFeature* cmdFeature = commandFeature(keys[i]);
|
||||
if (cmdFeature)
|
||||
caf::CmdFeature* cmdFeature = commandFeature( keys[i] );
|
||||
if ( cmdFeature )
|
||||
{
|
||||
if (cmdFeature->action()->shortcut().matches(keySequence) == QKeySequence::ExactMatch)
|
||||
if ( cmdFeature->action()->shortcut().matches( keySequence ) == QKeySequence::ExactMatch )
|
||||
{
|
||||
matches.push_back(cmdFeature);
|
||||
matches.push_back( cmdFeature );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,15 +330,15 @@ std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingKeyboardShort
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeatureManager::setCurrentContextMenuTargetWidget(QWidget * targetWidget)
|
||||
void CmdFeatureManager::setCurrentContextMenuTargetWidget( QWidget* targetWidget )
|
||||
{
|
||||
m_currentContextMenuTargetWidget = targetWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* CmdFeatureManager::currentContextMenuTargetWidget()
|
||||
{
|
||||
|
||||
@@ -34,28 +34,26 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QPointer>
|
||||
#include <QStringList>
|
||||
|
||||
class QAction;
|
||||
class QKeySequence;
|
||||
class QWidget;
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class CmdFeature;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class CmdFeatureManager : public QObject
|
||||
{
|
||||
@@ -65,37 +63,35 @@ public:
|
||||
static CmdFeatureManager* instance();
|
||||
~CmdFeatureManager() override;
|
||||
|
||||
QAction* action(const QString& commandId);
|
||||
QAction* action(const QString& commandId, const QString& customActionText);
|
||||
QAction* actionWithUserData(const QString& commandId, const QString& customActionText, const QVariant& userData);
|
||||
QAction* action( const QString& commandId );
|
||||
QAction* action( const QString& commandId, const QString& customActionText );
|
||||
QAction* actionWithUserData( const QString& commandId, const QString& customActionText, const QVariant& userData );
|
||||
|
||||
void refreshStates(const QStringList& commandIdList = QStringList());
|
||||
void refreshEnabledState(const QStringList& commandIdList = QStringList());
|
||||
void refreshCheckedState(const QStringList& commandIdList = QStringList());
|
||||
void refreshStates( const QStringList& commandIdList = QStringList() );
|
||||
void refreshEnabledState( const QStringList& commandIdList = QStringList() );
|
||||
void refreshCheckedState( const QStringList& commandIdList = QStringList() );
|
||||
|
||||
CmdFeature* getCommandFeature(const std::string& commandId);
|
||||
std::vector<CmdFeature*> commandFeaturesMatchingSubString(const std::string& subString) const;
|
||||
std::vector<CmdFeature*> commandFeaturesMatchingKeyboardShortcut(const QKeySequence& keySequence) const;
|
||||
CmdFeature* getCommandFeature( const std::string& commandId );
|
||||
std::vector<CmdFeature*> commandFeaturesMatchingSubString( const std::string& subString ) const;
|
||||
std::vector<CmdFeature*> commandFeaturesMatchingKeyboardShortcut( const QKeySequence& keySequence ) const;
|
||||
|
||||
void setCurrentContextMenuTargetWidget(QWidget * targetWidget);
|
||||
void setCurrentContextMenuTargetWidget( QWidget* targetWidget );
|
||||
QWidget* currentContextMenuTargetWidget();
|
||||
|
||||
private:
|
||||
CmdFeatureManager();
|
||||
|
||||
std::pair<CmdFeature*, size_t> createFeature(const std::string& commandId);
|
||||
std::pair<CmdFeature*, size_t> findExistingCmdFeature(const std::string& commandId);
|
||||
std::pair<CmdFeature*, size_t> createFeature( const std::string& commandId );
|
||||
std::pair<CmdFeature*, size_t> findExistingCmdFeature( const std::string& commandId );
|
||||
|
||||
CmdFeature* commandFeature(const std::string& commandId) const;
|
||||
CmdFeature* commandFeature( const std::string& commandId ) const;
|
||||
|
||||
private:
|
||||
std::vector<CmdFeature*> m_commandFeatures;
|
||||
std::map<std::string , size_t > m_commandIdToFeatureIdxMap;
|
||||
std::map<QAction*, size_t > m_actionToFeatureIdxMap;
|
||||
std::vector<CmdFeature*> m_commandFeatures;
|
||||
std::map<std::string, size_t> m_commandIdToFeatureIdxMap;
|
||||
std::map<QAction*, size_t> m_actionToFeatureIdxMap;
|
||||
|
||||
QPointer<QWidget> m_currentContextMenuTargetWidget;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -49,25 +49,29 @@ namespace caf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder::CmdFeatureMenuBuilder() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder::~CmdFeatureMenuBuilder() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::operator<<(const QString& commandId)
|
||||
CmdFeatureMenuBuilder::CmdFeatureMenuBuilder()
|
||||
{
|
||||
if (commandId == "Separator")
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder::~CmdFeatureMenuBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::operator<<( const QString& commandId )
|
||||
{
|
||||
if ( commandId == "Separator" )
|
||||
{
|
||||
addSeparator();
|
||||
}
|
||||
else
|
||||
{
|
||||
addCmdFeature(commandId);
|
||||
addCmdFeature( commandId );
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -76,13 +80,13 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::operator<<(const QString& commandI
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeature(const QString commandId, const QString& uiText)
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeature( const QString commandId, const QString& uiText )
|
||||
{
|
||||
MenuItem i;
|
||||
i.itemType = MenuItem::COMMAND;
|
||||
i.itemName = commandId;
|
||||
i.uiText = uiText;
|
||||
m_items.push_back(i);
|
||||
m_items.push_back( i );
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -90,15 +94,16 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeature(const QString comman
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeatureWithUserData(const QString commandId, const QString& uiText,
|
||||
const QVariant& userData)
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addCmdFeatureWithUserData( const QString commandId,
|
||||
const QString& uiText,
|
||||
const QVariant& userData )
|
||||
{
|
||||
MenuItem i;
|
||||
i.itemType = MenuItem::COMMAND;
|
||||
i.itemName = commandId;
|
||||
i.uiText = uiText;
|
||||
i.userData = userData;
|
||||
m_items.push_back(i);
|
||||
m_items.push_back( i );
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -110,7 +115,7 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addSeparator()
|
||||
{
|
||||
MenuItem i;
|
||||
i.itemType = MenuItem::SEPARATOR;
|
||||
m_items.push_back(i);
|
||||
m_items.push_back( i );
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -118,13 +123,13 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::addSeparator()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::subMenuStart(const QString& menuName, const QIcon& menuIcon)
|
||||
CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::subMenuStart( const QString& menuName, const QIcon& menuIcon )
|
||||
{
|
||||
MenuItem i;
|
||||
i.itemType = MenuItem::SUBMENU_START;
|
||||
i.itemName = menuName;
|
||||
i.icon = menuIcon;
|
||||
m_items.push_back(i);
|
||||
m_items.push_back( i );
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -136,7 +141,7 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::subMenuEnd()
|
||||
{
|
||||
MenuItem i;
|
||||
i.itemType = MenuItem::SUBMENU_END;
|
||||
m_items.push_back(i);
|
||||
m_items.push_back( i );
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -144,39 +149,39 @@ CmdFeatureMenuBuilder& CmdFeatureMenuBuilder::subMenuEnd()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFeatureMenuBuilder::appendToMenu(QMenu* menu)
|
||||
void CmdFeatureMenuBuilder::appendToMenu( QMenu* menu )
|
||||
{
|
||||
CAF_ASSERT(menu);
|
||||
CAF_ASSERT( menu );
|
||||
|
||||
std::vector<QMenu*> menus = {menu};
|
||||
for (size_t i = 0; i < m_items.size(); i++)
|
||||
for ( size_t i = 0; i < m_items.size(); i++ )
|
||||
{
|
||||
if (m_items[i].itemType == MenuItem::SEPARATOR)
|
||||
if ( m_items[i].itemType == MenuItem::SEPARATOR )
|
||||
{
|
||||
menus.back()->addSeparator();
|
||||
}
|
||||
else if (m_items[i].itemType == MenuItem::SUBMENU_START)
|
||||
else if ( m_items[i].itemType == MenuItem::SUBMENU_START )
|
||||
{
|
||||
QMenu* subMenu = menus.back()->addMenu(m_items[i].icon, m_items[i].itemName);
|
||||
menus.push_back(subMenu);
|
||||
QMenu* subMenu = menus.back()->addMenu( m_items[i].icon, m_items[i].itemName );
|
||||
menus.push_back( subMenu );
|
||||
}
|
||||
else if (m_items[i].itemType == MenuItem::SUBMENU_END)
|
||||
else if ( m_items[i].itemType == MenuItem::SUBMENU_END )
|
||||
{
|
||||
if (menus.size() > 1)
|
||||
if ( menus.size() > 1 )
|
||||
{
|
||||
QMenu* completeSubMenu = menus.back();
|
||||
menus.pop_back();
|
||||
|
||||
if (!menus.empty())
|
||||
if ( !menus.empty() )
|
||||
{
|
||||
// Remove the sub menu action if no (sub) actions are present in the sub menu
|
||||
if (completeSubMenu->actions().isEmpty())
|
||||
if ( completeSubMenu->actions().isEmpty() )
|
||||
{
|
||||
QMenu* menuWithEmptySubMenu = menus.back();
|
||||
|
||||
QAction* subMenuAction = completeSubMenu->menuAction();
|
||||
|
||||
menuWithEmptySubMenu->removeAction(subMenuAction);
|
||||
menuWithEmptySubMenu->removeAction( subMenuAction );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,50 +190,50 @@ void CmdFeatureMenuBuilder::appendToMenu(QMenu* menu)
|
||||
{
|
||||
CmdFeatureManager* commandManager = CmdFeatureManager::instance();
|
||||
QMenu* currentMenu = menus.back();
|
||||
caf::CmdFeature* feature = commandManager->getCommandFeature(m_items[i].itemName.toStdString());
|
||||
CAF_ASSERT(feature);
|
||||
caf::CmdFeature* feature = commandManager->getCommandFeature( m_items[i].itemName.toStdString() );
|
||||
CAF_ASSERT( feature );
|
||||
|
||||
if (feature->canFeatureBeExecuted())
|
||||
if ( feature->canFeatureBeExecuted() )
|
||||
{
|
||||
const QAction* act;
|
||||
if (!m_items[i].userData.isNull())
|
||||
if ( !m_items[i].userData.isNull() )
|
||||
{
|
||||
act = commandManager->actionWithUserData(m_items[i].itemName, m_items[i].uiText, m_items[i].userData);
|
||||
act = commandManager->actionWithUserData( m_items[i].itemName, m_items[i].uiText, m_items[i].userData );
|
||||
}
|
||||
else
|
||||
{
|
||||
act = commandManager->action(m_items[i].itemName);
|
||||
act = commandManager->action( m_items[i].itemName );
|
||||
}
|
||||
|
||||
CAF_ASSERT(act);
|
||||
CAF_ASSERT( act );
|
||||
|
||||
bool duplicateAct = false;
|
||||
for (QAction* existingAct : currentMenu->actions())
|
||||
for ( QAction* existingAct : currentMenu->actions() )
|
||||
{
|
||||
// If action exist, continue to make sure the action is positioned at the first
|
||||
// location of a command ID
|
||||
if (existingAct == act)
|
||||
if ( existingAct == act )
|
||||
{
|
||||
duplicateAct = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (duplicateAct) continue;
|
||||
if ( duplicateAct ) continue;
|
||||
|
||||
currentMenu->addAction(const_cast<QAction*>(act));
|
||||
currentMenu->addAction( const_cast<QAction*>( act ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdFeatureMenuBuilder::isCmdFeatureAdded(const QString &commandId)
|
||||
bool CmdFeatureMenuBuilder::isCmdFeatureAdded( const QString& commandId )
|
||||
{
|
||||
for (const MenuItem &item : m_items)
|
||||
for ( const MenuItem& item : m_items )
|
||||
{
|
||||
if (item.itemType == MenuItem::COMMAND && item.itemName == commandId)
|
||||
if ( item.itemType == MenuItem::COMMAND && item.itemName == commandId )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -57,20 +57,21 @@ public:
|
||||
CmdFeatureMenuBuilder();
|
||||
virtual ~CmdFeatureMenuBuilder();
|
||||
|
||||
CmdFeatureMenuBuilder& operator<<(const QString& commandIdOrSeparator);
|
||||
CmdFeatureMenuBuilder& addCmdFeature(const QString commandId, const QString& customUiText = "");
|
||||
CmdFeatureMenuBuilder& addCmdFeatureWithUserData(const QString commandId, const QString& customUiText,
|
||||
const QVariant& userData);
|
||||
CmdFeatureMenuBuilder& operator<<( const QString& commandIdOrSeparator );
|
||||
CmdFeatureMenuBuilder& addCmdFeature( const QString commandId, const QString& customUiText = "" );
|
||||
CmdFeatureMenuBuilder&
|
||||
addCmdFeatureWithUserData( const QString commandId, const QString& customUiText, const QVariant& userData );
|
||||
|
||||
CmdFeatureMenuBuilder& addSeparator();
|
||||
|
||||
CmdFeatureMenuBuilder& subMenuStart(const QString& menuName, const QIcon& menuIcon = QIcon());
|
||||
CmdFeatureMenuBuilder& subMenuStart( const QString& menuName, const QIcon& menuIcon = QIcon() );
|
||||
CmdFeatureMenuBuilder& subMenuEnd();
|
||||
|
||||
void appendToMenu(QMenu* menu);
|
||||
void appendToMenu( QMenu* menu );
|
||||
|
||||
bool isCmdFeatureAdded( const QString& commandId );
|
||||
size_t itemCount() const;
|
||||
|
||||
bool isCmdFeatureAdded(const QString &commandId);
|
||||
size_t itemCount() const;
|
||||
private:
|
||||
struct MenuItem
|
||||
{
|
||||
|
||||
@@ -34,41 +34,38 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafCmdFieldChangeExec.h"
|
||||
|
||||
#include "cafPdmReferenceHelper.h"
|
||||
#include "cafNotificationCenter.h"
|
||||
|
||||
#include "cafPdmReferenceHelper.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
CAF_PDM_SOURCE_INIT(CmdFieldChangeExecData, "CmdFieldChangeExecData");
|
||||
|
||||
CAF_PDM_SOURCE_INIT( CmdFieldChangeExecData, "CmdFieldChangeExecData" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString CmdFieldChangeExec::name()
|
||||
{
|
||||
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
|
||||
if (field)
|
||||
PdmFieldHandle* field =
|
||||
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
|
||||
if ( field )
|
||||
{
|
||||
QString fieldText;
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
if ( uiFieldHandle )
|
||||
{
|
||||
fieldText = QString("Change field '%1'").arg(uiFieldHandle->uiName());
|
||||
fieldText = QString( "Change field '%1'" ).arg( uiFieldHandle->uiName() );
|
||||
}
|
||||
|
||||
if (field->ownerObject())
|
||||
if ( field->ownerObject() )
|
||||
{
|
||||
PdmUiObjectHandle* uiObjHandle = uiObj(field->ownerObject());
|
||||
if (uiObjHandle)
|
||||
PdmUiObjectHandle* uiObjHandle = uiObj( field->ownerObject() );
|
||||
if ( uiObjHandle )
|
||||
{
|
||||
fieldText += QString(" in '%1'").arg(uiObjHandle->uiName());
|
||||
fieldText += QString( " in '%1'" ).arg( uiObjHandle->uiName() );
|
||||
}
|
||||
}
|
||||
return fieldText;
|
||||
@@ -80,108 +77,108 @@ QString CmdFieldChangeExec::name()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFieldChangeExec::redo()
|
||||
{
|
||||
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
|
||||
if (!field)
|
||||
PdmFieldHandle* field =
|
||||
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
|
||||
if ( !field )
|
||||
{
|
||||
CAF_ASSERT(false);
|
||||
CAF_ASSERT( false );
|
||||
return;
|
||||
}
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability();
|
||||
if (uiFieldHandle && xmlFieldHandle)
|
||||
if ( uiFieldHandle && xmlFieldHandle )
|
||||
{
|
||||
if (m_commandData->m_redoFieldValueSerialized.isEmpty())
|
||||
if ( m_commandData->m_redoFieldValueSerialized.isEmpty() )
|
||||
{
|
||||
// We end up here only when the user actually has done something in the actual living Gui editor.
|
||||
{
|
||||
QXmlStreamWriter xmlStream(&m_commandData->m_undoFieldValueSerialized);
|
||||
writeFieldDataToValidXmlDocument(xmlStream, xmlFieldHandle);
|
||||
QXmlStreamWriter xmlStream( &m_commandData->m_undoFieldValueSerialized );
|
||||
writeFieldDataToValidXmlDocument( xmlStream, xmlFieldHandle );
|
||||
}
|
||||
|
||||
// This function will notify field change, no need to explicitly call notification
|
||||
// The ui value might be an index into the option entry cache, so we need to set the value
|
||||
// The ui value might be an index into the option entry cache, so we need to set the value
|
||||
// and be aware of the option entries, and then serialize the actual field value we ended up with.
|
||||
|
||||
uiFieldHandle->setValueFromUiEditor(m_commandData->m_newUiValue);
|
||||
uiFieldHandle->setValueFromUiEditor( m_commandData->m_newUiValue );
|
||||
|
||||
{
|
||||
QXmlStreamWriter xmlStream(&m_commandData->m_redoFieldValueSerialized);
|
||||
writeFieldDataToValidXmlDocument(xmlStream, xmlFieldHandle);
|
||||
QXmlStreamWriter xmlStream( &m_commandData->m_redoFieldValueSerialized );
|
||||
writeFieldDataToValidXmlDocument( xmlStream, xmlFieldHandle );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QVariant oldFieldData = uiFieldHandle->toUiBasedQVariant();
|
||||
|
||||
QXmlStreamReader xmlStream(m_commandData->m_redoFieldValueSerialized);
|
||||
QXmlStreamReader xmlStream( m_commandData->m_redoFieldValueSerialized );
|
||||
|
||||
readFieldValueFromValidXmlDocument(xmlStream, xmlFieldHandle);
|
||||
readFieldValueFromValidXmlDocument( xmlStream, xmlFieldHandle );
|
||||
|
||||
QVariant newFieldData = uiFieldHandle->toUiBasedQVariant();
|
||||
|
||||
// New data is present in field, notify data changed
|
||||
uiFieldHandle->notifyFieldChanged(oldFieldData, newFieldData);
|
||||
uiFieldHandle->notifyFieldChanged( oldFieldData, newFieldData );
|
||||
}
|
||||
}
|
||||
|
||||
if (m_notificationCenter) m_notificationCenter->notifyObserversOfDataChange(field->ownerObject());
|
||||
if ( m_notificationCenter ) m_notificationCenter->notifyObserversOfDataChange( field->ownerObject() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFieldChangeExec::undo()
|
||||
{
|
||||
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
|
||||
if (!field)
|
||||
PdmFieldHandle* field =
|
||||
PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField );
|
||||
if ( !field )
|
||||
{
|
||||
CAF_ASSERT(false);
|
||||
CAF_ASSERT( false );
|
||||
return;
|
||||
}
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability();
|
||||
if (uiFieldHandle && xmlFieldHandle)
|
||||
if ( uiFieldHandle && xmlFieldHandle )
|
||||
{
|
||||
QXmlStreamReader xmlStream(m_commandData->m_undoFieldValueSerialized);
|
||||
QVariant oldFieldData = uiFieldHandle->toUiBasedQVariant();
|
||||
QXmlStreamReader xmlStream( m_commandData->m_undoFieldValueSerialized );
|
||||
QVariant oldFieldData = uiFieldHandle->toUiBasedQVariant();
|
||||
|
||||
readFieldValueFromValidXmlDocument(xmlStream, xmlFieldHandle);
|
||||
readFieldValueFromValidXmlDocument( xmlStream, xmlFieldHandle );
|
||||
|
||||
QVariant newFieldData = uiFieldHandle->toUiBasedQVariant();
|
||||
|
||||
// New data is present in field, notify data changed
|
||||
uiFieldHandle->notifyFieldChanged(oldFieldData, newFieldData);
|
||||
uiFieldHandle->notifyFieldChanged( oldFieldData, newFieldData );
|
||||
}
|
||||
|
||||
if (m_notificationCenter) m_notificationCenter->notifyObserversOfDataChange(field->ownerObject());
|
||||
if ( m_notificationCenter ) m_notificationCenter->notifyObserversOfDataChange( field->ownerObject() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFieldChangeExec::CmdFieldChangeExec(NotificationCenter* notificationCenter)
|
||||
: CmdExecuteCommand(notificationCenter)
|
||||
CmdFieldChangeExec::CmdFieldChangeExec( NotificationCenter* notificationCenter )
|
||||
: CmdExecuteCommand( notificationCenter )
|
||||
{
|
||||
m_commandData = new CmdFieldChangeExecData;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFieldChangeExec::~CmdFieldChangeExec()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFieldChangeExecData* CmdFieldChangeExec::commandData()
|
||||
{
|
||||
@@ -189,32 +186,32 @@ CmdFieldChangeExecData* CmdFieldChangeExec::commandData()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFieldChangeExec::writeFieldDataToValidXmlDocument(QXmlStreamWriter &xmlStream, PdmXmlFieldHandle* xmlFieldHandle)
|
||||
void CmdFieldChangeExec::writeFieldDataToValidXmlDocument( QXmlStreamWriter& xmlStream, PdmXmlFieldHandle* xmlFieldHandle )
|
||||
{
|
||||
xmlStream.setAutoFormatting(true);
|
||||
xmlStream.setAutoFormatting( true );
|
||||
xmlStream.writeStartDocument();
|
||||
xmlStream.writeStartElement("", "d");
|
||||
xmlFieldHandle->writeFieldData(xmlStream);
|
||||
xmlStream.writeStartElement( "", "d" );
|
||||
xmlFieldHandle->writeFieldData( xmlStream );
|
||||
xmlStream.writeEndElement();
|
||||
xmlStream.writeEndDocument();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdFieldChangeExec::readFieldValueFromValidXmlDocument(QXmlStreamReader &xmlStream, PdmXmlFieldHandle* xmlFieldHandle)
|
||||
void CmdFieldChangeExec::readFieldValueFromValidXmlDocument( QXmlStreamReader& xmlStream, PdmXmlFieldHandle* xmlFieldHandle )
|
||||
{
|
||||
// See PdmObject::readFields and friends to match token count for reading field values
|
||||
// The stream is supposed to be pointing at the first token of field content when calling readFieldData()
|
||||
QXmlStreamReader::TokenType tt;
|
||||
int tokenCount = 3;
|
||||
for (int i = 0; i < tokenCount; i++)
|
||||
int tokenCount = 3;
|
||||
for ( int i = 0; i < tokenCount; i++ )
|
||||
{
|
||||
tt = xmlStream.readNext();
|
||||
}
|
||||
xmlFieldHandle->readFieldData(xmlStream, PdmDefaultObjectFactory::instance());
|
||||
xmlFieldHandle->readFieldData( xmlStream, PdmDefaultObjectFactory::instance() );
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -40,13 +40,12 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class PdmChildArrayFieldHandle;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class CmdFieldChangeExecData : public PdmObject
|
||||
{
|
||||
@@ -55,45 +54,44 @@ class CmdFieldChangeExecData : public PdmObject
|
||||
public:
|
||||
CmdFieldChangeExecData()
|
||||
{
|
||||
CAF_PDM_InitObject("CmdFieldChangeExecData uiName", "", "CmdFieldChangeExecData tooltip", "CmdFieldChangeExecData whatsthis");
|
||||
CAF_PDM_InitObject( "CmdFieldChangeExecData uiName",
|
||||
"",
|
||||
"CmdFieldChangeExecData tooltip",
|
||||
"CmdFieldChangeExecData whatsthis" );
|
||||
|
||||
CAF_PDM_InitField(&m_pathToField, "PathToField", QString(), "PathToField", "", "PathToField tooltip", "PathToField whatsthis");
|
||||
CAF_PDM_InitField( &m_pathToField, "PathToField", QString(), "PathToField", "", "PathToField tooltip", "PathToField whatsthis" );
|
||||
}
|
||||
|
||||
caf::PdmPointer<PdmObjectHandle> m_rootObject;
|
||||
|
||||
PdmField<QString> m_pathToField;
|
||||
QVariant m_newUiValue; // QVariant coming from the UI
|
||||
PdmField<QString> m_pathToField;
|
||||
QVariant m_newUiValue; // QVariant coming from the UI
|
||||
|
||||
QString m_undoFieldValueSerialized;
|
||||
QString m_redoFieldValueSerialized;
|
||||
QString m_undoFieldValueSerialized;
|
||||
QString m_redoFieldValueSerialized;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class CmdFieldChangeExec : public CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
explicit CmdFieldChangeExec(NotificationCenter* notificationCenter);
|
||||
explicit CmdFieldChangeExec( NotificationCenter* notificationCenter );
|
||||
~CmdFieldChangeExec() override;
|
||||
|
||||
|
||||
CmdFieldChangeExecData* commandData();
|
||||
|
||||
QString name() override;
|
||||
void redo() override;
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
void undo() override;
|
||||
|
||||
private:
|
||||
void readFieldValueFromValidXmlDocument(QXmlStreamReader& xmlStream, PdmXmlFieldHandle* xmlFieldHandle);
|
||||
void writeFieldDataToValidXmlDocument(QXmlStreamWriter& xmlStream, PdmXmlFieldHandle* xmlFieldHandle);
|
||||
void readFieldValueFromValidXmlDocument( QXmlStreamReader& xmlStream, PdmXmlFieldHandle* xmlFieldHandle );
|
||||
void writeFieldDataToValidXmlDocument( QXmlStreamWriter& xmlStream, PdmXmlFieldHandle* xmlFieldHandle );
|
||||
|
||||
private:
|
||||
CmdFieldChangeExecData* m_commandData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,19 +34,16 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafCmdSelectionChangeExec.h"
|
||||
#include "cafPdmReferenceHelper.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
CAF_PDM_SOURCE_INIT(CmdSelectionChangeExecData, "CmdSelectionChangeExecData");
|
||||
CAF_PDM_SOURCE_INIT( CmdSelectionChangeExecData, "CmdSelectionChangeExecData" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString CmdSelectionChangeExec::name()
|
||||
{
|
||||
@@ -54,41 +51,41 @@ QString CmdSelectionChangeExec::name()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdSelectionChangeExec::redo()
|
||||
{
|
||||
SelectionManager::instance()->setSelectionAtLevelFromReferences(m_commandData->m_newSelection.v(), m_commandData->m_selectionLevel.v());
|
||||
SelectionManager::instance()->setSelectionAtLevelFromReferences( m_commandData->m_newSelection.v(),
|
||||
m_commandData->m_selectionLevel.v() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdSelectionChangeExec::undo()
|
||||
{
|
||||
SelectionManager::instance()->setSelectionAtLevelFromReferences(m_commandData->m_previousSelection.v(), m_commandData->m_selectionLevel.v());
|
||||
SelectionManager::instance()->setSelectionAtLevelFromReferences( m_commandData->m_previousSelection.v(),
|
||||
m_commandData->m_selectionLevel.v() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdSelectionChangeExec::CmdSelectionChangeExec(NotificationCenter* notificationCenter)
|
||||
: CmdExecuteCommand(notificationCenter)
|
||||
CmdSelectionChangeExec::CmdSelectionChangeExec( NotificationCenter* notificationCenter )
|
||||
: CmdExecuteCommand( notificationCenter )
|
||||
{
|
||||
m_commandData = new CmdSelectionChangeExecData;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdSelectionChangeExec::~CmdSelectionChangeExec()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdSelectionChangeExecData* CmdSelectionChangeExec::commandData()
|
||||
{
|
||||
|
||||
@@ -38,18 +38,14 @@
|
||||
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class CmdSelectionChangeExecData : public PdmObject
|
||||
{
|
||||
@@ -58,38 +54,39 @@ class CmdSelectionChangeExecData : public PdmObject
|
||||
public:
|
||||
CmdSelectionChangeExecData()
|
||||
{
|
||||
CAF_PDM_InitObject("CmdSelectionChangeExecData uiName", "", "CmdSelectionChangeExecData tooltip", "CmdSelectionChangeExecData whatsthis");
|
||||
CAF_PDM_InitObject( "CmdSelectionChangeExecData uiName",
|
||||
"",
|
||||
"CmdSelectionChangeExecData tooltip",
|
||||
"CmdSelectionChangeExecData whatsthis" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectionLevel, "selectionLevel", "selectionLevel", "", "", "");
|
||||
CAF_PDM_InitField(&m_previousSelection, "previousSelection", std::vector<QString>(), "previousSelection", "", "", "");
|
||||
CAF_PDM_InitField(&m_newSelection, "newSelection", std::vector<QString>(), "newSelection", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectionLevel, "selectionLevel", "selectionLevel", "", "", "" );
|
||||
CAF_PDM_InitField( &m_previousSelection, "previousSelection", std::vector<QString>(), "previousSelection", "", "", "" );
|
||||
CAF_PDM_InitField( &m_newSelection, "newSelection", std::vector<QString>(), "newSelection", "", "", "" );
|
||||
}
|
||||
|
||||
PdmField< int > m_selectionLevel;
|
||||
PdmField< std::vector<QString> > m_previousSelection;
|
||||
PdmField< std::vector<QString> > m_newSelection;
|
||||
PdmField<int> m_selectionLevel;
|
||||
PdmField<std::vector<QString>> m_previousSelection;
|
||||
PdmField<std::vector<QString>> m_newSelection;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class CmdSelectionChangeExec : public CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
explicit CmdSelectionChangeExec(NotificationCenter* notificationCenter);
|
||||
~CmdSelectionChangeExec() override;;
|
||||
explicit CmdSelectionChangeExec( NotificationCenter* notificationCenter );
|
||||
~CmdSelectionChangeExec() override;
|
||||
;
|
||||
|
||||
CmdSelectionChangeExecData* commandData();
|
||||
|
||||
QString name() override;
|
||||
void redo() override;
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
void undo() override;
|
||||
|
||||
private:
|
||||
CmdSelectionChangeExecData* m_commandData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafCmdSelectionHelper.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
@@ -42,38 +41,39 @@
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdSelectionHelper::executeSelectionCommand(const std::vector<PdmObjectHandle*>& selection, int selectionLevel)
|
||||
void CmdSelectionHelper::executeSelectionCommand( const std::vector<PdmObjectHandle*>& selection, int selectionLevel )
|
||||
{
|
||||
CmdSelectionChangeExec* selectionChangeExec = createSelectionCommand(selection, selectionLevel);
|
||||
CmdSelectionChangeExec* selectionChangeExec = createSelectionCommand( selection, selectionLevel );
|
||||
|
||||
CmdExecCommandManager::instance()->processExecuteCommand(selectionChangeExec);
|
||||
CmdExecCommandManager::instance()->processExecuteCommand( selectionChangeExec );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdSelectionChangeExec* CmdSelectionHelper::createSelectionCommand(const std::vector<PdmObjectHandle*>& selection, int selectionLevel)
|
||||
CmdSelectionChangeExec* CmdSelectionHelper::createSelectionCommand( const std::vector<PdmObjectHandle*>& selection,
|
||||
int selectionLevel )
|
||||
{
|
||||
CmdSelectionChangeExec* selectionChangeExec = new CmdSelectionChangeExec(SelectionManager::instance()->notificationCenter());
|
||||
CmdSelectionChangeExec* selectionChangeExec =
|
||||
new CmdSelectionChangeExec( SelectionManager::instance()->notificationCenter() );
|
||||
selectionChangeExec->commandData()->m_selectionLevel.v() = selectionLevel;
|
||||
|
||||
SelectionManager::instance()->selectionAsReferences(selectionChangeExec->commandData()->m_previousSelection.v(), selectionLevel);
|
||||
SelectionManager::instance()->selectionAsReferences( selectionChangeExec->commandData()->m_previousSelection.v(),
|
||||
selectionLevel );
|
||||
|
||||
for (size_t i = 0; i < selection.size(); i++)
|
||||
for ( size_t i = 0; i < selection.size(); i++ )
|
||||
{
|
||||
QString itemRef = PdmReferenceHelper::referenceFromRootToObject(PdmReferenceHelper::findRoot(selection[i]), selection[i]);
|
||||
selectionChangeExec->commandData()->m_newSelection.v().push_back(itemRef);
|
||||
QString itemRef =
|
||||
PdmReferenceHelper::referenceFromRootToObject( PdmReferenceHelper::findRoot( selection[i] ), selection[i] );
|
||||
selectionChangeExec->commandData()->m_newSelection.v().push_back( itemRef );
|
||||
}
|
||||
|
||||
return selectionChangeExec;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,12 +34,11 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
class CmdSelectionChangeExec;
|
||||
class PdmObjectHandle;
|
||||
@@ -47,10 +46,9 @@ class PdmObjectHandle;
|
||||
class CmdSelectionHelper
|
||||
{
|
||||
public:
|
||||
static void executeSelectionCommand(const std::vector<PdmObjectHandle*>& selection, int selectionLevel);
|
||||
static CmdSelectionChangeExec* createSelectionCommand(const std::vector<PdmObjectHandle*>& selection, int selectionLevel);
|
||||
static void executeSelectionCommand( const std::vector<PdmObjectHandle*>& selection, int selectionLevel );
|
||||
static CmdSelectionChangeExec* createSelectionCommand( const std::vector<PdmObjectHandle*>& selection,
|
||||
int selectionLevel );
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,13 +34,12 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cafCmdUiCommandSystemImpl.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
#include "cafCmdFieldChangeExec.h"
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafCmdFieldChangeExec.h"
|
||||
|
||||
#include "cafPdmFieldHandle.h"
|
||||
#include "cafPdmUiObjectHandle.h"
|
||||
@@ -53,72 +52,73 @@
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdUiCommandSystemImpl::CmdUiCommandSystemImpl()
|
||||
{
|
||||
m_undoFeatureEnabled = false;
|
||||
m_undoFeatureEnabled = false;
|
||||
m_disableUndoForFieldChange = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHandle*>& fieldsToUpdate, const QVariant& newUiValue)
|
||||
void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHandle*>& fieldsToUpdate,
|
||||
const QVariant& newUiValue )
|
||||
{
|
||||
if ( fieldsToUpdate.empty() ) return;
|
||||
|
||||
std::vector<CmdExecuteCommand*> commands;
|
||||
|
||||
for (size_t i = 0; i < fieldsToUpdate.size(); i++)
|
||||
for ( size_t i = 0; i < fieldsToUpdate.size(); i++ )
|
||||
{
|
||||
PdmFieldHandle* field = fieldsToUpdate[i];
|
||||
PdmFieldHandle* field = fieldsToUpdate[i];
|
||||
PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
if ( uiFieldHandle )
|
||||
{
|
||||
QVariant fieldCurrentUiValue = uiFieldHandle->uiValue();
|
||||
|
||||
if (fieldCurrentUiValue != newUiValue)
|
||||
if ( fieldCurrentUiValue != newUiValue )
|
||||
{
|
||||
PdmObjectHandle* rootObjHandle = PdmReferenceHelper::findRoot(field);
|
||||
PdmObjectHandle* rootObjHandle = PdmReferenceHelper::findRoot( field );
|
||||
|
||||
QString reference = PdmReferenceHelper::referenceFromRootToField(rootObjHandle, field);
|
||||
if (reference.isEmpty())
|
||||
QString reference = PdmReferenceHelper::referenceFromRootToField( rootObjHandle, field );
|
||||
if ( reference.isEmpty() )
|
||||
{
|
||||
CAF_ASSERT(false);
|
||||
CAF_ASSERT( false );
|
||||
return;
|
||||
}
|
||||
|
||||
CmdFieldChangeExec* fieldChangeExec = new CmdFieldChangeExec(SelectionManager::instance()->notificationCenter());
|
||||
CmdFieldChangeExec* fieldChangeExec =
|
||||
new CmdFieldChangeExec( SelectionManager::instance()->notificationCenter() );
|
||||
|
||||
fieldChangeExec->commandData()->m_newUiValue = newUiValue;
|
||||
fieldChangeExec->commandData()->m_newUiValue = newUiValue;
|
||||
fieldChangeExec->commandData()->m_pathToField = reference;
|
||||
fieldChangeExec->commandData()->m_rootObject = rootObjHandle;
|
||||
fieldChangeExec->commandData()->m_rootObject = rootObjHandle;
|
||||
|
||||
commands.push_back(fieldChangeExec);
|
||||
commands.push_back( fieldChangeExec );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmUiObjectHandle* uiOwnerObjectHandle = uiObj(fieldsToUpdate[0]->ownerObject());
|
||||
if (uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged())
|
||||
caf::PdmUiObjectHandle* uiOwnerObjectHandle = uiObj( fieldsToUpdate[0]->ownerObject() );
|
||||
if ( uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged() )
|
||||
{
|
||||
// Temporarily disable undo framework as requested by the PdmUiObjectHandle
|
||||
m_disableUndoForFieldChange = true;
|
||||
}
|
||||
|
||||
if (commands.size() == 1)
|
||||
if ( commands.size() == 1 )
|
||||
{
|
||||
CmdExecCommandManager::instance()->processExecuteCommand(commands[0]);
|
||||
CmdExecCommandManager::instance()->processExecuteCommand( commands[0] );
|
||||
}
|
||||
else
|
||||
{
|
||||
CmdExecCommandManager::instance()->processExecuteCommandsAsMacro("Multiple Field Change", commands);
|
||||
CmdExecCommandManager::instance()->processExecuteCommandsAsMacro( "Multiple Field Change", commands );
|
||||
}
|
||||
|
||||
if (uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged())
|
||||
if ( uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged() )
|
||||
{
|
||||
// Restore undo feature to normal operation
|
||||
m_disableUndoForFieldChange = false;
|
||||
@@ -126,26 +126,26 @@ void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHand
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdUiCommandSystemImpl::populateMenuWithDefaultCommands(const QString& uiConfigName, QMenu* menu)
|
||||
void CmdUiCommandSystemImpl::populateMenuWithDefaultCommands( const QString& uiConfigName, QMenu* menu )
|
||||
{
|
||||
if (uiConfigName == "PdmUiTreeViewEditor" ||
|
||||
uiConfigName == "PdmUiTableViewEditor")
|
||||
if ( uiConfigName == "PdmUiTreeViewEditor" || uiConfigName == "PdmUiTableViewEditor" )
|
||||
{
|
||||
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||
|
||||
menu->addAction(commandManager->action("PdmListField_AddItem"));
|
||||
menu->addAction(commandManager->action("PdmListField_DeleteItem"));
|
||||
menu->addAction( commandManager->action( "PdmListField_AddItem" ) );
|
||||
menu->addAction( commandManager->action( "PdmListField_DeleteItem" ) );
|
||||
|
||||
QStringList commandIdList;
|
||||
commandIdList << "PdmListField_AddItem" << "PdmListField_DeleteItem";
|
||||
commandManager->refreshStates(commandIdList);
|
||||
commandIdList << "PdmListField_AddItem"
|
||||
<< "PdmListField_DeleteItem";
|
||||
commandManager->refreshStates( commandIdList );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdUiCommandSystemImpl::isUndoEnabled()
|
||||
{
|
||||
@@ -153,15 +153,15 @@ bool CmdUiCommandSystemImpl::isUndoEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdUiCommandSystemImpl::enableUndoFeature(bool enable)
|
||||
void CmdUiCommandSystemImpl::enableUndoFeature( bool enable )
|
||||
{
|
||||
m_undoFeatureEnabled = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdUiCommandSystemImpl::disableUndoForFieldChange()
|
||||
{
|
||||
@@ -169,11 +169,11 @@ bool CmdUiCommandSystemImpl::disableUndoForFieldChange()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdUiCommandSystemImpl::setCurrentContextMenuTargetWidget(QWidget* targetWidget)
|
||||
void CmdUiCommandSystemImpl::setCurrentContextMenuTargetWidget( QWidget* targetWidget )
|
||||
{
|
||||
caf::CmdFeatureManager::instance()->setCurrentContextMenuTargetWidget(targetWidget);
|
||||
caf::CmdFeatureManager::instance()->setCurrentContextMenuTargetWidget( targetWidget );
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -34,15 +34,13 @@
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafInternalPdmUiCommandSystemInterface.h"
|
||||
#include <vector>
|
||||
|
||||
namespace caf
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class PdmFieldHandle;
|
||||
|
||||
class CmdUiCommandSystemImpl : public PdmUiCommandSystemInterface
|
||||
@@ -50,12 +48,12 @@ class CmdUiCommandSystemImpl : public PdmUiCommandSystemInterface
|
||||
public:
|
||||
CmdUiCommandSystemImpl();
|
||||
|
||||
void fieldChangedCommand(const std::vector<PdmFieldHandle*>& fieldsToUpdate, const QVariant& newUiValue) override;
|
||||
void setCurrentContextMenuTargetWidget(QWidget* targetWidget) override;
|
||||
void populateMenuWithDefaultCommands(const QString& uiConfigName, QMenu* menu) override;
|
||||
|
||||
void fieldChangedCommand( const std::vector<PdmFieldHandle*>& fieldsToUpdate, const QVariant& newUiValue ) override;
|
||||
void setCurrentContextMenuTargetWidget( QWidget* targetWidget ) override;
|
||||
void populateMenuWithDefaultCommands( const QString& uiConfigName, QMenu* menu ) override;
|
||||
|
||||
bool isUndoEnabled();
|
||||
void enableUndoFeature(bool enable);
|
||||
void enableUndoFeature( bool enable );
|
||||
|
||||
bool disableUndoForFieldChange();
|
||||
|
||||
@@ -64,5 +62,4 @@ private:
|
||||
bool m_disableUndoForFieldChange;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
Reference in New Issue
Block a user