New "EPGMaxStars" entry in settings mysql table (Defaults to 4)
New entry in the EPG configuration page 2
To avoid adding many new translation strings the present ones were recycled and the numbers replaced. A new generic string would be annoying for some languages where the words "star" changes when referring to 1, 2 and 3 or more of them.
There is also a second little patch to correct the mythweb version to use the max_stars in the searches.
--
Charlie Brej
APT Group, Dept. Computer Science, University of Manchester
Web: http://www.cs.man.ac.uk/~brejc8/ Tel: +44 161 275 6844
Mail: IT302, Manchester University, Manchester, M13 9PL, UK
Index: libs/libmythtv/proglist.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/proglist.cpp,v
retrieving revision 1.62
diff -u -3 -p -r1.62 proglist.cpp
--- libs/libmythtv/proglist.cpp 11 May 2005 14:35:58 -0000 1.62
+++ libs/libmythtv/proglist.cpp 15 May 2005 15:36:49 -0000
@@ -1304,17 +1304,33 @@ void ProgLister::fillViewList(const QStr
}
else if (type == plMovies)
{
+ int maxstars = gContext->GetNumSetting("EPGMaxStars", 4);
viewList << "0.0";
viewTextList << tr("All");
- viewList << "1.0";
- viewTextList << tr("4 stars");
- viewList << "0.875";
- viewTextList << tr("At least 3 1/2 stars");
- viewList << "0.75";
- viewTextList << tr("At least 3 stars");
- viewList << "0.5";
- viewTextList << tr("At least 2 stars");
- curView = 0;
+
+ if (maxstars > 2)
+ {
+ QString numberstr;
+ int stars = maxstars;
+ viewList << "1.0";
+ viewTextList << tr("4 stars").replace( '4',numberstr.setNum(maxstars));
+
+ while (stars > 2)
+ {
+ stars--;
+ viewList << numberstr.setNum((float)(stars +0.5)/ maxstars);
+ viewTextList << tr("At least 3 1/2 stars")
+ .replace( '3',numberstr.setNum(stars));
+
+ viewList << numberstr.setNum((float)stars/ maxstars);
+ if (maxstars == 2)
+ viewTextList << tr("At least 2 stars");
+ else viewTextList << tr("At least 3 stars")
+ .replace('3',numberstr.setNum(stars));
+
+ }
+ curView = 0;
+ }
}
else if (type == plTime)
{
@@ -1579,7 +1595,9 @@ void ProgLister::updateList(QPainter *p)
QStringList starMap;
QString starstr = "";
- for (int i = 0; i <= 4; i++)
+ int maxstars = gContext->GetNumSetting("EPGMaxStars", 4);
+
+ for (int i = 0; i <= maxstars; i++)
{
starMap << starstr;
starMap << starstr + "/";
@@ -1610,7 +1628,7 @@ void ProgLister::updateList(QPainter *p)
if (pi->stars > 0.0)
tmptitle = QString("%1 (%2, %3 )")
.arg(pi->title).arg(pi->year)
- .arg(starMap[(int) (pi->stars * 8)]);
+ .arg(starMap[(int) (pi->stars * (2 * maxstars))]);
else if (pi->subtitle == "")
tmptitle = pi->title;
else
Index: libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.206
diff -u -3 -p -r1.206 programinfo.cpp
--- libs/libmythtv/programinfo.cpp 7 May 2005 20:19:21 -0000 1.206
+++ libs/libmythtv/programinfo.cpp 15 May 2005 15:36:50 -0000
@@ -469,14 +469,15 @@ void ProgramInfo::ToMap(QMap<QString, QS
if (stars)
{
QString str = QObject::tr("stars");
- if (stars > 0 && stars <= 0.25)
+ int maxstars = gContext->GetNumSetting("EPGMaxStars", 4);
+ if (stars > 0 && stars <= 1.0/maxstars)
str = QObject::tr("star");
-
+
if (year != "")
progMap["stars"] = QString("(%1, %2 %3) ")
- .arg(year).arg(4.0 * stars).arg(str);
+ .arg(year).arg(maxstars * stars).arg(str);
else
- progMap["stars"] = QString("(%1 %2) ").arg(4.0 * stars).arg(str);
+ progMap["stars"] = QString("(%1 %2) ").arg(maxstars * stars).arg(str);
}
else
progMap["stars"] = "";
@@ -2389,10 +2390,12 @@ void ProgramInfo::showDetails()
if (stars > 0.0)
{
QString str = QObject::tr("stars");
- if (stars > 0 && stars <= 0.25)
+ int maxstars = gContext->GetNumSetting("EPGMaxStars", 4);
+
+ if (stars > 0 && stars <= 1.0/maxstars)
str = QObject::tr("star");
- attr += QString("%1 %2, ").arg(4.0 * stars).arg(str);
+ attr += QString("%1 %2, ").arg(maxstars * stars).arg(str);
}
}
Index: libs/libmythtv/tv_play.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/tv_play.cpp,v
retrieving revision 1.266
diff -u -3 -p -r1.266 tv_play.cpp
--- libs/libmythtv/tv_play.cpp 5 May 2005 02:51:15 -0000 1.266
+++ libs/libmythtv/tv_play.cpp 15 May 2005 15:36:53 -0000
@@ -3078,7 +3078,9 @@ void TV::GetChannelInfo(RemoteEncoder *e
if (stars.toFloat())
- infoMap["stars"] = QString("(%1 %2) ").arg(4.0 * stars.toFloat()).arg(QObject::tr("stars"));
+ infoMap["stars"] = QString("(%1 %2) ")
+ .arg(gContext->GetNumSetting("EPGMaxStars", 4) * stars.toFloat())
+ .arg(QObject::tr("stars"));
else
infoMap["stars"] = "";
Index: programs/mythfilldatabase/filldata.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfilldatabase/filldata.cpp,v
retrieving revision 1.177
diff -u -3 -p -r1.177 filldata.cpp
--- programs/mythfilldatabase/filldata.cpp 3 May 2005 21:56:29 -0000 1.177
+++ programs/mythfilldatabase/filldata.cpp 15 May 2005 15:36:54 -0000
@@ -1378,6 +1378,7 @@ ProgInfo *parseProgram(QDomElement &elem
stars = getFirstText(item);
num = stars.section('/', 0, 0);
den = stars.section('/', 1, 1);
+ printf("rating: %f %f %f\n ", num.toFloat(), den.toFloat(), (num.toFloat()/den.toFloat()) / (i+1));
if (0.0 >= den.toFloat())
continue;
avg *= i/(i+1);
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.249
diff -u -3 -p -r1.249 globalsettings.cpp
--- programs/mythfrontend/globalsettings.cpp 10 May 2005 11:13:57 -0000 1.249
+++ programs/mythfrontend/globalsettings.cpp 15 May 2005 15:36:56 -0000
@@ -1802,6 +1802,15 @@ static HostSpinBox *EPGChanDisplay()
return gs;
}
+static HostSpinBox *EPGMaxStars()
+{
+ HostSpinBox *gs = new HostSpinBox("EPGMaxStars", 1, 10, 1);
+ gs->setLabel(QObject::tr("Maximum Number of Stars"));
+ gs->setHelpText(QObject::tr("How many stars should programs be graded out of"));
+ gs->setValue(4);
+ return gs;
+}
+
static HostSpinBox *EPGTimeDisplay()
{
HostSpinBox *gs = new HostSpinBox("timePerPage", 1, 5, 1);
@@ -3015,6 +3024,7 @@ EPGSettings::EPGSettings()
gen->setLabel(QObject::tr("Program Guide") + " 2/2");
gen->addChild(UnknownTitle());
gen->addChild(UnknownCategory());
+ gen->addChild(EPGMaxStars());
gen->addChild(DefaultTVChannel());
gen->addChild(SelectChangesChannel());
gen->addChild(EPGRecThreshold());
Index: search.php
===================================================================
RCS file: /var/lib/mythcvs/mythplugins/mythweb/search.php,v
retrieving revision 1.19
diff -u -3 -p -r1.19 search.php
--- search.php 1 Mar 2005 07:10:23 -0000 1.19
+++ search.php 15 May 2005 16:13:14 -0000
@@ -83,7 +83,7 @@
$joiner = ' OR ';
// If it starts with a pair of stars, it's a movie rating query
if (preg_match('#(\\*+\s*(1/2\b|0?\.5\b|-)?)\s*#', $search_str, $stars)) {
- $starcount = substr_count($stars[1], '*') / 4.0;
+ $starcount = substr_count($stars[1], '*') / max_stars;
if (preg_match( "/1\\/2|\\.5|-/", $stars[1]))
$starcount += 0.125;
// Add this to the query -- convert european decimal to something mysql can understand
_______________________________________________ mythtv-dev mailing list [email protected] http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
