mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Added support for geo URIs (RFC 5870)
This commit is contained in:
@ -1069,6 +1069,16 @@ void GUI::openDir()
|
||||
|
||||
bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
{
|
||||
QUrl url(fileName);
|
||||
if (url.scheme() == "geo") {
|
||||
if (loadURL(url, showError)) {
|
||||
_fileActionGroup->setEnabled(true);
|
||||
_reloadFileAction->setEnabled(false);
|
||||
return true;
|
||||
} else if (showError)
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
QString canonicalFileName(fi.canonicalFilePath());
|
||||
|
||||
@ -1099,6 +1109,36 @@ bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GUI::loadURL(const QUrl &url, int &showError)
|
||||
{
|
||||
Data data(url);
|
||||
|
||||
if (data.isValid()) {
|
||||
loadData(data);
|
||||
return true;
|
||||
} else {
|
||||
if (showError) {
|
||||
QString error = tr("Error loading geo URI:") + "\n" + url.toString()
|
||||
+ ": " + data.errorString();
|
||||
|
||||
if (showError > 1) {
|
||||
QMessageBox message(QMessageBox::Critical, APP_NAME, error,
|
||||
QMessageBox::Ok, this);
|
||||
QCheckBox checkBox(tr("Don't show again"));
|
||||
message.setCheckBox(&checkBox);
|
||||
message.exec();
|
||||
if (checkBox.isChecked())
|
||||
showError = 0;
|
||||
} else
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
} else
|
||||
qWarning("%s: %s", qUtf8Printable(url.toString()),
|
||||
qUtf8Printable(data.errorString()));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool GUI::loadFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
{
|
||||
Data data(fileName, tryUnknown);
|
||||
|
@ -158,6 +158,7 @@ private:
|
||||
#endif // Q_OS_ANDROID
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName, bool tryUnknown, int &showError);
|
||||
bool loadURL(const QUrl &url, int &showError);
|
||||
void loadData(const Data &data);
|
||||
bool loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
|
||||
const QList<QAction*> &existingActions, int &showError);
|
||||
|
Reference in New Issue
Block a user