mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-12-04 16:29:09 +01:00
Compare commits
No commits in common. "984a8b6afc5b665e5bc918cfe6b314b21648d1c5" and "183c35ec7a2643028aab9ce61905fb42214a3c37" have entirely different histories.
984a8b6afc
...
183c35ec7a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -86,16 +86,14 @@ int App::run()
|
||||
{
|
||||
MapAction *lastReady = 0;
|
||||
QStringList args(arguments());
|
||||
int silent = 0;
|
||||
int showError = (args.count() - 1 > 1) ? 2 : 1;
|
||||
|
||||
_gui->show();
|
||||
|
||||
for (int i = 1; i < args.count(); i++) {
|
||||
if (!_gui->openFile(args.at(i), false, silent)) {
|
||||
if (!_gui->openFile(args.at(i), true)) {
|
||||
MapAction *a;
|
||||
if (!_gui->loadMap(args.at(i), a, true))
|
||||
_gui->openFile(args.at(i), true, showError);
|
||||
_gui->openFile(args.at(i), false);
|
||||
else {
|
||||
if (a)
|
||||
lastReady = a;
|
||||
@ -118,13 +116,10 @@ void App::appStateChanged(Qt::ApplicationState state)
|
||||
QJniObject activity = QNativeInterface::QAndroidApplication::context();
|
||||
QString path(activity.callObjectMethod<jstring>("intentPath").toString());
|
||||
if (!path.isEmpty()) {
|
||||
int silent = 0;
|
||||
int showError = 1;
|
||||
|
||||
if (!_gui->openFile(path, false, silent)) {
|
||||
if (!_gui->openFile(path, true)) {
|
||||
MapAction *a;
|
||||
if (!_gui->loadMap(path, a, true))
|
||||
_gui->openFile(path, true, showError);
|
||||
_gui->openFile(path, false);
|
||||
else {
|
||||
if (a)
|
||||
a->trigger();
|
||||
@ -137,16 +132,13 @@ void App::appStateChanged(Qt::ApplicationState state)
|
||||
|
||||
bool App::event(QEvent *event)
|
||||
{
|
||||
int silent = 0;
|
||||
int showError = 1;
|
||||
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
QFileOpenEvent *e = static_cast<QFileOpenEvent *>(event);
|
||||
|
||||
if (!_gui->openFile(e->file(), false, silent)) {
|
||||
if (!_gui->openFile(e->file(), true)) {
|
||||
MapAction *a;
|
||||
if (!_gui->loadMap(e->file(), a, true))
|
||||
return _gui->openFile(e->file(), true, showError);
|
||||
return _gui->openFile(e->file(), false);
|
||||
else {
|
||||
if (a)
|
||||
a->trigger();
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
#include <QMessageBox>
|
||||
#include <QCheckBox>
|
||||
#include <QFileDialog>
|
||||
#include <QPrintDialog>
|
||||
#include <QPainter>
|
||||
@ -948,10 +947,9 @@ void GUI::openFile()
|
||||
QStringList files(QFileDialog::getOpenFileNames(this, tr("Open file"),
|
||||
_dataDir, Data::formats()));
|
||||
#endif // Q_OS_ANDROID
|
||||
int showError = (files.size() > 1) ? 2 : 1;
|
||||
|
||||
for (int i = 0; i < files.size(); i++)
|
||||
openFile(files.at(i), true, showError);
|
||||
openFile(files.at(i));
|
||||
if (!files.isEmpty())
|
||||
_dataDir = QFileInfo(files.last()).path();
|
||||
}
|
||||
@ -961,21 +959,20 @@ void GUI::openDir()
|
||||
{
|
||||
QString dir(QFileDialog::getExistingDirectory(this, tr("Open directory"),
|
||||
_dataDir));
|
||||
int showError = 1;
|
||||
|
||||
if (!dir.isEmpty()) {
|
||||
_browser->setCurrentDir(dir);
|
||||
openFile(_browser->current(), true, showError);
|
||||
openFile(_browser->current());
|
||||
}
|
||||
}
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
bool GUI::openFile(const QString &fileName, bool silent)
|
||||
{
|
||||
if (_files.contains(fileName))
|
||||
return true;
|
||||
|
||||
if (!loadFile(fileName, tryUnknown, showError))
|
||||
if (!loadFile(fileName, silent))
|
||||
return false;
|
||||
|
||||
_files.append(fileName);
|
||||
@ -994,14 +991,14 @@ bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GUI::loadFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
bool GUI::loadFile(const QString &fileName, bool silent)
|
||||
{
|
||||
Data data(fileName, tryUnknown);
|
||||
Data data(fileName, !silent);
|
||||
|
||||
if (data.isValid()) {
|
||||
loadData(data);
|
||||
return true;
|
||||
} else {
|
||||
} else if (!silent) {
|
||||
updateNavigationActions();
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
@ -1010,26 +1007,14 @@ bool GUI::loadFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
if (_files.isEmpty())
|
||||
_fileActionGroup->setEnabled(false);
|
||||
|
||||
if (showError) {
|
||||
QString error = tr("Error loading data file:") + "\n"
|
||||
+ Util::displayName(fileName) + ": " + data.errorString();
|
||||
if (data.errorLine())
|
||||
error.append("\n" + tr("Line: %1").arg(data.errorLine()));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
QString error = tr("Error loading data file:") + "\n\n"
|
||||
+ Util::displayName(fileName) + "\n\n" + data.errorString();
|
||||
if (data.errorLine())
|
||||
error.append("\n" + tr("Line: %1").arg(data.errorLine()));
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::loadData(const Data &data)
|
||||
@ -1123,8 +1108,8 @@ bool GUI::openPOIFile(const QString &fileName)
|
||||
|
||||
return true;
|
||||
} else {
|
||||
QString error = tr("Error loading POI file:") + "\n"
|
||||
+ Util::displayName(fileName) + ": " + _poi->errorString();
|
||||
QString error = tr("Error loading POI file:") + "\n\n"
|
||||
+ Util::displayName(fileName) + "\n\n" + _poi->errorString();
|
||||
if (_poi->errorLine())
|
||||
error.append("\n" + tr("Line: %1").arg(_poi->errorLine()));
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
@ -1481,9 +1466,8 @@ void GUI::reloadFiles()
|
||||
_tabs.at(i)->clear();
|
||||
_mapView->clear();
|
||||
|
||||
int showError = 2;
|
||||
for (int i = 0; i < _files.size(); i++) {
|
||||
if (!loadFile(_files.at(i), true, showError)) {
|
||||
if (!loadFile(_files.at(i))) {
|
||||
_files.removeAt(i);
|
||||
i--;
|
||||
}
|
||||
@ -1708,8 +1692,8 @@ bool GUI::loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
|
||||
if (!map->isValid()) {
|
||||
if (!silent)
|
||||
QMessageBox::critical(this, APP_NAME,
|
||||
tr("Error loading map:") + "\n"
|
||||
+ Util::displayName(map->path()) + ": "
|
||||
tr("Error loading map:") + "\n\n"
|
||||
+ Util::displayName(map->path()) + "\n\n"
|
||||
+ map->errorString());
|
||||
delete map;
|
||||
} else {
|
||||
@ -1753,8 +1737,8 @@ void GUI::mapLoaded()
|
||||
_showMapAction->setEnabled(true);
|
||||
_clearMapCacheAction->setEnabled(true);
|
||||
} else {
|
||||
QString error = tr("Error loading map:") + "\n"
|
||||
+ Util::displayName(map->path()) + ": " + map->errorString();
|
||||
QString error = tr("Error loading map:") + "\n\n"
|
||||
+ Util::displayName(map->path()) + "\n\n" + map->errorString();
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
action->deleteLater();
|
||||
}
|
||||
@ -1772,8 +1756,8 @@ void GUI::mapLoadedDir()
|
||||
actions.append(action);
|
||||
_mapView->loadMaps(actions);
|
||||
} else {
|
||||
QString error = tr("Error loading map:") + "\n"
|
||||
+ Util::displayName(map->path()) + ": " + map->errorString();
|
||||
QString error = tr("Error loading map:") + "\n\n"
|
||||
+ Util::displayName(map->path()) + "\n\n" + map->errorString();
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
action->deleteLater();
|
||||
}
|
||||
@ -1795,7 +1779,7 @@ void GUI::loadMapDirNode(const TreeNode<Map *> &node, QList<MapAction*> &actions
|
||||
if (!(a = findMapAction(existingActions, map))) {
|
||||
if (!map->isValid()) {
|
||||
QMessageBox::critical(this, APP_NAME, tr("Error loading map:")
|
||||
+ "\n" + Util::displayName(map->path()) + ": "
|
||||
+ "\n\n" + Util::displayName(map->path()) + "\n\n"
|
||||
+ map->errorString());
|
||||
delete map;
|
||||
} else {
|
||||
@ -2096,53 +2080,48 @@ void GUI::setGraphType(GraphType type)
|
||||
|
||||
void GUI::next()
|
||||
{
|
||||
int showError = 1;
|
||||
QString file = _browser->next();
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFiles();
|
||||
openFile(file, true, showError);
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
void GUI::prev()
|
||||
{
|
||||
int showError = 1;
|
||||
QString file = _browser->prev();
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFiles();
|
||||
openFile(file, true, showError);
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
void GUI::last()
|
||||
{
|
||||
int showError = 1;
|
||||
QString file = _browser->last();
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFiles();
|
||||
openFile(file, true, showError);
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
void GUI::first()
|
||||
{
|
||||
int showError = 1;
|
||||
QString file = _browser->first();
|
||||
if (file.isNull())
|
||||
return;
|
||||
|
||||
closeFiles();
|
||||
openFile(file, true, showError);
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
void GUI::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QString file;
|
||||
int showError = 1;
|
||||
|
||||
switch (event->key()) {
|
||||
case PREV_KEY:
|
||||
@ -2188,7 +2167,7 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
||||
if (!file.isNull()) {
|
||||
if (!(event->modifiers() & MODIFIER))
|
||||
closeFiles();
|
||||
openFile(file, true, showError);
|
||||
openFile(file);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2221,16 +2200,14 @@ void GUI::dropEvent(QDropEvent *event)
|
||||
{
|
||||
MapAction *lastReady = 0;
|
||||
QList<QUrl> urls(event->mimeData()->urls());
|
||||
int silent = 0;
|
||||
int showError = (urls.size() > 1) ? 2 : 1;
|
||||
|
||||
for (int i = 0; i < urls.size(); i++) {
|
||||
QString file(urls.at(i).toLocalFile());
|
||||
|
||||
if (!openFile(file, false, silent)) {
|
||||
if (!openFile(file, true)) {
|
||||
MapAction *a;
|
||||
if (!loadMap(file, a, true))
|
||||
openFile(file, true, showError);
|
||||
openFile(file, false);
|
||||
else {
|
||||
if (a)
|
||||
lastReady = a;
|
||||
|
@ -44,7 +44,7 @@ class GUI : public QMainWindow
|
||||
public:
|
||||
GUI();
|
||||
|
||||
bool openFile(const QString &fileName, bool tryUnknown, int &showError);
|
||||
bool openFile(const QString &fileName, bool silent = false);
|
||||
bool loadMap(const QString &fileName, MapAction *&action,
|
||||
bool silent = false);
|
||||
void show();
|
||||
@ -151,7 +151,7 @@ private:
|
||||
void createBrowser();
|
||||
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName, bool tryUnknown, int &showError);
|
||||
bool loadFile(const QString &fileName, bool silent = false);
|
||||
void loadData(const Data &data);
|
||||
bool loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
|
||||
bool silent, const QList<QAction*> &existingActions);
|
||||
|
@ -13,7 +13,7 @@
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
Data(const QString &fileName, bool tryUnknown = true);
|
||||
Data(const QString &fileName, bool full = true);
|
||||
|
||||
bool isValid() const {return _valid;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
Loading…
Reference in New Issue
Block a user