Skip to content

Commit

Permalink
Changed semantics of Open and Import.
Browse files Browse the repository at this point in the history
Their names now reflect the action taken: Open opens a Merkaartor document,
Import imports files into the current document.

This is mostly to eliminate the magical code that guesses what should be done
based on files, and is different in import and open actions.
  • Loading branch information
Krakonos committed Jun 6, 2016
1 parent 51d51b2 commit 3e4a728
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/MainWindow.cpp
Expand Up @@ -132,6 +132,7 @@ class MainWindowPrivate
title = QString("%1 v%2").arg(STRINGIFY(PRODUCT)).arg(STRINGIFY(REVISION));
}

QString FILTER_OPEN_NATIVE;
QString FILTER_OPEN_SUPPORTED;
QString FILTER_IMPORT_SUPPORTED;
int lastPrefTabIndex;
Expand Down Expand Up @@ -203,6 +204,8 @@ MainWindow::MainWindow(QWidget *parent)
supported_import_formats_desc += tr("Protobuf Binary Format (*.pbf)\n");
#endif

p->FILTER_OPEN_NATIVE = tr("Merkaartor document (*.mdc)\n");

p->FILTER_OPEN_SUPPORTED = QString(tr("Supported formats") + " (*.mdc %1)\n").arg(supported_import_formats);
p->FILTER_OPEN_SUPPORTED += tr("Merkaartor document (*.mdc)\n") + supported_import_formats_desc;
p->FILTER_OPEN_SUPPORTED += tr("All Files (*)");
Expand Down Expand Up @@ -497,14 +500,16 @@ void MainWindow::handleMessage(const QString &msg)
loadUrl(u);
continue;
}
fileNames.append(args[i]);
if (args[i].endsWith(".mdc", Qt::CaseInsensitive))
loadDocument(args[i]);
else
fileNames.append(args[i]);
}
}

if (fileNames.isEmpty())
QDir::setCurrent(M_PREFS->getworkingdir());
else
loadFiles(fileNames);
if (fileNames.size() > 0) {
importFiles(theDocument, fileNames, NULL);
}
}

MainWindow::~MainWindow(void)
Expand Down Expand Up @@ -2018,12 +2023,10 @@ void MainWindow::on_fileOpenAction_triggered()
if (hasUnsavedChanges() && !mayDiscardUnsavedChanges(this))
return;

QStringList fileNames = QFileDialog::getOpenFileNames(
this,
tr("Open files"),
QString(), p->FILTER_OPEN_SUPPORTED);
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), QString(), p->FILTER_OPEN_NATIVE );

loadFiles(fileNames);
if (!fileName.isNull())
loadDocument(fileName);
}

void MainWindow::on_fileUploadAction_triggered()
Expand Down Expand Up @@ -3876,8 +3879,8 @@ void MainWindow::recentOpenTriggered(QAction* anAction)
if (hasUnsavedChanges() && !mayDiscardUnsavedChanges(this))
return;

QStringList fileNames(anAction->text());
loadFiles(fileNames);
QString fileName(anAction->text());
loadDocument(fileName);
}

void MainWindow::recentImportTriggered(QAction* anAction)
Expand Down

0 comments on commit 3e4a728

Please sign in to comment.