import com.trolltech.qt.core.QCoreApplication;\r
import com.trolltech.qt.core.QDateTime;\r
\r
-import cx.fbn.nevernote.filters.AttributeFilter;\r
-\r
public abstract class DateAttributeFilter extends AttributeFilter {\r
protected boolean checkSince;\r
public abstract boolean attributeCheck(QDateTime a, QDateTime b);\r
super(n);\r
}\r
public abstract String getLabel();\r
-\r
+ \r
public static class checkToday extends DateAttributeFilter {\r
public checkToday(boolean since) {\r
super();\r
checkSince=since; \r
}\r
// Check if it was within the last day\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
if (checkSince)\r
return noteDate.daysTo(current) == 0;\r
else \r
return noteDate.daysTo(current) > 0;\r
}\r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "Today");\r
}\r
checkSince=since; \r
}\r
// Check if it was within the last two days\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
if (checkSince) \r
return noteDate.daysTo(current) <= 1;\r
else\r
return noteDate.daysTo(current) > 1;\r
}\r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "Yesterday");\r
}\r
checkSince=since; \r
}\r
// Check if it was within the last two days\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
if (checkSince) \r
return noteDate.daysTo(current) <= 7;\r
else\r
return noteDate.daysTo(current) > 7;\r
}\r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "This Week");\r
}\r
checkSince=since; \r
}\r
// Check if it was within the last two weeks\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
if (checkSince) \r
return noteDate.daysTo(current) <= 14;\r
else\r
return noteDate.daysTo(current) > 14;\r
}\r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "Last Week");\r
}\r
checkSince=since; \r
}\r
// Check if it was within the last month\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
if (checkSince) {\r
if (noteDate.date().year() == current.date().year())\r
return noteDate.date().month() - current.date().month() != 0;\r
}\r
}\r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "This Month");\r
}\r
checkSince=since; \r
}\r
// Check if it was within the last two months\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
int ny = noteDate.date().year();\r
int cy = current.date().year();\r
return cm-nm > 1;\r
}\r
}\r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "Last Month");\r
}\r
checkSince=since; \r
}\r
// Check if it was within this year\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
int ny = noteDate.date().year();\r
int cy = current.date().year();\r
else\r
return cy-ny > 0;\r
} \r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "This Year");\r
}\r
checkSince=since; \r
}\r
// Check if it was within the last year\r
+ @Override\r
public boolean attributeCheck(QDateTime noteDate, QDateTime current) {\r
int ny = noteDate.date().year();\r
int cy = current.date().year();\r
else\r
return cy-ny > 1;\r
}\r
+ @Override\r
public String getLabel(){\r
return QCoreApplication.translate("DateAttributeFilter", "Last Year");\r
}\r