Modify the My Movies application so that each Movie object can store an extra piece of information: a QString called "location", which is where the movie is located—for example, the room and shelf. Provide only saving and loading of binary Qt format .mqb files and export and import of XML files, so remove the code for saving and loading pickles and text files. Make sure that your new My Movies application can still read the original application's .mqb and .xml files, that is, files that do not have location data.
The moviedata module's Movie class will need an extra QString attribute, called "location". The MovieContainer class will need several small changes. You will need to have both an old and a current file version number so you know which kind you are dealing with. The formats() method should now return only the string *.mqb, or could be eliminated entirely. The save() and load() methods need to handle only .mqb files, and must account for the location and the different file versions. Similarly the exportXml() method and the two import XML methods must also account for the possible presence of <LOCATION> tags. The changes to the user interface should be obvious, so we won't list them.
None of these changes involves many lines of code, but some are subtle and will take a bit of care to get right. Make sure that you test your changes. For example, load in an old file in .mqb format, and import a file in the old .xml format. Add some locations and save the data in a new .mqb file and export as XML. Read both of these back in to check that everything works properly.
A model solution is provided in the files, chap08/mymovies_ans.pyw, chap08/ moviedata_ans.pyw, chap08/addeditmoviedlg_ans.ui, and chap08/addeditmoviedlg-_ans.py.
Was this article helpful?
Video Marketing Will Never Be The Same Again. Here's How YOU - Or ANYONE - Can Leverage On The Internet's 4th MOST TRAFFICKED WEBSITE TO BOOST YOUR POPULARITY amp PUBLICITY FOR BUSINESS via Video Marketing! With The Emergence Of Web Video Popularity, You CANNOT Afford To Miss Out On This Exponentially Growing Trend - Because It Could Make Or Break Your Popularity amp Business Growth!