QED theory of the spectral line profile and its applications to atoms and ions