/***************************************************************************
                          myskydlg.cpp  -  description
                             -------------------
    begin                : Die Feb 11 2003
    copyright            : (C) 2003 by Harald Krippel
    email                : neuro.harald@surfeu.at
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "myskydlg.h"

#include <qvariant.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
 
MySkyEditDlg::MySkyEditDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : SkyEditDlg( parent, name, modal, fl )
{
    point = NULL;
}

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

void MySkyEditDlg::slotGetData()
{
    if(point != NULL)
    {
      slotGetData(point);
    }
}

void MySkyEditDlg::slotGetData(FolderListItem *i)
{
    point=i;

    text->setText(i->text(0));
    on->setChecked(i->GetValue("on",i).toInt());

    sunroth->setText(i->GetValue("sunroth",i));
    sunrotv->setText(i->GetValue("sunrotv",i));
    
    moonroth->setText(i->GetValue("moonroth",i));
    moonrotv->setText(i->GetValue("moonrotv",i));

    cl1on->setChecked(i->GetValue("cl1on",i).toInt());
    cl2on->setChecked(i->GetValue("cl2on",i).toInt());
    cl3on->setChecked(i->GetValue("cl3on",i).toInt());

    cl1h->setText(i->GetValue("cl1h",i));
    cl2h->setText(i->GetValue("cl2h",i));
    cl3h->setText(i->GetValue("cl3h",i));

    cl1s->setText(i->GetValue("cl1s",i));
    cl2s->setText(i->GetValue("cl2s",i));
    cl3s->setText(i->GetValue("cl3s",i));

    cl1d->setText(i->GetValue("cl1d",i));
    cl2d->setText(i->GetValue("cl2d",i));
    cl3d->setText(i->GetValue("cl3d",i));

    qWarning( "MySkyEditDlg::slotGetData(): Geht !" );
}

void MySkyEditDlg::slotEditData()
{
    point->setText(0,text->text());

    point->SetValue("on", on->isChecked() ? "1" : "0");

    point->SetValue("sunroth",sunroth->text());
    point->SetValue("sunrotv",sunrotv->text());
    
    point->SetValue("moonroth",moonroth->text());
    point->SetValue("moonrotv",moonrotv->text());

    point->SetValue("cl1on", cl1on->isChecked() ? "1" : "0");
    point->SetValue("cl2on", cl2on->isChecked() ? "1" : "0");
    point->SetValue("cl3on", cl3on->isChecked() ? "1" : "0");

    point->SetValue("cl1h",cl1h->text());
    point->SetValue("cl2h",cl2h->text());
    point->SetValue("cl3h",cl3h->text());

    point->SetValue("cl1s",cl1s->text());
    point->SetValue("cl2s",cl2s->text());
    point->SetValue("cl3s",cl3s->text());

    point->SetValue("cl1d",cl1d->text());
    point->SetValue("cl2d",cl2d->text());
    point->SetValue("cl3d",cl3d->text());

    point->updategl();

    qWarning( "MySkyEditDlg::slotEditData(): Geht !" );
}

