Think of two nights as one full day, three nights as two days, etc. Between cities you will have a travel day to relocate. If you get any time to see sights on a travel day, think of it as a bonus rather than something to plan for.
I'm not a big Madrid fan. El Prado is a world class art gallery and definitely worth seeing. The rest of the city is about as old as Baltimore (Maryland) and really doesn't have the history that I like in European cities. Toledo is worth spending some time in, since it was the capital before Madrid and has a great old center. It was our favorite "twisty-road" medieval town.
We stayed four nights in Seville which was great because we were their during the April Fair. If not then (or Holy Week), one full day to see the Alcazar, Cathedral (don't skip either of these, they are both great) and surrounding quarter (down to the Golden Tower on the River) would be enough for a tight trip - so two nights at a minimum. I'd plan to see a Flamenco performance one of those nights - Seville is where Flamenco originates.
Granada, on the other hand, has lots to see. The Alhambra alone is worth a full day to see. I'd plan at least two full days - three nights. Use the second day to see the Cathedral and other sights you're interested in. During one of the evenings, see a Sambra performance (similar to Flamenco) in a cave home.
Barcelona is a great city. I'm sure you can find things to do for however many nights you stay. We stayed four nights, three full days, which I considered a minimum. Beaches in Barcelona aren't special. If you're there during beach weather, you may want to train north to some of the small beach towns along the Costa Brava. I believe it cost about 7 euro to train from the station near the Olympic Village to Arenys de Mar or nearby town. The train goes right along the coast - so when you hop off, you're practically on the beach. I didn't visit some of the tourist destinations up there, to do so you probably want to rent a car. Sitges is popular for gays and lesbians, which may or may not appeal to you.
I'd also throw in a plug for a day stop between Seville and Madrid at Cordoba. The Mesquita is another top sight and the surrounding quarter is really nice. You can take a fast train to Cordoba, give yourself four hours, take a taxi downtown (it's walkable but you won't have too much extra time) to see the old quarter, then catch another fast train to your next destination.