/***************************************************************************
                          parseroptions.cpp  -  description
                             -------------------
    begin                : Fri Aug 23 2002
    copyright            : (C) 2002 by Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; version 2 of the License.               *
 *                                                                         *
 ***************************************************************************/

#include "parseroptions.h"
#include "parseroptions.moc"
#include <tqcombobox.h>
#include <tqspinbox.h>

#include <tdelocale.h>
#include <tdeconfig.h>

/*
 *  Constructs a ParserOptions which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'
 */
ParserOptions::ParserOptions( TDEConfig *a_config, TQWidget* parent,  const char* name )
    : ParserOptionsUI( parent, name )
{
    config = a_config;
    config->setGroup("Parser options");

    TQString handleLBM = config->readEntry("LBM", i18n("Find Tag & Open Tree"));
    TQString handleMBM = config->readEntry("MBM", i18n("Nothing"));
    TQString handleRBM = config->readEntry("RBM", i18n("Popup Menu"));
    TQString handleDoubleClick = config->readEntry("Double click", i18n("Select Tag Area"));


    if ( !name )
      setName( "ParserOptions" );

    if ( handleLBM == i18n("Find Tag & Open Tree") )
    {
      comboLBM->setCurrentItem(1);
    }
    else
    {
      comboLBM->setCurrentItem(0);
    }

    if ( handleMBM == i18n("Find Tag & Open Tree") ) comboMBM->setCurrentItem(0);
    if ( handleMBM == i18n("Find Tag") ) comboMBM->setCurrentItem(1);
    if ( handleMBM == i18n("Go to End of Tag") ) comboMBM->setCurrentItem(2);
    if ( handleMBM == i18n("Select Tag Area") ) comboMBM->setCurrentItem(3);
    if ( handleMBM == i18n("Nothing")) comboMBM->setCurrentItem(4);

    if ( handleDoubleClick == i18n("Select Tag Area") )
    {
      comboDoubleClick->setCurrentItem(0);
    }
    else
    {
      comboDoubleClick->setCurrentItem(1);
    }
}

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


void ParserOptions::updateConfig()
{

    config->setGroup("Parser options");

    config->writeEntry("MBM",comboMBM->currentText());
    config->writeEntry("LBM",comboLBM->currentText());
    config->writeEntry("RBM",comboRBM->currentText());
    config->writeEntry("Double click",comboDoubleClick->currentText());
}
