The menu of bookmarks is kept sorted.
Showing the changes to interface/src/Bookmarks.cpp (1 of 6 files). Show all
Unified · Split
| @@ -14,26 +14,22 @@ · 13 unmodified lines | |||
| 14 | Bookmarks::Bookmarks() { | 14 | Bookmarks::Bookmarks() { |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | void Bookmarks::insert(QString name, QString address) { | 17 | void Bookmarks::insert(const QString& name, const QString& address) { |
| 18 | QString key = name.toLower(); | 18 | QString key = name.toLower(); |
| 19 | 19 | ||
| 20 | if (isValidName(name)) { | 20 | QJsonObject bookmark; |
| 21 | QJsonObject bookmark; | 21 | bookmark.insert("name", name); |
| 22 | bookmark.insert("name", name); | 22 | bookmark.insert("address", address); |
| 23 | bookmark.insert("address", address); | 23 | _bookmarks.insert(key, bookmark); |
| 24 | _bookmarks.insert(key, bookmark); | 24 | |
| 25 | 25 | if (contains(key)) { | |
| 26 | if (contains(key)) { | 26 | qDebug() << "Added bookmark: " << name << ", " << address; |
| 27 | qDebug() << "Added bookmark: " << name << ", " << address; | ||
| 28 | } else { | ||
| 29 | qDebug() << "Couldn't add bookmark: " << name << ", " << address; | ||
| 30 | } | ||
| 31 | } else { | 27 | } else { |
| 32 | qDebug() << "Invalid bookmark: " << name << ", " << address; | 28 | qDebug() << "Couldn't add bookmark: " << name << ", " << address; |
| 33 | } | 29 | } |
| 34 | } | 30 | } |
| 35 | 31 | ||
| 36 | void Bookmarks::remove(QString name) { | 32 | void Bookmarks::remove(const QString& name) { |
| 37 | QString key = name.toLower(); | 33 | QString key = name.toLower(); |
| 38 | 34 | ||
| 39 | _bookmarks.remove(key); | 35 | _bookmarks.remove(key); |
| @@ -45,10 +41,6 @@ void Bookmarks::remove(QString name) { · 5 unmodified lines | |||
| 45 | } | 41 | } |
| 46 | } | 42 | } |
| 47 | 43 | ||
| 48 | bool Bookmarks::contains(QString name) { | 44 | bool Bookmarks::contains(const QString& name) const { |
| 49 | return _bookmarks.contains(name.toLower()); | 45 | return _bookmarks.contains(name.toLower()); |
| 50 | } | 46 | } |
| 51 | |||
| 52 | bool Bookmarks::isValidName(QString name) { | ||
| 53 | return _nameRegExp.exactMatch(name); | ||
| 54 | } | ||