@@ -240,7 +240,7 @@ msgs_filter::parse_search_string(QString s, fts_options& opt)
240240 }
241241 else if (state==20 ) {
242242 if (c==' ' ) {
243- opt.m_operators .insert (curr_op, curr_opval);
243+ opt.m_operators .insertMulti (curr_op, curr_opval);
244244 state=10 ;
245245 }
246246 else
@@ -276,7 +276,7 @@ msgs_filter::parse_search_string(QString s, fts_options& opt)
276276 DBG_PRINTF (3 , " parse error: state=%d" , state);
277277 }
278278 if (state==20 )
279- opt.m_operators .insert (curr_op, curr_opval);
279+ opt.m_operators .insertMulti (curr_op, curr_opval);
280280
281281 if (!curr_word.isEmpty ()) {
282282 if (curr_word.at (0 )==' -' )
@@ -462,6 +462,14 @@ msgs_filter::build_query(sql_query& q)
462462
463463 // </date clause>
464464
465+ // status clause through is:status and isnot:status
466+ if (m_fts.m_operators .contains (" is" )) {
467+ process_status_clause (q, status_is, m_fts.m_operators .values (" is" ));
468+ }
469+ if (m_fts.m_operators .contains (" isnot" )) {
470+ process_status_clause (q, status_isnot, m_fts.m_operators .values (" isnot" ));
471+ }
472+
465473 if (!m_body_substring.isEmpty ()) {
466474 q.add_table (" body b" );
467475 q.add_clause (QString (" strpos(b.bodytext,'" ) + m_body_substring + QString (" ')>0 and m.mail_id=b.mail_id" ));
@@ -676,6 +684,40 @@ msgs_filter::process_date_clause(sql_query& q, date_comparator comp, QString dat
676684 }
677685}
678686
687+ /*
688+ Create SQL clauses from the given comparator (status_is, status_isnot)
689+ to test if mail.status has or doesn't have bits corresponding
690+ to the statuses named in <vals>.
691+ */
692+ void
693+ msgs_filter::process_status_clause (sql_query& q,
694+ status_comparator comp,
695+ QList<QString> vals)
696+ {
697+ static struct {
698+ const char * name;
699+ int bitmask;
700+ } statuses[] = {
701+ {" read" , mail_msg::statusRead},
702+ {" replied" , mail_msg::statusReplied},
703+ {" forwarded" , mail_msg::statusFwded},
704+ {" archived" , mail_msg::statusArchived},
705+ {" sent" , mail_msg::statusSent}
706+ };
707+
708+ for (int si=0 ; si < vals.size (); ++si) {
709+ const QString& s = vals.at (si);
710+ for (int i=0 ; i < (int )sizeof (statuses)/(int )sizeof (statuses[0 ]); i++) {
711+ if (QString::compare (s, statuses[i].name , Qt::CaseInsensitive)==0 ) {
712+ if (comp == status_is)
713+ q.add_clause (QString (" m.status&%1=%1" ).arg (statuses[i].bitmask ));
714+ else if (comp == status_isnot)
715+ q.add_clause (QString (" m.status&%1=0" ).arg (statuses[i].bitmask ));
716+ }
717+ }
718+ }
719+ }
720+
679721/*
680722 Return values: same as build_query()
681723
0 commit comments