mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Coding - Apply .clang-format formatting #286
Update empty method guards to new style with regex (see PR). Used clang-format 18.1.8. New actions to validate code formatting is added. Update .clang-format with disabling of include sorting. It is temporary changes, then include will be sorted. Apply formatting for /src and /tools folder. The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TreeModel_ItemProperties.hxx>
|
||||
#include <inspector/TreeModel_ItemStream.hxx>
|
||||
@@ -34,26 +34,26 @@ IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient)
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ItemProperties::Init ()
|
||||
void TreeModel_ItemProperties::Init()
|
||||
{
|
||||
myRowValues.Clear();
|
||||
|
||||
InitByStream (Item()->Stream());
|
||||
InitByStream(Item()->Stream());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitByStream
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ItemProperties::InitByStream (const Standard_SStream& aStream)
|
||||
void TreeModel_ItemProperties::InitByStream(const Standard_SStream& aStream)
|
||||
{
|
||||
NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> aValues;
|
||||
TCollection_AsciiString aStreamText = Standard_Dump::Text (aStream);
|
||||
Standard_Dump::SplitJson (aStreamText, aValues);
|
||||
TCollection_AsciiString aStreamText = Standard_Dump::Text(aStream);
|
||||
Standard_Dump::SplitJson(aStreamText, aValues);
|
||||
|
||||
TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(Item());
|
||||
TCollection_AsciiString aKey;
|
||||
Standard_DumpValue aKeyValue;
|
||||
Standard_DumpValue aKeyValue;
|
||||
if (!aStreamParent)
|
||||
{
|
||||
if (!Item() || Item()->Object().IsNull())
|
||||
@@ -65,9 +65,9 @@ void TreeModel_ItemProperties::InitByStream (const Standard_SStream& aStream)
|
||||
const Handle(Standard_Transient)& anItemObject = Item()->Object();
|
||||
aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name();
|
||||
}
|
||||
aKeyValue = Standard_DumpValue (aStreamText, 1);
|
||||
aKeyValue = Standard_DumpValue(aStreamText, 1);
|
||||
|
||||
myKey = aKey;
|
||||
myKey = aKey;
|
||||
myStreamValue = aKeyValue;
|
||||
}
|
||||
else
|
||||
@@ -77,43 +77,46 @@ void TreeModel_ItemProperties::InitByStream (const Standard_SStream& aStream)
|
||||
{
|
||||
const Handle(TreeModel_ItemProperties)& aParentProperties = Item()->Parent()->Properties();
|
||||
if (aParentProperties)
|
||||
aParentProperties->ChildStream (Item()->Row(), aKey, aKeyValue);
|
||||
aParentProperties->ChildStream(Item()->Row(), aKey, aKeyValue);
|
||||
}
|
||||
myKey = aKey;
|
||||
myKey = aKey;
|
||||
myStreamValue = aKeyValue;
|
||||
|
||||
aValues.Clear();
|
||||
Standard_Dump::SplitJson (myStreamValue.myValue, aValues);
|
||||
Standard_Dump::SplitJson(myStreamValue.myValue, aValues);
|
||||
}
|
||||
|
||||
for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++)
|
||||
{
|
||||
Standard_DumpValue aValue = aValues.FindFromIndex (anIndex);
|
||||
if (Standard_Dump::HasChildKey (aValue.myValue))
|
||||
myChildren.Add (aValues.FindKey (anIndex), aValue);
|
||||
Standard_DumpValue aValue = aValues.FindFromIndex(anIndex);
|
||||
if (Standard_Dump::HasChildKey(aValue.myValue))
|
||||
myChildren.Add(aValues.FindKey(anIndex), aValue);
|
||||
else
|
||||
{
|
||||
TreeModel_RowValue aRowValue (aValue.myStartPosition, aValues.FindKey (anIndex).ToCString(), aValue.myValue.ToCString());
|
||||
myRowValues.Add (myRowValues.Size() + 1, aRowValue);
|
||||
TreeModel_RowValue aRowValue(aValue.myStartPosition,
|
||||
aValues.FindKey(anIndex).ToCString(),
|
||||
aValue.myValue.ToCString());
|
||||
myRowValues.Add(myRowValues.Size() + 1, aRowValue);
|
||||
}
|
||||
}
|
||||
if (myRowValues.Size() == 1)
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
if (Convert_Tools::ConvertStreamToColor (aStream, aColor))
|
||||
if (Convert_Tools::ConvertStreamToColor(aStream, aColor))
|
||||
{
|
||||
Standard_Real aRed, aGreen, aBlue;
|
||||
aColor.Values (aRed, aGreen, aBlue, Quantity_TOC_sRGB);
|
||||
aColor.Values(aRed, aGreen, aBlue, Quantity_TOC_sRGB);
|
||||
|
||||
int aDelta = 255;
|
||||
myRowValues.ChangeFromIndex (1).CustomValues.insert ((int)Qt::BackgroundRole, QColor((int)(aRed * aDelta),
|
||||
(int)(aGreen * aDelta), (int)(aBlue * aDelta)));
|
||||
myRowValues.ChangeFromIndex(1).CustomValues.insert(
|
||||
(int)Qt::BackgroundRole,
|
||||
QColor((int)(aRed * aDelta), (int)(aGreen * aDelta), (int)(aBlue * aDelta)));
|
||||
}
|
||||
}
|
||||
// in case if the stream alert has empty key avalue, use as the key the first row value
|
||||
if ((myKey.IsEmpty() || myKey.IsEqual ("Dump")) && myRowValues.Size() > 0)
|
||||
if ((myKey.IsEmpty() || myKey.IsEqual("Dump")) && myRowValues.Size() > 0)
|
||||
{
|
||||
myKey = myRowValues.FindFromIndex (1).Value.toString().toStdString().c_str();
|
||||
myKey = myRowValues.FindFromIndex(1).Value.toString().toStdString().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +126,7 @@ void TreeModel_ItemProperties::InitByStream (const Standard_SStream& aStream)
|
||||
// =======================================================================
|
||||
void TreeModel_ItemProperties::Reset()
|
||||
{
|
||||
myKey = "";
|
||||
myKey = "";
|
||||
myStreamValue = Standard_DumpValue();
|
||||
|
||||
myChildren.Clear();
|
||||
@@ -143,12 +146,12 @@ int TreeModel_ItemProperties::RowCount() const
|
||||
// function : Data
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant TreeModel_ItemProperties::Data (const int theRow, const int theColumn, int theRole) const
|
||||
QVariant TreeModel_ItemProperties::Data(const int theRow, const int theColumn, int theRole) const
|
||||
{
|
||||
if (theColumn == 1 && theRole == Qt::BackgroundRole)
|
||||
{
|
||||
const QMap<int, QVariant>& aCachedValues = RowValues().FindFromIndex (theRow + 1).CustomValues;
|
||||
if (aCachedValues.contains ((int)theRole))
|
||||
const QMap<int, QVariant>& aCachedValues = RowValues().FindFromIndex(theRow + 1).CustomValues;
|
||||
if (aCachedValues.contains((int)theRole))
|
||||
return aCachedValues[(int)theRole];
|
||||
}
|
||||
|
||||
@@ -157,20 +160,22 @@ QVariant TreeModel_ItemProperties::Data (const int theRow, const int theColumn,
|
||||
if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
|
||||
{
|
||||
QFont aFont = qApp->font();
|
||||
aFont.setItalic (true);
|
||||
aFont.setItalic(true);
|
||||
return aFont;
|
||||
}
|
||||
}
|
||||
if (theRole == Qt::ForegroundRole)
|
||||
{
|
||||
if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
|
||||
return QColor (Qt::darkGray).darker(150);
|
||||
return QColor(Qt::darkGray).darker(150);
|
||||
}
|
||||
|
||||
if (theRole == Qt::DisplayRole || theRole == Qt::ToolTipRole)
|
||||
{
|
||||
if (theColumn == 0) return RowValues().FindFromIndex (theRow + 1).Key;
|
||||
else if (theColumn == 1) return RowValues().FindFromIndex (theRow + 1).Value;
|
||||
if (theColumn == 0)
|
||||
return RowValues().FindFromIndex(theRow + 1).Key;
|
||||
else if (theColumn == 1)
|
||||
return RowValues().FindFromIndex(theRow + 1).Value;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
@@ -180,13 +185,13 @@ QVariant TreeModel_ItemProperties::Data (const int theRow, const int theColumn,
|
||||
// function : EditType
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
ViewControl_EditType TreeModel_ItemProperties::EditType (const int, const int theColumn) const
|
||||
ViewControl_EditType TreeModel_ItemProperties::EditType(const int, const int theColumn) const
|
||||
{
|
||||
if (theColumn == 0)
|
||||
return ViewControl_EditType_None;
|
||||
|
||||
Quantity_Color aColor;
|
||||
if (Convert_Tools::ConvertStreamToColor (Item()->Stream(), aColor))
|
||||
if (Convert_Tools::ConvertStreamToColor(Item()->Stream(), aColor))
|
||||
{
|
||||
return ViewControl_EditType_Color;
|
||||
}
|
||||
@@ -197,21 +202,22 @@ ViewControl_EditType TreeModel_ItemProperties::EditType (const int, const int th
|
||||
// function : ReplaceValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean ReplaceValue (const TCollection_AsciiString& theFromValue,
|
||||
const TCollection_AsciiString& theToValue,
|
||||
Standard_DumpValue& theStreamValue)
|
||||
Standard_Boolean ReplaceValue(const TCollection_AsciiString& theFromValue,
|
||||
const TCollection_AsciiString& theToValue,
|
||||
Standard_DumpValue& theStreamValue)
|
||||
{
|
||||
TCollection_AsciiString aStreamValue = theStreamValue.myValue;
|
||||
|
||||
int aPosition = aStreamValue.FirstLocationInSet (theFromValue, 1, aStreamValue.Length());
|
||||
int aPosition = aStreamValue.FirstLocationInSet(theFromValue, 1, aStreamValue.Length());
|
||||
if (aPosition < 1)
|
||||
return Standard_False;
|
||||
|
||||
aPosition += 2; // due to 'FirstLocationInSet' returns position taking into account '"\' as 1 position
|
||||
aPosition +=
|
||||
2; // due to 'FirstLocationInSet' returns position taking into account '"\' as 1 position
|
||||
|
||||
TCollection_AsciiString aPartStart = aStreamValue.SubString(1, aPosition - 1);
|
||||
TCollection_AsciiString aPartFinal = aStreamValue.SubString(aPosition + theFromValue.Length(),
|
||||
aStreamValue.Length());
|
||||
TCollection_AsciiString aPartFinal =
|
||||
aStreamValue.SubString(aPosition + theFromValue.Length(), aStreamValue.Length());
|
||||
theStreamValue.myValue = aPartStart + theToValue + aPartFinal;
|
||||
|
||||
return Standard_True;
|
||||
@@ -221,7 +227,10 @@ Standard_Boolean ReplaceValue (const TCollection_AsciiString& theFromValue,
|
||||
// function : SetData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TreeModel_ItemProperties::SetData (const int theRow, const int theColumn, const QVariant& theValue, int theRole)
|
||||
bool TreeModel_ItemProperties::SetData(const int theRow,
|
||||
const int theColumn,
|
||||
const QVariant& theValue,
|
||||
int theRole)
|
||||
{
|
||||
if (theColumn == 0)
|
||||
return false;
|
||||
@@ -231,47 +240,49 @@ bool TreeModel_ItemProperties::SetData (const int theRow, const int theColumn, c
|
||||
|
||||
if (myRowValues.Size() == 1 && theColumn == 1)
|
||||
{
|
||||
TCollection_AsciiString aStreamValue (theValue.toString().toStdString().c_str());
|
||||
TCollection_AsciiString aStreamValue(theValue.toString().toStdString().c_str());
|
||||
NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> aKeyToValues;
|
||||
if (Standard_Dump::SplitJson (aStreamValue, aKeyToValues))
|
||||
if (Standard_Dump::SplitJson(aStreamValue, aKeyToValues))
|
||||
{
|
||||
Standard_SStream aStream;
|
||||
aStream << aStreamValue.ToCString();
|
||||
|
||||
int aStartPos = 1;
|
||||
int aStartPos = 1;
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColor.InitFromJson (aStream, aStartPos))
|
||||
if (aColor.InitFromJson(aStream, aStartPos))
|
||||
{
|
||||
Standard_Real aRed, aGreen, aBlue;
|
||||
aColor.GetRGB().Values (aRed, aGreen, aBlue, Quantity_TOC_sRGB);
|
||||
aColor.GetRGB().Values(aRed, aGreen, aBlue, Quantity_TOC_sRGB);
|
||||
int aDelta = 255;
|
||||
myRowValues.ChangeFromIndex (1).CustomValues.insert ((int)Qt::BackgroundRole, QColor((int)(aRed * aDelta),
|
||||
(int)(aGreen * aDelta), (int)(aBlue * aDelta)));
|
||||
myRowValues.ChangeFromIndex(1).CustomValues.insert(
|
||||
(int)Qt::BackgroundRole,
|
||||
QColor((int)(aRed * aDelta), (int)(aGreen * aDelta), (int)(aBlue * aDelta)));
|
||||
}
|
||||
Standard_DumpValue aValue = aKeyToValues.FindFromIndex (1);
|
||||
myStreamValue.myValue = aValue.myValue.ToCString();
|
||||
myRowValues.ChangeFromIndex (1).Value = aValue.myValue.ToCString();
|
||||
Standard_DumpValue aValue = aKeyToValues.FindFromIndex(1);
|
||||
myStreamValue.myValue = aValue.myValue.ToCString();
|
||||
myRowValues.ChangeFromIndex(1).Value = aValue.myValue.ToCString();
|
||||
|
||||
Item()->StoreItemProperties (theRow, theColumn, theValue);
|
||||
Item()->StoreItemProperties(theRow, theColumn, theValue);
|
||||
return true;
|
||||
}
|
||||
TCollection_AsciiString aFromValue = myRowValues.ChangeFromIndex (1).Value.toString().toStdString().c_str();
|
||||
TCollection_AsciiString aFromValue =
|
||||
myRowValues.ChangeFromIndex(1).Value.toString().toStdString().c_str();
|
||||
if (ReplaceValue(aFromValue, aStreamValue, myStreamValue))
|
||||
{
|
||||
aStreamValue = myStreamValue.myValue;
|
||||
if (Standard_Dump::SplitJson (aStreamValue, aKeyToValues))
|
||||
if (Standard_Dump::SplitJson(aStreamValue, aKeyToValues))
|
||||
{
|
||||
Standard_DumpValue aValue = aKeyToValues.FindFromIndex (1);
|
||||
myRowValues.ChangeFromIndex (1).Value = aValue.myValue.ToCString();
|
||||
Standard_DumpValue aValue = aKeyToValues.FindFromIndex(1);
|
||||
myRowValues.ChangeFromIndex(1).Value = aValue.myValue.ToCString();
|
||||
|
||||
Item()->StoreItemProperties (theRow, theColumn, aStreamValue.ToCString());
|
||||
Item()->StoreItemProperties(theRow, theColumn, aStreamValue.ToCString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myRowValues.ChangeFromIndex (theRow + 1).Value = theValue;
|
||||
Item()->StoreItemProperties (theRow, theColumn, theValue);
|
||||
myRowValues.ChangeFromIndex(theRow + 1).Value = theValue;
|
||||
Item()->StoreItemProperties(theRow, theColumn, theValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -279,21 +290,22 @@ bool TreeModel_ItemProperties::SetData (const int theRow, const int theColumn, c
|
||||
// function : Presentations
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ItemProperties::Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
void TreeModel_ItemProperties::Presentations(
|
||||
NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
{
|
||||
if (!Item())
|
||||
{
|
||||
return;
|
||||
}
|
||||
const Standard_SStream& aStream = Item()->Stream();
|
||||
Convert_Tools::ConvertStreamToPresentations (aStream, 1, -1, thePresentations);
|
||||
Convert_Tools::ConvertStreamToPresentations(aStream, 1, -1, thePresentations);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : TableFlags
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Qt::ItemFlags TreeModel_ItemProperties::TableFlags (const int, const int theColumn) const
|
||||
Qt::ItemFlags TreeModel_ItemProperties::TableFlags(const int, const int theColumn) const
|
||||
{
|
||||
Qt::ItemFlags aFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
|
||||
@@ -307,15 +319,15 @@ Qt::ItemFlags TreeModel_ItemProperties::TableFlags (const int, const int theColu
|
||||
// function : ChildStream
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ItemProperties::ChildStream (const int theRowId,
|
||||
TCollection_AsciiString& theKey,
|
||||
Standard_DumpValue& theValue) const
|
||||
void TreeModel_ItemProperties::ChildStream(const int theRowId,
|
||||
TCollection_AsciiString& theKey,
|
||||
Standard_DumpValue& theValue) const
|
||||
{
|
||||
if (myChildren.Size() <= theRowId)
|
||||
return;
|
||||
|
||||
theKey = myChildren.FindKey (theRowId + 1);
|
||||
theValue = myChildren.FindFromIndex (theRowId + 1);
|
||||
theKey = myChildren.FindKey(theRowId + 1);
|
||||
theValue = myChildren.FindFromIndex(theRowId + 1);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
Reference in New Issue
Block a user