History

Add bookmarks with Bookmark Location menu item

The menu of bookmarks is kept sorted.

David Rowe committed 11 years ago

Commit fa6faa71 parent 7130c576 files · +77 −26Browse files

Showing the changes to interface/src/Bookmarks.cpp (1 of 6 files). Show all

Unified · Split

interface/src/Bookmarks.cpp+11−19
@@ -14,26 +14,22 @@ · 13 unmodified lines
1414 Bookmarks::Bookmarks() {
1515 }
1616
17−void Bookmarks::insert(QString name, QString address) {
17+void Bookmarks::insert(const QString& name, const QString& address) {
1818 QString key = name.toLower();
1919
20− if (isValidName(name)) {
21− QJsonObject bookmark;
22− bookmark.insert("name", name);
23− bookmark.insert("address", address);
24− _bookmarks.insert(key, bookmark);
25−
26− if (contains(key)) {
27− qDebug() << "Added bookmark: " << name << ", " << address;
28− } else {
29− qDebug() << "Couldn't add bookmark: " << name << ", " << address;
30− }
20+ QJsonObject bookmark;
21+ bookmark.insert("name", name);
22+ bookmark.insert("address", address);
23+ _bookmarks.insert(key, bookmark);
24+
25+ if (contains(key)) {
26+ qDebug() << "Added bookmark: " << name << ", " << address;
3127 } else {
32− qDebug() << "Invalid bookmark: " << name << ", " << address;
28+ qDebug() << "Couldn't add bookmark: " << name << ", " << address;
3329 }
3430 }
3531
36−void Bookmarks::remove(QString name) {
32+void Bookmarks::remove(const QString& name) {
3733 QString key = name.toLower();
3834
3935 _bookmarks.remove(key);
@@ -45,10 +41,6 @@ void Bookmarks::remove(QString name) { · 5 unmodified lines
4541 }
4642 }
4743
48−bool Bookmarks::contains(QString name) {
44+bool Bookmarks::contains(const QString& name) const {
4945 return _bookmarks.contains(name.toLower());
5046 }
51−
52−bool Bookmarks::isValidName(QString name) {
53− return _nameRegExp.exactMatch(name);
54−}