mirror of
https://github.com/overte-org/overte.git
synced 2025-07-22 19:46:00 +02:00
Simplify bookmark handling
This commit is contained in:
parent
1ffe22d5e9
commit
d9bd7f019f
3 changed files with 7 additions and 15 deletions
|
@ -15,14 +15,9 @@ Bookmarks::Bookmarks() {
|
|||
}
|
||||
|
||||
void Bookmarks::insert(const QString& name, const QString& address) {
|
||||
QString key = name.toLower();
|
||||
_bookmarks.insert(name, address);
|
||||
|
||||
QJsonObject bookmark;
|
||||
bookmark.insert("name", name);
|
||||
bookmark.insert("address", address);
|
||||
_bookmarks.insert(key, bookmark);
|
||||
|
||||
if (contains(key)) {
|
||||
if (contains(name)) {
|
||||
qDebug() << "Added bookmark: " << name << ", " << address;
|
||||
} else {
|
||||
qDebug() << "Couldn't add bookmark: " << name << ", " << address;
|
||||
|
@ -30,11 +25,9 @@ void Bookmarks::insert(const QString& name, const QString& address) {
|
|||
}
|
||||
|
||||
void Bookmarks::remove(const QString& name) {
|
||||
QString key = name.toLower();
|
||||
_bookmarks.remove(name);
|
||||
|
||||
_bookmarks.remove(key);
|
||||
|
||||
if (!contains(key)) {
|
||||
if (!contains(name)) {
|
||||
qDebug() << "Removed bookmark: " << name;
|
||||
} else {
|
||||
qDebug() << "Couldn't remove bookmark: " << name;
|
||||
|
@ -42,5 +35,5 @@ void Bookmarks::remove(const QString& name) {
|
|||
}
|
||||
|
||||
bool Bookmarks::contains(const QString& name) const {
|
||||
return _bookmarks.contains(name.toLower());
|
||||
return _bookmarks.contains(name);
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ public:
|
|||
bool contains(const QString& name) const;
|
||||
|
||||
private:
|
||||
QMap<QString, QJsonObject> _bookmarks; // key: { name: string, address: string }
|
||||
// key is a lowercase copy of name, used to make the bookmarks case insensitive.
|
||||
QVariantMap _bookmarks; // { name: address, ... }
|
||||
};
|
||||
|
||||
#endif // hifi_Bookmarks_h
|
|
@ -1069,7 +1069,7 @@ void Menu::bookmarkLocation() {
|
|||
addActionToQMenuAndActionHash(_bookmarksMenu, teleportAction, bookmarkName, 0,
|
||||
QAction::NoRole, position);
|
||||
|
||||
bookmarks->insert(bookmarkName, bookmarkAddress);
|
||||
bookmarks->insert(bookmarkName, bookmarkAddress); // Overwrites any item with the same bookmarkName.
|
||||
|
||||
_bookmarksMenu->setEnabled(true);
|
||||
_deleteBookmarksMenu->setEnabled(true);
|
||||
|
|
Loading…
Reference in a new issue