Subversion Repositories public

Rev

Rev 283 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/***************************************************************************
 *   Copyright (C) 2007, 2008 by Andreas Theofilu                          *
 *   andreas@theosys.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 version 3 of the License.                *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <ksimpleconfig.h>
#include <knuminput.h>
#include <kcombobox.h>
#include <kurlrequester.h>
#include <klineedit.h>
#include <qdir.h>
#include <qcheckbox.h>
#include "wmsbase.h"
#include "wmsselectorwidget.h"

wmsbase::wmsbase ( QWidget* parent, Qt::WFlags fl )
                : QDialog(parent, fl), Ui::wmsWidgetBase ()
{
QDir dir = QDir::home();
QString path = dir.absolutePath();

        setupUi (this);
        // Load the config parameters
        KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
        KConfigGroup ic (&cfg, "WMS");
        edServerURL->setUrl (ic.readEntry("ServerURL", "http://onearth.jpl.nasa.gov/wms.cgi"));
        edLayer->setText (ic.readEntry("Layer", QString("modis,global_mosaic")));
        cbSRS->setCurrentIndex (ic.readEntry("SRS", 0));
        cbCRS->setCurrentIndex (ic.readEntry("CRS", 0));
        edBands->setValue (ic.readEntry("Bands", 3));
        cbImage->setCurrentIndex (ic.readEntry("Image", 2));
        cbVersion->setCurrentIndex (ic.readEntry("Version", 0));
        edStyles->setText (ic.readEntry("Styles", QString("")));
        cbTile->setCurrentIndex (ic.readEntry("Tile", 2));
        edDepth->setValue (ic.readEntry("Depth", 2));
        edOverview->setValue (ic.readEntry("Overview", 10));
        chSquare->setChecked (ic.readEntry("Square", false));
        chOffline->setChecked (ic.readEntry("Offline", false));
        chAdvice->setChecked (ic.readEntry("Advice", true));
        chVerify->setChecked (ic.readEntry("Verify", false));
        edCorrX->setValue (ic.readEntry("CorrX", 0));
        edCorrY->setValue (ic.readEntry("CorrY", 0));
}

wmsbase::~wmsbase()
{
}

/*$SPECIALIZATION$*/
void wmsbase::slotGetCapabilities()
{
wmsSelectorWidget *dlg = new wmsSelectorWidget(this);

        if (dlg->exec() == QDialog::Accepted)
        {
           edServerURL->setUrl(dlg->getServer());
           edLayer->setText(dlg->getLayers());
           edBands->setValue(dlg->getBands());
           edStyles->setText(dlg->getStyles());
        }

        delete dlg;
}

void wmsbase::bpCancelSlot()
{
        done(QDialog::Rejected);
}

void wmsbase::bpSaveSlot()
{
        KConfig cfg (QString("sportwatcher.rc"), KConfig::SimpleConfig);
        KConfigGroup ic (&cfg, "WMS");
        // Put the data into the config file
        ic.writeEntry("ServerURL", edServerURL->url());
        ic.writeEntry("Layer", edLayer->text());
        ic.writeEntry("SRS", cbSRS->currentIndex());
        ic.writeEntry("CRS", cbCRS->currentIndex());
        ic.writeEntry("Bands", edBands->value());
        ic.writeEntry("Image", cbImage->currentIndex());
        ic.writeEntry("Version", cbVersion->currentIndex());
        ic.writeEntry("Styles", edStyles->text());
        ic.writeEntry("Tile", cbTile->currentIndex());
        ic.writeEntry("Depth", edDepth->value());
        ic.writeEntry("Overview", edOverview->value());
        ic.writeEntry("Square", chSquare->isChecked());
        ic.writeEntry("Offline", chOffline->isChecked());
        ic.writeEntry("Advice", chAdvice->isChecked());
        ic.writeEntry("Verify", chVerify->isChecked());
        ic.writeEntry("CorrX", edCorrX->value());
        ic.writeEntry("CorrY", edCorrY->value());
        done(QDialog::Accepted);
}



#include "wmsbase.moc"