Salome HOME
Auto-formatting according to the defined code standard.
[modules/shaper.git] / src / XGUI / XGUI_Workbench.cpp
index 61da43fa236f0fcb7f2ee8c7d3ed3bdf535fd31b..b3a1aee2b98d5db5c01e5ada92be46433ad7ec30 100644 (file)
@@ -5,67 +5,68 @@
 #include <QResizeEvent>
 #include <QPushButton>
 
-
 #define SCROLL_STEP 20
 
 //**************************************************
-class CommandsArea : public QScrollArea
+class CommandsArea: public QScrollArea
 {
 public:
-    CommandsArea(QWidget* theParent) : QScrollArea(theParent) {}
+  CommandsArea(QWidget* theParent)
+      : QScrollArea(theParent)
+  {
+  }
 
 protected:
-    virtual void resizeEvent(QResizeEvent * theEvent);
+  virtual void resizeEvent(QResizeEvent * theEvent);
 };
 
 void CommandsArea::resizeEvent(QResizeEvent* theEvent)
 {
-    int x = widget()->x();
-    QScrollArea::resizeEvent(theEvent);
-    QRect aRect = widget()->childrenRect();
-    QSize aNewSize = theEvent->size();
-    if (aRect.width() > aNewSize.width())
-        aNewSize.setWidth(aRect.width() * 2);
-    widget()->resize(aNewSize);
-    widget()->move(x, 0);
+  int x = widget()->x();
+  QScrollArea::resizeEvent(theEvent);
+  QRect aRect = widget()->childrenRect();
+  QSize aNewSize = theEvent->size();
+  if (aRect.width() > aNewSize.width())
+    aNewSize.setWidth(aRect.width() * 2);
+  widget()->resize(aNewSize);
+  widget()->move(x, 0);
 }
 
-
 //**************************************************
-XGUI_Workbench::XGUI_Workbench(QWidget *theParent) :
-    QWidget(theParent)
+XGUI_Workbench::XGUI_Workbench(QWidget *theParent)
+    QWidget(theParent)
 {
-    setMinimumHeight(30);
-    QHBoxLayout* aMainLayout = new QHBoxLayout(this);
-    aMainLayout->setSpacing(0);
-    aMainLayout->setMargin(0);
-    aMainLayout->setContentsMargins(0,0,0,0);
-
-    myLeftButton = new QPushButton("<", this);
-    myLeftButton->setMaximumWidth(14);
-    myLeftButton->setVisible(false);
-    connect(myLeftButton,SIGNAL(clicked()), this, SLOT(onLeftScroll()));
-    aMainLayout->addWidget(myLeftButton);
-
-    myCommandsArea = new CommandsArea(this);
-    aMainLayout->addWidget(myCommandsArea);
-
-    myChildWidget = new QWidget(myCommandsArea);
-    myCommandsArea->setWidget(myChildWidget);
-    myCommandsArea->setAlignment(Qt::AlignLeft | Qt::AlignTop);
-    myCommandsArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    myCommandsArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
-    myLayout = new QHBoxLayout(myChildWidget);
-    myLayout->setSpacing(0);
-    myLayout->setMargin(0);
-    myLayout->setContentsMargins(0,0,0,0);
-
-    myRightButton = new QPushButton(">", this);
-    myRightButton->setMaximumWidth(14);
-    myRightButton->setVisible(false);
-    connect(myRightButton,SIGNAL(clicked()), this, SLOT(onRightScroll()));
-    aMainLayout->addWidget(myRightButton);
+  setMinimumHeight(30);
+  QHBoxLayout* aMainLayout = new QHBoxLayout(this);
+  aMainLayout->setSpacing(0);
+  aMainLayout->setMargin(0);
+  aMainLayout->setContentsMargins(0, 0, 0, 0);
+
+  myLeftButton = new QPushButton("<", this);
+  myLeftButton->setMaximumWidth(14);
+  myLeftButton->setVisible(false);
+  connect(myLeftButton, SIGNAL(clicked()), this, SLOT(onLeftScroll()));
+  aMainLayout->addWidget(myLeftButton);
+
+  myCommandsArea = new CommandsArea(this);
+  aMainLayout->addWidget(myCommandsArea);
+
+  myChildWidget = new QWidget(myCommandsArea);
+  myCommandsArea->setWidget(myChildWidget);
+  myCommandsArea->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+  myCommandsArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+  myCommandsArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+  myLayout = new QHBoxLayout(myChildWidget);
+  myLayout->setSpacing(0);
+  myLayout->setMargin(0);
+  myLayout->setContentsMargins(0, 0, 0, 0);
+
+  myRightButton = new QPushButton(">", this);
+  myRightButton->setMaximumWidth(14);
+  myRightButton->setVisible(false);
+  connect(myRightButton, SIGNAL(clicked()), this, SLOT(onRightScroll()));
+  aMainLayout->addWidget(myRightButton);
 
 }
 
@@ -74,18 +75,18 @@ XGUI_Workbench::XGUI_Workbench(QWidget *theParent) :
  */
 XGUI_MenuGroupPanel* XGUI_Workbench::addGroup(const QString& theId)
 {
-    if (!myLayout->isEmpty()) {
-        int aNb = myLayout->count();
-        QLayoutItem* aItem = myLayout->itemAt(aNb - 1);
-        myLayout->removeItem(aItem);
-    }
-    XGUI_MenuGroupPanel* aGroup = new XGUI_MenuGroupPanel(myChildWidget);
-    aGroup->setObjectName(theId);
-    myLayout->addWidget(aGroup);
-    addSeparator();
-    myLayout->addStretch();
-    myGroups.append(aGroup);
-    return aGroup;
+  if (!myLayout->isEmpty()) {
+    int aNb = myLayout->count();
+    QLayoutItem* aItem = myLayout->itemAt(aNb - 1);
+    myLayout->removeItem(aItem);
+  }
+  XGUI_MenuGroupPanel* aGroup = new XGUI_MenuGroupPanel(myChildWidget);
+  aGroup->setObjectName(theId);
+  myLayout->addWidget(aGroup);
+  addSeparator();
+  myLayout->addStretch();
+  myGroups.append(aGroup);
+  return aGroup;
 }
 
 /*
@@ -94,71 +95,67 @@ XGUI_MenuGroupPanel* XGUI_Workbench::addGroup(const QString& theId)
 XGUI_MenuGroupPanel* XGUI_Workbench::findGroup(const QString& theId)
 {
   XGUI_MenuGroupPanel* aPanel;
-  foreach(aPanel, myGroups) {
-    if(aPanel->objectName() == theId) {
+  foreach(aPanel, myGroups)
+  {
+    if (aPanel->objectName() == theId) {
       return aPanel;
     }
   }
   return NULL;
 }
 
-
 void XGUI_Workbench::addSeparator()
 {
-    QFrame* aLine = new QFrame(myChildWidget);
-    aLine->setFrameShape(QFrame::VLine);
-    aLine->setFrameShadow(QFrame::Sunken);
-    myLayout->addWidget(aLine);
+  QFrame* aLine = new QFrame(myChildWidget);
+  aLine->setFrameShape(QFrame::VLine);
+  aLine->setFrameShadow(QFrame::Sunken);
+  myLayout->addWidget(aLine);
 }
 
-
 void XGUI_Workbench::resizeEvent(QResizeEvent* theEvent)
 {
-    QWidget::resizeEvent(theEvent);
-    QSize aSize = theEvent->size();
-    myLeftButton->setMinimumHeight(aSize.height() - 2);
-    myRightButton->setMinimumHeight(aSize.height() - 2);
-
-    QSize aS = myChildWidget->sizeHint();
-       int aW = myChildWidget->width();
-       if (aW < aS.width())
-               myChildWidget->resize(aS.width(), myChildWidget->height());
-
-    myLeftButton->setVisible(isExceedsLeft());
-    myRightButton->setVisible(isExceedsRight());
+  QWidget::resizeEvent(theEvent);
+  QSize aSize = theEvent->size();
+  myLeftButton->setMinimumHeight(aSize.height() - 2);
+  myRightButton->setMinimumHeight(aSize.height() - 2);
+
+  QSize aS = myChildWidget->sizeHint();
+  int aW = myChildWidget->width();
+  if (aW < aS.width())
+    myChildWidget->resize(aS.width(), myChildWidget->height());
+
+  myLeftButton->setVisible(isExceedsLeft());
+  myRightButton->setVisible(isExceedsRight());
 }
 
-
 void XGUI_Workbench::onLeftScroll()
 {
-    if (!isExceedsLeft())
-               return;
-    myChildWidget->move( myChildWidget->pos().x() + SCROLL_STEP, 0 );
-    myLeftButton->setVisible(isExceedsLeft());
-    myRightButton->setVisible(isExceedsRight());
+  if (!isExceedsLeft())
+    return;
+  myChildWidget->move(myChildWidget->pos().x() + SCROLL_STEP, 0);
+  myLeftButton->setVisible(isExceedsLeft());
+  myRightButton->setVisible(isExceedsRight());
 }
 
-
 void XGUI_Workbench::onRightScroll()
 {
-    if (!isExceedsRight())
-               return;
-    myChildWidget->move( myChildWidget->pos().x() - SCROLL_STEP, 0 );
-    myLeftButton->setVisible(isExceedsLeft());
-    myRightButton->setVisible(isExceedsRight());
+  if (!isExceedsRight())
+    return;
+  myChildWidget->move(myChildWidget->pos().x() - SCROLL_STEP, 0);
+  myLeftButton->setVisible(isExceedsLeft());
+  myRightButton->setVisible(isExceedsRight());
 }
 
-
 bool XGUI_Workbench::isExceedsLeft()
 {
-    QPoint aPos = myChildWidget->pos();
-    return (aPos.x() < 0);
+  QPoint aPos = myChildWidget->pos();
+  return (aPos.x() < 0);
 }
 
 bool XGUI_Workbench::isExceedsRight()
 {
-    QPoint aPos = myChildWidget->pos();
-    int aVPWidth = myCommandsArea->viewport()->rect().width();
-    int aWgtWidth = myChildWidget->childrenRect().width();
-    return ((aVPWidth - aPos.x()) < aWgtWidth);
+  QPoint aPos = myChildWidget->pos();
+  int aVPWidth = myCommandsArea->viewport()->rect().width();
+  int aWgtWidth = myChildWidget->childrenRect().width();
+  return ((aVPWidth - aPos.x()) < aWgtWidth);
 }