1
0
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:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

View File

@@ -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/DFBrowser_SearchLine.hxx>
#include <inspector/DFBrowser_SearchLineModel.hxx>
@@ -41,45 +41,48 @@
#include <Standard_WarningsRestore.hxx>
//! class DFBrowser_LineEdit
//! Extension of Qt line edit to visualize help text until the line edit control has not been filled yet
//! Extension of Qt line edit to visualize help text until the line edit control has not been filled
//! yet
class DFBrowser_LineEdit : public QLineEdit
{
public:
//! Constructor
DFBrowser_LineEdit (QWidget* theParent) : QLineEdit(theParent) {}
DFBrowser_LineEdit(QWidget* theParent)
: QLineEdit(theParent)
{
}
//! Destructor
virtual ~DFBrowser_LineEdit() {}
//! Sets text that is shown in line edit it the text of this control is empty
//! \param theText a string value
void setPlaneHolder (const QString& theText) { myPlaceHolder = theText; }
void setPlaneHolder(const QString& theText) { myPlaceHolder = theText; }
//! Draws the line edit context, put plane holder if text is empty
//! \param theEvent a paint event
virtual void paintEvent (QPaintEvent* theEvent) Standard_OVERRIDE
virtual void paintEvent(QPaintEvent* theEvent) Standard_OVERRIDE
{
QLineEdit::paintEvent (theEvent);
QLineEdit::paintEvent(theEvent);
if (!text().isEmpty())
return;
QPainter aPainter (this);
QFontMetrics aFontMetrics = fontMetrics();
QRect aLineRect = rect();
Qt::Alignment anAlignment = QStyle::visualAlignment (layoutDirection(), Qt::AlignLeft);
QPainter aPainter(this);
QFontMetrics aFontMetrics = fontMetrics();
QRect aLineRect = rect();
Qt::Alignment anAlignment = QStyle::visualAlignment(layoutDirection(), Qt::AlignLeft);
QColor aColor = Qt::gray;
QPen anOldpen = aPainter.pen();
aPainter.setPen (aColor);
aLineRect.adjust (4, 4, 0, 0);
QString anElidedText = aFontMetrics.elidedText (myPlaceHolder, Qt::ElideRight, aLineRect.width());
aPainter.drawText (aLineRect, anAlignment, anElidedText);
aPainter.setPen (anOldpen);
QColor aColor = Qt::gray;
QPen anOldpen = aPainter.pen();
aPainter.setPen(aColor);
aLineRect.adjust(4, 4, 0, 0);
QString anElidedText =
aFontMetrics.elidedText(myPlaceHolder, Qt::ElideRight, aLineRect.width());
aPainter.drawText(aLineRect, anAlignment, anElidedText);
aPainter.setPen(anOldpen);
}
private:
QString myPlaceHolder; //!< text of filling line edit content if the text is empty
};
@@ -87,40 +90,43 @@ private:
// function : Constructor
// purpose :
// =======================================================================
DFBrowser_SearchLine::DFBrowser_SearchLine (QWidget* theParent)
: QFrame (theParent)
DFBrowser_SearchLine::DFBrowser_SearchLine(QWidget* theParent)
: QFrame(theParent)
{
QHBoxLayout* aLayout = new QHBoxLayout (this);
aLayout->setContentsMargins (0, 0, 0, 0);
aLayout->setSpacing (0);
QHBoxLayout* aLayout = new QHBoxLayout(this);
aLayout->setContentsMargins(0, 0, 0, 0);
aLayout->setSpacing(0);
myLineControl = new DFBrowser_LineEdit (this);
((DFBrowser_LineEdit*)myLineControl)->setPlaneHolder (QString (tr ("Scanning application ...")));
mySearchButton = new QToolButton (this);
mySearchButton->setIcon (QIcon (":/icons/search.png"));
myLineControl = new DFBrowser_LineEdit(this);
((DFBrowser_LineEdit*)myLineControl)->setPlaneHolder(QString(tr("Scanning application ...")));
mySearchButton = new QToolButton(this);
mySearchButton->setIcon(QIcon(":/icons/search.png"));
QCompleter* aCompleter = new QCompleter (this);
aCompleter->setCaseSensitivity (Qt::CaseInsensitive);
myLineControl->setCompleter (aCompleter);
QCompleter* aCompleter = new QCompleter(this);
aCompleter->setCaseSensitivity(Qt::CaseInsensitive);
myLineControl->setCompleter(aCompleter);
aLayout->addWidget (myLineControl);
aLayout->addWidget (mySearchButton);
aLayout->addWidget(myLineControl);
aLayout->addWidget(mySearchButton);
connect (myLineControl, SIGNAL (textChanged (const QString&)), this, SLOT (onTextChanged (const QString&)));
connect (myLineControl, SIGNAL (returnPressed()), this, SLOT (onReturnPressed()));
connect (mySearchButton, SIGNAL (clicked()), this, SLOT (onSearchButtonClicked()));
connect(myLineControl,
SIGNAL(textChanged(const QString&)),
this,
SLOT(onTextChanged(const QString&)));
connect(myLineControl, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
connect(mySearchButton, SIGNAL(clicked()), this, SLOT(onSearchButtonClicked()));
ViewControl_Tools::SetWhiteBackground (this);
ViewControl_Tools::SetWhiteBackground(this);
}
// =======================================================================
// function : SetModule
// purpose :
// =======================================================================
void DFBrowser_SearchLine::SetModule (DFBrowser_Module* theModule)
void DFBrowser_SearchLine::SetModule(DFBrowser_Module* theModule)
{
DFBrowser_SearchLineModel* aModel = new DFBrowser_SearchLineModel (myLineControl, theModule);
myLineControl->completer()->setModel (aModel);
DFBrowser_SearchLineModel* aModel = new DFBrowser_SearchLineModel(myLineControl, theModule);
myLineControl->completer()->setModel(aModel);
}
// =======================================================================
@@ -129,7 +135,7 @@ void DFBrowser_SearchLine::SetModule (DFBrowser_Module* theModule)
// =======================================================================
DFBrowser_Module* DFBrowser_SearchLine::GetModule()
{
DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*>(GetModel());
return aModel->GetModule();
}
@@ -137,15 +143,17 @@ DFBrowser_Module* DFBrowser_SearchLine::GetModule()
// function : SetValues
// purpose :
// =======================================================================
void DFBrowser_SearchLine::SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
const QMap<int, QStringList>& theDocumentInfoValues)
void DFBrowser_SearchLine::SetValues(
const QMap<int, QMap<QString, DFBrowser_SearchItemInfo>>& theDocumentValues,
const QMap<int, QStringList>& theDocumentInfoValues)
{
DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
aModel->SetValues (theDocumentValues, theDocumentInfoValues);
DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*>(GetModel());
aModel->SetValues(theDocumentValues, theDocumentInfoValues);
QString aFirstValue = !theDocumentInfoValues.empty() ? theDocumentInfoValues.begin().value().first() : "";
DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*> (myLineControl);
aLineEdit->setPlaneHolder (QString (tr ("Search : %1")).arg (aFirstValue));
QString aFirstValue =
!theDocumentInfoValues.empty() ? theDocumentInfoValues.begin().value().first() : "";
DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*>(myLineControl);
aLineEdit->setPlaneHolder(QString(tr("Search : %1")).arg(aFirstValue));
}
// =======================================================================
@@ -154,21 +162,21 @@ void DFBrowser_SearchLine::SetValues (const QMap<int, QMap<QString, DFBrowser_Se
// =======================================================================
void DFBrowser_SearchLine::ClearValues()
{
DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*>(GetModel());
aModel->ClearValues();
DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*> (myLineControl);
aLineEdit->setPlaneHolder(QString (tr ("Scanning application ...")));
DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*>(myLineControl);
aLineEdit->setPlaneHolder(QString(tr("Scanning application ...")));
}
// =======================================================================
// function : onTextChanged
// purpose :
// =======================================================================
void DFBrowser_SearchLine::onTextChanged (const QString& theText)
void DFBrowser_SearchLine::onTextChanged(const QString& theText)
{
mySearchButton->setIcon (theText.isEmpty() ? QIcon (":/icons/search.png")
: QIcon (":/icons/search_cancel.png"));
mySearchButton->setIcon(theText.isEmpty() ? QIcon(":/icons/search.png")
: QIcon(":/icons/search_cancel.png"));
emit searchActivated();
}
@@ -179,5 +187,5 @@ void DFBrowser_SearchLine::onTextChanged (const QString& theText)
void DFBrowser_SearchLine::onSearchButtonClicked()
{
if (!Text().isEmpty())
SetText (QString());
SetText(QString());
}