Four hours isn't really an issue, but daily stretches of eight hours is very long. This isn't a breed I would recommend owning as a single dog if it is to spend long hours alone, day after day. I regularly rehome cavaliers through rescue, and would not be inclined to place a dog in a home where it will be alone daily, with no animal companion, for eight hour stretches or longer unless people could demonstrate a very serious level of commitment to resolve that issue so the dog won't actually be alone for so long.
I also would not use a dog flap -- this breed is a key target for thieves and opportunists as they are easy to grab and run, easy to sell on to unscrupulous breeders, and expensive to buy in the first place in many countries making them very attractive to thieves. Regularly on the international cavalier lists, and in the lost and found listings here in Ireland, you see posts for stolen cavaliers taken from back gardens even while people are home.
I do think with animal ownership there are two sets of needs and desires -- on the one hand, there's a person who would sometimes dearly love a dog -- but may hardly be at home during most of the life of their dog. On the other side, you have a dog that is a highy social animal, but may be left on its own for most of its life.
A balance can be found, but it takes a serious effort on the human's side. The dog's needs will NOT change; but the human's will HAVE to change significantly to accommodate the dog in a way that gives a decent quality of life to the dog. That may mean arranging midday walkers, getting a companion dog, paying to place the dog in a doggie daycare situation (especially on those 8 hour workdays, especially so if they become regular), and certainly will mean giving a lot of time to your dog when you are at home (eg you can't just arrive in, feed the dog, then head out with friends all evening).
I think a lot of people want a dog to bring back many of the pleasures they had with one when they were a child, for example, but forget that at that time, the dog was probably rarely on its own longer than 3-4 hours a day. That situation has changed now for most people, adding a greater level of active responsibility to taking on a dog. Or else, for some, perhaps realising this isn't the right time for dog ownership (I waited a long time in my adult life even to make the commitment to cats, which are far more capable on their own for long stretches, but made sure to get two).
In general, cavaliers are not a breed that does well left entirely alone for long days but there are ways to work around tis if you are really commited. A midday walk or break is good but still not great for the nature of this breed in particular. Therefore if you are considering a cavalier, I would strongly recommend getting a second dog of whatever breed or mix; and figuring out a way to deal with those 8 hour stretches -- maybe exchanging dogs with another dog owner, doggie daycare, etc. There are more independent breeds who do better left alone, which is also something to consider. I regularly get cavaliers into rescue that are handed over because people have left the dog alone all day and it is clearly deeply unhappy and/or has picked up anxious behaviours like barking all day, chewing, trying to escape, pottying inside, etc. Indeed, the number one reason people turn dogs over to rescue is they don't have enough time for the dog and it has become a problem as a result, and they no longer want or can cope with the cavalier. Just another perspective to consider -- it is often very painful for the people who fall into the latter category to have to surrender their dog so it is much better to be truly honest about what you can offer a dog (rather than vice versa) and make a careful decision about what you can and cannot manage, afford, accommodate.