When Valentina proposes measurement file it should select it in dialog.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-01-30 10:54:19 +02:00
parent 0cfe0b5936
commit 509955f2c6

View File

@ -4852,7 +4852,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
return path; return path;
} }
auto FindLocation = [this](const QString &filter, const QString &dirPath) auto FindLocation = [this](const QString &filter, const QString &dirPath, const QString &selectedName)
{ {
VCommonSettings::PrepareMultisizeTables(VCommonSettings::GetDefPathMultisizeMeasurements()); VCommonSettings::PrepareMultisizeTables(VCommonSettings::GetDefPathMultisizeMeasurements());
@ -4863,8 +4863,18 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
usedNotExistedDir = directory.mkpath("."); usedNotExistedDir = directory.mkpath(".");
} }
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), dirPath, filter, nullptr, QString mPath;
QFileDialog::DontUseNativeDialog);
QFileDialog dialog(this, tr("Open file"), dirPath, filter);
dialog.selectFile(selectedName);
dialog.setFileMode(QFileDialog::ExistingFile);
if (dialog.exec() == QDialog::Accepted)
{
mPath = dialog.selectedFiles().value(0);
}
// const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), dirPath, filter, nullptr,
// QFileDialog::DontUseNativeDialog);
if (usedNotExistedDir) if (usedNotExistedDir)
{ {
@ -4905,12 +4915,13 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
patternType = MeasurementsType::Individual; // or Unknown patternType = MeasurementsType::Individual; // or Unknown
} }
auto DirPath = [patternPath, table](const QString &defPath) auto DirPath = [patternPath, table](const QString &defPath, QString &selectedName)
{ {
QString dirPath; QString dirPath;
const QDir patternDir = QFileInfo(patternPath).absoluteDir(); const QDir patternDir = QFileInfo(patternPath).absoluteDir();
if (patternDir.exists(table.fileName())) if (patternDir.exists(table.fileName()))
{ {
selectedName = table.fileName();
dirPath = patternDir.absolutePath(); dirPath = patternDir.absolutePath();
} }
else else
@ -4927,16 +4938,20 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst);;") + const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst);;") +
tr("Individual measurements") + QLatin1String(" (*.vit)"); tr("Individual measurements") + QLatin1String(" (*.vit)");
//Use standard path to multisize measurements //Use standard path to multisize measurements
const QString dirPath = DirPath(qApp->ValentinaSettings()->GetPathMultisizeMeasurements()); QString selectedName;
mPath = FindLocation(filter, dirPath); const QString dirPath = DirPath(qApp->ValentinaSettings()->GetPathMultisizeMeasurements(),
selectedName);
mPath = FindLocation(filter, dirPath, selectedName);
} }
else else
{ {
const QString filter = tr("Individual measurements") + QLatin1String(" (*.vit);;") + const QString filter = tr("Individual measurements") + QLatin1String(" (*.vit);;") +
tr("Multisize measurements") + QLatin1String(" (*.vst)"); tr("Multisize measurements") + QLatin1String(" (*.vst)");
//Use standard path to individual measurements //Use standard path to individual measurements
const QString dirPath = DirPath(qApp->ValentinaSettings()->GetPathIndividualMeasurements()); QString selectedName;
mPath = FindLocation(filter, dirPath); const QString dirPath = DirPath(qApp->ValentinaSettings()->GetPathIndividualMeasurements(),
selectedName);
mPath = FindLocation(filter, dirPath, selectedName);
} }
if (mPath.isEmpty()) if (mPath.isEmpty())