Files
comaps/libs/traffxml/traff_assessment_tool/trafficmodeinitdlg.cpp
mvglasow 38e98df6cc Merge commit '05cc660641' into traffic
# Conflicts:
#	CMakeLists.txt
#	android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java
#	android/sdk/src/main/cpp/app/organicmaps/sdk/Framework.hpp
#	android/sdk/src/main/cpp/app/organicmaps/sdk/OrganicMaps.cpp
#	android/sdk/src/main/cpp/app/organicmaps/sdk/util/Config.cpp
#	libs/indexer/data_source.hpp
#	libs/indexer/feature.hpp
#	libs/indexer/ftypes_matcher.hpp
#	libs/map/framework.cpp
#	libs/map/traffic_manager.cpp
#	libs/routing/absent_regions_finder.cpp
#	libs/routing/edge_estimator.hpp
#	libs/routing/index_router.cpp
#	libs/routing/index_router.hpp
#	libs/routing/routing_session.hpp
#	libs/routing_common/num_mwm_id.hpp
#	libs/traffic/traffic_info.cpp
#	qt/mainwindow.hpp
#	qt/preferences_dialog.cpp
#	tools/openlr/helpers.hpp
#	tools/openlr/openlr_decoder.cpp
#	tools/openlr/openlr_decoder.hpp
#	tools/openlr/openlr_stat/openlr_stat.cpp
#	tools/openlr/router.hpp
#	tools/openlr/score_candidate_paths_getter.cpp
#	tools/openlr/score_candidate_paths_getter.hpp
#	xcode/CoMaps.xcworkspace/contents.xcworkspacedata
2025-09-10 21:22:40 +03:00

60 lines
1.6 KiB
C++

#include "traffxml/traff_assessment_tool/trafficmodeinitdlg.h"
#include "ui_trafficmodeinitdlg.h"
#include "platform/settings.hpp"
#include <QtWidgets/QFileDialog>
#include <QFileInfo>
#include <string>
namespace
{
std::string const kDataFilePath = "LastTraffAssessmentDataFilePath";
} // namespace
namespace traffxml
{
TrafficModeInitDlg::TrafficModeInitDlg(QWidget * parent) :
QDialog(parent),
m_ui(new Ui::TrafficModeInitDlg)
{
m_ui->setupUi(this);
QString directory = {};
std::string lastDataFilePath;
if (settings::Get(kDataFilePath, lastDataFilePath))
{
m_ui->dataFileName->setText(QString::fromStdString(lastDataFilePath));
directory = QFileInfo(QString::fromStdString(lastDataFilePath)).absolutePath();
}
connect(m_ui->chooseDataFileButton, &QPushButton::clicked, [this, directory](bool) {
SetFilePathViaDialog(*m_ui->dataFileName, tr("Choose data file"), directory, "*.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 & directory, QString const & filter)
{
QFileDialog openFileDlg(nullptr, title, directory, filter);
openFileDlg.exec();
if (openFileDlg.result() != QDialog::DialogCode::Accepted)
return;
dest.setText(openFileDlg.selectedFiles().first());
}
} // namespace traffxml