Ticket #6159: MVScreenshots.diff

File MVScreenshots.diff, 15.7 KB (added by robert.mcnamara@…, 15 years ago)

Patch to add screenshot metadata to MV

Line 
1Index: mythvideo/mythvideo/videodlg.h
2===================================================================
3--- mythvideo/mythvideo/videodlg.h      (revision 19786)
4+++ mythvideo/mythvideo/videodlg.h      (working copy)
5@@ -111,6 +111,7 @@
6     virtual void loadData();
7     void fetchVideos();
8     QString GetCoverImage(MythGenericTree *node);
9+    QString GetScreenshot(MythGenericTree *node);
10 
11     Metadata *GetMetadata(MythUIButtonListItem *item);
12 
13@@ -183,6 +184,7 @@
14     MythUIText       *m_crumbText;
15 
16     MythUIImage      *m_coverImage;
17+    MythUIImage      *m_screenshot;
18 
19     MythUIStateType  *m_parentalLevelState;
20     MythUIStateType  *m_videoLevelState;
21Index: mythvideo/mythvideo/metadatalistmanager.cpp
22===================================================================
23--- mythvideo/mythvideo/metadatalistmanager.cpp (revision 19786)
24+++ mythvideo/mythvideo/metadatalistmanager.cpp (working copy)
25@@ -113,7 +113,7 @@
26     const QString BaseMetadataQuery(
27         "SELECT title, director, plot, rating, year, userrating,"
28         "length, filename, showlevel, coverfile, inetref, childid,"
29-        "browse, playcommand, category, intid, trailer FROM videometadata");
30+        "browse, playcommand, category, intid, trailer, screenshot FROM videometadata");
31 
32     query.prepare(BaseMetadataQuery);
33 
34Index: mythvideo/mythvideo/metadata.cpp
35===================================================================
36--- mythvideo/mythvideo/metadata.cpp    (revision 19786)
37+++ mythvideo/mythvideo/metadata.cpp    (working copy)
38@@ -88,7 +88,7 @@
39 
40   public:
41     MetadataImp(const QString &filename, const QString &trailer, const QString &coverfile,
42-             const QString &title, int year,
43+             const QString &screenshot, const QString &title, int year,
44              const QString &inetref, const QString &director,
45              const QString &plot, float userrating,
46              const QString &rating, int length,
47@@ -103,8 +103,8 @@
48         m_rating(rating), m_playcommand(playcommand), m_category(category),
49         m_genres(genres), m_countries(countries), m_cast(cast),
50         m_filename(filename), m_trailer(trailer), m_coverfile(coverfile),
51-        m_categoryID(categoryID), m_childID(childID), m_year(year),
52-        m_length(length), m_showlevel(showlevel), m_browse(browse), m_id(id),
53+        m_screenshot(screenshot), m_categoryID(categoryID), m_childID(childID),
54+        m_year(year), m_length(length), m_showlevel(showlevel), m_browse(browse), m_id(id),
55         m_userrating(userrating)
56     {
57         VideoCategory::getCategory().get(m_categoryID, m_category);
58@@ -137,6 +137,7 @@
59             m_filename = rhs.m_filename;
60             m_trailer = rhs.m_trailer;
61             m_coverfile = rhs.m_coverfile;
62+            m_screenshot = rhs.m_screenshot;
63 
64             m_categoryID = rhs.m_categoryID;
65             m_childID = rhs.m_childID;
66@@ -216,6 +217,9 @@
67     const QString &getCoverFile() const { return m_coverfile; }
68     void setCoverFile(const QString &coverFile) { m_coverfile = coverFile; }
69 
70+    const QString &getScreenshot() const { return m_screenshot; }
71+    void setScreenshot(const QString &screenshot) { m_screenshot = screenshot; }
72+
73     int getCategoryID() const
74     {
75         return m_categoryID;
76@@ -281,6 +285,7 @@
77     QString m_filename;
78     QString m_trailer;
79     QString m_coverfile;
80+    QString m_screenshot;
81 
82     int m_categoryID;
83     int m_childID;
84@@ -383,8 +388,8 @@
85 void MetadataImp::Reset()
86 {
87     MetadataImp tmp(m_filename, VIDEO_TRAILER_DEFAULT, VIDEO_COVERFILE_DEFAULT,
88-                    Metadata::FilenameToTitle(m_filename), VIDEO_YEAR_DEFAULT,
89-                    VIDEO_INETREF_DEFAULT, VIDEO_DIRECTOR_DEFAULT,
90+                    VIDEO_SCREENSHOT_DEFAULT, Metadata::FilenameToTitle(m_filename),
91+                    VIDEO_YEAR_DEFAULT, VIDEO_INETREF_DEFAULT, VIDEO_DIRECTOR_DEFAULT,
92                     VIDEO_PLOT_DEFAULT, 0.0, VIDEO_RATING_DEFAULT, 0, m_id,
93                     ParentalLevel::plLowest, 0, -1, true, "", "",
94                     Metadata::genre_list(), Metadata::country_list(), Metadata::cast_list());
95@@ -475,6 +480,7 @@
96     m_categoryID = query.value(14).toInt();
97     m_id = query.value(15).toInt();
98     m_trailer = query.value(16).toString();
99+    m_screenshot = query.value(17).toString();
100 
101     VideoCategory::getCategory().get(m_categoryID, m_category);
102 
103@@ -500,6 +506,8 @@
104         m_rating = VIDEO_RATING_DEFAULT;
105     if (m_coverfile.isEmpty())
106         m_coverfile = VIDEO_COVERFILE_DEFAULT;
107+    if (m_screenshot.isEmpty())
108+        m_screenshot = VIDEO_SCREENSHOT_DEFAULT;
109     if (m_trailer.isEmpty())
110         m_trailer = VIDEO_TRAILER_DEFAULT;
111     if (m_inetref.isEmpty())
112@@ -519,9 +527,10 @@
113 
114         query.prepare("INSERT INTO videometadata (title,director,plot,"
115                       "rating,year,userrating,length,filename,showlevel,"
116-                      "coverfile,inetref,browse,trailer) VALUES (:TITLE, :DIRECTOR, "
117-                      ":PLOT, :RATING, :YEAR, :USERRATING, :LENGTH, "
118-                      ":FILENAME, :SHOWLEVEL, :COVERFILE, :INETREF, :BROWSE, :TRAILER)");
119+                      "coverfile,inetref,browse,trailer,screenshot) VALUES (:TITLE, "
120+                      ":DIRECTOR, :PLOT, :RATING, :YEAR, :USERRATING, :LENGTH, "
121+                      ":FILENAME, :SHOWLEVEL, :COVERFILE, :INETREF, :BROWSE, "
122+                      ":TRAILER, :SCREENSHOT)");
123 
124     }
125     else
126@@ -531,8 +540,8 @@
127                       "year = :YEAR, userrating = :USERRATING, "
128                       "length = :LENGTH, filename = :FILENAME, trailer = :TRAILER, "
129                       "showlevel = :SHOWLEVEL, coverfile = :COVERFILE, "
130-                      "inetref = :INETREF, browse = :BROWSE, "
131-                      "playcommand = :PLAYCOMMAND, childid = :CHILDID, "
132+                      "screenshot = :SCREENSHOT, inetref = :INETREF, "
133+                      "browse = :BROWSE, playcommand = :PLAYCOMMAND, childid = :CHILDID, "
134                       "category = :CATEGORY WHERE intid = :INTID");
135 
136         query.bindValue(":PLAYCOMMAND", m_playcommand);
137@@ -552,6 +561,7 @@
138     query.bindValue(":TRAILER", m_trailer);
139     query.bindValue(":SHOWLEVEL", m_showlevel);
140     query.bindValue(":COVERFILE", m_coverfile);
141+    query.bindValue(":SCREENSHOT", m_screenshot);
142     query.bindValue(":INETREF", m_inetref);
143     query.bindValue(":BROWSE", m_browse);
144 
145@@ -783,7 +793,8 @@
146     return ret;
147 }
148 
149-Metadata::Metadata(const QString &filename, const QString &trailer, const QString &coverfile,
150+Metadata::Metadata(const QString &filename, const QString &trailer,
151+             const QString &coverfile, const QString &screenshot,
152              const QString &title, int year,
153              const QString &inetref, const QString &director,
154              const QString &plot, float userrating,
155@@ -795,10 +806,10 @@
156              const country_list &countries,
157              const cast_list &cast)
158 {
159-    m_imp = new MetadataImp(filename, trailer, coverfile, title, year, inetref, director,
160-                            plot, userrating, rating, length, id, showlevel,
161-                            categoryID, childID, browse, playcommand, category,
162-                            genres, countries, cast);
163+    m_imp = new MetadataImp(filename, trailer, coverfile, screenshot, title,
164+                            year, inetref, director, plot, userrating, rating,
165+                            length, id, showlevel, categoryID, childID, browse,
166+                            playcommand, category, genres, countries, cast);
167 }
168 
169 Metadata::~Metadata()
170@@ -1011,6 +1022,16 @@
171     m_imp->setCoverFile(coverFile);
172 }
173 
174+const QString &Metadata::Screenshot() const
175+{
176+    return m_imp->getScreenshot();
177+}
178+                           
179+void Metadata::setScreenshot(const QString &screenshot)
180+{
181+    m_imp->setScreenshot(screenshot);
182+}   
183+
184 const QString &Metadata::Category() const
185 {
186     return m_imp->getCategory();
187Index: mythvideo/mythvideo/globalsettings.cpp
188===================================================================
189--- mythvideo/mythvideo/globalsettings.cpp      (revision 19786)
190+++ mythvideo/mythvideo/globalsettings.cpp      (working copy)
191@@ -247,6 +270,18 @@
192     return gc;
193 }
194 
195+HostLineEdit *VideoScreenshotDirectory()
196+{
197+    HostLineEdit *gc = new HostLineEdit("VideoScreenshotDir");
198+    gc->setLabel(QObject::tr("Directory that holds movie screenshots"));
199+    gc->setValue(GetConfDir() + "/MythVideo/Screenshots");
200+    gc->setHelpText(QObject::tr("This directory must exist, and the user "
201+                    "running MythVideo needs to have read/write permission "
202+                    "to the directory."));
203+    return gc;
204+}
205+
206+
207 HostLineEdit *TrailerDirectory()
208 {
209     HostLineEdit *gc = new HostLineEdit("mythvideo.TrailersDir");
210@@ -682,7 +716,10 @@
211     VConfigPage page1(pages, false);
212     page1->addChild(VideoStartupDirectory());
213     page1->addChild(VideoArtworkDirectory());
214+    page1->addChild(VideoScreenshotDirectory());
215     page1->addChild(VideoDefaultView());
216 
217     VConfigPage page2(pages, false);
218     page2->addChild(VideoListUnknownFiletypes());
219Index: mythvideo/mythvideo/globals.cpp
220===================================================================
221--- mythvideo/mythvideo/globals.cpp     (revision 19786)
222+++ mythvideo/mythvideo/globals.cpp     (working copy)
223@@ -16,6 +16,7 @@
224 const QString VIDEO_INETREF_DEFAULT = "00000000";
225 const QString VIDEO_COVERFILE_DEFAULT = QObject::tr("No Cover");
226 const QString VIDEO_TRAILER_DEFAULT;
227+const QString VIDEO_SCREENSHOT_DEFAULT;
228 const QString VIDEO_RATING_DEFAULT = QObject::tr("NR");
229 const QString VIDEO_PLOT_DEFAULT = QObject::tr("None");
230 const QString VIDEO_CAST_DEFAULT = VIDEO_CAST_UNKNOWN;
231Index: mythvideo/mythvideo/dbcheck.cpp
232===================================================================
233--- mythvideo/mythvideo/dbcheck.cpp     (revision 19786)
234+++ mythvideo/mythvideo/dbcheck.cpp     (working copy)
235@@ -38,7 +38,7 @@
236     const QString lastMythDVDDBVersion = "1002";
237     const QString lastMythVideoVersion = "1010";
238 
239-    const QString currentDatabaseVersion = "1021";
240+    const QString currentDatabaseVersion = "1022";
241 
242     const QString OldMythVideoVersionName = "VideoDBSchemaVer";
243     const QString OldMythDVDVersionName = "DVDDBSchemaVer";
244@@ -816,6 +816,13 @@
245 
246             UpdateDBVersionNumber(MythVideoVersionName, "1021");
247         }
248+
249+        if (dbver == "1021")
250+        {
251+            QStringList updates(
252+                    "ALTER TABLE videometadata ADD `screenshot` TEXT;");
253+            performActualUpdate(updates, "1022", dbver, MythVideoVersionName);
254+        }
255     }
256 }
257 
258Index: mythvideo/mythvideo/videoutils.cpp
259===================================================================
260--- mythvideo/mythvideo/videoutils.cpp  (revision 19786)
261+++ mythvideo/mythvideo/videoutils.cpp  (working copy)
262@@ -70,6 +70,12 @@
263             coverfile == VIDEO_COVERFILE_DEFAULT_OLD;
264 }
265 
266+bool IsDefaultScreenshot(const QString &screenshot)
267+{
268+    return screenshot == VIDEO_SCREENSHOT_DEFAULT;
269+}
270+
271+
272 QString GetDisplayUserRating(float userrating)
273 {
274     return QString::number(userrating, 'f', 1);
275Index: mythvideo/mythvideo/videodlg.cpp
276===================================================================
277--- mythvideo/mythvideo/videodlg.cpp    (revision 19786)
278+++ mythvideo/mythvideo/videodlg.cpp    (working copy)
279@@ -783,6 +783,12 @@
280 
281             tmp["coverfile"] = coverfile;
282 
283+            const QString screenshotfile = metadata->Screenshot();
284+            if (!IsDefaultScreenshot(screenshotfile))
285+                tmp["screenshot"] = screenshotfile;
286+
287+            tmp["screenshotfile"] = screenshotfile;
288+
289             tmp["video_player"] = VideoPlayerCommand::PlayerFor(metadata)
290                     .GetCommandDisplayName();
291             tmp["player"] = metadata->PlayCommand();
292@@ -836,8 +842,10 @@
293         helper h(tmp, dest);
294 
295         h.handleImage("coverimage");
296+        h.handleImage("screenshot");
297 
298         h.handleText("coverfile");
299+        h.handleText("screenshotfile");
300         h.handleText("video_player");
301         h.handleText("player");
302         h.handleText("filename");
303@@ -1162,7 +1170,7 @@
304     MythScreenType(lparent, lname), m_menuPopup(0), m_busyPopup(0),
305     m_videoButtonList(0), m_videoButtonTree(0), m_titleText(0),
306     m_novideoText(0), m_positionText(0), m_crumbText(0), m_coverImage(0),
307-    m_parentalLevelState(0)
308+    m_screenshot(0), m_parentalLevelState(0)
309 {
310     m_d = new VideoDialogPrivate(video_list, type);
311 
312@@ -1240,6 +1248,7 @@
313     UIUtilW::Assign(this, m_crumbText, "breadcrumbs");
314 
315     UIUtilW::Assign(this, m_coverImage, "coverimage");
316+    UIUtilW::Assign(this, m_screenshot, "screenshot");   
317 
318     UIUtilW::Assign(this, m_parentalLevelState, "parentallevel");
319 
320@@ -1484,6 +1493,31 @@
321     return icon_file;
322 }
323 
324+QString VideoDialog::GetScreenshot(MythGenericTree *node)
325+{
326+    int nodeInt = node->getInt();
327+
328+    QString icon_file;
329+
330+    if (nodeInt  == kSubFolder || nodeInt == kUpFolder)  // subdirectory
331+    {
332+        icon_file = VIDEO_SCREENSHOT_DEFAULT;
333+    }
334+    else
335+    {
336+        const Metadata *metadata = GetMetadataPtrFromNode(node);
337+
338+        if (metadata)
339+            icon_file = metadata->Screenshot();
340+    }
341+
342+    if (IsDefaultScreenshot(icon_file))
343+        icon_file.clear();
344+
345+    return icon_file;
346+}
347+
348+
349 bool VideoDialog::keyPressEvent(QKeyEvent *levent)
350 {
351     if (GetFocusWidget()->keyPressEvent(levent))
352Index: mythvideo/mythvideo/videoscan.cpp
353===================================================================
354--- mythvideo/mythvideo/videoscan.cpp   (revision 19786)
355+++ mythvideo/mythvideo/videoscan.cpp   (working copy)
356@@ -216,7 +216,8 @@
357             if (!p->second)
358             {
359                 Metadata newFile(p->first, VIDEO_TRAILER_DEFAULT,
360-                                 VIDEO_COVERFILE_DEFAULT,
361+                                 VIDEO_COVERFILE_DEFAULT,
362+                                 VIDEO_SCREENSHOT_DEFAULT,
363                                  Metadata::FilenameToTitle(p->first),
364                                  VIDEO_YEAR_DEFAULT,
365                                  VIDEO_INETREF_DEFAULT, VIDEO_DIRECTOR_DEFAULT,
366Index: mythvideo/mythvideo/metadata.h
367===================================================================
368--- mythvideo/mythvideo/metadata.h      (revision 19786)
369+++ mythvideo/mythvideo/metadata.h      (working copy)
370@@ -51,6 +51,7 @@
371     Metadata(const QString &filename = QString(),
372              const QString &trailer = QString(),
373              const QString &coverfile = QString(),
374+             const QString &screenshot = QString(),
375              const QString &title = QString(),
376              int year = VIDEO_YEAR_DEFAULT,
377              const QString &inetref = QString(),
378@@ -130,6 +131,9 @@
379     const QString &CoverFile() const;
380     void setCoverFile(const QString &coverFile);
381 
382+    const QString &Screenshot() const;
383+    void setScreenshot(const QString &screenshot);
384+
385     const QString &Category() const;
386 
387     const genre_list &Genres() const;
388Index: mythvideo/mythvideo/globals.h
389===================================================================
390--- mythvideo/mythvideo/globals.h       (revision 19786)
391+++ mythvideo/mythvideo/globals.h       (working copy)
392@@ -14,6 +14,7 @@
393 extern const QString VIDEO_INETREF_DEFAULT;
394 extern const QString VIDEO_COVERFILE_DEFAULT;
395 extern const QString VIDEO_TRAILER_DEFAULT;
396+extern const QString VIDEO_SCREENSHOT_DEFAULT;
397 extern const QString VIDEO_RATING_DEFAULT;
398 extern const QString VIDEO_PLOT_DEFAULT;
399 extern const QString VIDEO_CAST_DEFAULT;
400Index: mythvideo/mythvideo/videoutils.h
401===================================================================
402--- mythvideo/mythvideo/videoutils.h    (revision 19786)
403+++ mythvideo/mythvideo/videoutils.h    (working copy)
404@@ -22,6 +22,7 @@
405 QStringList GetVideoDirs();
406 
407 bool IsDefaultCoverFile(const QString &coverfile);
408+bool IsDefaultScreenshot(const QString &screenshot);
409 
410 class Metadata;
411