  Heavy quarks are sensitive probes of the colour-deconfined medium formed in
ultra-relativistic heavy-ion collisions, the Quark-Gluon Plasma (QGP). The
ALICE Collaboration measured the production of ${\rm D}^0$, ${\rm D}^+$, ${\rm
D}^{*+}$ and ${\rm D_s}^+$ mesons in Pb-Pb collisions at $\sqrt{s_{\rm
NN}}=5.02~{\rm TeV}$. The properties of the in-medium energy loss and the
possible modification of the charm-quark hadronisation mechanism are
investigated via the measurement of the nuclear modification factor ($R_{\rm
AA}$) of non-strange and strange D mesons. In mid-central collisions, the
measurement of the D-meson elliptic flow ($v_2$) at low and intermediate
transverse momentum ($p_{\rm T}$) gives insight into the participation of the
charm quark in the collective motion of the system, while at high $p_{\rm T}$
it constrains the path-length dependence of the energy loss. The coupling of
the charm quark to the light quarks in the underlying medium is further
investigated with the application of the event-shape engineering (ESE)
technique to D-meson elliptic flow. Finally, the role of the early magnetic
field created in heavy-ion collisions is studied via the first measurement at
the LHC energies of the charged-dependent directed flow ($v_1$) of ${\rm D}^0$
mesons as a function of pseudorapidity.
