<commit_before>/*=========================================================================

  Library:   CTK

  Copyright (c) Kitware Inc.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0.txt

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  =========================================================================*/

// Qt includes
#include <QWidget>
#include <QList>
#include <QPushButton>
#include <QBoxLayout>
#include <QDebug>
#include <QPointer>
#include <QStyle>

// CTK includes
#include "ctkWorkflowButtonBoxWidget.h"
#include "ctkWorkflowStep.h"
#include "ctkWorkflowWidgetStep.h"
#include "ctkWorkflow.h"

// STD includes
#include <iostream>

//-----------------------------------------------------------------------------
class ctkWorkflowButtonBoxWidgetPrivate
{
  Q_DECLARE_PUBLIC(ctkWorkflowButtonBoxWidget);
protected:
  ctkWorkflowButtonBoxWidget* const q_ptr;
public:
  ctkWorkflowButtonBoxWidgetPrivate(ctkWorkflowButtonBoxWidget& object);
  ~ctkWorkflowButtonBoxWidgetPrivate(){}

  void setupUi(QWidget * newParent);

  QPointer<ctkWorkflow>    Workflow;

  // Convenient typedefs
  typedef QMap<QPushButton*, ctkWorkflowStep*> ButtonToStepMapType;

  // The buttons on the widget (maintain maps associating each forward/goTo button with its step)
  QPushButton*        BackButton;
  QString             BackButtonDefaultText;
  QPushButton*        NextButton;
  QString             NextButtonDefaultText;
  ButtonToStepMapType GoToButtonToStepMap;

  // Direction for layout (for use with QBoxLayout only)
  QBoxLayout::Direction Direction;
  QSizePolicy ButtonSizePolicy;

  bool HideGoToButtons;
  bool HideInvalidButtons;

  // Functions to add/remove buttons
  void updateBackButton(ctkWorkflowStep* currentStep);
  void updateNextButton(ctkWorkflowStep* currentStep);
  void updateGoToButtons(ctkWorkflowStep* currentStep);

};

//-----------------------------------------------------------------------------
// ctkWorkflowButtonBoxWidgetPrivate methods

//-----------------------------------------------------------------------------
ctkWorkflowButtonBoxWidgetPrivate::ctkWorkflowButtonBoxWidgetPrivate(ctkWorkflowButtonBoxWidget& object)
  :q_ptr(&object)
{
  this->BackButton = 0;
  this->BackButtonDefaultText = "Back";
  this->NextButton = 0;
  this->NextButtonDefaultText = "Next";
  this->Direction = QBoxLayout::LeftToRight;
  this->ButtonSizePolicy = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
  this->HideGoToButtons = false;
  this->HideInvalidButtons = false;
}

//-----------------------------------------------------------------------------
void ctkWorkflowButtonBoxWidgetPrivate::setupUi(QWidget * newParent)
{
  QBoxLayout * boxLayout = new QBoxLayout(this->Direction, newParent);
  boxLayout->setSpacing(0);
  boxLayout->setContentsMargins(0, 0, 0, 0);
  newParent->setLayout(boxLayout);

  // Retrieve standard icons
  QIcon backIcon = newParent->style()->standardIcon(QStyle::SP_ArrowLeft);
  QIcon nextIcon = newParent->style()->standardIcon(QStyle::SP_ArrowRight);

  // Setup the buttons
  this->BackButton = new QPushButton(backIcon, this->BackButtonDefaultText, newParent);
  this->BackButton->setSizePolicy(this->ButtonSizePolicy);
  newParent->layout()->addWidget(this->BackButton);

  this->NextButton = new QPushButton(nextIcon, this->NextButtonDefaultText, newParent);
  this->NextButton->setSizePolicy(this->ButtonSizePolicy);
  this->NextButton->setLayoutDirection(Qt::RightToLeft);
  newParent->layout()->addWidget(this->NextButton);
}

//-----------------------------------------------------------------------------
void ctkWorkflowButtonBoxWidgetPrivate::updateBackButton(ctkWorkflowStep* currentStep)
{
#ifndef QT_NO_DEBUG
  Q_Q(ctkWorkflowButtonBoxWidget);

  Q_ASSERT(this->Workflow);
  Q_ASSERT(q->layout());
#endif
<commit_msg>Fix workflow next button arrow and text<commit_after>/*=========================================================================

  Library:   CTK

  Copyright (c) Kitware Inc.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0.txt

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  =========================================================================*/

// Qt includes
#include <QWidget>
#include <QList>
#include <QBoxLayout>
#include <QDebug>
#include <QPointer>
#include <QStyle>

// CTK includes
#include "ctkPushButton.h"
#include "ctkWorkflowButtonBoxWidget.h"
#include "ctkWorkflowStep.h"
#include "ctkWorkflowWidgetStep.h"
#include "ctkWorkflow.h"

// STD includes
#include <iostream>

//-----------------------------------------------------------------------------
class ctkWorkflowButtonBoxWidgetPrivate
{
  Q_DECLARE_PUBLIC(ctkWorkflowButtonBoxWidget);
protected:
  ctkWorkflowButtonBoxWidget* const q_ptr;
public:
  ctkWorkflowButtonBoxWidgetPrivate(ctkWorkflowButtonBoxWidget& object);
  ~ctkWorkflowButtonBoxWidgetPrivate(){}

  void setupUi(QWidget * newParent);

  QPointer<ctkWorkflow>    Workflow;

  // Convenient typedefs
  typedef QMap<QPushButton*, ctkWorkflowStep*> ButtonToStepMapType;

  // The buttons on the widget (maintain maps associating each forward/goTo button with its step)
  ctkPushButton*      BackButton;
  QString             BackButtonDefaultText;
  ctkPushButton*      NextButton;
  QString             NextButtonDefaultText;
  ButtonToStepMapType GoToButtonToStepMap;

  // Direction for layout (for use with QBoxLayout only)
  QBoxLayout::Direction Direction;
  QSizePolicy ButtonSizePolicy;

  bool HideGoToButtons;
  bool HideInvalidButtons;

  // Functions to add/remove buttons
  void updateBackButton(ctkWorkflowStep* currentStep);
  void updateNextButton(ctkWorkflowStep* currentStep);
  void updateGoToButtons(ctkWorkflowStep* currentStep);

};

//-----------------------------------------------------------------------------
// ctkWorkflowButtonBoxWidgetPrivate methods

//-----------------------------------------------------------------------------
ctkWorkflowButtonBoxWidgetPrivate::ctkWorkflowButtonBoxWidgetPrivate(ctkWorkflowButtonBoxWidget& object)
  :q_ptr(&object)
{
  this->BackButton = 0;
  this->BackButtonDefaultText = "Back";
  this->NextButton = 0;
  this->NextButtonDefaultText = "Next";
  this->Direction = QBoxLayout::LeftToRight;
  this->ButtonSizePolicy = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
  this->HideGoToButtons = false;
  this->HideInvalidButtons = false;
}

//-----------------------------------------------------------------------------
void ctkWorkflowButtonBoxWidgetPrivate::setupUi(QWidget * newParent)
{
  QBoxLayout * boxLayout = new QBoxLayout(this->Direction, newParent);
  boxLayout->setSpacing(0);
  boxLayout->setContentsMargins(0, 0, 0, 0);
  newParent->setLayout(boxLayout);

  // Retrieve standard icons
  QIcon backIcon = newParent->style()->standardIcon(QStyle::SP_ArrowLeft);
  QIcon nextIcon = newParent->style()->standardIcon(QStyle::SP_ArrowRight);

  // Setup the buttons
  this->BackButton = new ctkPushButton(backIcon, this->BackButtonDefaultText, newParent);
  this->BackButton->setSizePolicy(this->ButtonSizePolicy);
  this->BackButton->setIconAlignment(Qt::AlignLeft | Qt::AlignVCenter);
  newParent->layout()->addWidget(this->BackButton);

  this->NextButton = new ctkPushButton(nextIcon, this->NextButtonDefaultText, newParent);
  this->NextButton->setSizePolicy(this->ButtonSizePolicy);
  this->NextButton->setIconAlignment(Qt::AlignRight | Qt::AlignVCenter);
  newParent->layout()->addWidget(this->NextButton);
}

//-----------------------------------------------------------------------------
void ctkWorkflowButtonBoxWidgetPrivate::updateBackButton(ctkWorkflowStep* currentStep)
{
#ifndef QT_NO_DEBUG
  Q_Q(ctkWorkflowButtonBoxWidget);

  Q_ASSERT(this->Workflow);
  Q_ASSERT(q->layout());
#endif

{'fraction_non_alphanumeric': 0.21173469387755103, 'fraction_numerical': 0.002551020408163265, 'mean_word_length': 3.4298921417565484, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 96, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3859244', 'n_tokens_mistral': 2392, 'n_tokens_neox': 2330, 'n_words': 533}