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

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkQTextEditIODevice.h
	Version:		$Revision: 1817 $
	Date:			$Date: 2011-09-30 16:52:28 +0200 (Fri, 30 Sep 2011) $

	Copyright (c) 2010-2011
	Pattern Recognition Lab, 
    University Erlangen-Nuremberg, Germany
    All rights reserved.

	This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
	See RITKCopyright.txt for more information.

	http://www5.informatik.uni-erlangen.de/research/software/ritk

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

#ifndef QTEXTEDITIODEVICE_H__
#define QTEXTEDITIODEVICE_H__


#include "ritkCore.h"

#include <QIODevice>
#include <QTextEdit>
#include <QPointer>

namespace ritk
{

/// Based on http://stackoverflow.com/questions/2350940/streaming-to-qtextedit-via-qtextstream
class CORE_EXPORT QTextEditIODevice : public QIODevice 
{
    Q_OBJECT

public:
	/// Constructor
    QTextEditIODevice(QTextEdit *TextEdit, QObject *Parent);
	/// Destructor
	~QTextEditIODevice();

protected:
	/**	@name Read/write data */
	//@{
	qint64 readData(char *data, qint64 maxSize);
	qint64 writeData(const char *data, qint64 maxSize);
	//@}

private:
	/// Purposely not implemented
	QTextEditIODevice();

private:
	/// The text edit where we put the output
    QPointer<QTextEdit> m_QTextEdit;
};

} // end namespace ritk

#endif // QTEXTEDITIODEVICE_H__
