InsertLinkOrPictureDialog::InsertLinkOrPictureDialog(int type, QString proDir, QWidget *parent) :
    QDialog(parent, Qt::WindowTitleHint|Qt::WindowSystemMenuHint),
    ui(new Ui::InsertLinkOrPictureDialog),
    proDir(proDir)
{
    ui->setupUi(this);
    ui->urlLineEdit->setFocus();
    conf = Configuration::getInstance();
    if(type==MdCharmGlobal::ShortcutInsertPicture){
        ui->textLabel->setText(tr("Alt Text:"));
        ui->urlLabel->setText(tr("Picture Url:"));
        if(conf->getMarkdownEngineType()!=MarkdownToHtml::MultiMarkdown){
            ui->widthLineEdit->hide();
            ui->widthLabel->hide();
            ui->heightLineEdit->hide();
            ui->heightLabel->hide();
        }
        setWindowTitle(tr("Insert Picture"));
    } else {
        ui->insertLocalPushButton->hide();
        ui->textLabel->setText(tr("Link Text:"));
        ui->urlLabel->setText(tr("Link Url:"));
        ui->widthLineEdit->hide();
        ui->widthLabel->hide();
        ui->heightLineEdit->hide();
        ui->heightLabel->hide();
        setWindowTitle(tr("Insert Link"));
    }
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(checkAndAccept()));
    connect(ui->insertLocalPushButton, SIGNAL(clicked()), this, SLOT(insertLocalFileSlot()));
    this->type = type;
    setFixedHeight(sizeHint().height());
}
SurfacesConfigDialog::SurfacesConfigDialog(const QVector<struct wsPCD> &collectionPoints,
																		 const QVector<std::string> &collectionAttributes,
																		 const QVector<struct wsWeatherDataPcdSurface> &collectionSurfaces,
																		 const wsProjectionParams &projection,
																		 QWidget *parent, Qt::WFlags f) : QDialog(parent, f), _parent(parent),

  _collectionPoints(collectionPoints),
  _collectionAttributes(collectionAttributes),
  _collectionSurfaces(collectionSurfaces),
  _projection(projection),
  _attributeListIsLoaded(false),
  _baseBox(0, 0, 0, 0)

{
  setupUi(this);

  // métodos de interpolação
  interpCmb->addItem(tr("Vizinho mais próximo"));
  interpCmb->addItem(tr("K-vizinhos mais próximos"));
  interpCmb->addItem(tr("K-vizinhos mais próximos ponderados"));
#ifndef _WIN64  
  interpCmb->addItem(tr("Superfície de tendência"));
#endif

  // Menus associados a botões
  QMenu* menuMask = new QMenu(tr("Máscaras"), _parent);
  menuMask->addAction(tr("%a - ano com dois digitos"));
  menuMask->addAction(tr("%A - ano com quatro digitos"));
  menuMask->addAction(tr("%d - dia com dois digitos"));
  menuMask->addAction(tr("%M - mes com dois digitos"));
  menuMask->addAction(tr("%h - hora com dois digitos"));
  menuMask->addAction(tr("%m - minuto com dois digitos"));
  menuMask->addAction(tr("%s - segundo com dois digitos"));

  fileAnaGridMaskBtn->setMenu(menuMask);
  fileAnaGridMaskBtn->setPopupMode(QToolButton::InstantPopup);

  // Coneta os sinais
  connect(menuMask, SIGNAL(triggered(QAction*)), SLOT(menuMaskClick(QAction*)));

  connect(surfaceList,    SIGNAL(currentRowChanged(int)),   SLOT(showSurfaceDetails(int)));
  connect(interpCmb,      SIGNAL(currentIndexChanged(int)), SLOT(interpolationChanged(int)));
  connect(resDegreeRadio, SIGNAL(toggled(bool)),            SLOT(resDegreeRadioToggled(bool)));

  connect(outputGridEdit,  SIGNAL(textEdited(const QString&)), SLOT(updateCurrentSurface()));
  connect(attributeCmb,    SIGNAL(activated(int)),             SLOT(updateCurrentSurface()));
  connect(interpCmb,       SIGNAL(activated(int)),             SLOT(updateCurrentSurface()));
  connect(neighborNumEdit, SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(powValueEdit,    SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(degreeCmb,       SIGNAL(activated(int)),             SLOT(updateCurrentSurface()));
  connect(x1Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(y1Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(x2Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(y2Edit,          SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(resXEdit,        SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(resYEdit,        SIGNAL(editingFinished()),          SLOT(updateCurrentSurface()));
  connect(resDegreeRadio,  SIGNAL(clicked(bool)),              SLOT(updateCurrentSurface()));
  connect(resMeterRadio,   SIGNAL(clicked(bool)),              SLOT(updateCurrentSurface()));

  connect(outputGridEdit,  SIGNAL(textEdited(const QString&)), SLOT(updateSurfaceList()));
  connect(outputGridEdit,  SIGNAL(editingFinished()),          SLOT(trimGridOutputName()));

  connect(addAttributeBtn,    SIGNAL(clicked()), SLOT(addSurface()));
  connect(removeAttributeBtn, SIGNAL(clicked()), SLOT(removeSurface()));
  connect(okBtn,              SIGNAL(clicked()), SLOT(checkAndAccept()));
  connect(cancelBtn,          SIGNAL(clicked()), SLOT(checkAndReject()));

  neighborNumEdit->setValidator(new QIntValidator(0, 9999, neighborNumEdit));
  powValueEdit->setValidator(new QIntValidator(0, 9999, powValueEdit));

  x1Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, x1Edit));
  y1Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, y1Edit));
  x2Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, x2Edit));
  y2Edit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, y2Edit));

  resXEdit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, resXEdit));
  resYEdit->setValidator(new QDoubleValidator(-TeMAXFLOAT, TeMAXFLOAT, 20, resYEdit));

  // Carrega as superfícies já cadastradas
  if(!collectionSurfaces.isEmpty())
  {
    loadAttributeList();
    updateSurfaceList(0);
  }
  else // Nenhuma cadastrada, desabilita a parte direita da interface
    clearSurfaceDetails();

  // Calcula o box padrão
  {
    TePointSet pointSet;
    for(int i = 0; i < _collectionPoints.size(); i++)
    {
      if(_collectionPoints.at(i).isActive)
      {
        TeCoord2D aux = TeCoord2D(_collectionPoints.at(i).longitude, _collectionPoints.at(i).latitude);
        TePoint p(aux);
        pointSet.add(p);
      }
    }

    if(pointSet.size() > 0)
    {
      std::auto_ptr<TeProjection> projection(TeProjectionFactory::make(wsUtils::ProjectionParams::teFromWs(_projection)));

      for(unsigned int i = 0; i < pointSet.size(); ++i)
      {
        if(pointSet[i].srid() == -1)
          pointSet[i].srid(projection->epsgCode());
      }

      // Atualiza o box padrão
      _baseBox = pointSet.box();
    }
  }

  // Grava configuração inicial
  _startConfig = _collectionSurfaces;
}
void MyRoutesAddDialog::createConnections() {
    connect(okButton, SIGNAL(clicked()), this, SLOT(checkAndAccept()));
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    connect(reverseCheckBox, SIGNAL(toggled(bool)), reverseNameLineEdit, SLOT(setEnabled(bool)));
}