I agree with the travel direction as suggested by Redpaddy - Vienna, Berlin (via Paris), Barcelona, London (via Paris).
To be honest, Barcelona is a bit awkward and travelling to Barcelona from either Berlin or Vienna will take pretty much a full day of train travel, with several (at least 3-4) changes in between as well. Not only that, train itinerary that crosses multiple borders often means you'll have difficulty booking them online on just one site.
Travelling from Barcelona to London, the easiest that I am aware of is overnight train from Barcelona to Paris, then Eurostar from Paris to London (2.5 hours for Eurostar).
Part of the journey would also be on overnight train, and part of the journey would usually be on fast train. If you plan to use Eurail, reservation and supplementary charges will also apply. The most appropriate Eurail would be a 4-countries Eurail, with Austria, Germany, France and Spain on it. UK is not covered by Eurail, so I don't know if it's allowed for travel with Eurostar.
Alternative to train travel to/fro Barcelona, why not consider budget airline such as Ryanair? You can save quite a lot of time and it is much more convenient.
Re time to spend in each of the cities without rushing around too much, I'd suggest at least 3-4 days, and London could do with an extra day. And if you're taking long distance trains, don't forget to factor the travelling time in.