All pastes #637060 Raw Edit

Unbenannt

public text v1 · immutable
#637060 ·published 2007-07-28 14:33 UTC
rendered paste body
#include "cMainWidget.h"

cMainWidget::cMainWidget( QWidget* parent ) : QWidget( parent )
{
	this->m_topLayout	=	new QGridLayout;

	this->m_Create		=	new QPushButton( QString("Erstellen") );

	this->m_tPic		=	new QLineEdit;
	this->m_tCodec		=	new QLineEdit( QString( "Xvid" ) );
	this->m_tTime		=	new QLineEdit;
	this->m_tSize		=	new QLineEdit;
	this->m_tDesc		=	new QTextEdit;
	this->m_tLinks		=	new QTextEdit;

	this->initLayout();
	this->initSignals();
}

void cMainWidget::initLayout( void )
{
	this->m_topLayout->addWidget( new QLabel( QString( "Bild" ) ), 0, 0 );
	this->m_topLayout->addWidget( new QLabel( QString( "Beschreibung\n\n" ) ), 1, 0 );
	this->m_topLayout->addWidget( new QLabel( QString( "Dauer" ) ), 3, 0 );
	this->m_topLayout->addWidget( new QLabel( QString( "Format" ) ), 4, 0 );
	this->m_topLayout->addWidget( new QLabel( QString( "Größe" ) ), 5, 0 );
	this->m_topLayout->addWidget( new QLabel( QString( "Links" ) ), 6, 0 );

	this->m_topLayout->addWidget( this->m_tPic, 0, 1 );
	this->m_topLayout->addWidget( this->m_tDesc, 1, 1 );
	this->m_topLayout->addWidget( this->m_tTime, 3, 1 );
	this->m_topLayout->addWidget( this->m_tCodec, 4, 1 );
	this->m_topLayout->addWidget( this->m_tSize, 5, 1 );
	this->m_topLayout->addWidget( this->m_tLinks, 6, 1 );
	this->m_topLayout->addWidget( this->m_Create, 7, 1 );

	this->m_topLayout->addWidget( new QLabel( QString( "Minuten" ) ), 3, 2 );
	this->m_topLayout->addWidget( new QLabel( QString( "MB" ) ), 5, 2 );

	this->m_tDesc->setMaximumHeight( 75 );
	this->m_tLinks->setMaximumHeight( 75 );
	
	setLayout( this->m_topLayout );
} 

void cMainWidget::initSignals( void )
{
	connect( this->m_Create, SIGNAL( clicked() ), this, SLOT( createThread() ) );
}

void cMainWidget::createThread( void )
{
	if(!this->checkWidgets())
	{
		QMessageBox::information( this, QString("Error"), QString("Du musst alle Felder ausfüllen!"), 0 );
		return;
	}

	this->createThreadCode();

	return;
}

bool cMainWidget::checkWidgets( void )
{
	if( this->m_tCodec->text().count() == 0 )
	{
		return false;
	}

	if( this->m_tPic->text().count() == 0 )
	{
		return false;
	}
	
	if( this->m_tCodec->text().count() == 0 )
	{
		return false;
	}

	if( this->m_tSize->text().count() == 0 )
	{
		return false;
	}

	if( this->m_tDesc->toPlainText().count() == 0 )
	{
		return false;
	}

	if( this->m_tLinks->toPlainText().count() == 0 )
	{
		return false;
	}

	return true;
}

void cMainWidget::createThreadCode( void )
{
	QStringList	splittedDownloads = this->m_tLinks->toPlainText().split( '\n', QString::SkipEmptyParts );
	QString		threadContent;

	threadContent.append( QString( "[img]%1[/img]\n" ).arg( this->m_tPic->text() ) );
	threadContent.append( QString("%1\n\n").arg( this->m_tDesc->toPlainText() ) );
	threadContent.append( QString( "%1%2 Minuten | %3%4 | %5%6 MB\n" ).arg( "[b]Dauer:[/b] " ).arg( this->m_tTime->text() ).arg( "[b]Format:[/b] ").arg( this->m_tCodec->text() ).arg("[b]Größe:[/b] ").arg( this->m_tSize->text() ) );

/* b]Download #1:[/b] [url href = "http://moviespot.kuba.to/download/f-d618b73b0cb1bdcd/rc_ichbineinfile.html"]Rapidshare.com[/url]*/

	for( int i=0; i<splittedDownloads.count(); i++ )
	{
		QRegExp rHost( ".*/\\d|\\w-.*/([\\w-]+)_.*" );
		QString	Host;

		rHost.indexIn( splittedDownloads[i] );

		if( rHost.cap(1) == QString("rc") )
		{
			Host = QString("Rapidshare.com");
		}
		else if( rHost.cap(1) == QString("filefactory-com") )
		{
			Host = QString("Filefactory.com");
		}
		else if( rHost.cap(1) == QString("moviespot-kuba-to") )
		{
			Host = QString("Uploaded.to");
		}
		else if( rHost.cap(1) == QString("nl") )
		{
			Host = QString("Netload.in");
		}

		threadContent.append( QString("[b]Download #%1:[/b] [url href=\"%2\"]%3[/url]\n").arg( i+1 ).arg( splittedDownloads[i] ).arg( Host ) );
	}

	QTextEdit* threadCode = new QTextEdit;
	threadCode->setPlainText( threadContent );
	threadCode->setGeometry( QRect( 500, 500, 500, 500 ) );
	threadCode->show();
}