/****************************************************************************
** Form implementation generated from reading ui file './codecconf.ui'
**
** Created: Thu Sep 14 13:08:18 2000
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "codecconf_p.h"

#include <qdial.h>
#include <qheader.h>
#include <qhbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlcdnumber.h>
#include <qlistbox.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>

class VideoCodecGroupBox: public QGroupBox
{
public:
    VideoCodecGroupBox(CodecConfigDialog* parent, const char* name)
	: QGroupBox(parent, name)
    {
	setTitle( tr( "Video codecs" ) );
	setColumnLayout(0, Qt::Vertical);

	QHBoxLayout* hl = new QHBoxLayout(this->layout());

	parent->_listCodecs = new QListBox( this, "_listCodecs" );
	parent->_listCodecs->insertItem( tr( "DivX ;-)" ) );

        hl->addWidget(parent->_listCodecs);
    }
};

class CodecAttrsGroupBox: public QGroupBox
{
public:
    CodecAttrsGroupBox(CodecConfigDialog* parent, const char* name)
	: QGroupBox(parent, name)
    {
	setTitle( tr( "Codec attributes" ) );
	setColumnLayout(0, Qt::Vertical);

	QHBoxLayout* hl = new QHBoxLayout(this->layout());
	parent->_tabAttr = new QListView( this, "listTabAttr" );
	parent->_tabAttr->addColumn( tr( "Attribute" ) );
	parent->_tabAttr->addColumn( tr( "Value" ) );

        hl->addWidget(parent->_tabAttr);

	QListViewItem * item = new QListViewItem( parent->_tabAttr, 0 );
	item->setText( 0, tr( "Item" ) );
	item->setText( 1, tr( "Subitem" ) );

	//_tabAttr->setGeometry( QRect( 170, 40, 157, 104 ) );
    }
};

class CodecQualityGroupBox: public QGroupBox
{
public:
    CodecQualityGroupBox(CodecConfigDialog* parent, const char* name)
	: QGroupBox(parent, name)
    {
	setTitle( tr( "Quality" ) );
	setColumnLayout(0, Qt::Horizontal);
        setMaximumHeight(100);
	QHBoxLayout* vl = new QHBoxLayout(this->layout());

	parent->_pQuality = new QDial( this, "dialQuality" );
	parent->_pQuality->setMaxValue( 100 );
	parent->_pQuality->setValue( 95 );

	vl->addWidget(parent->_pQuality);

	parent->LCDNumber1 = new QLCDNumber( this, "LCDNumber1" );
	parent->LCDNumber1->setFrameShadow( QLCDNumber::Raised );
	parent->LCDNumber1->setSegmentStyle( QLCDNumber::Flat );
	parent->LCDNumber1->setNumDigits( 3 );
	parent->LCDNumber1->setProperty( "intValue", 95 );

	vl->addWidget(parent->LCDNumber1);
    }
};

class CodecKeyFrameGroupBox: public QGroupBox
{
public:
    CodecKeyFrameGroupBox(CodecConfigDialog* parent, const char* name)
	: QGroupBox(parent, name)
    {
	setTitle( tr( "Key frame frequency" ) );
	setColumnLayout(0, Qt::Horizontal);
        setMaximumHeight(100);

	QHBoxLayout* vl = new QHBoxLayout(this->layout());

	parent->_pKeyframe = new QDial( this, "dialKeyframe" );
	parent->_pKeyframe->setMaxValue( 200 );
	parent->_pKeyframe->setValue( 75 );
	parent->_pKeyframe->setMinValue( 1 );

	vl->addWidget(parent->_pKeyframe);

	parent->LCDNumber2 = new QLCDNumber( this, "LCDNumber2" );
	parent->LCDNumber2->setSegmentStyle( QLCDNumber::Flat );
	parent->LCDNumber2->setNumDigits( 3 );
	parent->LCDNumber2->setProperty( "intValue", 75 );

	vl->addWidget(parent->LCDNumber2);
    }
};

/*
 *  Constructs a CodecConfigDialog which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  TRUE to construct a modal dialog.
 */
CodecConfigDialog::CodecConfigDialog( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
	setName( "CodecConfigDialog" );
    //resize( 341, 312 );
    setCaption( tr( "Configure video codec"  ) );

    QGridLayout* qgl = new QGridLayout(this);
    qgl->setMargin(5);
    qgl->setSpacing(10);

    qgl->addMultiCellWidget(new VideoCodecGroupBox(this, "vcodec"), 0, 1, 0, 0);
    qgl->setRowStretch(0, 1);
    qgl->addWidget(new CodecAttrsGroupBox(this, "cattrs"), 0, 1);

    QPushButton* _about = new QPushButton( this, "_about" );
    _about->setText( tr( "About video codec..." ) );
    qgl->addWidget(_about, 1, 1);

    qgl->addWidget(new CodecQualityGroupBox(this, "cquality"), 2, 0);
    qgl->addWidget(new CodecKeyFrameGroupBox(this, "ckeyframe"), 2, 1);

    QHBox* ok_cancel = new QHBox(this);
    QWidget* s = new QWidget( ok_cancel );
    ok_cancel->setStretchFactor( s, 1 );

    QPushButton* PushButton22 = new QPushButton( ok_cancel, "PushButton22" );
    PushButton22->setText( tr( "Ok"  ) );

    QPushButton* PushButton21 = new QPushButton( ok_cancel, "PushButton21" );
    PushButton21->setText( tr( "Cancel"  ) );

    qgl->addMultiCellWidget(ok_cancel, 3, 3, 0, 1);

    // signals and slots connections
    connect( PushButton22, SIGNAL( clicked() ), this, SLOT( accept() ) );
    connect( PushButton21, SIGNAL( clicked() ), this, SLOT( reject() ) );
    connect( _pKeyframe, SIGNAL( valueChanged(int) ), LCDNumber2, SLOT( display(int) ) );
    connect( _pQuality, SIGNAL( valueChanged(int) ), LCDNumber1, SLOT( display(int) ) );
    connect( _tabAttr, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( change_attr(QListViewItem*) ) );
    connect( _about, SIGNAL( clicked() ), this, SLOT( about_clicked() ) );
}

/*
 *  Destroys the object and frees any allocated resources
 */
CodecConfigDialog::~CodecConfigDialog()
{
    // no need to delete child widgets, Qt does it all for us
}

void CodecConfigDialog::change_attr(QListViewItem*)
{
    qWarning( "CodecConfigDialog::change_attr(QListViewItem*): Not implemented yet!" );
}

void CodecConfigDialog::about_clicked()
{
    qWarning( "CodecConfigDialog::about_clicked(): Not implemented yet!" );
}
