MCPcopy Create free account
hub / github.com/QuiteRSS/quiterss / runUserFilter

Method runUserFilter

src/parseobject.cpp:1009–1292  ·  view source on GitHub ↗

@brief Apply user filters * @param feedId - Feed Id * @param filterId - Id of particular filter *---------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

1007 * @param filterId - Id of particular filter
1008 *---------------------------------------------------------------------------*/
1009void ParseObject::runUserFilter(int feedId, int filterId)
1010{
1011 QSqlQuery q(db_);
1012 bool isAllFilters = true;
1013
1014 if (filterId != -1) {
1015 isAllFilters = false;
1016 q.exec(QString("SELECT enable, type FROM filters WHERE id='%1' AND feeds LIKE '%,%2,%'").
1017 arg(filterId).arg(feedId));
1018 } else {
1019 q.exec(QString("SELECT enable, type, id FROM filters WHERE feeds LIKE '%,%1,%' ORDER BY num").
1020 arg(feedId));
1021 }
1022
1023 while (q.next()) {
1024 if ((q.value(0).toInt() == 0) && isAllFilters) continue;
1025
1026 if (isAllFilters)
1027 filterId = q.value(2).toInt();
1028 int filterType = q.value(1).toInt();
1029
1030 QString qStr("UPDATE news SET");
1031 QString qStr1;
1032 QString qStr2;
1033 QString whereStr;
1034 QList<int> idLabelsList;
1035 QStringList soundList;
1036 QStringList colorList;
1037
1038 QSqlQuery q1(db_);
1039 q1.exec(QString("SELECT action, params FROM filterActions "
1040 "WHERE idFilter=='%1'").arg(filterId));
1041 while (q1.next()) {
1042 switch (q1.value(0).toInt()) {
1043 case 0: // action -> Mark news as read
1044 if (!qStr1.isNull()) qStr1.append(",");
1045 qStr1.append(" new=0, read=2");
1046 break;
1047 case 1: // action -> Add star
1048 if (!qStr1.isNull()) qStr1.append(",");
1049 qStr1.append(" starred=1");
1050 break;
1051 case 2: // action -> Delete
1052 if (!qStr1.isNull()) qStr1.append(",");
1053 qStr1.append(" new=0, read=2, deleted=1, ");
1054 qStr1.append(QString("deleteDate='%1'").
1055 arg(QDateTime::currentDateTime().toString(Qt::ISODate)));
1056 break;
1057 case 3: // action -> Add Label
1058 idLabelsList.append(q1.value(1).toInt());
1059 break;
1060 case 4: // action -> Play Sound
1061 soundList.append(q1.value(1).toString());
1062 break;
1063 case 5: // action -> Show News in Notifier
1064 colorList.append(q1.value(1).toString());
1065 break;
1066 }

Callers

nothing calls this directly

Calls 4

execMethod · 0.80
valueMethod · 0.80
isNullMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected