#include "RasterWidgetMessageShow.h"
#include <stdio.h>
#include <iostream>
namespace RasterMessageShow {

	RasterWidgetMessageShow* RasterWidgetMessageShow::_instance = nullptr;

	RasterWidgetMessageShow::RasterWidgetMessageShow(QObject* parant):QObject(parant)
	{
		QObject::connect(this, SIGNAL(ShowMessage(QString)), this, SLOT(ShowMessageInfo(QString)));
	}

	RasterWidgetMessageShow::~RasterWidgetMessageShow()
	{
	}

	void RasterWidgetMessageShow::bandingTextBrowserMessage(QTextBrowser* intextBrowserMessage)
	{
		this->textBrowserMessage = intextBrowserMessage;
	}

	QTextBrowser* RasterWidgetMessageShow::getTextBrowserMessage()
	{
		return textBrowserMessage;
	}

	void RasterWidgetMessageShow::ShowMessageInfo(QString Message)
	{
		if (nullptr != this->textBrowserMessage) {
			this->textBrowserMessage->append(Message);
			this->textBrowserMessage->moveCursor(QTextCursor::MoveOperation::End);
			this->textBrowserMessage->repaint();
			std::cout << Message.toLocal8Bit().constData() <<  std::endl;
			
		}
		else {}
	}

	RasterWidgetMessageShow*  RasterWidgetMessageShow::getInstance(QObject* parant)
	{
		if (nullptr == RasterWidgetMessageShow::_instance) {
			RasterWidgetMessageShow::_instance = new RasterWidgetMessageShow(parant);
		}
		return RasterWidgetMessageShow::_instance;
	}



};