1 | *** mythtv-0.25/programs/mythfrontend/customedit.cpp 2012-05-17 17:10:23.000000000 +0200 |
---|
2 | --- mythtv-0.25-mod/programs/mythfrontend/customedit.cpp 2012-05-17 20:23:41.000000000 +0200 |
---|
3 | *************** |
---|
4 | *** 35,40 **** |
---|
5 | --- 35,41 ---- |
---|
6 | m_baseTitle.remove(QRegExp(" \\(.*\\)$")); |
---|
7 | |
---|
8 | m_maxex = 0; |
---|
9 | + m_evaluate = 1; // default: evaluate |
---|
10 | m_seSuffix = QString(" (%1)").arg(tr("stored search")); |
---|
11 | m_exSuffix = QString(" (%1)").arg(tr("stored example")); |
---|
12 | |
---|
13 | *************** |
---|
14 | *** 150,165 **** |
---|
15 | textChanged(); |
---|
16 | } |
---|
17 | |
---|
18 | ! void CustomEdit::loadClauses() |
---|
19 | { |
---|
20 | ! QString quoteTitle = m_baseTitle; |
---|
21 | ! quoteTitle.replace("\'","\'\'"); |
---|
22 | |
---|
23 | CustomRuleInfo rule; |
---|
24 | |
---|
25 | rule.title = tr("Match an exact title"); |
---|
26 | if (!m_baseTitle.isEmpty()) |
---|
27 | ! rule.description = QString("program.title = '%1' ").arg(quoteTitle); |
---|
28 | else |
---|
29 | rule.description = "program.title = 'Nova' "; |
---|
30 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
31 | --- 151,231 ---- |
---|
32 | textChanged(); |
---|
33 | } |
---|
34 | |
---|
35 | ! QString CustomEdit::evaluate(QString clause) |
---|
36 | { |
---|
37 | ! int s0=0; |
---|
38 | ! int e0=0; |
---|
39 | ! |
---|
40 | ! while (1) { |
---|
41 | ! s0 = clause.indexOf (QRegExp("\\{[A-Z]+\\}"), e0); |
---|
42 | ! |
---|
43 | ! if (s0 < 0) |
---|
44 | ! break; |
---|
45 | ! |
---|
46 | ! e0 = clause.indexOf ("}", s0); |
---|
47 | ! |
---|
48 | ! QString mid = clause.mid(s0 + 1, e0 - s0 - 1); |
---|
49 | ! QString repl = ""; |
---|
50 | ! |
---|
51 | ! if (!mid.compare("TITLE")) { |
---|
52 | ! repl = m_pginfo->GetTitle(); |
---|
53 | ! repl.replace("\'","\'\'"); |
---|
54 | ! } else if (!mid.compare("SUBTITLE")) { |
---|
55 | ! repl = m_pginfo->GetSubtitle(); |
---|
56 | ! repl.replace("\'","\'\'"); |
---|
57 | ! } else if (!mid.compare("DESCR")) { |
---|
58 | ! repl = m_pginfo->GetDescription(); |
---|
59 | ! repl.replace("\'","\'\'"); |
---|
60 | ! } else if (!mid.compare("SERIESID")) { |
---|
61 | ! repl = QString("%1").arg(m_pginfo->GetSeriesID()); |
---|
62 | ! } else if (!mid.compare("PROGID")) { |
---|
63 | ! repl = m_pginfo->GetProgramID(); |
---|
64 | ! } else if (!mid.compare("SEASON")) { |
---|
65 | ! repl = QString::number(m_pginfo->GetSeason()); |
---|
66 | ! } else if (!mid.compare("EPISODE")) { |
---|
67 | ! repl = QString::number(m_pginfo->GetEpisode()); |
---|
68 | ! } else if (!mid.compare("CATEGORY")) { |
---|
69 | ! repl = m_pginfo->GetCategory(); |
---|
70 | ! } else if (!mid.compare("CHANID")) { |
---|
71 | ! repl = QString("%1").arg(m_pginfo->GetChanID()); |
---|
72 | ! } else if (!mid.compare("CHANNUM")) { |
---|
73 | ! repl = m_pginfo->GetChanNum(); |
---|
74 | ! } else if (!mid.compare("SCHEDID")) { |
---|
75 | ! repl = m_pginfo->GetChannelSchedulingID(); |
---|
76 | ! } else if (!mid.compare("CHANNAME")) { |
---|
77 | ! repl = m_pginfo->GetChannelName(); |
---|
78 | ! } else if (!mid.compare("DAYNAME")) { |
---|
79 | ! repl = m_pginfo->GetScheduledStartTime().toString("dddd"); |
---|
80 | ! } else if (!mid.compare("STARTDATE")) { |
---|
81 | ! repl = m_pginfo->GetScheduledStartTime().toString("yyyy-mm-dd hh:mm:ss"); |
---|
82 | ! } else if (!mid.compare("ENDDATE")) { |
---|
83 | ! repl = m_pginfo->GetScheduledEndTime().toString("yyyy-mm-dd hh:mm:ss"); |
---|
84 | ! } else if (!mid.compare("STARTTIME")) { |
---|
85 | ! repl = m_pginfo->GetScheduledStartTime().toString("hh:mm"); |
---|
86 | ! } else if (!mid.compare("ENDTIME")) { |
---|
87 | ! repl = m_pginfo->GetScheduledEndTime().toString("hh:mm"); |
---|
88 | ! } else if (!mid.compare("STARTSEC")) { |
---|
89 | ! QDateTime date = m_pginfo->GetScheduledStartTime(); |
---|
90 | ! QDateTime midnight = QDateTime(date.date()); |
---|
91 | ! repl = QString("%1").arg(midnight.secsTo(date)); |
---|
92 | ! } else if (!mid.compare("ENDSEC")) { |
---|
93 | ! QDateTime date = m_pginfo->GetScheduledEndTime(); |
---|
94 | ! QDateTime midnight = QDateTime(date.date()); |
---|
95 | ! repl = QString("%1").arg(midnight.secsTo(date)); |
---|
96 | ! } |
---|
97 | ! // unknown tags are simply removed |
---|
98 | ! clause.replace(s0, e0 - s0 + 1, repl); |
---|
99 | ! } |
---|
100 | ! return clause; |
---|
101 | ! } |
---|
102 | |
---|
103 | + void CustomEdit::loadClauses() |
---|
104 | + { |
---|
105 | CustomRuleInfo rule; |
---|
106 | |
---|
107 | rule.title = tr("Match an exact title"); |
---|
108 | if (!m_baseTitle.isEmpty()) |
---|
109 | ! rule.description = QString("program.title = '{TITLE}' "); |
---|
110 | else |
---|
111 | rule.description = "program.title = 'Nova' "; |
---|
112 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
113 | *************** |
---|
114 | *** 169,176 **** |
---|
115 | { |
---|
116 | rule.title = tr("Match this series"); |
---|
117 | rule.subtitle.clear(); |
---|
118 | ! rule.description = QString("program.seriesid = '%1' ") |
---|
119 | ! .arg(m_pginfo->GetSeriesID()); |
---|
120 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
121 | qVariantFromValue(rule)); |
---|
122 | } |
---|
123 | --- 235,241 ---- |
---|
124 | { |
---|
125 | rule.title = tr("Match this series"); |
---|
126 | rule.subtitle.clear(); |
---|
127 | ! rule.description = QString("program.seriesid = '{SERIESID}' "); |
---|
128 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
129 | qVariantFromValue(rule)); |
---|
130 | } |
---|
131 | *************** |
---|
132 | *** 178,185 **** |
---|
133 | rule.title = tr("Match words in the title"); |
---|
134 | rule.subtitle.clear(); |
---|
135 | if (!m_pginfo->GetTitle().isEmpty()) |
---|
136 | ! rule.description = QString("program.title LIKE '%%1%' ") |
---|
137 | ! .arg(quoteTitle); |
---|
138 | else |
---|
139 | rule.description = "program.title LIKE 'CSI: %' "; |
---|
140 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
141 | --- 243,249 ---- |
---|
142 | rule.title = tr("Match words in the title"); |
---|
143 | rule.subtitle.clear(); |
---|
144 | if (!m_pginfo->GetTitle().isEmpty()) |
---|
145 | ! rule.description = QString("program.title LIKE '%{TITLE}%' "); |
---|
146 | else |
---|
147 | rule.description = "program.title LIKE 'CSI: %' "; |
---|
148 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
149 | *************** |
---|
150 | *** 188,199 **** |
---|
151 | rule.title = tr("Match words in the subtitle"); |
---|
152 | rule.subtitle.clear(); |
---|
153 | if (!m_pginfo->GetSubtitle().isEmpty()) |
---|
154 | ! { |
---|
155 | ! QString subt = m_pginfo->GetSubtitle(); |
---|
156 | ! subt.replace("\'","\'\'"); |
---|
157 | ! rule.description = QString("program.subtitle LIKE '%%1%' ") |
---|
158 | ! .arg(subt); |
---|
159 | ! } |
---|
160 | else |
---|
161 | rule.description = "program.subtitle LIKE '%Las Vegas%' "; |
---|
162 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
163 | --- 252,258 ---- |
---|
164 | rule.title = tr("Match words in the subtitle"); |
---|
165 | rule.subtitle.clear(); |
---|
166 | if (!m_pginfo->GetSubtitle().isEmpty()) |
---|
167 | ! rule.description = QString("program.subtitle LIKE '%{SUBTITLE}%' "); |
---|
168 | else |
---|
169 | rule.description = "program.subtitle LIKE '%Las Vegas%' "; |
---|
170 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
171 | *************** |
---|
172 | *** 203,219 **** |
---|
173 | { |
---|
174 | rule.title = tr("Match this episode"); |
---|
175 | rule.subtitle.clear(); |
---|
176 | ! rule.description = QString("program.programid = '%1' ") |
---|
177 | ! .arg(m_pginfo->GetProgramID()); |
---|
178 | } |
---|
179 | else if (!m_pginfo->GetSubtitle().isEmpty()) |
---|
180 | { |
---|
181 | rule.title = tr("Match this episode"); |
---|
182 | rule.subtitle.clear(); |
---|
183 | ! rule.description = QString("program.subtitle = '%1' \n" |
---|
184 | ! "AND program.description = '%2' ") |
---|
185 | ! .arg(m_pginfo->GetSubtitle().replace("\'","\'\'")) |
---|
186 | ! .arg(m_pginfo->GetDescription().replace("\'","\'\'")); |
---|
187 | } |
---|
188 | else |
---|
189 | { |
---|
190 | --- 262,275 ---- |
---|
191 | { |
---|
192 | rule.title = tr("Match this episode"); |
---|
193 | rule.subtitle.clear(); |
---|
194 | ! rule.description = QString("program.programid = '{PROGID}' "); |
---|
195 | } |
---|
196 | else if (!m_pginfo->GetSubtitle().isEmpty()) |
---|
197 | { |
---|
198 | rule.title = tr("Match this episode"); |
---|
199 | rule.subtitle.clear(); |
---|
200 | ! rule.description = QString("program.subtitle = '{SUBTITLE}' \n" |
---|
201 | ! "AND program.description = '{DESCR}' "); |
---|
202 | } |
---|
203 | else |
---|
204 | { |
---|
205 | *************** |
---|
206 | *** 259,266 **** |
---|
207 | |
---|
208 | rule.title = tr("Anytime on a specific day of the week"); |
---|
209 | rule.subtitle.clear(); |
---|
210 | ! rule.description = QString("DAYNAME(program.starttime) = '%1' ") |
---|
211 | ! .arg(m_pginfo->GetScheduledStartTime().toString("dddd")); |
---|
212 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
213 | qVariantFromValue(rule)); |
---|
214 | |
---|
215 | --- 315,321 ---- |
---|
216 | |
---|
217 | rule.title = tr("Anytime on a specific day of the week"); |
---|
218 | rule.subtitle.clear(); |
---|
219 | ! rule.description = QString("DAYNAME(program.starttime) = '{DAYNAME}' "); |
---|
220 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
221 | qVariantFromValue(rule)); |
---|
222 | |
---|
223 | *************** |
---|
224 | *** 293,300 **** |
---|
225 | rule.title = tr("Only on a specific station"); |
---|
226 | rule.subtitle.clear(); |
---|
227 | if (!m_pginfo->GetChannelSchedulingID().isEmpty()) |
---|
228 | ! rule.description = QString("channel.callsign = '%1' ") |
---|
229 | ! .arg(m_pginfo->GetChannelSchedulingID()); |
---|
230 | else |
---|
231 | rule.description = "channel.callsign = 'ESPN' "; |
---|
232 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
233 | --- 348,354 ---- |
---|
234 | rule.title = tr("Only on a specific station"); |
---|
235 | rule.subtitle.clear(); |
---|
236 | if (!m_pginfo->GetChannelSchedulingID().isEmpty()) |
---|
237 | ! rule.description = QString("channel.callsign = '{SCHEDID}' "); |
---|
238 | else |
---|
239 | rule.description = "channel.callsign = 'ESPN' "; |
---|
240 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
241 | *************** |
---|
242 | *** 366,373 **** |
---|
243 | rule.title = tr("Limit by category"); |
---|
244 | rule.subtitle.clear(); |
---|
245 | if (!m_pginfo->GetCategory().isEmpty()) |
---|
246 | ! rule.description = QString("program.category = '%1' ") |
---|
247 | ! .arg(m_pginfo->GetCategory()); |
---|
248 | else |
---|
249 | rule.description = "program.category = 'Reality' "; |
---|
250 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
251 | --- 420,426 ---- |
---|
252 | rule.title = tr("Limit by category"); |
---|
253 | rule.subtitle.clear(); |
---|
254 | if (!m_pginfo->GetCategory().isEmpty()) |
---|
255 | ! rule.description = QString("program.category = '{CATEGORY}' "); |
---|
256 | else |
---|
257 | rule.description = "program.category = 'Reality' "; |
---|
258 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
259 | *************** |
---|
260 | *** 378,385 **** |
---|
261 | "program.chanid = programgenres.chanid AND " |
---|
262 | "program.starttime = programgenres.starttime "; |
---|
263 | if (!m_pginfo->GetCategory().isEmpty()) |
---|
264 | ! rule.description = QString("programgenres.genre = '%1' ") |
---|
265 | ! .arg(m_pginfo->GetCategory()); |
---|
266 | else |
---|
267 | rule.description = "programgenres.genre = 'Reality' "; |
---|
268 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
269 | --- 431,437 ---- |
---|
270 | "program.chanid = programgenres.chanid AND " |
---|
271 | "program.starttime = programgenres.starttime "; |
---|
272 | if (!m_pginfo->GetCategory().isEmpty()) |
---|
273 | ! rule.description = QString("programgenres.genre = '{CATEGORY}' "); |
---|
274 | else |
---|
275 | rule.description = "programgenres.genre = 'Reality' "; |
---|
276 | new MythUIButtonListItem(m_clauseList, rule.title, |
---|
277 | *************** |
---|
278 | *** 545,551 **** |
---|
279 | |
---|
280 | CustomRuleInfo rule = qVariantValue<CustomRuleInfo>(item->GetData()); |
---|
281 | |
---|
282 | ! QString msg = rule.description; |
---|
283 | msg.replace('\n', ' '); |
---|
284 | msg.replace(QRegExp(" [ ]*"), " "); |
---|
285 | msg = QString("\"%1\"").arg(msg); |
---|
286 | --- 597,603 ---- |
---|
287 | |
---|
288 | CustomRuleInfo rule = qVariantValue<CustomRuleInfo>(item->GetData()); |
---|
289 | |
---|
290 | ! QString msg = (m_evaluate) ? evaluate(rule.description) : rule.description; |
---|
291 | msg.replace('\n', ' '); |
---|
292 | msg.replace(QRegExp(" [ ]*"), " "); |
---|
293 | msg = QString("\"%1\"").arg(msg); |
---|
294 | *************** |
---|
295 | *** 570,576 **** |
---|
296 | |
---|
297 | if (desc.contains(QRegExp("\\S"))) |
---|
298 | clause = "AND "; |
---|
299 | ! clause += rule.description; |
---|
300 | m_descriptionEdit->SetText(desc.append(clause)); |
---|
301 | |
---|
302 | QString sub = m_subtitleEdit->GetText(); |
---|
303 | --- 622,629 ---- |
---|
304 | |
---|
305 | if (desc.contains(QRegExp("\\S"))) |
---|
306 | clause = "AND "; |
---|
307 | ! clause += (m_evaluate) ? evaluate(rule.description) : rule.description; |
---|
308 | ! |
---|
309 | m_descriptionEdit->SetText(desc.append(clause)); |
---|
310 | |
---|
311 | QString sub = m_subtitleEdit->GetText(); |
---|
312 | *************** |
---|
313 | *** 586,592 **** |
---|
314 | |
---|
315 | MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); |
---|
316 | ProgLister *pl = new ProgLister(mainStack, plSQLSearch, |
---|
317 | ! m_descriptionEdit->GetText(), |
---|
318 | m_subtitleEdit->GetText()); |
---|
319 | if (pl->Create()) |
---|
320 | { |
---|
321 | --- 639,645 ---- |
---|
322 | |
---|
323 | MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); |
---|
324 | ProgLister *pl = new ProgLister(mainStack, plSQLSearch, |
---|
325 | ! evaluate(m_descriptionEdit->GetText()), |
---|
326 | m_subtitleEdit->GetText()); |
---|
327 | if (pl->Create()) |
---|
328 | { |
---|
329 | *************** |
---|
330 | *** 610,622 **** |
---|
331 | if (cur_recid > 0) |
---|
332 | { |
---|
333 | record->ModifyPowerSearchByID(cur_recid, m_titleEdit->GetText(), |
---|
334 | ! m_descriptionEdit->GetText(), |
---|
335 | m_subtitleEdit->GetText()); |
---|
336 | } |
---|
337 | else |
---|
338 | { |
---|
339 | record->LoadBySearch(kPowerSearch, m_titleEdit->GetText(), |
---|
340 | ! m_descriptionEdit->GetText(), |
---|
341 | m_subtitleEdit->GetText()); |
---|
342 | } |
---|
343 | |
---|
344 | --- 663,675 ---- |
---|
345 | if (cur_recid > 0) |
---|
346 | { |
---|
347 | record->ModifyPowerSearchByID(cur_recid, m_titleEdit->GetText(), |
---|
348 | ! evaluate(m_descriptionEdit->GetText()), |
---|
349 | m_subtitleEdit->GetText()); |
---|
350 | } |
---|
351 | else |
---|
352 | { |
---|
353 | record->LoadBySearch(kPowerSearch, m_titleEdit->GetText(), |
---|
354 | ! evaluate(m_descriptionEdit->GetText()), |
---|
355 | m_subtitleEdit->GetText()); |
---|
356 | } |
---|
357 | |
---|
358 | *************** |
---|
359 | *** 700,706 **** |
---|
360 | bool ret = false; |
---|
361 | QString msg; |
---|
362 | |
---|
363 | ! QString desc = m_descriptionEdit->GetText(); |
---|
364 | QString from = m_subtitleEdit->GetText(); |
---|
365 | if (desc.contains(QRegExp("^\\s*AND\\s", Qt::CaseInsensitive))) |
---|
366 | { |
---|
367 | --- 753,759 ---- |
---|
368 | bool ret = false; |
---|
369 | QString msg; |
---|
370 | |
---|
371 | ! QString desc = evaluate(m_descriptionEdit->GetText()); |
---|
372 | QString from = m_subtitleEdit->GetText(); |
---|
373 | if (desc.contains(QRegExp("^\\s*AND\\s", Qt::CaseInsensitive))) |
---|
374 | { |
---|
375 | *************** |
---|
376 | *** 867,873 **** |
---|
377 | // else if (GetFocusWidget() == m_ruleList) |
---|
378 | // deleteRecordingRule(); |
---|
379 | } |
---|
380 | ! else |
---|
381 | handled = false; |
---|
382 | } |
---|
383 | |
---|
384 | --- 920,932 ---- |
---|
385 | // else if (GetFocusWidget() == m_ruleList) |
---|
386 | // deleteRecordingRule(); |
---|
387 | } |
---|
388 | ! else if (action == "EDIT") |
---|
389 | ! { |
---|
390 | ! // toggle evaluated/unevaluated sample view |
---|
391 | ! m_evaluate = 1-m_evaluate; |
---|
392 | ! MythUIButtonListItem* item = m_clauseList->GetItemCurrent(); |
---|
393 | ! clauseChanged(item); |
---|
394 | ! } else |
---|
395 | handled = false; |
---|
396 | } |
---|
397 | |
---|
398 | *** mythtv-0.25/programs/mythfrontend/customedit.h 2012-05-17 17:15:49.000000000 +0200 |
---|
399 | --- mythtv-0.25-mod/programs/mythfrontend/customedit.h 2012-05-17 17:15:27.000000000 +0200 |
---|
400 | *************** |
---|
401 | *** 39,48 **** |
---|
402 | --- 39,51 ---- |
---|
403 | void storeRule(bool is_search, bool is_new); |
---|
404 | void deleteRule(void); |
---|
405 | |
---|
406 | + QString evaluate(QString clause); |
---|
407 | + |
---|
408 | ProgramInfo *m_pginfo; |
---|
409 | QString m_baseTitle; |
---|
410 | |
---|
411 | int m_maxex; |
---|
412 | + int m_evaluate; |
---|
413 | |
---|
414 | QString m_seSuffix; |
---|
415 | QString m_exSuffix; |
---|