Length in smart playlists works again. Fixes issue 1796

This commit is contained in:
Andrea Decorte 2011-04-24 19:07:01 +00:00
parent 071f1f4f7e
commit 4d19917b05
3 changed files with 14 additions and 3 deletions

View File

@ -16,6 +16,7 @@
*/
#include "search.h"
#include "core/logging.h"
#include "core/song.h"
#include <QStringList>
@ -89,6 +90,7 @@ QString Search::ToSql(const QString& songs_table) const {
} else if (limit_ != -1) {
sql += " LIMIT " + QString::number(limit_);
}
qLog(Debug) << sql;
return sql;
}

View File

@ -72,6 +72,9 @@ QString SearchTerm::ToSql() const {
second_value = QString::number(second_value_.toInt()*7);
}
}
} else if (TypeOf(field_) == Type_Time) {
// Convert seconds to nanoseconds
value = "CAST (" + value + " *1000000000 AS INTEGER)";
}
switch (operator_) {
@ -87,19 +90,22 @@ QString SearchTerm::ToSql() const {
if (TypeOf(field_) == Type_Text)
return col + " LIKE '" + value + "'";
else if (TypeOf(field_) == Type_Rating ||
TypeOf(field_) == Type_Date)
TypeOf(field_) == Type_Date ||
TypeOf(field_) == Type_Time)
return col + " = " + value + "";
else
return col + " = '" + value + "'";
case Op_GreaterThan:
if (TypeOf(field_) == Type_Rating ||
TypeOf(field_) == Type_Date)
TypeOf(field_) == Type_Date ||
TypeOf(field_) == Type_Time)
return col + " > " + value + "";
else
return col + " > '" + value + "'";
case Op_LessThan:
if (TypeOf(field_) == Type_Rating ||
TypeOf(field_) == Type_Date)
TypeOf(field_) == Type_Date ||
TypeOf(field_) == Type_Time)
return col + " < " + value + "";
else
return col + " < '" + value + "'";

View File

@ -107,6 +107,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="displayFormat">
<string notr="true">mm:ss</string>
</property>
</widget>
</item>
</layout>