//-----------------------------
ConfigTaskPanelImpl::ConfigTaskPanelImpl(QWidget *p )
    : QWidget(p)
{

    setupUi(this);
    kcfg_ExpectedEstimate->setMinimumUnit( (Duration::Unit)KPlatoSettings::self()->minimumDurationUnit() );
    kcfg_ExpectedEstimate->setMaximumUnit( (Duration::Unit)KPlatoSettings::self()->maximumDurationUnit() );

#ifndef PLAN_KDEPIMLIBS_FOUND
    chooseLeader->hide();
#endif

    // FIXME
    // [Bug 311940] New: Plan crashes when typing a text in the filter textbox before the textbook is fully loaded when selecting a contact from the adressbook
    chooseLeader->hide();

    initDescription();

    connect(chooseLeader, SIGNAL(clicked()), SLOT(changeLeader()));
    
    connect( kcfg_ConstraintStartTime, SIGNAL(dateTimeChanged(QDateTime)), SLOT(startDateTimeChanged(QDateTime)) );
    
    connect( kcfg_ConstraintEndTime, SIGNAL(dateTimeChanged(QDateTime)), SLOT(endDateTimeChanged(QDateTime)) );

    // Hack to have an interface to kcfg wo adding a custom class for this
    kcfg_Unit->addItems( Duration::unitList( true ) );
    connect( kcfg_ExpectedEstimate, SIGNAL(unitChanged(int)), SLOT(unitChanged(int)) );
    kcfg_Unit->hide();
    connect( kcfg_Unit, SIGNAL(currentIndexChanged(int)), SLOT(currentUnitChanged(int)) );
}
//----------------------------------------------------------------------------
ctkDICOMQueryWidget::~ctkDICOMQueryWidget()
{
  Q_D(ctkDICOMQueryWidget);

  disconnect(d->NameSearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  disconnect(d->StudySearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  disconnect(d->SeriesSearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  disconnect(d->IdSearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  disconnect(d->DateRangeWidget, SIGNAL(endDateTimeChanged(QDateTime)), this, SLOT(startTimer()));
  disconnect(d->DateRangeWidget, SIGNAL(startDateTimeChanged(QDateTime)), this, SLOT(startTimer()));
  disconnect(d->ModalityWidget, SIGNAL(selectedModalitiesChanged(QStringList)), this, SLOT(startTimer()));

  disconnect(d->SearchTimer, SIGNAL(timeout()), this, SIGNAL(parameterChanged()));

  disconnect(d->NameSearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
  disconnect(d->StudySearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
  disconnect(d->SeriesSearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
  disconnect(d->IdSearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
}
//----------------------------------------------------------------------------
ctkDICOMQueryWidget::ctkDICOMQueryWidget(QWidget* _parent):Superclass(_parent), 
  d_ptr(new ctkDICOMQueryWidgetPrivate)
{
  Q_D(ctkDICOMQueryWidget);
  
  d->setupUi(this);

  d->NameSearch->setFocus(Qt::PopupFocusReason);

  connect(d->NameSearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  connect(d->StudySearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  connect(d->SeriesSearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  connect(d->IdSearch, SIGNAL(textChanged(QString)), this, SLOT(startTimer()));
  connect(d->DateRangeWidget, SIGNAL(endDateTimeChanged(QDateTime)), this, SLOT(startTimer()));
  connect(d->DateRangeWidget, SIGNAL(startDateTimeChanged(QDateTime)), this, SLOT(startTimer()));
  connect(d->ModalityWidget, SIGNAL(selectedModalitiesChanged(QStringList)), this, SLOT(startTimer()));

  connect(d->SearchTimer, SIGNAL(timeout()), this, SIGNAL(parameterChanged()));

  connect(d->NameSearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
  connect(d->StudySearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
  connect(d->SeriesSearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
  connect(d->IdSearch, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
}