mirror of
https://github.com/overte-org/overte.git
synced 2025-04-29 20:42:36 +02:00
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
//
|
|
// Bookmarks.h
|
|
// interface/src
|
|
//
|
|
// Created by David Rowe on 13 Jan 2015.
|
|
// Copyright 2015 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
#ifndef hifi_Bookmarks_h
|
|
#define hifi_Bookmarks_h
|
|
|
|
#include <QMap>
|
|
#include <QObject>
|
|
#include <QPointer>
|
|
|
|
class QAction;
|
|
class QMenu;
|
|
class Menu;
|
|
class MenuWrapper;
|
|
|
|
class Bookmarks: public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
Bookmarks();
|
|
|
|
virtual void setupMenus(Menu* menubar, MenuWrapper* menu) = 0;
|
|
QString addressForBookmark(const QString& name) const;
|
|
|
|
protected:
|
|
void deleteBookmark(const QString& bookmarkName);
|
|
|
|
void addBookmarkToFile(const QString& bookmarkName, const QVariant& bookmark);
|
|
virtual void addBookmarkToMenu(Menu* menubar, const QString& name, const QVariant& bookmark) = 0;
|
|
void enableMenuItems(bool enabled);
|
|
virtual void readFromFile();
|
|
void insert(const QString& name, const QVariant& address); // Overwrites any existing entry with same name.
|
|
void sortActions(Menu* menubar, MenuWrapper* menu);
|
|
int getMenuItemLocation(QList<QAction*> actions, const QString& name) const;
|
|
void removeBookmarkFromMenu(Menu* menubar, const QString& name);
|
|
bool contains(const QString& name) const;
|
|
void remove(const QString& name);
|
|
|
|
QVariantMap _bookmarks; // { name: url, ... }
|
|
QPointer<MenuWrapper> _bookmarksMenu;
|
|
QPointer<QAction> _deleteBookmarksAction;
|
|
QString _bookmarksFilename;
|
|
bool _isMenuSorted;
|
|
|
|
protected slots:
|
|
/**jsdoc
|
|
* @function AvatarBookmarks.deleteBookmark
|
|
*/
|
|
/**jsdoc
|
|
* @function LocationBookmarks.deleteBookmark
|
|
*/
|
|
void deleteBookmark();
|
|
|
|
private:
|
|
static bool sortOrder(QAction* a, QAction* b);
|
|
|
|
void persistToFile();
|
|
};
|
|
|
|
#endif // hifi_Bookmarks_h
|