#include <kdialog.h>
#include <klocale.h>

#include "queryfieldmetadata_base.h"

#include <qvariant.h>
#include <kcombobox.h>
#include <klineedit.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <kguiitem.h>
#include <kapplication.h>
#include <kiconloader.h>


/*
 *  Constructs a QueryMetaDataBase as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 */
QueryFieldMetaDataBase::QueryFieldMetaDataBase( QWidget* parent, const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    supportedMimeTypeCombo = new KComboBox( FALSE, this, "supportedMimeTypeCombo" );
//     supportedMimeTypeCombo->setEditable(TRUE);
//     supportedMimeTypeCombo->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, supportedMimeTypeCombo->sizePolicy().hasHeightForWidth() ) );
    supportedMimeTypeCombo->setMinimumSize( QSize( 200, 0 ) );
//     supportedMimeTypeCombo->setMaximumSize( QSize( 200, 32767 ) );
    supportedMimeTypeCombo->setAutoCompletion( FALSE );

    supportedKeys = new KComboBox( FALSE, this, "supportedKeys" );
//     supportedKeys->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, supportedKeys->sizePolicy().hasHeightForWidth() ) );
    supportedKeys->setMinimumSize( QSize( 170, 0 ) );
//     supportedKeys->setMaximumSize( QSize( 200, 32767 ) );
    query = new KLineEdit( this, "query" );
    
    reloadMetaData = new KPushButton(KGuiItem(
		    "",
    "reload",
    "Reload metadata",
    "Reload metadata"),
    this,"reload");
    reloadMetaData->setToggleButton( FALSE );
    reloadMetaData->setFlat( TRUE );
    reloadMetaData->setSizePolicy(
		    QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding,1,1,TRUE)
				);
    
//     query->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 2, 0, query->sizePolicy().hasHeightForWidth() ) );
//     query->setMaximumSize( QSize( 120, 32767 ) );
    
    
    languageChange();
//     resize( QSize(492, 40).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );
    layoutA = new QHBoxLayout(this);
    layoutA->addWidget(reloadMetaData, 1, 0);
    layoutA->addWidget(supportedMimeTypeCombo , 2, 0);
    layoutA->addWidget(supportedKeys, 2, 0);
    layoutA->addWidget(query, 1, 0);
    
}

void QueryFieldMetaDataBase::languageChange()
{
    setCaption( tr2i18n( "Form1" ) );
    supportedMimeTypeCombo->clear();
    supportedMimeTypeCombo->insertItem( tr2i18n( "Any type" ) );
    
    //HACK: makes those fields appear first
    supportedMimeTypeCombo->insertItem(
		    	kapp->iconLoader()->loadIcon( "sound", KIcon::Small ),
			tr2i18n( "All sounds" )
				      );
    supportedMimeTypeCombo->insertItem(
		    kapp->iconLoader()->loadIcon( "image", KIcon::Small ),
    tr2i18n( "All images" )
				      );
    supportedMimeTypeCombo->insertItem(
		    kapp->iconLoader()->loadIcon( "video", KIcon::Small ),
    tr2i18n( "All video" )
				      );
    supportedKeys->clear();
    supportedKeys->insertItem( tr2i18n( "Any field" ) );
}

#include "queryfieldmetadata_base.moc"
