#include "addanswerwidget.h"

AddAnswerWidget::AddAnswerWidget( QWidget *parent ) : QWidget( parent )
{
  setupUi( this );

  connect( cbAnswerTrue, SIGNAL( clicked( bool ) ), this, SLOT( showExplanationMLE( bool ) ) );
  showExplanationMLE( false );
}

QString AddAnswerWidget::getDEAnswerText( void )
{
  return mleAnswer->getDEText();
}

QString AddAnswerWidget::getENAnswerText( void )
{
  return mleAnswer->getENText();
}

QString AddAnswerWidget::getEEAnswerText( void )
{
  return mleAnswer->getEEText();
}

QString AddAnswerWidget::getDEExplanationText( void )
{
  return mleExplanation->getDEText();
}

QString AddAnswerWidget::getENExplanationText( void )
{
  return mleExplanation->getENText();
}

QString AddAnswerWidget::getEEExplanationText( void )
{
  return mleExplanation->getEEText();
}

bool AddAnswerWidget::isAnswerTrue( void )
{
  return cbAnswerTrue->isChecked();
}

bool AddAnswerWidget::isSomeoneEmpty( void )
{
  if( mleAnswer->isSomeoneEmpty() || ( isAnswerTrue() && mleExplanation->isSomeoneEmpty() ) )
    return true;
  return false;
}

void AddAnswerWidget::reset( void )
{
  mleAnswer->clearEdits();
  mleExplanation->clearEdits();
  cbAnswerTrue->setChecked( false );
}

void AddAnswerWidget::showExplanationMLE( bool state )
{
  if( state )
  {
    tlExplanation->show();
    mleExplanation->show();
  }
  else
  {
    tlExplanation->hide();
    mleExplanation->hide();
  }
}
