First...i dont play 40d but 2010 so a few things may be subtley different with the way dwarf thoughts work
Theres a considerable amount of bad thoughts kicking about that dwarfs mind so its little surprise shes less than happy, in particular loss of a lover is a heavy blow.
having provided engravings/bed in the prison youve taken care of the first part
Assuming you are using a chain rather than a cage for justice it should be possible to put a 1-tile food stockpile and a 1-tile booze stockpile within reach of the chain. This allows you to get more quality stamped goods into her which should help, the dwarf does mention she cant remember the last time she drank alcohol
Over time the negative thoughts about loss of friends/lovers should disappear and the good thoughts will be refreshed as she admires/eats/drinks and her mood will recover.
Removing her from the military is certainly an option to limit future tragedies, though leaving her in may lead to her 'not caring about anything much' which makes her almost impossible to upset. (not 100% certain this happens in 40d)
Overall I'm fairly sure that without the engravings/bed you added this dwarf would have gone melancholy long ago, ive had people tanrum after losing just a pet, shes down a lover, a friend, saw them die, was beaten, locked up, denied alcohol, left hungry and saw vermin she despises