#include <kdialog.h>
#include <tdelocale.h>

/****************************************************************************
** Form implementation generated from reading ui file 'torrentcreatordlgbase.ui'
**
** Created by: The TQt user interface compiler (TQt 3.5.0)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#include "torrentcreatordlgbase.h"

#include <ntqvariant.h>
#include <kcombobox.h>
#include <keditlistbox.h>
#include <klineedit.h>
#include <knuminput.h>
#include <kpushbutton.h>
#include <kurlrequester.h>
#include <tdelistview.h>
#include <ntqpushbutton.h>
#include <ntqlabel.h>
#include <ntqgroupbox.h>
#include <ntqcheckbox.h>
#include <ntqlayout.h>
#include <ntqtooltip.h>
#include <ntqwhatsthis.h>

/*
 *  Constructs a TorrentCreatorDlgBase as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 *  The qdialog will by default be modeless, unless you set 'modal' to
 *  true to construct a modal qdialog.
 */
TorrentCreatorDlgBase::TorrentCreatorDlgBase( TQWidget* parent, const char* name, bool modal, WFlags fl )
    : TQDialog( parent, name, modal, fl )
{
    if ( !name )
	setName( "TorrentCreatorDlgBase" );
    setSizeGripEnabled( true );
    TorrentCreatorDlgBaseLayout = new TQGridLayout( this, 1, 1, 11, 6, "TorrentCreatorDlgBaseLayout"); 

    layout2 = new TQVBoxLayout( 0, 0, 6, "layout2"); 

    textLabel1 = new TQLabel( this, "textLabel1" );
    layout2->addWidget( textLabel1 );

    m_file_or_dir = new KURLRequester( this, "m_file_or_dir" );
    layout2->addWidget( m_file_or_dir );

    TorrentCreatorDlgBaseLayout->addLayout( layout2, 0, 0 );

    m_label1 = new TQLabel( this, "m_label1" );

    TorrentCreatorDlgBaseLayout->addWidget( m_label1, 2, 0 );

    groupBox1 = new TQGroupBox( this, "groupBox1" );
    groupBox1->setColumnLayout(0, TQt::Vertical );
    groupBox1->layout()->setSpacing( 6 );
    groupBox1->layout()->setMargin( 11 );
    groupBox1Layout = new TQGridLayout( groupBox1->layout() );
    groupBox1Layout->setAlignment( TQt::AlignTop );

    layout7 = new TQHBoxLayout( 0, 0, 6, "layout7"); 

    textLabel2 = new TQLabel( groupBox1, "textLabel2" );
    layout7->addWidget( textLabel2 );

    m_chunk_size = new KComboBox( false, groupBox1, "m_chunk_size" );
    layout7->addWidget( m_chunk_size );

    textLabel3 = new TQLabel( groupBox1, "textLabel3" );
    layout7->addWidget( textLabel3 );
    spacer2 = new TQSpacerItem( 21, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    layout7->addItem( spacer2 );

    groupBox1Layout->addLayout( layout7, 0, 0 );

    m_start_seeding = new TQCheckBox( groupBox1, "m_start_seeding" );
    m_start_seeding->setChecked( true );

    groupBox1Layout->addWidget( m_start_seeding, 1, 0 );

    m_decentralized = new TQCheckBox( groupBox1, "m_decentralized" );

    groupBox1Layout->addWidget( m_decentralized, 3, 0 );

    m_private = new TQCheckBox( groupBox1, "m_private" );

    groupBox1Layout->addWidget( m_private, 2, 0 );

    TorrentCreatorDlgBaseLayout->addWidget( groupBox1, 1, 0 );

    layout9 = new TQHBoxLayout( 0, 0, 6, "layout9"); 

    textLabel2_2 = new TQLabel( this, "textLabel2_2" );
    layout9->addWidget( textLabel2_2 );

    m_comments = new KLineEdit( this, "m_comments" );
    layout9->addWidget( m_comments );

    TorrentCreatorDlgBaseLayout->addLayout( layout9, 5, 0 );

    Layout1 = new TQHBoxLayout( 0, 0, 6, "Layout1"); 
    Horizontal_Spacing2 = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    Layout1->addItem( Horizontal_Spacing2 );

    m_create_btn = new TQPushButton( this, "m_create_btn" );
    m_create_btn->setAutoDefault( true );
    m_create_btn->setDefault( true );
    Layout1->addWidget( m_create_btn );

    m_cancel_btn = new TQPushButton( this, "m_cancel_btn" );
    m_cancel_btn->setAutoDefault( true );
    Layout1->addWidget( m_cancel_btn );

    TorrentCreatorDlgBaseLayout->addLayout( Layout1, 6, 0 );

    m_trackers = new KEditListBox( this, "m_trackers" );

    TorrentCreatorDlgBaseLayout->addWidget( m_trackers, 3, 0 );

    m_nodes = new TQGroupBox( this, "m_nodes" );
    m_nodes->setColumnLayout(0, TQt::Vertical );
    m_nodes->layout()->setSpacing( 6 );
    m_nodes->layout()->setMargin( 11 );
    m_nodesLayout = new TQGridLayout( m_nodes->layout() );
    m_nodesLayout->setAlignment( TQt::AlignTop );

    btnRemoveNode = new KPushButton( m_nodes, "btnRemoveNode" );
    btnRemoveNode->setEnabled( false );
    btnRemoveNode->setProperty( "stdItem", 28 );

    m_nodesLayout->addMultiCellWidget( btnRemoveNode, 2, 2, 1, 2 );

    btnAddNode = new KPushButton( m_nodes, "btnAddNode" );
    btnAddNode->setEnabled( false );
    btnAddNode->setProperty( "stdItem", 27 );

    m_nodesLayout->addMultiCellWidget( btnAddNode, 1, 1, 1, 2 );

    layout9_2 = new TQHBoxLayout( 0, 0, 6, "layout9_2"); 

    textLabel1_2 = new TQLabel( m_nodes, "textLabel1_2" );
    layout9_2->addWidget( textLabel1_2 );

    m_node = new KLineEdit( m_nodes, "m_node" );
    layout9_2->addWidget( m_node );

    textLabel1_2_2 = new TQLabel( m_nodes, "textLabel1_2_2" );
    layout9_2->addWidget( textLabel1_2_2 );

    m_port = new KIntNumInput( m_nodes, "m_port" );
    m_port->setValue( 6882 );
    m_port->setMinValue( 0 );
    m_port->setMaxValue( 65535 );
    layout9_2->addWidget( m_port );

    m_nodesLayout->addLayout( layout9_2, 0, 0 );
    spacer6 = new TQSpacerItem( 40, 20, TQSizePolicy::Maximum, TQSizePolicy::Minimum );
    m_nodesLayout->addItem( spacer6, 0, 1 );

    m_nodeList = new TDEListView( m_nodes, "m_nodeList" );
    m_nodeList->addColumn( tr2i18n( "IP or hostname" ) );
    m_nodeList->addColumn( tr2i18n( "Port" ) );
    m_nodeList->setAllColumnsShowFocus( true );
    m_nodeList->setResizeMode( TDEListView::AllColumns );

    m_nodesLayout->addMultiCellWidget( m_nodeList, 1, 3, 0, 0 );
    spacer5 = new TQSpacerItem( 20, 40, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
    m_nodesLayout->addItem( spacer5, 3, 2 );

    textLabel1_3 = new TQLabel( m_nodes, "textLabel1_3" );
    textLabel1_3->setAlignment( int( TQLabel::WordBreak | TQLabel::AlignVCenter ) );

    m_nodesLayout->addMultiCellWidget( textLabel1_3, 4, 4, 0, 2 );

    TorrentCreatorDlgBaseLayout->addWidget( m_nodes, 4, 0 );
    languageChange();
    resize( TQSize(503, 669).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( m_private, TQ_SIGNAL( toggled(bool) ), m_decentralized, TQ_SLOT( setDisabled(bool) ) );
    connect( m_decentralized, TQ_SIGNAL( toggled(bool) ), m_private, TQ_SLOT( setDisabled(bool) ) );
    connect( m_decentralized, TQ_SIGNAL( toggled(bool) ), m_trackers, TQ_SLOT( setHidden(bool) ) );
    connect( m_decentralized, TQ_SIGNAL( toggled(bool) ), m_nodes, TQ_SLOT( setShown(bool) ) );
    connect( btnRemoveNode, TQ_SIGNAL( clicked() ), this, TQ_SLOT( btnRemoveNode_clicked() ) );
    connect( btnAddNode, TQ_SIGNAL( clicked() ), this, TQ_SLOT( btnAddNode_clicked() ) );
    connect( m_node, TQ_SIGNAL( textChanged(const TQString&) ), this, TQ_SLOT( m_node_textChanged(const TQString&) ) );
    connect( m_nodeList, TQ_SIGNAL( selectionChanged(TQListViewItem*) ), this, TQ_SLOT( m_nodeList_selectionChanged(TQListViewItem*) ) );

    // tab order
    setTabOrder( m_file_or_dir, m_chunk_size );
    setTabOrder( m_chunk_size, m_start_seeding );
    setTabOrder( m_start_seeding, m_private );
    setTabOrder( m_private, m_decentralized );
    setTabOrder( m_decentralized, m_node );
    setTabOrder( m_node, m_port );
    setTabOrder( m_port, btnAddNode );
    setTabOrder( btnAddNode, btnRemoveNode );
    setTabOrder( btnRemoveNode, m_comments );
    setTabOrder( m_comments, m_create_btn );
    setTabOrder( m_create_btn, m_cancel_btn );
}

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

/*
 *  Sets the strings of the subwidgets using the current
 *  language.
 */
void TorrentCreatorDlgBase::languageChange()
{
    setCaption( tr2i18n( "Create Torrent" ) );
    textLabel1->setText( tr2i18n( "The file or folder of which you want to create a torrent:" ) );
    m_label1->setText( tr2i18n( "You must add at least one tracker or node." ) );
    groupBox1->setTitle( tr2i18n( "File Options" ) );
    textLabel2->setText( tr2i18n( "Size of each chunk:" ) );
    m_chunk_size->clear();
    m_chunk_size->insertItem( tr2i18n( "32" ) );
    m_chunk_size->insertItem( tr2i18n( "64" ) );
    m_chunk_size->insertItem( tr2i18n( "128" ) );
    m_chunk_size->insertItem( tr2i18n( "256" ) );
    m_chunk_size->insertItem( tr2i18n( "512" ) );
    m_chunk_size->insertItem( tr2i18n( "1024" ) );
    m_chunk_size->insertItem( tr2i18n( "2048" ) );
    m_chunk_size->insertItem( tr2i18n( "4096" ) );
    m_chunk_size->insertItem( tr2i18n( "8192" ) );
    textLabel3->setText( tr2i18n( "KB" ) );
    m_start_seeding->setText( tr2i18n( "Start seedin&g the torrent" ) );
    m_decentralized->setText( tr2i18n( "Decentrali&zed (DHT only)" ) );
    m_private->setText( tr2i18n( "Private torrent (DHT not allowed)" ) );
    textLabel2_2->setText( tr2i18n( "Comments:" ) );
    m_create_btn->setText( tr2i18n( "&Create" ) );
    m_cancel_btn->setText( tr2i18n( "Ca&ncel" ) );
    m_trackers->setTitle( tr2i18n( "Trackers" ) );
    m_nodes->setTitle( tr2i18n( "DHT nodes" ) );
    btnRemoveNode->setText( tr2i18n( "Remove" ) );
    btnAddNode->setText( tr2i18n( "Add" ) );
    textLabel1_2->setText( tr2i18n( "Node:" ) );
    textLabel1_2_2->setText( tr2i18n( "Port:" ) );
    m_nodeList->header()->setLabel( 0, tr2i18n( "IP or hostname" ) );
    m_nodeList->header()->setLabel( 1, tr2i18n( "Port" ) );
    textLabel1_3->setText( tr2i18n( "NOTE: Some known good DHT nodes are already inserted. You should probably insert your own IP address and port too if you plan to seed this torrent." ) );
}

void TorrentCreatorDlgBase::btnRemoveNode_clicked()
{
    tqWarning( "TorrentCreatorDlgBase::btnRemoveNode_clicked(): Not implemented yet" );
}

void TorrentCreatorDlgBase::btnAddNode_clicked()
{
    tqWarning( "TorrentCreatorDlgBase::btnAddNode_clicked(): Not implemented yet" );
}

void TorrentCreatorDlgBase::m_node_textChanged(const TQString&)
{
    tqWarning( "TorrentCreatorDlgBase::m_node_textChanged(const TQString&): Not implemented yet" );
}

void TorrentCreatorDlgBase::m_nodeList_selectionChanged(TQListViewItem*)
{
    tqWarning( "TorrentCreatorDlgBase::m_nodeList_selectionChanged(TQListViewItem*): Not implemented yet" );
}

/****************************************************************************
** TorrentCreatorDlgBase meta object code from reading C++ file 'torrentcreatordlgbase.h'
**
** Created by: The TQt Meta Object Compiler version 26 (TQt 3.5.0)
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#undef TQT_NO_COMPAT
#include "torrentcreatordlgbase.h"
#include <ntqmetaobject.h>
#include <ntqapplication.h>

#include <private/qucomextra_p.h>
#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26)
#error "This file was generated using the moc from 3.5.0. It"
#error "cannot be used with the include files from this version of TQt."
#error "(The moc has changed too much.)"
#endif

const char *TorrentCreatorDlgBase::className() const
{
    return "TorrentCreatorDlgBase";
}

TQMetaObject *TorrentCreatorDlgBase::metaObj = 0;
static TQMetaObjectCleanUp cleanUp_TorrentCreatorDlgBase( "TorrentCreatorDlgBase", &TorrentCreatorDlgBase::staticMetaObject );

#ifndef TQT_NO_TRANSLATION
TQString TorrentCreatorDlgBase::tr( const char *s, const char *c )
{
    if ( tqApp )
	return tqApp->translate( "TorrentCreatorDlgBase", s, c, TQApplication::DefaultCodec );
    else
	return TQString::fromLatin1( s );
}
#ifndef TQT_NO_TRANSLATION_UTF8
TQString TorrentCreatorDlgBase::trUtf8( const char *s, const char *c )
{
    if ( tqApp )
	return tqApp->translate( "TorrentCreatorDlgBase", s, c, TQApplication::UnicodeUTF8 );
    else
	return TQString::fromUtf8( s );
}
#endif // TQT_NO_TRANSLATION_UTF8

#endif // TQT_NO_TRANSLATION

TQMetaObject* TorrentCreatorDlgBase::staticMetaObject()
{
    if ( metaObj ) {
	return metaObj;
}
#ifdef TQT_THREAD_SUPPORT
    if (tqt_sharedMetaObjectMutex) tqt_sharedMetaObjectMutex->lock();
    if ( metaObj ) {
	if (tqt_sharedMetaObjectMutex) tqt_sharedMetaObjectMutex->unlock();
	return metaObj;
    }
#endif // TQT_THREAD_SUPPORT
    TQMetaObject* parentObject = TQDialog::staticMetaObject();
    static const TQUMethod slot_0 = {"btnRemoveNode_clicked", 0, 0 };
    static const TQUMethod slot_1 = {"btnAddNode_clicked", 0, 0 };
    static const TQUParameter param_slot_2[] = {
	{ 0, &static_QUType_TQString, 0, TQUParameter::In }
    };
    static const TQUMethod slot_2 = {"m_node_textChanged", 1, param_slot_2 };
    static const TQUParameter param_slot_3[] = {
	{ 0, &static_QUType_ptr, "TQListViewItem", TQUParameter::In }
    };
    static const TQUMethod slot_3 = {"m_nodeList_selectionChanged", 1, param_slot_3 };
    static const TQUMethod slot_4 = {"languageChange", 0, 0 };
    static const TQMetaData slot_tbl[] = {
	{ "btnRemoveNode_clicked()", &slot_0, TQMetaData::Public },
	{ "btnAddNode_clicked()", &slot_1, TQMetaData::Public },
	{ "m_node_textChanged(const TQString&)", &slot_2, TQMetaData::Public },
	{ "m_nodeList_selectionChanged(TQListViewItem*)", &slot_3, TQMetaData::Public },
	{ "languageChange()", &slot_4, TQMetaData::Protected }
    };
    metaObj = TQMetaObject::new_metaobject(
	"TorrentCreatorDlgBase", parentObject,
	slot_tbl, 5,
	0, 0,
#ifndef TQT_NO_PROPERTIES
	0, 0,
	0, 0,
#endif // TQT_NO_PROPERTIES
	0, 0 );
    cleanUp_TorrentCreatorDlgBase.setMetaObject( metaObj );
#ifdef TQT_THREAD_SUPPORT
    if (tqt_sharedMetaObjectMutex) tqt_sharedMetaObjectMutex->unlock();
#endif // TQT_THREAD_SUPPORT
    return metaObj;
}

void* TorrentCreatorDlgBase::tqt_cast( const char* clname )
{
    if ( !qstrcmp( clname, "TorrentCreatorDlgBase" ) )
	return this;
    return TQDialog::tqt_cast( clname );
}

bool TorrentCreatorDlgBase::tqt_invoke( int _id, TQUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: btnRemoveNode_clicked(); break;
    case 1: btnAddNode_clicked(); break;
    case 2: m_node_textChanged((const TQString&)static_QUType_TQString.get(_o+1)); break;
    case 3: m_nodeList_selectionChanged((TQListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 4: languageChange(); break;
    default:
	return TQDialog::tqt_invoke( _id, _o );
    }
    return true;
}

bool TorrentCreatorDlgBase::tqt_emit( int _id, TQUObject* _o )
{
    return TQDialog::tqt_emit(_id,_o);
}
#ifndef TQT_NO_PROPERTIES

bool TorrentCreatorDlgBase::tqt_property( int id, int f, TQVariant* v)
{
    return TQDialog::tqt_property( id, f, v);
}

bool TorrentCreatorDlgBase::tqt_static_property( TQObject* , int , int , TQVariant* ){ return false; }
#endif // TQT_NO_PROPERTIES
