Ticket #5818: SWpatch_filemarkup_131008

File SWpatch_filemarkup_131008, 9.5 KB (added by simonwalls@…, 16 years ago)

Commented out the debug-output statements

Line 
1Index: libs/libmythtv/programinfo.cpp
2===================================================================
3--- libs/libmythtv/programinfo.cpp      (revision 17451)
4+++ libs/libmythtv/programinfo.cpp      (working copy)
5@@ -2483,6 +2483,8 @@
6 void ProgramInfo::ClearMarkupMap(int type, long long min_frame,
7                                            long long max_frame) const
8 {
9+    int videoid=0;
10+
11     MSqlQuery query(MSqlQuery::InitCon());
12     QString comp = "";
13 
14@@ -2505,10 +2507,21 @@
15     
16     if (isVideo)
17     {
18+        query.prepare("SELECT intid FROM videometadata"
19+                      " WHERE filename = :PATH ;");
20+        query.bindValue(":PATH", pathname);
21+
22+       if (query.exec() && query.isActive() && query.size() > 0)
23+       {
24+               while(query.next())
25+               videoid = query.value(0).toInt();
26+       }
27+        //VERBOSE(VB_IMPORTANT, QString(LOC + "ClearMarkupMap: Video has id of '%1'")
28+        //                     .arg(videoid));
29         query.prepare("DELETE FROM filemarkup"
30-                      " WHERE filename = :PATH "
31+                      " WHERE filename = :ID "
32                       + comp + ";");
33-        query.bindValue(":PATH", pathname);
34+        query.bindValue(":ID", videoid);
35     }
36     else
37     {
38@@ -2529,6 +2542,8 @@
39                                int type, long long min_frame,
40                                long long max_frame) const
41 {
42+    int videoid=0;
43+
44     QMap<long long, int>::Iterator i;
45     MSqlQuery query(MSqlQuery::InitCon());
46     
47@@ -2567,9 +2582,20 @@
48 
49         if (isVideo)
50         {
51+            query.prepare("SELECT intid FROM videometadata"
52+                          " WHERE filename = :PATH ;");
53+            query.bindValue(":PATH", pathname);
54+
55+           if (query.exec() && query.isActive() && query.size() > 0)
56+           {
57+                   while(query.next())
58+                   videoid = query.value(0).toInt();
59+           }
60+            //VERBOSE(VB_IMPORTANT, QString(LOC + "SetMarkupMap: Video has id of '%1'")
61+            //                 .arg(videoid));
62             query.prepare("INSERT INTO filemarkup (filename, mark, type)"
63-                          " VALUES ( :PATH , :MARK , :TYPE );");
64-            query.bindValue(":PATH", pathname);
65+                          " VALUES ( :ID , :MARK , :TYPE );");
66+            query.bindValue(":ID", videoid);
67         }
68         else
69         {
70@@ -2590,6 +2616,8 @@
71 void ProgramInfo::GetMarkupMap(frm_dir_map_t &marks,
72                                int type, bool mergeIntoMap) const
73 {
74+    int videoid=0;
75+
76     if (!mergeIntoMap)
77         marks.clear();
78 
79@@ -2597,11 +2625,22 @@
80     
81     if (isVideo)
82     {
83+        query.prepare("SELECT intid FROM videometadata"
84+                      " WHERE filename = :PATH ;");
85+        query.bindValue(":PATH", pathname);
86+
87+       if (query.exec() && query.isActive() && query.size() > 0)
88+       {
89+               while(query.next())
90+               videoid = query.value(0).toInt();
91+       }
92+        //VERBOSE(VB_IMPORTANT, QString(LOC + "GetMarkupMap: Video has id of '%1'")
93+        //                     .arg(videoid));
94         query.prepare("SELECT mark, type FROM filemarkup"
95-                      " WHERE filename = :PATH"
96+                      " WHERE filename = :ID"
97                       " AND type = :TYPE"
98                       " ORDER BY mark;");
99-        query.bindValue(":PATH", pathname);
100+        query.bindValue(":ID", videoid);
101     }
102     else
103     {
104@@ -2647,15 +2686,31 @@
105 void ProgramInfo::GetPositionMap(frm_pos_map_t &posMap,
106                                  int type) const
107 {
108+    int videoid=0;
109+
110     posMap.clear();
111     MSqlQuery query(MSqlQuery::InitCon());
112 
113     if (isVideo)
114     {
115-        query.prepare("SELECT mark, offset FROM filemarkup"
116-                      " WHERE filename = :PATH"
117-                      " AND type = :TYPE ;");
118+        //VERBOSE(VB_IMPORTANT, QString(LOC + "GetPositionMap: Searching for '%1'")
119+        //                     .arg(pathname));
120+        query.prepare("SELECT intid FROM videometadata"
121+                      " WHERE filename = :PATH ;");
122         query.bindValue(":PATH", pathname);
123+
124+       if (query.exec() && query.isActive() && query.size() > 0)
125+       {
126+               while(query.next())
127+               videoid = query.value(0).toInt();
128+       }
129+        //VERBOSE(VB_IMPORTANT, QString(LOC + "GetPositionMap: Video has id of '%1'")
130+        //                     .arg(videoid));
131+        query.prepare("SELECT mark, type FROM filemarkup"
132+                      " WHERE filename = :ID"
133+                      " AND type = :TYPE"
134+                      " ORDER BY mark;");
135+        query.bindValue(":ID", videoid);
136     }
137     else
138     {
139@@ -2677,14 +2732,29 @@
140 
141 void ProgramInfo::ClearPositionMap(int type) const
142 {
143+    int videoid=0;
144+
145     MSqlQuery query(MSqlQuery::InitCon());
146   
147     if (isVideo)
148     {
149+        //VERBOSE(VB_IMPORTANT, QString(LOC + "ClearPositionMap: Searching for '%1'")
150+        //                     .arg(pathname));
151+        query.prepare("SELECT intid FROM videometadata"
152+                      " WHERE filename = :PATH ;");
153+        query.bindValue(":PATH", pathname);
154+
155+       if (query.exec() && query.isActive() && query.size() > 0)
156+       {
157+               while(query.next())
158+               videoid = query.value(0).toInt();
159+       }
160+        //VERBOSE(VB_IMPORTANT, QString(LOC + "ClearPositionMap: Video has id of '%1'")
161+        //                     .arg(videoid));
162         query.prepare("DELETE FROM filemarkup"
163-                      " WHERE filename = :PATH"
164+                      " WHERE filename = :ID"
165                       " AND type = :TYPE ;");
166-        query.bindValue(":PATH", pathname);
167+        query.bindValue(":ID", videoid);
168     }
169     else
170     {
171@@ -2705,6 +2775,8 @@
172 void ProgramInfo::SetPositionMap(frm_pos_map_t &posMap, int type,
173                                  long long min_frame, long long max_frame) const
174 {
175+    int videoid=0;
176+
177     QMap<long long, long long>::Iterator i;
178     MSqlQuery query(MSqlQuery::InitCon());
179     QString comp = "";
180@@ -2716,11 +2788,30 @@
181 
182     if (isVideo)
183     {
184+        query.prepare("SELECT intid FROM videometadata"
185+                      " WHERE filename = :PATH ;");
186+        query.bindValue(":PATH", pathname);
187+
188+       if (query.exec() && query.isActive() && query.size() > 0)
189+       {
190+               while(query.next())
191+               videoid = query.value(0).toInt();
192+       }
193+        //VERBOSE(VB_IMPORTANT, QString(LOC + "SetPositionMap: Video has id of '%1'")
194+        //                     .arg(videoid));
195         query.prepare("DELETE FROM filemarkup"
196-                      " WHERE filename = :PATH"
197-                      " AND type = :TYPE"
198+                      " WHERE filename = :ID "
199+                      " AND type = :TYPE "
200                       + comp + ";");
201-        query.bindValue(":PATH", pathname);
202+        query.bindValue(":ID", videoid);
203+
204+        // Keep videoid for later
205+
206+        //query.prepare("DELETE FROM filemarkup"
207+        //              " WHERE filename = :PATH"
208+        //              " AND type = :TYPE"
209+        //              + comp + ";");
210+        //query.bindValue(":PATH", pathname);
211     }
212     else
213     {
214@@ -2759,8 +2850,8 @@
215             query.prepare("INSERT INTO filemarkup"
216                           " (filename, mark, type, offset)"
217                           " VALUES"
218-                          " ( :PATH , :MARK , :TYPE , :OFFSET );");
219-            query.bindValue(":PATH", pathname);
220+                          " ( :ID , :MARK , :TYPE , :OFFSET );");
221+            query.bindValue(":ID", videoid);
222         }
223         else
224         {       
225@@ -2784,6 +2875,8 @@
226 void ProgramInfo::SetPositionMapDelta(frm_pos_map_t &posMap,
227                                       int type) const
228 {
229+    int videoid=0;
230+
231     QMap<long long, long long>::Iterator i;
232     MSqlQuery query(MSqlQuery::InitCon());
233 
234@@ -2794,11 +2887,22 @@
235 
236         if (isVideo)
237         {
238+            query.prepare("SELECT intid FROM videometadata"
239+                       " WHERE filename = :PATH ;");
240+            query.bindValue(":PATH", pathname);
241+       
242+           if (query.exec() && query.isActive() && query.size() > 0)
243+           {
244+                 while(query.next())
245+                 videoid = query.value(0).toInt();
246+            }
247+            //VERBOSE(VB_IMPORTANT, QString(LOC + "SetPositionMapDelta: Video has id of '%1'")
248+            //            .arg(videoid));
249             query.prepare("INSERT INTO filemarkup"
250                           " (filename, mark, type, offset)"
251                           " VALUES"
252-                          " ( :PATH , :MARK , :TYPE , :OFFSET );");
253-            query.bindValue(":PATH", pathname);
254+                          " ( :ID , :MARK , :TYPE , :OFFSET );");
255+            query.bindValue(":ID", videoid);
256         }
257         else
258         {
259@@ -3972,7 +4076,7 @@
260     MSqlQuery query(MSqlQuery::InitCon());
261 
262     query.prepare("SELECT commflagged, cutlist, autoexpire, "
263-                  "editing, bookmark, watched, preserve "
264+                  "editing, bookmark, watched, preserve, transcoded "
265                   "FROM recorded LEFT JOIN recordedprogram ON "
266                   "(recorded.chanid = recordedprogram.chanid AND "
267                   "recorded.progstart = recordedprogram.starttime) "
268@@ -3993,6 +4097,7 @@
269         flags |= (query.value(4).toInt() == 1) ? FL_BOOKMARK : 0;
270         flags |= (query.value(5).toInt() == 1) ? FL_WATCHED : 0;
271         flags |= (query.value(6).toInt() == 1) ? FL_PRESERVED : 0;
272+        flags |= (query.value(7).toInt() == 1) ? FL_TRANSCODED : 0;
273     }
274 
275     return flags;