/
map_editor.cpp
4102 lines (3559 loc) · 145 KB
/
map_editor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2012, 2013 Thomas Schöps
* Copyright 2012-2018 Kai Pastor
*
* This file is part of OpenOrienteering.
*
* OpenOrienteering is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenOrienteering is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.
*/
#include "map_editor.h"
#include "map_editor_p.h"
#include <algorithm>
#include <cstddef>
#include <functional>
#include <iterator>
#include <limits>
#include <set>
#include <vector>
// IWYU pragma: no_include <ext/alloc_traits.h>
#include <Qt>
#include <QtGlobal>
#include <QtMath>
#include <QAbstractButton>
#include <QAction>
#include <QActionGroup>
#include <QApplication>
#include <QBuffer>
#include <QByteArray>
#include <QComboBox>
#include <QDate>
#include <QDialog>
#include <QDir>
#include <QDockWidget>
#include <QEvent>
#include <QFile>
#include <QFileInfo>
#include <QFlags>
#include <QFont>
#include <QFontMetrics>
#include <QFrame>
#include <QHBoxLayout>
#include <QIcon>
#include <QImage> // IWYU pragma: keep
#include <QInputDialog>
#include <QIODevice>
#include <QKeyEvent> // IWYU pragma: keep
#include <QKeySequence>
#include <QLabel>
#include <QLatin1Char>
#include <QLatin1String>
#include <QLineEdit>
#include <QList>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
// IWYU pragma: no_include <QMetaObject>
#include <QMimeData>
#include <QPainter>
#include <QPixmap>
#include <QPoint>
#include <QPushButton>
#include <QRect>
#include <QRectF>
#include <QSettings>
#include <QSignalBlocker>
#include <QSignalMapper>
#include <QSize>
#include <QSizeGrip> // IWYU pragma: keep
#include <QSizePolicy>
#include <QSplitter>
#include <QStatusBar>
#include <QStringList>
#include <QTextEdit>
#include <QToolBar>
#include <QToolButton>
#include <QVariant>
#include <QVBoxLayout>
#include <QWidget>
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QAndroidJniObject>
#endif
#include "settings.h"
#include "core/georeferencing.h"
#include "core/map.h"
#include "core/map_coord.h"
#include "core/map_part.h"
#include "core/map_view.h"
#include "core/objects/boolean_tool.h"
#include "core/objects/object.h"
#include "core/objects/object_operations.h"
#include "core/symbols/point_symbol.h"
#include "core/symbols/area_symbol.h"
#include "core/symbols/symbol.h"
#include "core/symbols/symbol_icon_decorator.h"
#include "fileformats/file_format.h"
#include "fileformats/file_format_registry.h"
#include "gui/configure_grid_dialog.h"
#include "gui/file_dialog.h"
#include "gui/georeferencing_dialog.h"
#include "gui/main_window.h"
#include "gui/print_widget.h"
#include "gui/text_browser_dialog.h"
#include "gui/util_gui.h"
#include "gui/map/map_dialog_rotate.h"
#include "gui/map/map_dialog_scale.h"
#include "gui/map/map_editor_activity.h"
#include "gui/map/map_find_feature.h"
#include "gui/map/map_widget.h"
#include "gui/symbols/replace_symbol_set_dialog.h"
#include "gui/widgets/action_grid_bar.h"
#include "gui/widgets/color_list_widget.h"
#include "gui/widgets/compass_display.h"
#include "gui/widgets/key_button_bar.h" // IWYU pragma: keep
#include "gui/widgets/measure_widget.h"
#include "gui/widgets/symbol_widget.h"
#include "gui/widgets/tags_widget.h"
#include "gui/widgets/template_list_widget.h"
#include "sensors/compass.h"
#include "sensors/gps_display.h"
#include "sensors/gps_temporary_markers.h"
#include "sensors/gps_track_recorder.h"
#include "templates/template.h"
#include "templates/template_dialog_reopen.h"
#include "templates/template_position_dock_widget.h"
#include "templates/template_tool_paint.h"
#include "templates/template_track.h"
#include "tools/cut_tool.h"
#include "tools/cut_hole_tool.h"
#include "tools/cutout_tool.h"
#include "tools/distribute_points_tool.h"
#include "tools/draw_circle_tool.h"
#include "tools/draw_freehand_tool.h"
#include "tools/draw_path_tool.h"
#include "tools/draw_point_tool.h"
#include "tools/draw_point_gps_tool.h"
#include "tools/draw_rectangle_tool.h"
#include "tools/draw_text_tool.h"
#include "tools/edit_point_tool.h"
#include "tools/edit_line_tool.h"
#include "tools/fill_tool.h"
#include "tools/pan_tool.h"
#include "tools/rotate_pattern_tool.h"
#include "tools/rotate_tool.h"
#include "tools/scale_tool.h"
#include "tools/tool.h"
#include "undo/map_part_undo.h"
#include "undo/object_undo.h"
#include "undo/undo.h"
#include "undo/undo_manager.h"
#include "util/backports.h" // IWYU pragma: keep
namespace OpenOrienteering {
namespace {
/**
* Creates a partial, resizable widget overlay over the main window.
*
* This widget is meant to be used as a dock widget replacement in the
* mobile app. In landscape mode, the child widget is placed on the right
* side, spanning the full height. In portrait mode, the child is placed
* on the top, spanning the full width.
*/
QSplitter* createDockWidgetSubstitute(MainWindow* window, QWidget* child)
{
auto splitter = new QSplitter(window);
splitter->setChildrenCollapsible(false);
auto placeholder = new QWidget();
splitter->setAttribute(Qt::WA_NoSystemBackground, true);
placeholder->setAttribute(Qt::WA_NoSystemBackground, true);
child->setAutoFillBackground(true);
auto geometry = window->geometry();
splitter->setGeometry(geometry);
if (geometry.height() > geometry.width())
{
splitter->setOrientation(Qt::Vertical);
splitter->addWidget(child);
splitter->addWidget(placeholder);
}
else
{
splitter->setOrientation(Qt::Horizontal);
splitter->addWidget(placeholder);
splitter->addWidget(child);
}
return splitter;
}
template<class T>
bool containsPathObject(const T& container)
{
return std::any_of(begin(container), end(container), [](const auto object) {
return object->getType() == Object::Path;
});
}
} // namespace
namespace MimeType {
/// The MIME type of Mapper data
QString OpenOrienteeringObjects()
{
return QStringLiteral("openorienteering/objects");
}
} // namespace MimeType
// ### MapEditorController ###
MapEditorController::MapEditorController(OperatingMode mode, Map* map, MapView* map_view)
: MainWindowController()
, mobile_mode(MainWindow::mobileMode())
, active_symbol(nullptr)
, template_list_widget(nullptr)
, mappart_remove_act(nullptr)
, mappart_merge_act(nullptr)
, mappart_merge_menu(nullptr)
, mappart_move_menu(nullptr)
, mappart_selector_box(nullptr)
, mappart_merge_mapper(new QSignalMapper(this))
, mappart_move_mapper(new QSignalMapper(this))
{
this->mode = mode;
this->map = nullptr;
main_view = nullptr;
symbol_widget = nullptr;
window = nullptr;
editing_in_progress = false;
cut_hole_menu = nullptr;
if (map)
setMapAndView(map, map_view ? map_view : new MapView(this, map));
editor_activity = nullptr;
current_tool = nullptr;
override_tool = nullptr;
last_painted_on_template = nullptr;
paste_act = nullptr;
reopen_template_act = nullptr;
overprinting_simulation_act = nullptr;
toolbar_view = nullptr;
toolbar_mapparts = nullptr;
toolbar_drawing = nullptr;
toolbar_editing = nullptr;
toolbar_advanced_editing = nullptr;
print_dock_widget = nullptr;
measure_dock_widget = nullptr;
symbol_dock_widget = nullptr;
statusbar_zoom_frame = nullptr;
statusbar_cursorpos_label = nullptr;
gps_display = nullptr;
gps_track_recorder = nullptr;
compass_display = nullptr;
gps_marker_display = nullptr;
actionsById[""] = new QAction(this); // dummy action
connect(mappart_merge_mapper, QOverload<int>::of(&QSignalMapper::mapped), this, &MapEditorController::mergeCurrentMapPartTo);
connect(mappart_move_mapper, QOverload<int>::of(&QSignalMapper::mapped), this, &MapEditorController::reassignObjectsToMapPart);
}
MapEditorController::~MapEditorController()
{
paste_act = nullptr;
delete current_tool;
delete override_tool;
delete editor_activity;
delete toolbar_view;
delete toolbar_drawing;
delete toolbar_editing;
delete toolbar_advanced_editing;
delete toolbar_mapparts;
delete print_dock_widget;
delete measure_dock_widget;
if (color_dock_widget)
delete color_dock_widget;
delete symbol_dock_widget;
if (template_dock_widget)
delete template_dock_widget;
if (tags_dock_widget)
delete tags_dock_widget;
delete cut_hole_menu;
delete mappart_merge_act;
delete mappart_merge_menu;
delete mappart_move_menu;
for (TemplatePositionDockWidget* widget : qAsConst(template_position_widgets))
delete widget;
delete gps_display;
delete gps_track_recorder;
delete compass_display;
delete map;
}
bool MapEditorController::isInMobileMode() const
{
return mobile_mode;
}
void MapEditorController::setTool(MapEditorTool* new_tool)
{
if (current_tool)
{
if (current_tool->editingInProgress())
{
current_tool->finishEditing();
}
current_tool->deleteLater();
}
if (!override_tool)
{
map->clearDrawingBoundingBox();
window->setStatusBarText(QString{});
}
current_tool = new_tool;
if (current_tool && !override_tool)
{
current_tool->init();
}
if (!override_tool)
map_widget->setTool(current_tool);
}
void MapEditorController::setEditTool()
{
if (!current_tool || current_tool->toolType() != MapEditorTool::EditPoint)
setTool(new EditPointTool(this, edit_tool_act));
}
void MapEditorController::setOverrideTool(MapEditorTool* new_override_tool)
{
if (override_tool == new_override_tool)
return;
if (override_tool)
{
if (override_tool->editingInProgress())
{
override_tool->finishEditing();
}
delete override_tool;
}
map->clearDrawingBoundingBox();
window->setStatusBarText(QString{});
override_tool = new_override_tool;
if (override_tool)
{
override_tool->init();
}
else if (current_tool)
{
current_tool->init();
}
map_widget->setTool(override_tool ? override_tool : current_tool);
}
MapEditorTool* MapEditorController::getDefaultDrawToolForSymbol(const Symbol* symbol)
{
if (!symbol)
return new EditPointTool(this, edit_tool_act);
else if (symbol->getType() == Symbol::Point)
return new DrawPointTool(this, draw_point_act);
else if (symbol->getType() == Symbol::Line || symbol->getType() == Symbol::Area || symbol->getType() == Symbol::Combined)
return new DrawPathTool(this, draw_path_act, false, true);
else if (symbol->getType() == Symbol::Text)
return new DrawTextTool(this, draw_text_act);
else
Q_ASSERT(false);
return nullptr;
}
void MapEditorController::setEditingInProgress(bool value)
{
if (value != editing_in_progress)
{
editing_in_progress = value;
// Widgets
map_widget->setGesturesEnabled(!editing_in_progress);
Q_ASSERT(symbol_widget);
symbol_widget->setEnabled(!editing_in_progress);
if (isInMobileMode())
mobile_symbol_selector_action->setEnabled(!editing_in_progress);
if (color_dock_widget)
color_dock_widget->widget()->setEnabled(!editing_in_progress);
if (mappart_selector_box)
mappart_selector_box->setEnabled(!editing_in_progress);
// Edit menu
undo_act->setEnabled(!editing_in_progress && map->undoManager().canUndo());
redo_act->setEnabled(!editing_in_progress && map->undoManager().canRedo());
updatePasteAvailability();
select_all_act->setEnabled(!editing_in_progress);
select_nothing_act->setEnabled(!editing_in_progress);
invert_selection_act->setEnabled(!editing_in_progress);
select_by_current_symbol_act->setEnabled(!editing_in_progress);
find_feature->setEnabled(!editing_in_progress);
// Map menu
georeferencing_act->setEnabled(!editing_in_progress);
scale_map_act->setEnabled(!editing_in_progress);
rotate_map_act->setEnabled(!editing_in_progress);
map_notes_act->setEnabled(!editing_in_progress);
// Map menu, continued
const int num_parts = map->getNumParts();
mappart_add_act->setEnabled(!editing_in_progress);
mappart_rename_act->setEnabled(!editing_in_progress && num_parts > 0);
mappart_remove_act->setEnabled(!editing_in_progress && num_parts > 1);
mappart_move_menu->setEnabled(!editing_in_progress && num_parts > 1);
mappart_merge_act->setEnabled(!editing_in_progress && num_parts > 1);
mappart_merge_menu->setEnabled(!editing_in_progress && num_parts > 1);
// Symbol menu
symbol_set_id_act->setEnabled(!editing_in_progress);
scale_all_symbols_act->setEnabled(!editing_in_progress);
load_symbols_from_act->setEnabled(!editing_in_progress);
load_crt_act->setEnabled(!editing_in_progress);
updateObjectDependentActions();
updateSymbolDependentActions();
updateSymbolAndObjectDependentActions();
}
}
bool MapEditorController::isEditingInProgress() const
{
return editing_in_progress;
}
void MapEditorController::setEditorActivity(MapEditorActivity* new_activity)
{
delete editor_activity;
map->clearActivityBoundingBox();
editor_activity = new_activity;
if (editor_activity)
editor_activity->init();
map_widget->setActivity(editor_activity);
}
void MapEditorController::addTemplatePositionDockWidget(Template* temp)
{
Q_ASSERT(!existsTemplatePositionDockWidget(temp));
auto dock_widget = new TemplatePositionDockWidget(temp, this, window);
addFloatingDockWidget(dock_widget);
template_position_widgets.insert(temp, dock_widget);
}
void MapEditorController::removeTemplatePositionDockWidget(Template* temp)
{
emit templatePositionDockWidgetClosed(temp);
delete getTemplatePositionDockWidget(temp);
int num_deleted = template_position_widgets.remove(temp);
Q_ASSERT(num_deleted == 1);
Q_UNUSED(num_deleted);
}
void MapEditorController::showPopupWidget(QWidget* child_widget, const QString& title)
{
if (mobile_mode)
{
// FIXME: This is used for KeyButtonBar only
// and not related to mobile_mode!
QSize size = child_widget->sizeHint();
QRect map_widget_rect = map_widget->rect();
child_widget->setParent(map_widget);
child_widget->setGeometry(
qMax(0, qRound(map_widget_rect.center().x() - 0.5f * size.width())),
qMax(0, map_widget_rect.bottom() - size.height()),
qMin(size.width(), map_widget_rect.width()),
qMin(size.height(), map_widget_rect.height())
);
child_widget->show();
}
else
{
auto dock_widget = new QDockWidget(title, window);
dock_widget->setFeatures(dock_widget->features() & ~QDockWidget::DockWidgetClosable);
dock_widget->setWidget(child_widget);
// Show dock in floating state
dock_widget->setFloating(true);
dock_widget->show();
dock_widget->setGeometry(window->geometry().left() + 40, window->geometry().top() + 100, dock_widget->width(), dock_widget->height());
}
}
void MapEditorController::deletePopupWidget(QWidget* child_widget)
{
if (mobile_mode)
{
delete child_widget;
}
else
{
// Delete the dock widget
delete child_widget->parentWidget();
}
}
bool MapEditorController::save(const QString& path)
{
if (map)
{
if (editing_in_progress)
{
QMessageBox::warning(window, tr("Editing in progress"), tr("The map is currently being edited. Please finish the edit operation before saving."));
return false;
}
bool success = map->saveTo(path, main_view);
if (success)
window->showStatusBarMessage(tr("Map saved"), 1000);
return success;
}
else
return false;
}
bool MapEditorController::exportTo(const QString& path, const FileFormat* format)
{
if (map && !editing_in_progress)
{
return map->exportTo(path, main_view, format);
}
return false;
}
bool MapEditorController::load(const QString& path, QWidget* dialog_parent)
{
if (!dialog_parent)
dialog_parent = window;
if (!map)
{
map = new Map();
main_view = new MapView(this, map);
}
bool success = map->loadFrom(path, dialog_parent, main_view);
if (success)
{
setMapAndView(map, main_view);
}
else
{
delete map;
map = nullptr;
main_view = nullptr;
}
return success;
}
void MapEditorController::attach(MainWindow* window)
{
print_dock_widget = nullptr;
measure_dock_widget = nullptr;
color_dock_widget = nullptr;
symbol_dock_widget = nullptr;
std::function<void(const QString&)> zoom_display_function;
this->window = window;
if (mode == MapEditor)
{
window->setHasUnsavedChanges(map->hasUnsavedChanges());
}
connect(map, &Map::hasUnsavedChanged, window, &MainWindow::setHasUnsavedChanges);
#ifdef Q_OS_ANDROID
QAndroidJniObject::callStaticMethod<void>("org/openorienteering/mapper/MapperActivity",
"lockOrientation",
"()V");
#endif
if (mobile_mode)
{
window->setWindowState(window->windowState() | Qt::WindowFullScreen);
zoom_display_function = [window](const QString& text) {
window->showStatusBarMessage(text, 1000);
};
}
else
{
// Add zoom / cursor position field to status bar
auto statusbar_zoom_icon = new QLabel();
auto fontmetrics = statusbar_zoom_icon->fontMetrics();
auto pixmap = QPixmap(QLatin1String(":/images/magnifying-glass.png"));
auto scale = qreal(fontmetrics.height()) / pixmap.height();
if (scale < 0.9 || scale > 1.1)
pixmap = pixmap.scaledToHeight(qRound(scale * pixmap.height()), Qt::SmoothTransformation);
statusbar_zoom_icon->setPixmap(pixmap);
auto statusbar_zoom_label = new QLabel();
statusbar_zoom_label->setMinimumWidth(fontmetrics.width(QLatin1String(" 0.333x")));
statusbar_zoom_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
statusbar_zoom_label->setFrameShape(QFrame::NoFrame);
zoom_display_function = [statusbar_zoom_label](const QString& text) {
statusbar_zoom_label->setText(text);
};
statusbar_zoom_frame = new QFrame();
#ifdef Q_OS_WIN
statusbar_zoom_frame->setFrameShape(QFrame::NoFrame);
#else
statusbar_zoom_frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
#endif
auto statusbar_zoom_frame_layout = new QHBoxLayout();
statusbar_zoom_frame_layout->setMargin(0);
statusbar_zoom_frame_layout->setSpacing(0);
statusbar_zoom_frame_layout->addSpacing(1);
statusbar_zoom_frame_layout->addWidget(statusbar_zoom_icon);
statusbar_zoom_frame_layout->addWidget(statusbar_zoom_label);
statusbar_zoom_frame->setLayout(statusbar_zoom_frame_layout);
statusbar_cursorpos_label = new QLabel();
#ifdef Q_OS_WIN
statusbar_cursorpos_label->setFrameShape(QFrame::NoFrame);
#else
statusbar_cursorpos_label->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
#endif
statusbar_cursorpos_label->setMinimumWidth(fontmetrics.width(QLatin1String("-3,333.33 -333.33 (mm)")));
statusbar_cursorpos_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
window->statusBar()->addPermanentWidget(statusbar_zoom_frame);
window->statusBar()->addPermanentWidget(statusbar_cursorpos_label);
}
// Create map widget
map_widget = new MapWidget(mode == MapEditor, mode == SymbolEditor);
map_widget->setMapView(main_view);
map_widget->setZoomDisplay(zoom_display_function);
// Create menu and toolbar together, so actions can be inserted into one or both
if (mode == MapEditor)
{
gps_display = new GPSDisplay(map_widget, map->getGeoreferencing());
gps_marker_display = new GPSTemporaryMarkers(map_widget, gps_display);
createActions();
if (mobile_mode)
{
createMobileGUI();
compass_display = new CompassDisplay(map_widget->parentWidget());
compass_display->setVisible(false);
}
else
{
map_widget->setCursorposLabel(statusbar_cursorpos_label);
window->setCentralWidget(map_widget);
createMenuAndToolbars();
restoreWindowState();
}
}
else if (mode == SymbolEditor)
{
map_widget->setCursorposLabel(statusbar_cursorpos_label);
window->setCentralWidget(map_widget);
}
// Update enabled/disabled state for the tools ...
updateWidgets();
templateAvailabilityChanged();
// ... and make sure it is kept up to date for copy/paste
connect(QApplication::clipboard(), &QClipboard::changed, this, &MapEditorController::clipboardChanged);
clipboardChanged(QClipboard::Clipboard);
if (mode == MapEditor)
{
// Create/show the dock widgets
if (mobile_mode)
{
createSymbolWidget(window);
}
else
{
symbol_window_act->trigger();
createColorWindow();
createTemplateWindow();
createTagEditor();
if (map->getNumColors() == 0)
QTimer::singleShot(0, color_dock_widget, SLOT(show())); // clazy:exclude=old-style-connect
}
// Auto-select the edit tool
edit_tool_act->setChecked(true);
setEditTool();
// Set the coordinates display mode
coordsDisplayChanged();
}
else
{
// Set the coordinates display mode
map_widget->setCoordsDisplay(MapWidget::MAP_COORDS);
}
}
QAction* MapEditorController::newAction(const char* id, const QString &tr_text, QObject* receiver, const char* slot, const char* icon, const QString& tr_tip, const char* whats_this_link)
{
Q_ASSERT(window); // Qt documentation recommends that actions are created as children of the window they are used in.
QAction* action = new QAction(icon ? QIcon(QLatin1String(":/images/") + QLatin1String(icon)) : QIcon(), tr_text, window);
if (!tr_tip.isEmpty()) action->setStatusTip(tr_tip);
if (whats_this_link) action->setWhatsThis(Util::makeWhatThis(whats_this_link));
if (receiver) QObject::connect(action, SIGNAL(triggered()), receiver, slot);
actionsById[id] = action;
action->setMenuRole(QAction::NoRole);
return action;
}
QAction* MapEditorController::newCheckAction(const char* id, const QString &tr_text, QObject* receiver, const char* slot, const char* icon, const QString& tr_tip, const char* whats_this_link)
{
auto action = newAction(id, tr_text, nullptr, nullptr, icon, tr_tip, whats_this_link);
action->setCheckable(true);
if (receiver) QObject::connect(action, SIGNAL(triggered(bool)), receiver, slot);
return action;
}
QAction* MapEditorController::newToolAction(const char* id, const QString &tr_text, QObject* receiver, const char* slot, const char* icon, const QString& tr_tip, const char* whats_this_link)
{
Q_ASSERT(window); // Qt documentation recommends that actions are created as children of the window they are used in.
QAction* action = new MapEditorToolAction(icon ? QIcon(QLatin1String(":/images/") + QLatin1String(icon)) : QIcon(), tr_text, window);
if (!tr_tip.isEmpty()) action->setStatusTip(tr_tip);
if (whats_this_link) action->setWhatsThis(Util::makeWhatThis(whats_this_link));
if (receiver) QObject::connect(action, SIGNAL(activated()), receiver, slot);
actionsById[id] = action;
return action;
}
QAction* MapEditorController::findAction(const char* id)
{
if (!actionsById.contains(id)) return actionsById[""];
else return actionsById[id];
}
QAction* MapEditorController::getAction(const char* id)
{
return actionsById.contains(id) ? actionsById[id] : nullptr;
}
void MapEditorController::assignKeyboardShortcuts()
{
// Standard keyboard shortcuts
findAction("print")->setShortcut(QKeySequence::Print);
findAction("undo")->setShortcut(QKeySequence::Undo);
findAction("redo")->setShortcut(QKeySequence::Redo);
findAction("cut")->setShortcut(QKeySequence::Cut);
findAction("copy")->setShortcut(QKeySequence::Copy);
findAction("paste")->setShortcut(QKeySequence::Paste);
// Custom keyboard shortcuts
// QKeySequence::Deselect is empty for Windows, so be explicit all select-*
findAction("select-all")->setShortcut(QKeySequence(tr("Ctrl+A")));
findAction("select-nothing")->setShortcut(QKeySequence(tr("Ctrl+Shift+A")));
findAction("invert-selection")->setShortcut(QKeySequence(tr("Ctrl+I")));
findAction("showgrid")->setShortcut(QKeySequence(tr("G")));
findAction("zoomin")->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_F7) << QKeySequence(Qt::Key_Plus) << QKeySequence(Qt::KeypadModifier + Qt::Key_Plus));
findAction("zoomout")->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_F8) << QKeySequence(Qt::Key_Minus) << QKeySequence(Qt::KeypadModifier + Qt::Key_Minus));
findAction("hatchareasview")->setShortcut(QKeySequence(Qt::Key_F2));
findAction("baselineview")->setShortcut(QKeySequence(Qt::Key_F3));
findAction("hidealltemplates")->setShortcut(QKeySequence(Qt::Key_F10));
findAction("overprintsimulation")->setShortcut(QKeySequence(Qt::Key_F4));
findAction("fullscreen")->setShortcut(QKeySequence(Qt::Key_F11));
tags_window_act->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_6));
color_window_act->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_7));
symbol_window_act->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_8));
template_window_act->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_9));
findAction("editobjects")->setShortcut(QKeySequence(tr("E")));
findAction("editlines")->setShortcut(QKeySequence(tr("L")));
findAction("drawpoint")->setShortcut(QKeySequence(tr("S")));
findAction("drawpath")->setShortcut(QKeySequence(tr("P")));
findAction("drawcircle")->setShortcut(QKeySequence(tr("O")));
findAction("drawrectangle")->setShortcut(QKeySequence(tr("Ctrl+R")));
findAction("drawfill")->setShortcut(QKeySequence(tr("F")));
findAction("drawtext")->setShortcut(QKeySequence(tr("T")));
findAction("duplicate")->setShortcut(QKeySequence(tr("D")));
findAction("switchsymbol")->setShortcut(QKeySequence(tr("Ctrl+G")));
findAction("fillborder")->setShortcut(QKeySequence(tr("Ctrl+F")));
findAction("switchdashes")->setShortcut(QKeySequence(tr("Ctrl+D")));
findAction("connectpaths")->setShortcut(QKeySequence(tr("C")));
findAction("rotateobjects")->setShortcut(QKeySequence(tr("R")));
findAction("scaleobjects")->setShortcut(QKeySequence(tr("Z")));
findAction("cutobject")->setShortcut(QKeySequence(tr("K")));
findAction("cuthole")->setShortcut(QKeySequence(tr("H")));
findAction("measure")->setShortcut(QKeySequence(tr("M")));
findAction("booleanunion")->setShortcut(QKeySequence(tr("U")));
findAction("converttocurves")->setShortcut(QKeySequence(tr("N")));
findAction("simplify")->setShortcut(QKeySequence(tr("Ctrl+M")));
}
void MapEditorController::createActions()
{
// Define all the actions, saving them into variables as necessary. Can also get them by ID.
#ifdef QT_PRINTSUPPORT_LIB
auto print_act_mapper = new QSignalMapper(this);
connect(print_act_mapper, QOverload<int>::of(&QSignalMapper::mapped), this, QOverload<int>::of(&MapEditorController::printClicked));
print_act = newAction("print", tr("Print..."), print_act_mapper, SLOT(map()), "print.png", QString{}, "file_menu.html");
print_act_mapper->setMapping(print_act, PrintWidget::PRINT_TASK);
export_image_act = newAction("export-image", tr("&Image"), print_act_mapper, SLOT(map()), nullptr, QString{}, "file_menu.html");
print_act_mapper->setMapping(export_image_act, PrintWidget::EXPORT_IMAGE_TASK);
export_pdf_act = newAction("export-pdf", tr("&PDF"), print_act_mapper, SLOT(map()), nullptr, QString{}, "file_menu.html");
print_act_mapper->setMapping(export_pdf_act, PrintWidget::EXPORT_PDF_TASK);
#else
print_act = nullptr;
export_image_act = nullptr;
export_pdf_act = nullptr;
#endif
undo_act = newAction("undo", tr("Undo"), this, SLOT(undo()), "undo.png", tr("Undo the last step"), "edit_menu.html");
redo_act = newAction("redo", tr("Redo"), this, SLOT(redo()), "redo.png", tr("Redo the last step"), "edit_menu.html");
cut_act = newAction("cut", tr("Cu&t"), this, SLOT(cut()), "cut.png", QString{}, "edit_menu.html");
cut_act->setMenuRole(QAction::TextHeuristicRole);
copy_act = newAction("copy", tr("C&opy"), this, SLOT(copy()), "copy.png", QString{}, "edit_menu.html");
copy_act->setMenuRole(QAction::TextHeuristicRole);
paste_act = newAction("paste", tr("&Paste"), this, SLOT(paste()), "paste", QString{}, "edit_menu.html");
paste_act->setMenuRole(QAction::TextHeuristicRole);
delete_act = newAction("delete", tr("Delete"), this, SLOT(deleteClicked()), "delete.png", QString{}, "toolbars.html#delete");
select_all_act = newAction("select-all", tr("Select all"), this, SLOT(selectAll()), nullptr, QString{}, "edit_menu.html");
select_nothing_act = newAction("select-nothing", tr("Select nothing"), this, SLOT(selectNothing()), nullptr, QString{}, "edit_menu.html");
invert_selection_act = newAction("invert-selection", tr("Invert selection"), this, SLOT(invertSelection()), nullptr, QString{}, "edit_menu.html");
select_by_current_symbol_act = newAction("select-by-symbol", QApplication::translate("OpenOrienteering::SymbolRenderWidget", "Select all objects with selected symbols"), this, SLOT(selectByCurrentSymbols()), nullptr, QString{}, "edit_menu.html");
find_feature.reset(new MapFindFeature(*this));
clear_undo_redo_history_act = newAction("clearundoredohistory", tr("Clear undo / redo history"), this, SLOT(clearUndoRedoHistory()), nullptr, tr("Clear the undo / redo history to reduce map file size."), "edit_menu.html");
show_grid_act = newCheckAction("showgrid", tr("Show grid"), this, SLOT(showGrid()), "grid.png", QString{}, "grid.html");
configure_grid_act = newAction("configuregrid", tr("Configure grid..."), this, SLOT(configureGrid()), "grid.png", QString{}, "grid.html");
pan_act = newToolAction("panmap", tr("Pan"), this, SLOT(pan()), "move.png", QString{}, "view_menu.html");
move_to_gps_pos_act = newAction("movegps", tr("Move to my location"), this, SLOT(moveToGpsPos()), "move-to-gps.png", QString{}, "view_menu.html");
move_to_gps_pos_act->setEnabled(false);
zoom_in_act = newAction("zoomin", tr("Zoom in"), this, SLOT(zoomIn()), "view-zoom-in.png", QString{}, "view_menu.html");
zoom_out_act = newAction("zoomout", tr("Zoom out"), this, SLOT(zoomOut()), "view-zoom-out.png", QString{}, "view_menu.html");
show_all_act = newAction("showall", tr("Show whole map"), this, SLOT(showWholeMap()), "view-show-all.png", QString{}, "view_menu.html");
fullscreen_act = newAction("fullscreen", tr("Toggle fullscreen mode"), window, SLOT(toggleFullscreenMode()), nullptr, QString{}, "view_menu.html");
custom_zoom_act = newAction("setzoom", tr("Set custom zoom factor..."), this, SLOT(setCustomZoomFactorClicked()), nullptr, QString{}, "view_menu.html");
hatch_areas_view_act = newCheckAction("hatchareasview", tr("Hatch areas"), this, SLOT(hatchAreas(bool)), nullptr, QString{}, "view_menu.html");
baseline_view_act = newCheckAction("baselineview", tr("Baseline view"), this, SLOT(baselineView(bool)), nullptr, QString{}, "view_menu.html");
hide_all_templates_act = newCheckAction("hidealltemplates", tr("Hide all templates"), this, SLOT(hideAllTemplates(bool)), nullptr, QString{}, "view_menu.html");
overprinting_simulation_act = newCheckAction("overprintsimulation", tr("Overprinting simulation"), this, SLOT(overprintingSimulation(bool)), nullptr, QString{}, "view_menu.html");
symbol_window_act = newCheckAction("symbolwindow", tr("Symbol window"), this, SLOT(showSymbolWindow(bool)), "symbols.png", tr("Show/Hide the symbol window"), "symbol_dock_widget.html");
color_window_act = newCheckAction("colorwindow", tr("Color window"), this, SLOT(showColorWindow(bool)), "colors.png", tr("Show/Hide the color window"), "color_dock_widget.html");
symbol_set_id_act = newAction("symbol-set-id", tr("Symbol set ID..."), this, SLOT(symbolSetIdClicked()), nullptr, tr("Edit the symbol set ID"), nullptr);
load_symbols_from_act = newAction("loadsymbols", tr("Replace symbol set..."), this, SLOT(loadSymbolsFromClicked()), nullptr, tr("Replace the symbols with those from another map file"), "symbol_replace_dialog.html");
load_crt_act = newAction("loadcrt", tr("Load CRT file..."), this, SLOT(loadCrtClicked()), nullptr, tr("Assign new symbols by cross-reference table"), "symbol_replace_dialog.html");
/*QAction* load_colors_from_act = newAction("loadcolors", tr("Load colors from..."), this, SLOT(loadColorsFromClicked()), nullptr, tr("Replace the colors with those from another map file"));*/
scale_all_symbols_act = newAction("scaleall", tr("Scale all symbols..."), this, SLOT(scaleAllSymbolsClicked()), nullptr, tr("Scale the whole symbol set"), "map_menu.html");
georeferencing_act = newAction("georef", tr("Georeferencing..."), this, SLOT(editGeoreferencing()), nullptr, QString{}, "georeferencing.html");
scale_map_act = newAction("scalemap", tr("Change map scale..."), this, SLOT(scaleMapClicked()), "tool-scale.png", tr("Change the map scale and adjust map objects and symbol sizes"), "map_menu.html");
rotate_map_act = newAction("rotatemap", tr("Rotate map..."), this, SLOT(rotateMapClicked()), "tool-rotate.png", tr("Rotate the whole map"), "map_menu.html");
map_notes_act = newAction("mapnotes", tr("Map notes..."), this, SLOT(mapNotesClicked()), nullptr, QString{}, "map_menu.html");
template_window_act = newCheckAction("templatewindow", tr("Template setup window"), this, SLOT(showTemplateWindow(bool)), "templates", tr("Show/Hide the template window"), "templates_menu.html");
//QAction* template_config_window_act = newCheckAction("templateconfigwindow", tr("Template configurations window"), this, SLOT(showTemplateConfigurationsWindow(bool)), "window-new", tr("Show/Hide the template configurations window"));
//QAction* template_visibilities_window_act = newCheckAction("templatevisibilitieswindow", tr("Template visibilities window"), this, SLOT(showTemplateVisbilitiesWindow(bool)), "window-new", tr("Show/Hide the template visibilities window"));
open_template_act = newAction("opentemplate", tr("Open template..."), this, SLOT(openTemplateClicked()), nullptr, QString{}, "templates_menu.html");
reopen_template_act = newAction("reopentemplate", tr("Reopen template..."), this, SLOT(reopenTemplateClicked()), nullptr, QString{}, "templates_menu.html");
tags_window_act = newCheckAction("tagswindow", tr("Tag editor"), this, SLOT(showTagsWindow(bool)), "window-new", tr("Show/Hide the tag editor window"), "tag_editor.html");
edit_tool_act = newToolAction("editobjects", tr("Edit objects"), this, SLOT(editToolClicked()), "tool-edit.png", QString{}, "toolbars.html#tool_edit_point");
edit_line_tool_act = newToolAction("editlines", tr("Edit lines"), this, SLOT(editLineToolClicked()), "tool-edit-line.png", QString{}, "toolbars.html#tool_edit_line");
draw_point_act = newToolAction("drawpoint", tr("Set point objects"), this, SLOT(drawPointClicked()), "draw-point.png", QString{}, "toolbars.html#tool_draw_point");
draw_path_act = newToolAction("drawpath", tr("Draw paths"), this, SLOT(drawPathClicked()), "draw-path.png", QString{}, "toolbars.html#tool_draw_path");
draw_circle_act = newToolAction("drawcircle", tr("Draw circles and ellipses"), this, SLOT(drawCircleClicked()), "draw-circle.png", QString{}, "toolbars.html#tool_draw_circle");
draw_rectangle_act = newToolAction("drawrectangle", tr("Draw rectangles"), this, SLOT(drawRectangleClicked()), "draw-rectangle.png", QString{}, "toolbars.html#tool_draw_rectangle");
draw_freehand_act = newToolAction("drawfreehand", tr("Draw free-handedly"), this, SLOT(drawFreehandClicked()), "draw-freehand.png", QString{}, "toolbars.html#tool_draw_freehand"); // TODO: documentation
draw_fill_act = newToolAction("drawfill", tr("Fill bounded areas"), this, SLOT(drawFillClicked()), "tool-fill.png", QString{}, "toolbars.html#tool_draw_fill"); // TODO: documentation
draw_text_act = newToolAction("drawtext", tr("Write text"), this, SLOT(drawTextClicked()), "draw-text.png", QString{}, "toolbars.html#tool_draw_text");
duplicate_act = newAction("duplicate", tr("Duplicate"), this, SLOT(duplicateClicked()), "tool-duplicate.png", QString{}, "toolbars.html#duplicate");
switch_symbol_act = newAction("switchsymbol", tr("Switch symbol"), this, SLOT(switchSymbolClicked()), "tool-switch-symbol.png", QString{}, "toolbars.html#switch_symbol");
fill_border_act = newAction("fillborder", tr("Fill / Create border"), this, SLOT(fillBorderClicked()), "tool-fill-border.png", QString{}, "toolbars.html#fill_create_border");
switch_dashes_act = newAction("switchdashes", tr("Switch dash direction"), this, SLOT(switchDashesClicked()), "tool-switch-dashes", QString{}, "toolbars.html#switch_dashes");
connect_paths_act = newAction("connectpaths", tr("Connect paths"), this, SLOT(connectPathsClicked()), "tool-connect-paths.png", QString{}, "toolbars.html#connect");
cut_tool_act = newToolAction("cutobject", tr("Cut object"), this, SLOT(cutClicked()), "tool-cut.png", QString{}, "toolbars.html#cut_tool");
cut_hole_act = newToolAction("cuthole", tr("Cut free form hole"), this, SLOT(cutHoleClicked()), "tool-cut-hole.png", QString{}, "toolbars.html#cut_hole"); // cut hole using a path
cut_hole_circle_act = newToolAction("cutholecircle", tr("Cut round hole"), this, SLOT(cutHoleCircleClicked()), "tool-cut-hole.png", QString{}, "toolbars.html#cut_hole");
cut_hole_rectangle_act = newToolAction("cutholerectangle", tr("Cut rectangular hole"), this, SLOT(cutHoleRectangleClicked()), "tool-cut-hole.png", QString{}, "toolbars.html#cut_hole");
cut_hole_menu = new QMenu(tr("Cut hole"));
cut_hole_menu->menuAction()->setMenuRole(QAction::NoRole);
cut_hole_menu->setIcon(QIcon(QString::fromLatin1(":/images/tool-cut-hole.png")));
cut_hole_menu->addAction(cut_hole_act);
cut_hole_menu->addAction(cut_hole_circle_act);
cut_hole_menu->addAction(cut_hole_rectangle_act);
rotate_act = newToolAction("rotateobjects", tr("Rotate objects"), this, SLOT(rotateClicked()), "tool-rotate.png", QString{}, "toolbars.html#rotate");
rotate_pattern_act = newToolAction("rotatepatterns", tr("Rotate pattern"), this, SLOT(rotatePatternClicked()), "tool-rotate-pattern.png", QString{}, "toolbars.html#tool_rotate_pattern");
scale_act = newToolAction("scaleobjects", tr("Scale objects"), this, SLOT(scaleClicked()), "tool-scale.png", QString{}, "toolbars.html#scale");
measure_act = newCheckAction("measure", tr("Measure lengths and areas"), this, SLOT(measureClicked(bool)), "tool-measure.png", QString{}, "toolbars.html#measure");
boolean_union_act = newAction("booleanunion", tr("Unify areas"), this, SLOT(booleanUnionClicked()), "tool-boolean-union.png", QString{}, "toolbars.html#unify_areas");
boolean_intersection_act = newAction("booleanintersection", tr("Intersect areas"), this, SLOT(booleanIntersectionClicked()), "tool-boolean-intersection.png", QString{}, "toolbars.html#intersect_areas");
boolean_difference_act = newAction("booleandifference", tr("Cut away from area"), this, SLOT(booleanDifferenceClicked()), "tool-boolean-difference.png", QString{}, "toolbars.html#area_difference");
boolean_xor_act = newAction("booleanxor", tr("Area XOr"), this, SLOT(booleanXOrClicked()), "tool-boolean-xor.png", QString{}, "toolbars.html#area_xor");
boolean_merge_holes_act = newAction("booleanmergeholes", tr("Merge area holes"), this, SLOT(booleanMergeHolesClicked()), "tool-boolean-merge-holes.png", QString{}, "toolbars.html#area_merge_holes"); // TODO:documentation
convert_to_curves_act = newAction("converttocurves", tr("Convert to curves"), this, SLOT(convertToCurvesClicked()), "tool-convert-to-curves.png", QString{}, "toolbars.html#convert_to_curves");
simplify_path_act = newAction("simplify", tr("Simplify path"), this, SLOT(simplifyPathClicked()), "tool-simplify-path.png", QString{}, "toolbars.html#simplify_path");
cutout_physical_act = newToolAction("cutoutphysical", tr("Cutout"), this, SLOT(cutoutPhysicalClicked()), "tool-cutout-physical.png", QString{}, "toolbars.html#cutout_physical");
cutaway_physical_act = newToolAction("cutawayphysical", tr("Cut away"), this, SLOT(cutawayPhysicalClicked()), "tool-cutout-physical-inner.png", QString{}, "toolbars.html#cutaway_physical");
distribute_points_act = newAction("distributepoints", tr("Distribute points along path"), this, SLOT(distributePointsClicked()), "tool-distribute-points.png", QString{}, "toolbars.html#distribute_points"); // TODO: write documentation
paint_on_template_act = new QAction(QIcon(QString::fromLatin1(":/images/pencil.png")), tr("Paint on template"), this);
paint_on_template_act->setMenuRole(QAction::NoRole);
paint_on_template_act->setCheckable(true);
paint_on_template_act->setWhatsThis(Util::makeWhatThis("toolbars.html#draw_on_template"));
connect(paint_on_template_act, &QAction::triggered, this, &MapEditorController::paintOnTemplateClicked);
paint_on_template_settings_act = new QAction(QIcon(QString::fromLatin1(":/images/paint-on-template-settings.png")), tr("Paint on template settings"), this);
paint_on_template_settings_act->setMenuRole(QAction::NoRole);
paint_on_template_settings_act->setWhatsThis(Util::makeWhatThis("toolbars.html#draw_on_template"));
connect(paint_on_template_settings_act, &QAction::triggered, this, &MapEditorController::paintOnTemplateSelectClicked);
touch_cursor_action = newCheckAction("touchcursor", tr("Enable touch cursor"), map_widget, SLOT(enableTouchCursor(bool)), "tool-touch-cursor.png", QString{}, "toolbars.html#touch_cursor"); // TODO: write documentation
gps_display_action = newCheckAction("gpsdisplay", tr("Enable GPS display"), this, SLOT(enableGPSDisplay(bool)), "tool-gps-display.png", QString{}, "toolbars.html#gps_display"); // TODO: write documentation
gps_display_action->setEnabled(map->getGeoreferencing().isValid() && ! map->getGeoreferencing().isLocal());
gps_distance_rings_action = newCheckAction("gpsdistancerings", tr("Enable GPS distance rings"), this, SLOT(enableGPSDistanceRings(bool)), "gps-distance-rings.png", QString{}, "toolbars.html#gps_distance_rings"); // TODO: write documentation
gps_distance_rings_action->setEnabled(false);
draw_point_gps_act = newToolAction("drawpointgps", tr("Set point object at GPS position"), this, SLOT(drawPointGPSClicked()), "draw-point-gps.png", QString{}, "toolbars.html#tool_draw_point_gps"); // TODO: write documentation
draw_point_gps_act->setEnabled(false);
gps_temporary_point_act = newAction("gpstemporarypoint", tr("Set temporary marker at GPS position"), this, SLOT(gpsTemporaryPointClicked()), "gps-temporary-point.png", QString{}, "toolbars.html#gps_temporary_point"); // TODO: write documentation
gps_temporary_point_act->setEnabled(false);
gps_temporary_path_act = newCheckAction("gpstemporarypath", tr("Create temporary path at GPS position"), this, SLOT(gpsTemporaryPathClicked(bool)), "gps-temporary-path.png", QString{}, "toolbars.html#gps_temporary_path"); // TODO: write documentation
gps_temporary_path_act->setEnabled(false);
gps_temporary_clear_act = newAction("gpstemporaryclear", tr("Clear temporary GPS markers"), this, SLOT(gpsTemporaryClearClicked()), "gps-temporary-clear.png", QString{}, "toolbars.html#gps_temporary_clear"); // TODO: write documentation
gps_temporary_clear_act->setEnabled(false);
compass_action = newCheckAction("compassdisplay", tr("Enable compass display"), this, SLOT(enableCompassDisplay(bool)), "compass.png", QString{}, "toolbars.html#compass_display"); // TODO: write documentation
align_map_with_north_act = newCheckAction("alignmapwithnorth", tr("Align map with north"), this, SLOT(alignMapWithNorth(bool)), "rotate-map.png", QString{}, "toolbars.html#align_map_with_north"); // TODO: write documentation
mappart_add_act = newAction("addmappart", tr("Add new part..."), this, SLOT(addMapPart()));
mappart_rename_act = newAction("renamemappart", tr("Rename current part..."), this, SLOT(renameMapPart()));
mappart_remove_act = newAction("removemappart", tr("Remove current part"), this, SLOT(removeMapPart()));
mappart_merge_act = newAction("mergemapparts", tr("Merge all parts"), this, SLOT(mergeAllMapParts()));
import_act = newAction("import", tr("Import..."), this, SLOT(importClicked()), nullptr, QString{}, "file_menu.html");
map_coordinates_act = new QAction(tr("Map coordinates"), this);
map_coordinates_act->setCheckable(true);
projected_coordinates_act = new QAction(tr("Projected coordinates"), this);
projected_coordinates_act->setCheckable(true);
geographic_coordinates_act = new QAction(tr("Latitude/Longitude (Dec)"), this);
geographic_coordinates_act->setCheckable(true);
geographic_coordinates_dms_act = new QAction(tr("Latitude/Longitude (DMS)"), this);
geographic_coordinates_dms_act->setCheckable(true);
auto coordinates_group = new QActionGroup(this);
coordinates_group->addAction(map_coordinates_act);
coordinates_group->addAction(projected_coordinates_act);
coordinates_group->addAction(geographic_coordinates_act);