Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

omggdalwarp.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Tim Sutton and Peter Brewer   *
00003  *   tim@linfiniti.com and dovecote@pembshideaway.co.uk  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <omggdalwarp.h>
00022 #include <omggdal.h>
00023 
00024 //qt includes
00025 #include <QSettings>
00026 #include <QFileDialog>
00027 #include <QString>
00028 #include <QMessageBox>
00029 #include <QFileInfo>
00030 #include <QListWidget>
00031 #include <QListWidgetItem>
00032 #include <QLineEdit>
00033 
00034 OmgGdalWarp::OmgGdalWarp(QWidget* parent, Qt::WFlags fl)
00035     : QDialog(parent,fl) ,
00036     mpOmgGdal (new OmgGdal()),
00037     mFilterList(QString())
00038 {
00039   //required by Qt4 to initialise the ui
00040   setupUi(this);
00041   readSettings();
00042   connect(mpOmgGdal, SIGNAL(error(QString)), this, SLOT(error(QString)));
00043   connect(mpOmgGdal, SIGNAL(updateProgress(int, int )), this, SLOT(updateProgress(int, int )));
00044   connect(mpOmgGdal, SIGNAL(convertComplete()), this, SLOT(convertComplete()));
00045   mpOmgGdal->buildSupportedRasterFileFilter(mFilterList);
00046 }
00047 
00048 OmgGdalWarp::~OmgGdalWarp()
00049 {}
00050 
00051 void OmgGdalWarp::accept()
00052 {
00053   writeSettings();
00054   done(1);
00055 }
00056 
00057 void OmgGdalWarp::on_pbnSelectFile_clicked()
00058 {
00059   QSettings mySettings;
00060   QString myBaseDir = mySettings.value("gdalwarp/inputLayersDirectory","/tmp").toString(); //initial dir
00062   QStringList myFileNameQStringList = QFileDialog::getOpenFileNames(
00063                                         this,
00064                                         "Select one or more files",
00065                                         myBaseDir, //initial dir
00066                                         mFilterList  //filters to select
00067                                       );
00068   QFileInfo myFileInfo(myFileNameQStringList.at(0));
00069   myBaseDir = myFileInfo.dir().path();
00070 
00071     mySettings.setValue("gdalwarp/inputLayersDirectory",myBaseDir);
00072   QStringList::Iterator it = myFileNameQStringList.begin();
00073   while(it != myFileNameQStringList.end())
00074   {
00075     lstInputFiles->addItem(*it);
00076     ++it;
00077   }
00078 }
00079 
00080 void OmgGdalWarp::on_pbnSelectDir_clicked()
00081 {
00082   QSettings mySettings;
00083   QString myBaseDir = mySettings.value("gdalwarp/outputDirectory","/tmp").toString(); //initial dir
00084   QString myDir = QFileDialog::getExistingDirectory(
00085                     this,
00086                     "Choose a directory",
00087                     myBaseDir);
00088 
00089   mySettings.setValue("gdalwarp/outputDirectory",myDir);
00090 
00091   leOutputDir->setText(myDir);
00092 }
00093 
00094 void OmgGdalWarp::on_pbnProcess_clicked()
00095 {
00096   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
00097 
00098   // Iterate through file list and process
00099   for ( int myFileInt = 0; myFileInt < lstInputFiles->count(); myFileInt++ )
00100   {
00101     //QListWidgetItem *myFileItem = lstInputFiles->item( myFileInt );
00102   //  mpOmgGdal->gdalResize(myFileItem->text(), leOutputDir->text(), leWidth->text().toInt(), leHeight->text().toInt());
00103   }
00104   progressBar->reset();
00105   QApplication::restoreOverrideCursor();
00106 }
00107 
00108 
00109 void OmgGdalWarp::readSettings()
00110 {
00111   QSettings mySettings;
00112 }
00113 
00114 void OmgGdalWarp::writeSettings()
00115 {
00116   QSettings mySettings;
00117 }
00118 
00119 void OmgGdalWarp::error(QString theError)
00120 {
00121   QMessageBox::warning( this,QString(tr("File Format Converter Error")),theError);
00122 }
00123 
00124 void OmgGdalWarp::updateProgress (int theCurrentValue, int theMaximumValue)
00125 {
00126   progressBar->setMaximum(theMaximumValue);
00127   progressBar->setValue(theCurrentValue);
00128   QApplication::processEvents();
00129 }
00130 
00131 QStringList OmgGdalWarp::getListWidgetEntries(const QListWidget * theListWidget)
00132 {
00133   QStringList myList;
00134   for ( int myCounter = 0; myCounter < theListWidget->count(); myCounter++ )
00135   {
00136     myList.append(theListWidget->item(myCounter)->text());
00137   }
00138   return myList;
00139 }

Generated on Mon Apr 28 15:07:20 2008 for openModellerDesktop by  doxygen 1.4.1-20050210