| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 bool UserDefinedSubscription::IsDefaultFor(const Filter* filter) const | 36 bool UserDefinedSubscription::IsDefaultFor(const Filter* filter) const |
| 37 { | 37 { |
| 38 return mDefaults & filterTypeToDefaults[filter->mType]; | 38 return mDefaults & filterTypeToDefaults[filter->mType]; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter) | 41 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter) |
| 42 { | 42 { |
| 43 mDefaults |= filterTypeToDefaults[filter->mType]; | 43 mDefaults |= filterTypeToDefaults[filter->mType]; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void UserDefinedSubscription::InsertFilterAt(Filter* filter, unsigned pos) |
| 47 { |
| 48 if (pos >= mFilters.size()) |
| 49 mFilters.emplace_back(filter); |
| 50 else |
| 51 mFilters.emplace(mFilters.begin() + pos, filter); |
| 52 } |
| 53 |
| 54 bool UserDefinedSubscription::RemoveFilterAt(unsigned pos) |
| 55 { |
| 56 if (pos >= mFilters.size()) |
| 57 return false; |
| 58 |
| 59 mFilters.erase(mFilters.begin() + pos); |
| 60 return true; |
| 61 } |
| 62 |
| 46 OwnedString UserDefinedSubscription::Serialize() const | 63 OwnedString UserDefinedSubscription::Serialize() const |
| 47 { | 64 { |
| 48 OwnedString result(Subscription::Serialize()); | 65 OwnedString result(Subscription::Serialize()); |
| 49 if (mDefaults) | 66 if (mDefaults) |
| 50 { | 67 { |
| 51 result.append(u"defaults="_str); | 68 result.append(u"defaults="_str); |
| 52 if (mDefaults & Defaults::BLOCKING) | 69 if (mDefaults & Defaults::BLOCKING) |
| 53 result.append(u" blocking"_str); | 70 result.append(u" blocking"_str); |
| 54 if (mDefaults & Defaults::WHITELIST) | 71 if (mDefaults & Defaults::WHITELIST) |
| 55 result.append(u" whitelist"_str); | 72 result.append(u" whitelist"_str); |
| 56 if (mDefaults & Defaults::ELEMHIDE) | 73 if (mDefaults & Defaults::ELEMHIDE) |
| 57 result.append(u" elemhide"_str); | 74 result.append(u" elemhide"_str); |
| 58 result.append(u'\n'); | 75 result.append(u'\n'); |
| 59 } | 76 } |
| 60 return result; | 77 return result; |
| 61 } | 78 } |
| OLD | NEW |