First-principles theory of the luminescence lineshape for the triplet transition in diamond NV centres