WSF
wizard::EditorHelpers Namespace Reference

Functions

QString GetInsertWithComments (const UtTextDocumentRange &aEntryRange, const QString &aAttributeName, const QString &aInsert)
bool ReplaceTextInEditor (const UtTextDocumentRange &aEntryRange, const QString &aAttributeName, const QString &aInsert)
QTextCursor FindStartCursor (const WsfPProxyNode &aNode) noexcept
QTextCursor FindEndCursor (const WsfPProxyNode &aNode) noexcept
int GetIndentLevel (const QString &aLine) noexcept
QString ConstructTextToAppendToBlock (const QTextCursor &aStartCursor, const QTextCursor &aEndCursor, const QString &aAttributeName, const QString &aDataValue) noexcept
void AddNewAttributeInText (const WsfPProxyNode &aProxyNode, const QString &aAttributeName, const QString &aDataValue) noexcept
bool MoveToPreviousNonWhitespaceToken (QTextCursor &aCursor, QTextCursor::MoveMode aMoveMode, int aOperationCount) noexcept
bool IsWhitespaceString (const QString &aText) noexcept
bool ReplacePositionText (QStringList &aPositionTokens, int aCommandIndex, const vespa::VaPosition &aNewPosition) noexcept
bool ReplaceMGRS_Text (QStringList &aMGRS_Tokens, int aCommandIndex, const vespa::VaPosition &aNewPosition) noexcept
void InsertTextAndResetCursor (wizard::Editor *aEditorPtr, QTextCursor &aCursor, const QString &aTextToInsert) noexcept
QString GetPositionString (const vespa::VaPosition &aPosition) noexcept
template<typename UNITARY_PROPERTY>
bool ReplaceUnitaryText (QStringList &aUnitaryTokens, int aCommandIndex, UNITARY_PROPERTY &aNewUnitary) noexcept
template<wkf::ValueType UNITARY_TYPE, typename UNITARY_PROPERTY>
QString GetUnitaryString (UNITARY_PROPERTY &aUnitary) noexcept

Function Documentation

◆ AddNewAttributeInText()

void VI_EXPORT wizard::EditorHelpers::AddNewAttributeInText ( const WsfPProxyNode & aProxyNode,
const QString & aAttributeName,
const QString & aDataValue )
noexcept

Add a new attribute in the text

Parameters
aProxyNodecontains the context for the new attribute
aAttributeNameis the name of the new attribute
aDataValueis the value of the new attribute

References ConstructTextToAppendToBlock(), FindEndCursor(), FindStartCursor(), wizard::ProjectWorkspace::GotoFile(), wizard::Editor::GoToLine(), wizard::ProjectWorkspace::Instance(), and MoveToPreviousNonWhitespaceToken().

◆ ConstructTextToAppendToBlock()

QString VI_EXPORT wizard::EditorHelpers::ConstructTextToAppendToBlock ( const QTextCursor & aStartCursor,
const QTextCursor & aEndCursor,
const QString & aAttributeName,
const QString & aDataValue )
noexcept

Constructs the new text to append to the AFSIM input block designated by the given QTextCursors

Parameters
aStartCursoris the cursor pointing to the start of the AFSIM input block
aEndCursoris the cursor pointing to the end of the AFSIM input block
aAttributeNameis the name of the attribute to append
aDataValueis the value of the attribute to append

References GetIndentLevel(), and wizard::EditorPrefObject::TabSpace().

Referenced by AddNewAttributeInText().

◆ FindEndCursor()

QTextCursor VI_EXPORT wizard::EditorHelpers::FindEndCursor ( const WsfPProxyNode & aNode)
noexcept

Get the cursor pointing to the end of the definition

Parameters
aNodeis the proxy node containing the definition
Returns
the cursor pointing to the end of the definition

References FindStartCursor().

Referenced by AddNewAttributeInText().

◆ FindStartCursor()

QTextCursor VI_EXPORT wizard::EditorHelpers::FindStartCursor ( const WsfPProxyNode & aNode)
noexcept

Get the cursor pointing to the start of the definition

Parameters
aNodeis the proxy node containing the definition
Returns
the cursor pointing to the start of the definition

References wizard::Project::GotoFile(), and wizard::Project::Instance().

Referenced by AddNewAttributeInText(), and FindEndCursor().

◆ GetIndentLevel()

int VI_EXPORT wizard::EditorHelpers::GetIndentLevel ( const QString & aLine)
noexcept

Gets the level of indent for the given line

Parameters
aLineis the line of text
Returns
the level of indent for the given line, or -1 if the line is entirely whitespace

Referenced by ConstructTextToAppendToBlock().

◆ GetInsertWithComments()

QString VI_EXPORT wizard::EditorHelpers::GetInsertWithComments ( const UtTextDocumentRange & aEntryRange,
const QString & aAttributeName,
const QString & aInsert )

Replaces the value of the given attribute with a new value or removes the attribute

Parameters
aEntryRangethe range that is to be modified
aAttributeNamethe name of the attribute
aInsertthe text to insert
Returns
a string representing the given range after the modification

References wizard::Editor::FindNextValidToken(), and wizard::Editor::Split().

Referenced by ReplaceTextInEditor().

◆ GetPositionString()

QString VI_EXPORT wizard::EditorHelpers::GetPositionString ( const vespa::VaPosition & aPosition)
noexcept

Converts a vespa::VaPosition to a QString

Parameters
aPositionis the vespa::VaPosition to convert to a QString
Returns
the vespa::VaPosition as a QString
Note
the user preferences determine the format of the position's latitude and longitude

◆ GetUnitaryString()

template<wkf::ValueType UNITARY_TYPE, typename UNITARY_PROPERTY>
QString wizard::EditorHelpers::GetUnitaryString ( UNITARY_PROPERTY & aUnitary)
noexcept

Converts a UtUnitaryValue to a QString

Parameters
aUnitaryis the UtUnitaryValue to convert to a QString
Returns
the UtUnitaryValue as a QString
Note
the user preferences determine the unit of the unitary property's value

◆ InsertTextAndResetCursor()

void VI_EXPORT wizard::EditorHelpers::InsertTextAndResetCursor ( wizard::Editor * aEditorPtr,
QTextCursor & aCursor,
const QString & aTextToInsert )
noexcept

Inserts the given QString into the given wizard::Editor at the given QTextCursor and resets the QTextCursor's position to the start of the block

Parameters
aEditorPtris the wizard::Editor in which to add the text
aCursoris the QTextCursor pointing to the location to insert the text
aTextToInsertis the text to insert

◆ IsWhitespaceString()

bool VI_EXPORT wizard::EditorHelpers::IsWhitespaceString ( const QString & aText)
noexcept

Determines whether the given string is composed of only whitespace characters

Parameters
aTextis the input text
Returns
whether the given string is composed of only whitespace characters

Referenced by MoveToPreviousNonWhitespaceToken().

◆ MoveToPreviousNonWhitespaceToken()

bool VI_EXPORT wizard::EditorHelpers::MoveToPreviousNonWhitespaceToken ( QTextCursor & aCursor,
QTextCursor::MoveMode aMoveMode,
int aOperationCount = 1 )
noexcept

Moves the QTextCursor to the beginning of the previous non-whitespace token

Parameters
aCursoris the QTextCursor (a return value parameter)
aMoveModeis whether to move or keep the anchor
aOperationCountis the number of times to move the cursor
Returns
whether the operations were a success (to mimic the behavior of QTextCursor::movePosition)

References IsWhitespaceString(), and ok.

Referenced by AddNewAttributeInText().

◆ ReplaceMGRS_Text()

bool VI_EXPORT wizard::EditorHelpers::ReplaceMGRS_Text ( QStringList & aMGRS_Tokens,
int aCommandIndex,
const vespa::VaPosition & aNewPosition )
noexcept

Replaces the old MGRS coordinate text with the new MGRS coordinate text

Parameters
aMGRS_Tokensare the tokens from the "mgrs_coordinate" (or similar) UtTextDocumentRange
aCommandIndexis the index in aMGRS_Tokens of the "mgrs_coordinate" (or similar) command
aNewPositionis the new position whose MGRS coordinate text will replace the old MGRS coordinate text

References wizard::Editor::FindNextValidToken().

◆ ReplacePositionText()

bool VI_EXPORT wizard::EditorHelpers::ReplacePositionText ( QStringList & aPositionTokens,
int aCommandIndex,
const vespa::VaPosition & aNewPosition )
noexcept

Replaces the position's old latitude and longitude text with new latitude and longitude text

Parameters
aPositionTokensare the tokens from the "position" (or similar) UtTextDocumentRange
aCommandIndexis the index in aPositionTokens of the "position" (or similar) command
aNewPositionis the new position whose latitude and longitude text will replace the old latitude and longitude text

References wizard::Editor::FindNextValidToken().

◆ ReplaceTextInEditor()

CPP17_NODISCARD bool VI_EXPORT wizard::EditorHelpers::ReplaceTextInEditor ( const UtTextDocumentRange & aEntryRange,
const QString & aAttributeName,
const QString & aInsert )

Modifies the given range by replacing the given attribute's value or removing the attribute

Parameters
aEntryRangethe range that is to be modified
aAttributeNamethe name of the attribute
aInsertthe text to insert
Precondition
The callee made a call to wizEnv.BeginUndoCapture() BEFORE calling this function.
Returns
whether the text replacement was a success

References GetInsertWithComments(), wizard::Project::GotoFile(), wizard::Project::Instance(), pos, success, and wizEnv.

◆ ReplaceUnitaryText()

template<typename UNITARY_PROPERTY>
bool wizard::EditorHelpers::ReplaceUnitaryText ( QStringList & aUnitaryTokens,
int aCommandIndex,
UNITARY_PROPERTY & aNewUnitary )
noexcept

Replaces the old unitary property with the new unitary property

Parameters
aUnitaryTokensare the tokens from the unitary property's UtTextDocumentRange
aCommandIndexis the index in aUnitaryTokens of the unitary property's command
aNewUnitaryis the new unitary property whose text will replace the old unitary property's text

References wizard::Editor::FindNextValidToken(), and ReplaceUnitaryText().

Referenced by ReplaceUnitaryText().

Copyrights Multiple, All Rights Reserved