In about 20 or so meals out in Italy past july, only once I was asked to wear long pants. It is hard not to wear shorts when it's 30-35 oC outside so I was hardly alone. Casual places with tables both inside and outside are certainly OK with shorts, very formal restaurants are likely to have a problem with them. Even in churches knee-long shorts were OK.
For those who want to look like locals by not wearing shorts - who are you trying to kid? You are tourists and you will look like tourists - shorts or not. My sunglasses were a dead giveaway - guys overthere wear "top gun" "back from the 80s" kind this summer.