Skip to content

Major rework of Map's template API and of TemplateListWidget - #1653

Merged
dg0yt merged 26 commits into
masterfrom
template-1
Jun 11, 2020
Merged

Major rework of Map's template API and of TemplateListWidget#1653
dg0yt merged 26 commits into
masterfrom
template-1

Conversation

@dg0yt

@dg0ytdg0yt commented Jun 8, 2020

Copy link
Copy Markdown
Member

Move responsibilites from client code to Map where reasonable.
Factor our a proper TemplateTableModel from TemplateListWidget.

@dg0ytdg0yt linked an issue Jun 8, 2020 that may be closed by this pull request
@lpechaceklpechacek changed the title Major of Map's template API and of TemplateListWidgetMajor rework of Map's template API and of TemplateListWidgetJun 8, 2020
dg0yt added 23 commits June 8, 2020 20:05
Move separate inline definitions either to class or to cpp file:
We don't need to force inlining for getters, and we probaly don't
want inlining for setters.
Consistently use identifier "pos" for the index of the template
(but leaving "i" for closed templates).
Use idiomatic non-member begin().
Fix implicit conversions.
Rewrite findTemplateIndex using std algorithms.
Revise documentation.
Change addTemplate and setTemplate parameter order to the more common
position, template. This also matches the signals.
Add method to move templates in the list, and send a new signal.
Explicitly take, hold, and release strong ownership of templates
by using std::unique_ptr<Template>.
Update the index of the first front template when templates are
added or removed in the background of the map.
Introduce the special value '-1' to insert templates just below
the map.
Rewrite ReopenTemplateDialog::OpenTemplateList::dropEvent to make
use of this API change.
Note that the changed interactions at template deletion require
another TemplateListWidget connection to be marked as queued: When
the template table selection model emits selectionChanged, the
template table still holds the row for the template which is already
removed from Map, so table row <-> template index mappings do not
work correctly in this moment.
Emit signals before adding, moving or removing templates, and when
changing the index of the first front template.
This follows the pattern of signals in QAbstractItemModel. It allows to
do some light-weight independent actions, e.g. initializing template
visibility, before more complex actions.
... when changing the list of templates, changing the start of the
front templates, or being notified of a changed template.
Note: This is the combined state of the templates with regard to what
is saved on disk. It is not the state for repainting the screen.
For all common events, Map knows that setTemplateAreaDirty needs to
be called (and when).
In addition, a change of template visibility shouldn't affect more
than the map widgets attached to the particular map view.
This change leverages Qt's model/view classes, separating the
template list GUI from the the data model.
To let the model properly deal with templates being added to the map
next to the map layer, the map must also explicitly signal whether a
template is meant to be added to the background or not. To avoid
a hard dependency on map.h in target slot declarations, we use
a simple bool, not a more verbose enum in map.h.
Change order of functions for reasonable grouping.
Add '*' to 'auto' where dealing with pointers.
Rename 'getCurrentTemplate' to 'currentTemplate'.
Tear down the tool when the user select another row in the list.
FixesGH-1517 (unintuitive move-template function).
@dg0ytdg0yt linked an issue Jun 9, 2020 that may be closed by this pull request
dg0yt added 2 commits June 10, 2020 07:41
Move full lifecycle control to TemplateListWidget and
TemplatePositionDockWidget.
Turn these dock widget into regular MapEditorController/QMainWindow
dock widgets for which state is saved and restored.
Dock widgets need an object name in order to let QMainWindow properly
save and restore the state. Fixes a runtime warning at the console.
@dg0yt
dg0yt merged commit 3cdc8b8 into masterJun 11, 2020
@dg0yt
dg0yt deleted the template-1 branch June 11, 2020 04:32
Comment threadsrc/core/map.h
typedef std::vector<MapColor*> ColorVector;
typedef std::vector<Symbol*> SymbolVector;
typedef std::vector<Template*> TemplateVector;
typedef std::vector<std::unique_ptr<Template>> TemplateVector;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of unique_ptr obsoletes delete placeholder; in Importer::validate() (file_import_export.cpp). In fact, the delete leads to a crash.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Will look into this tonight.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Release notes updated.
Side note: I meant to test the binaries once more before publishing the draft release, but accidenty hit the wrong button.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Templates window show wrong information after adding Draft template Counter-intuitive behavior of Move template function

2 participants

@dg0yt@lpechacek