Welcome to mirror list, hosted at ThFree Co, Russian Federation.

trafficmodeinitdlg.cpp « openlr_assessment_tool « openlr_match_quality « openlr - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a66a949c1f80f63c0397ce91f9976c5338b775af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "openlr/openlr_match_quality/openlr_assessment_tool/trafficmodeinitdlg.h"
#include "ui_trafficmodeinitdlg.h"

#include "platform/settings.hpp"

#include <QtWidgets/QFileDialog>

namespace
{
string const kDataFilePath = "LastOpenlrAssessmentDataFilePath";
}  // namespace

namespace openlr
{
TrafficModeInitDlg::TrafficModeInitDlg(QWidget * parent) :
  QDialog(parent),
  m_ui(new Ui::TrafficModeInitDlg)
{
  m_ui->setupUi(this);

  string lastDataFilePath;
  if (settings::Get(kDataFilePath, lastDataFilePath))
    m_ui->dataFileName->setText(QString::fromStdString(lastDataFilePath));

  connect(m_ui->chooseDataFileButton, &QPushButton::clicked, [this](bool) {
      SetFilePathViaDialog(*m_ui->dataFileName, tr("Choose data file"), "*.xml");
  });
}

TrafficModeInitDlg::~TrafficModeInitDlg()
{
  delete m_ui;
}

void TrafficModeInitDlg::accept()
{
  m_dataFileName = m_ui->dataFileName->text().trimmed().toStdString();
  settings::Set(kDataFilePath, m_dataFileName);
  QDialog::accept();
}

void TrafficModeInitDlg::SetFilePathViaDialog(QLineEdit & dest, QString const & title,
                                              QString const & filter)
{
  QFileDialog openFileDlg(nullptr, title, {} /* directory */, filter);
  openFileDlg.exec();
  if (openFileDlg.result() != QDialog::DialogCode::Accepted)
    return;

  dest.setText(openFileDlg.selectedFiles().first());
}
}  // namespace openlr