Skip to content
Snippets Groups Projects
Commit b5981969 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ADD: Real add of Qt Widget VectorDataParameter

parent af579d5f
No related branches found
No related tags found
No related merge requests found
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbWrapperQtWidgetInputVectorDataParameter.h"
namespace otb
{
namespace Wrapper
{
QtWidgetInputVectorDataParameter::QtWidgetInputVectorDataParameter(InputVectorDataParameter* param, QtWidgetModel* m)
: QtWidgetParameterBase(param, m),
m_InputVectorDataParam(param)
{
}
QtWidgetInputVectorDataParameter::~QtWidgetInputVectorDataParameter()
{
}
void QtWidgetInputVectorDataParameter::DoUpdateGUI()
{
}
void QtWidgetInputVectorDataParameter::DoCreateWidget()
{
// Set up input text edit
m_HLayout = new QHBoxLayout;
m_HLayout->setSpacing(0);
m_HLayout->setContentsMargins(0, 0, 0, 0);
m_Input = new QLineEdit;
m_Input->setToolTip( m_InputVectorDataParam->GetDescription() );
connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) );
connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) );
m_HLayout->addWidget(m_Input);
// Set up input text edit
m_Button = new QPushButton;
m_Button->setText("...");
m_Button->setToolTip("Select file...");
m_Button->setMaximumWidth(m_Button->width());
connect( m_Button, SIGNAL(clicked()), this, SLOT(SelectFile()) );
m_HLayout->addWidget(m_Button);
this->setLayout(m_HLayout);
}
void QtWidgetInputVectorDataParameter::SelectFile()
{
QFileDialog fileDialog;
fileDialog.setConfirmOverwrite(true);
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setNameFilter("Vector data files (*)");
if (fileDialog.exec())
{
if ( this->SetFileName(fileDialog.selectedFiles().at(0)) == false )
m_Input->setText(fileDialog.selectedFiles().at(0));
}
}
void QtWidgetInputVectorDataParameter::SetFileName(const QString& value)
{
// save value
if(m_InputVectorDataParam->SetFromFileName(value.toStdString()) == false )
{
// notify of value change
QString key( QString::fromStdString(m_InputVectorDataParam->GetKey()) );
emit ParameterChanged(key);
}
}
}
}
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbWrapperQtWidgetInputVectorDataParameter_h
#define __otbWrapperQtWidgetInputVectorDataParameter_h
#include <QtGui>
#include "otbWrapperInputVectorDataParameter.h"
#include "otbWrapperQtWidgetParameterBase.h"
namespace otb
{
namespace Wrapper
{
/** \class
* \brief
*/
class QtWidgetInputVectorDataParameter : public QtWidgetParameterBase
{
Q_OBJECT
public:
QtWidgetInputVectorDataParameter(InputVectorDataParameter*, QtWidgetModel*);
virtual ~QtWidgetInputVectorDataParameter();
protected slots:
void SetFileName( const QString& value );
void SelectFile();
private:
QtWidgetInputVectorDataParameter(const QtWidgetInputVectorDataParameter&); //purposely not implemented
void operator=(const QtWidgetInputVectorDataParameter&); //purposely not implemented
virtual void DoCreateWidget();
virtual void DoUpdateGUI();
InputVectorDataParameter::Pointer m_InputVectorDataParam;
QHBoxLayout * m_HLayout;
QLineEdit* m_Input;
QPushButton * m_Button;
};
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment