#include "ymorpherewidget.h"

#include "ymfilterchildren.h"
#include <QDebug>
YMorphereWidget::YMorphereWidget(QWidget *parent)
    : QWidget(parent)
{
}

YMorphereWidget::~YMorphereWidget()
{
}

void YMorphereWidget::clearResult()
{
    m_mapResult.clear();
}

void YMorphereWidget::clearParam()
{

}

QString YMorphereWidget::getName()
{
    return m_strName;
}

void YMorphereWidget::Exec()
{
    clearResult();
    clearViewResult();
    clearView();

    m_pYAlgorithm = YAFactory::getInstance()->getYAlgorithm(convertToParam());
    m_pYAlgorithm->init();
    m_pYAlgorithm->setParam(convertToParam());

    //qDebug() << "EXEC: "<< convertToParam().value("Article");


    m_pYAlgorithm->Start();
    m_mapResult = m_pYAlgorithm->getResult();
    //qDebug() << m_mapResult.count();
    ViewResult();
}

void YMorphereWidget::SaveFile()
{

}


void YMorphereWidget::SaveFileSimple()
{

}

void YMorphereWidget::TestUpload()
{

}


void YMorphereWidget::D3View()
{

}


void YMorphereWidget::D3ViewTree()
{

}



void YMorphereWidget::D3ViewFile()
{

}


void YMorphereWidget::D3ViewTreeFile()
{

}


void YMorphereWidget::setParam(QString strJson)
{


}


void YMorphereWidget::Exec(int nTitleBody)
{
    clearResult();
    clearViewResult();
    clearView();
    QMap <QString, QString> mapParam = convertToParam();
    mapParam["TitleBody"] = QString::number(nTitleBody);

    m_pYAlgorithm = YAFactory::getInstance()->getYAlgorithm(mapParam);
    m_pYAlgorithm->init();
    m_pYAlgorithm->setParam(mapParam);
    m_pYAlgorithm->Start();
    m_mapResult = m_pYAlgorithm->getResult();
    //qDebug() << m_mapResult.count();
    ViewResult();
}

void YMorphereWidget::setTabWidget(QTabWidget *tabWidget)
{
    m_pTabWidget = tabWidget;
}
