I'm working on "yet another" media manager for movies. So I have a list of movie data in some data structure, including cover images. The user has the option to display these movie items (widgets) in different modes, e.g. "cover only", "cover + title" or "cover + title + year" and so forth. So the first problem is what kind of pattern would I use for easily adding new display modes? Would it be something like this (not tested or anything, just to give an idea of what I've thought):

Qt Code:
  1. typedef QMap<QString, QString> MovieData;
  2.  
  3. QWidget *coverAndTitle(const MovieData &data)
  4. {
  5. QWidget *w = new QWidget;
  6. // Build the widget out of data so that it contains title and cover image
  7. return w;
  8. }
  9.  
  10. QWidget *coverOnly(const MovieData &data)
  11. {
  12. QWidget *w = new QWidget;
  13. // Build the widget out of data so that it contains only cover
  14. return w;
  15. }
  16.  
  17. QList<MovieData> movieDataList;
  18. enum { DisplayMode_Cover, DisplayMode_CoverAndTitle };
  19.  
  20. // ...
  21.  
  22. for(int i = 0; i < movieDataList.size(); ++i)
  23. {
  24. MovieData md = movieDataList.at(i);
  25.  
  26. QWidget *w = nullptr;
  27. if(displayMode == DisplayMode_CoverAndTitle)
  28. {
  29. w = coverAndTitle(md);
  30. }
  31. else if(displayMode == DisplayMode_Cover)
  32. {
  33. w = coverOnly(md);
  34. }
  35.  
  36. // proceed to add this widget to some container where it's displayed
  37. }
  38. }
To copy to clipboard, switch view to plain text mode 

So that's a pretty simplistic solution (if it even works). Would appreciate some feedback on this solution and on better solutions.

Then another problem is if my widgets e.g. take 100x150 pixels of space + 15px margin. So that would probably only display cover image for every movie. I'd want them to behave like this in the container. Drag the vertical bar sideways and you'll see how the yellow boxes behave as the space changes. How would I go about implementing it this way when the user resizes the window the widgets would behave similarly?

Thanks!