Cut the white parts of the leeks into 1 cm thick slices. Cook in salted water for 4-5 minutes until crisp-tender, then drain.
Clean the mushrooms and slice them. Fry them in a pan over medium-high heat without any fat for 3-4 minutes, stirring occasionally, until the released water evaporates.
Dice the onions and cut the ham into thin strips. Heat the butter in a pan over medium heat and cook the onions and ham for 3-4 minutes until the onions are softened.
In a large bowl, mix the quark, sweet cream, sour cream, eggs, flour, and finely chopped dill or chervil. Fold in the cooked leeks, mushrooms, onions, and ham. Season with salt, pepper, and nutmeg to taste.
Preheat oven to 150°C (302°F). Butter a baking dish and coat the bottom and sides with breadcrumbs. Pour the mixture into the dish and bake for 1 hour. Insert a toothpick into the center—if nothing sticks, the casserole is done.