/****************************************************************************
** Form implementation generated from reading ui file 'tonewconnectionui.ui'
**
** Created: Tue Sep 18 08:21:29 2007
**      by: The User Interface Compiler ($Id: qt/main.cpp   3.3.8   edited Jan 11 14:47 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#include "tonewconnectionui.h"

#include <qvariant.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qspinbox.h>
#include <qbuttongroup.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include "toresultview.h"

/*
 *  Constructs a toNewConnectionUI as 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.
 */
toNewConnectionUI::toNewConnectionUI( QWidget* parent, const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
	setName( "toNewConnectionUI" );
    toNewConnectionUILayout = new QGridLayout( this, 1, 1, 11, 6, "toNewConnectionUILayout"); 

    CancelButton = new QPushButton( this, "CancelButton" );
    CancelButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, CancelButton->sizePolicy().hasHeightForWidth() ) );

    toNewConnectionUILayout->addWidget( CancelButton, 13, 3 );

    OkButton = new QPushButton( this, "OkButton" );
    OkButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, OkButton->sizePolicy().hasHeightForWidth() ) );
    OkButton->setDefault( TRUE );

    toNewConnectionUILayout->addWidget( OkButton, 13, 2 );
    Spacer1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    toNewConnectionUILayout->addMultiCell( Spacer1, 13, 13, 0, 1 );

    Previous = new toListView( this, "Previous" );
    Previous->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, Previous->sizePolicy().hasHeightForWidth() ) );
    Previous->setFocusPolicy( toListView::StrongFocus );

    toNewConnectionUILayout->addMultiCellWidget( Previous, 1, 12, 0, 0 );

    TextLabel2 = new QLabel( this, "TextLabel2" );
    TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) );

    toNewConnectionUILayout->addWidget( TextLabel2, 0, 0 );

    Password = new QLineEdit( this, "Password" );
    Password->setEchoMode( QLineEdit::Password );

    toNewConnectionUILayout->addMultiCellWidget( Password, 5, 5, 1, 3 );

    TextLabel1 = new QLabel( this, "TextLabel1" );
    TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) );

    toNewConnectionUILayout->addMultiCellWidget( TextLabel1, 2, 2, 1, 3 );

    TextLabel1_2 = new QLabel( this, "TextLabel1_2" );
    TextLabel1_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, 0, 0, TextLabel1_2->sizePolicy().hasHeightForWidth() ) );

    toNewConnectionUILayout->addMultiCellWidget( TextLabel1_2, 4, 4, 1, 3 );

    Username = new QLineEdit( this, "Username" );

    toNewConnectionUILayout->addMultiCellWidget( Username, 3, 3, 1, 3 );

    ProviderLabel = new QLabel( this, "ProviderLabel" );

    toNewConnectionUILayout->addMultiCellWidget( ProviderLabel, 0, 0, 1, 3 );

    Provider = new QComboBox( FALSE, this, "Provider" );

    toNewConnectionUILayout->addMultiCellWidget( Provider, 1, 1, 1, 3 );

    Database = new QComboBox( FALSE, this, "Database" );
    Database->setEditable( TRUE );
    Database->setAutoCompletion( TRUE );
    Database->setDuplicatesEnabled( FALSE );

    toNewConnectionUILayout->addMultiCellWidget( Database, 10, 10, 1, 3 );

    TextLabel3 = new QLabel( this, "TextLabel3" );

    toNewConnectionUILayout->addMultiCellWidget( TextLabel3, 9, 9, 1, 3 );

    Host = new QComboBox( FALSE, this, "Host" );
    Host->setEditable( TRUE );
    Host->setAutoCompletion( TRUE );
    Host->setDuplicatesEnabled( FALSE );

    toNewConnectionUILayout->addMultiCellWidget( Host, 7, 7, 1, 3 );

    HostLabel = new QLabel( this, "HostLabel" );

    toNewConnectionUILayout->addMultiCellWidget( HostLabel, 6, 6, 1, 3 );

    PortLabel = new QLabel( this, "PortLabel" );

    toNewConnectionUILayout->addMultiCellWidget( PortLabel, 8, 8, 1, 2 );

    Port = new QSpinBox( this, "Port" );
    Port->setMaxValue( 65535 );

    toNewConnectionUILayout->addWidget( Port, 8, 3 );

    OptionGroup = new QButtonGroup( this, "OptionGroup" );
    OptionGroup->setFocusPolicy( QButtonGroup::StrongFocus );

    toNewConnectionUILayout->addMultiCellWidget( OptionGroup, 11, 11, 1, 3 );
    Spacer3 = new QSpacerItem( 20, 30, QSizePolicy::Minimum, QSizePolicy::Expanding );
    toNewConnectionUILayout->addItem( Spacer3, 12, 1 );
    languageChange();
    resize( QSize(654, 424).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( OkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
    connect( CancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
    connect( Provider, SIGNAL( activated(int) ), this, SLOT( changeProvider() ) );
    connect( Host, SIGNAL( textChanged(const QString&) ), this, SLOT( changeHost() ) );

    // tab order
    setTabOrder( Provider, Username );
    setTabOrder( Username, Password );
    setTabOrder( Password, Host );
    setTabOrder( Host, Port );
    setTabOrder( Port, Database );
    setTabOrder( Database, OptionGroup );
    setTabOrder( OptionGroup, OkButton );
    setTabOrder( OkButton, CancelButton );
    setTabOrder( CancelButton, Previous );

    // buddies
    TextLabel2->setBuddy( Previous );
    TextLabel1->setBuddy( Username );
    TextLabel1_2->setBuddy( Password );
    ProviderLabel->setBuddy( Provider );
    TextLabel3->setBuddy( Database );
    HostLabel->setBuddy( Host );
    PortLabel->setBuddy( Host );
}

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

/*
 *  Sets the strings of the subwidgets using the current
 *  language.
 */
void toNewConnectionUI::languageChange()
{
    setCaption( tr( "New connection" ) );
    CancelButton->setText( tr( "Cancel" ) );
    OkButton->setText( tr( "&Ok" ) );
    TextLabel2->setText( tr( "&Previous connections" ) );
    QToolTip::add( TextLabel2, tr( "A list of previous connections. Select to bring over to the right." ) );
    TextLabel1->setText( tr( "&Username" ) );
    QToolTip::add( TextLabel1, tr( "Username to connect with" ) );
    TextLabel1_2->setText( tr( "&Password" ) );
    QToolTip::add( TextLabel1_2, tr( "Password to connect with." ) );
    ProviderLabel->setText( tr( "Connection provider" ) );
    TextLabel3->setText( tr( "&Database" ) );
    QToolTip::add( TextLabel3, tr( "Select the database ID to connect to." ) );
    HostLabel->setText( tr( "&Host" ) );
    QToolTip::add( HostLabel, tr( "Select the database ID to connect to." ) );
    PortLabel->setText( tr( "&Port" ) );
    QToolTip::add( PortLabel, tr( "Select the database ID to connect to." ) );
    OptionGroup->setTitle( tr( "Options" ) );
}

void toNewConnectionUI::changeHost()
{
    qWarning( "toNewConnectionUI::changeHost(): Not implemented yet" );
}

void toNewConnectionUI::changeProvider()
{
    qWarning( "toNewConnectionUI::changeProvider(): Not implemented yet" );
}

void toNewConnectionUI::historySelection()
{
    qWarning( "toNewConnectionUI::historySelection(): Not implemented yet" );
}

void toNewConnectionUI::historyConnect()
{
    qWarning( "toNewConnectionUI::historyConnect(): Not implemented yet" );
}

