| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | /*=========================================================================  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.commontk.org/LICENSE  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 <QList>#include <QDebug>// CTK includes#include "ctkWorkflowWidgetStep.h"#include "ctkWorkflowWidgetStep_p.h"#include "ctkWorkflowWidget.h"#include "ctkWorkflow.h"#include "ctkLogger.h"// STD includes#include <iostream>//-----------------------------------------------------------------------------static ctkLogger logger("org.commontk.libs.widgets.ctkWorkflowWidgetStep");//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// ctkWorkflowWidgetStepPrivate methods//-----------------------------------------------------------------------------ctkWorkflowWidgetStepPrivate::ctkWorkflowWidgetStepPrivate(ctkWorkflowWidgetStep& object)  :Superclass(object), q_ptr(&object){//  this->buttonBoxWidget = 0;//  this->hasButtonBoxWidget = false;  this->icon = QIcon();  this->created = false;}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStepPrivate::invokeShowUserInterfaceCommandInternal()const{  emit invokeShowUserInterfaceCommand();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStepPrivate::showUserInterfaceCompleteInternal()const{  emit showUserInterfaceComplete();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStepPrivate::showUserInterface(){  Q_Q(ctkWorkflowWidgetStep);  q->showUserInterface();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStepPrivate::invokeCreateUserInterfaceCommandInternal()const{  emit invokeCreateUserInterfaceCommand();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStepPrivate::createUserInterfaceCompleteInternal()const{  emit createUserInterfaceComplete();}//-----------------------------------------------------------------------------// ctkWorkflowWidgetStep methods//-----------------------------------------------------------------------------ctkWorkflowWidgetStep::ctkWorkflowWidgetStep(QWidget* newParent) :  QWidget(newParent),  ctkWorkflowStep(new ctkWorkflowWidgetStepPrivate(*this), 0, QString()){  Q_D(ctkWorkflowWidgetStep);  d->hasShowUserInterfaceCommand = false;  d->hasCreateUserInterfaceCommand = false;  d->ButtonBoxHints = ctkWorkflowWidgetStep::NoHints;}//-----------------------------------------------------------------------------ctkWorkflowWidgetStep::ctkWorkflowWidgetStep(ctkWorkflow* newWorkflow,                                                             const QString& newId,                                                             QWidget* newParent) :  QWidget(newParent),  ctkWorkflowStep(new ctkWorkflowWidgetStepPrivate(*this), newWorkflow, newId){  Q_D(ctkWorkflowWidgetStep);  d->hasShowUserInterfaceCommand = false;  d->hasCreateUserInterfaceCommand = false;  d->ButtonBoxHints = ctkWorkflowWidgetStep::NoHints;}//-----------------------------------------------------------------------------ctkWorkflowWidgetStep::~ctkWorkflowWidgetStep(){}//-----------------------------------------------------------------------------CTK_GET_CPP(ctkWorkflowWidgetStep, bool, hasShowUserInterfaceCommand, hasShowUserInterfaceCommand);CTK_SET_CPP(ctkWorkflowWidgetStep, bool, setHasShowUserInterfaceCommand, hasShowUserInterfaceCommand);CTK_GET_CPP(ctkWorkflowWidgetStep, bool, hasCreateUserInterfaceCommand, hasCreateUserInterfaceCommand);CTK_SET_CPP(ctkWorkflowWidgetStep, bool, setHasCreateUserInterfaceCommand, hasCreateUserInterfaceCommand);CTK_GET_CPP(ctkWorkflowWidgetStep, QString, backButtonText, backButtonText);CTK_SET_CPP(ctkWorkflowWidgetStep, const QString&, setBackButtonText, backButtonText);CTK_GET_CPP(ctkWorkflowWidgetStep, QString, nextButtonText, nextButtonText);CTK_SET_CPP(ctkWorkflowWidgetStep, const QString&, setNextButtonText, nextButtonText);// CTK_GET_CPP(ctkWorkflowWidgetStep, QList<QString>, finishButtonTexts, finishButtonTexts);// CTK_SET_CPP(ctkWorkflowWidgetStep, QList<QString>, setFinishButtonTexts, finishButtonTexts);//CTK_GET_CPP(ctkWorkflowWidgetStep, bool, hasButtonBoxWidget, hasButtonBoxWidget);//CTK_SET_CPP(ctkWorkflowWidgetStep, bool, setHasButtonBoxWidget, hasButtonBoxWidget);CTK_GET_CPP(ctkWorkflowWidgetStep, QIcon, icon, icon);CTK_SET_CPP(ctkWorkflowWidgetStep, const QIcon&, setIcon, icon);//-----------------------------------------------------------------------------QWidget* ctkWorkflowWidgetStep::stepArea(){  return this;}//-----------------------------------------------------------------------------CTK_GET_CPP(ctkWorkflowWidgetStep, ctkWorkflowWidgetStep::ButtonBoxHints,            buttonBoxHints, ButtonBoxHints);CTK_SET_CPP(ctkWorkflowWidgetStep, ctkWorkflowWidgetStep::ButtonBoxHints,            setButtonBoxHints, ButtonBoxHints);//-----------------------------------------------------------------------------// void ctkWorkflowWidgetStep::setFinishButtonText(const QString& name)// {//   QList<QString> names;//   names << name;//   this->setFinishButtonTexts(names);// }// //-----------------------------------------------------------------------------// ctkWorkflowButtonBoxWidget* ctkWorkflowWidgetStep::buttonBoxWidget()// {//   Q_D(ctkWorkflowWidgetStep);//   if (!d->hasButtonBoxWidget)//     {//     return 0;//     }//   if (!d->buttonBoxWidget)//     {//     if (!this->workflow())//       {//       logger.error("buttonBoxWidget - Cannot create buttonBoxWidget without a workflow");//       return 0;//       }//     d->buttonBoxWidget = new ctkWorkflowButtonBoxWidget(this->workflow());//     }//   return d->buttonBoxWidget;// }//-----------------------------------------------------------------------------void ctkWorkflowWidgetStep::showUserInterface(){  Q_D(ctkWorkflowWidgetStep);  // use the user's showUserInterfaceCommand if given  if (d->hasShowUserInterfaceCommand)    {    this->invokeShowUserInterfaceCommand();    return;    }  // otherwise we provide an implementation here  logger.debug(QString("showUserInterface - showing %1").arg(this->name()));  // create the user interface if this is the first time we're showing this step  if (!d->created)    {    if (d->hasCreateUserInterfaceCommand)      {      this->invokeCreateUserInterfaceCommand();      }    else      {      this->createUserInterface();      }    d->created = true;    }  emit showUserInterfaceComplete();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStep::invokeShowUserInterfaceCommand()const{  Q_D(const ctkWorkflowWidgetStep);  d->invokeShowUserInterfaceCommandInternal();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStep::showUserInterfaceComplete()const{  Q_D(const ctkWorkflowWidgetStep);  d->showUserInterfaceCompleteInternal();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStep::invokeCreateUserInterfaceCommand()const{  Q_D(const ctkWorkflowWidgetStep);  d->invokeCreateUserInterfaceCommandInternal();}//-----------------------------------------------------------------------------void ctkWorkflowWidgetStep::createUserInterfaceComplete()const{  Q_D(const ctkWorkflowWidgetStep);  d->createUserInterfaceCompleteInternal();}
 |