Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneytransactionfilter.cpp
Context not available. | |||||
51 | , m_matchOnly(false) | 51 | , m_matchOnly(false) | ||
---|---|---|---|---|---|
52 | , m_matchingSplitsCount(0) | 52 | , m_matchingSplitsCount(0) | ||
53 | , m_invertText(false) | 53 | , m_invertText(false) | ||
54 | , m_origin({eMyMoney::Transaction::Origin::MatchingInput}) // most of the time we don't want transactions that served as an input for creating matched transaction | ||||
54 | { | 55 | { | ||
55 | m_filterSet.allFilter = 0; | 56 | m_filterSet.allFilter = 0; | ||
57 | m_filterSet.singleFilter.originFilter = 1; // because of m_origin being set | ||||
56 | } | 58 | } | ||
57 | 59 | | |||
58 | MyMoneyTransactionFilter::FilterSet m_filterSet; | 60 | MyMoneyTransactionFilter::FilterSet m_filterSet; | ||
Context not available. | |||||
71 | QHash<int, QString> m_states; | 73 | QHash<int, QString> m_states; | ||
72 | QHash<int, QString> m_types; | 74 | QHash<int, QString> m_types; | ||
73 | QHash<int, QString> m_validity; | 75 | QHash<int, QString> m_validity; | ||
76 | QSet<eMyMoney::Transaction::Origin> m_origin; | ||||
74 | QString m_fromNr, m_toNr; | 77 | QString m_fromNr, m_toNr; | ||
75 | QDate m_fromDate, m_toDate; | 78 | QDate m_fromDate, m_toDate; | ||
76 | MyMoneyMoney m_fromAmount, m_toAmount; | 79 | MyMoneyMoney m_fromAmount, m_toAmount; | ||
Context not available. | |||||
113 | d->m_types.clear(); | 116 | d->m_types.clear(); | ||
114 | d->m_states.clear(); | 117 | d->m_states.clear(); | ||
115 | d->m_validity.clear(); | 118 | d->m_validity.clear(); | ||
119 | d->m_origin.clear(); | ||||
116 | d->m_fromDate = QDate(); | 120 | d->m_fromDate = QDate(); | ||
117 | d->m_toDate = QDate(); | 121 | d->m_toDate = QDate(); | ||
118 | } | 122 | } | ||
Context not available. | |||||
251 | d->m_validity.insert(type, QString()); | 255 | d->m_validity.insert(type, QString()); | ||
252 | } | 256 | } | ||
253 | 257 | | |||
258 | void MyMoneyTransactionFilter::removeOrigin(eMyMoney::Transaction::Origin origin) | ||||
259 | { | ||||
260 | Q_D(MyMoneyTransactionFilter); | ||||
261 | d->m_origin.insert(origin); | ||||
262 | d->m_filterSet.singleFilter.originFilter = 1; | ||||
263 | } | ||||
264 | | ||||
254 | void MyMoneyTransactionFilter::setNumberFilter(const QString& from, const QString& to) | 265 | void MyMoneyTransactionFilter::setNumberFilter(const QString& from, const QString& to) | ||
255 | { | 266 | { | ||
256 | Q_D(MyMoneyTransactionFilter); | 267 | Q_D(MyMoneyTransactionFilter); | ||
Context not available. | |||||
302 | 313 | | |||
303 | // perform checks on the MyMoneyTransaction object first | 314 | // perform checks on the MyMoneyTransaction object first | ||
304 | 315 | | |||
316 | if (filter.originFilter) { | ||||
317 | const auto transactionOrigin = transaction.origin(); | ||||
318 | for (const auto &filterOrigin : d->m_origin) { | ||||
319 | if (filterOrigin & transactionOrigin) { | ||||
320 | d->m_matchingSplitsCount = 0; | ||||
321 | matchingSplits.clear(); | ||||
322 | return matchingSplits; | ||||
323 | } | ||||
324 | } | ||||
325 | } | ||||
326 | | ||||
305 | // check the date range | 327 | // check the date range | ||
306 | if (filter.dateFilter) { | 328 | if (filter.dateFilter) { | ||
307 | if ((d->m_fromDate != QDate() && | 329 | if ((d->m_fromDate != QDate() && | ||
Context not available. | |||||
329 | auto isMatchingSplitsEmpty = true; | 351 | auto isMatchingSplitsEmpty = true; | ||
330 | 352 | | |||
331 | auto extendedFilter = d->m_filterSet; | 353 | auto extendedFilter = d->m_filterSet; | ||
332 | extendedFilter.singleFilter.dateFilter = | 354 | extendedFilter.singleFilter.dateFilter = | ||
333 | extendedFilter.singleFilter.accountFilter = | 355 | extendedFilter.singleFilter.accountFilter = | ||
334 | extendedFilter.singleFilter.categoryFilter = 0; | 356 | extendedFilter.singleFilter.categoryFilter = | ||
357 | extendedFilter.singleFilter.originFilter = 0; | ||||
335 | 358 | | |||
336 | if (filter.accountFilter || | 359 | if (filter.accountFilter || | ||
337 | filter.categoryFilter || | 360 | filter.categoryFilter || | ||
Context not available. |