ui: Fixes and improvements for bookmarks

* moved bookmark buttons behind search bar
* suggest qualified name when creating, file name for files
* fixed bug when updating bookmark category
* changed comment toggle arrow
* changed edit and delete icons
* fixed undo for edge bookmarks
* keep categories always alphabetical regardless of subsorting
* keep category expansion state when opening and closing browser
* removed QtBookmarkBar, moved logic into QtBookmarkView
* added bookmarks Menu with shortcuts
	Ctrl + D: Create Bookmark
	Ctrl + B: Bookmark Manager
This commit is contained in:
Eberhard Graether
2017-04-26 00:33:34 +02:00
parent 4ac41de61e
commit 0468168d61
32 changed files with 398 additions and 563 deletions
+3 -3
View File
@@ -33,9 +33,6 @@ void ComponentManager::setup(ViewLayout* viewLayout)
m_componentFactory->getViewFactory()->createCompositeView(viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search");
m_compositeViews.push_back(compositeView);
std::shared_ptr<Component> bookmarkComponent = m_componentFactory->createBookmarkComponent(compositeView.get());
m_components.push_back(bookmarkComponent);
std::shared_ptr<Component> undoRedoComponent = m_componentFactory->createUndoRedoComponent(compositeView.get());
m_components.push_back(undoRedoComponent);
@@ -45,6 +42,9 @@ void ComponentManager::setup(ViewLayout* viewLayout)
std::shared_ptr<Component> searchComponent = m_componentFactory->createSearchComponent(compositeView.get());
m_components.push_back(searchComponent);
std::shared_ptr<Component> bookmarkComponent = m_componentFactory->createBookmarkComponent(compositeView.get());
m_components.push_back(bookmarkComponent);
std::shared_ptr<Component> graphComponent = m_componentFactory->createGraphComponent(viewLayout);
m_components.push_back(graphComponent);
@@ -16,8 +16,8 @@
#include "data/bookmark/EdgeBookmark.h"
#include "data/bookmark/NodeBookmark.h"
const std::string BookmarkController::s_edgeSeperatorToken = "=>";
const std::string BookmarkController::s_defaultCategoryName = "Default Bookmark Category";
const std::string BookmarkController::s_edgeSeperatorToken = " => ";
const std::string BookmarkController::s_defaultCategoryName = "default";
BookmarkController::BookmarkController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
@@ -34,7 +34,8 @@ void BookmarkController::clear()
{
}
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getBookmarks(const MessageDisplayBookmarks::BookmarkFilter& filter, const MessageDisplayBookmarks::BookmarkOrder& order) const
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getBookmarks(
const MessageDisplayBookmarks::BookmarkFilter& filter, const MessageDisplayBookmarks::BookmarkOrder& order) const
{
LOG_INFO_STREAM(<< "Retrieving bookmarks with filter \"" << std::to_string(filter) << "\" and order \"" << std::to_string(order) << "\"");
@@ -75,7 +76,8 @@ std::shared_ptr<Bookmark> BookmarkController::getBookmarkForActiveToken() const
{
for (std::shared_ptr<EdgeBookmark> edgeBookmark: getAllEdgeBookmarks())
{
if (!m_activeNodeIds.empty() && edgeBookmark->getActiveNodeId() == m_activeNodeIds.front() && utility::isPermutation(edgeBookmark->getEdgeIds(), m_activeEdgeIds))
if (!m_activeNodeIds.empty() && edgeBookmark->getActiveNodeId() == m_activeNodeIds.front() &&
utility::isPermutation(edgeBookmark->getEdgeIds(), m_activeEdgeIds))
{
return std::make_shared<EdgeBookmark>(*(edgeBookmark.get()));
}
@@ -132,10 +134,6 @@ void BookmarkController::handleMessage(MessageActivateBookmark* message)
if (std::shared_ptr<EdgeBookmark> bookmark = std::dynamic_pointer_cast<EdgeBookmark>(message->bookmark))
{
MessageActivateNodes activateNodes;
activateNodes.addNode(bookmark->getActiveNodeId(), NameHierarchy());
activateNodes.dispatch();
if (!bookmark->getEdgeIds().empty())
{
const Id firstEdgeId = bookmark->getEdgeIds().front();
@@ -146,6 +144,14 @@ void BookmarkController::handleMessage(MessageActivateBookmark* message)
if (bookmark->getEdgeIds().size() == 1)
{
Id activeNodeId = bookmark->getActiveNodeId();
if (activeNodeId)
{
MessageActivateNodes activateNodes;
activateNodes.addNode(activeNodeId, m_storageAccess->getNameHierarchyForNodeId(activeNodeId));
activateNodes.dispatch();
}
MessageActivateEdge(firstEdgeId, Edge::intToType(storageEdge.type), sourceName, targetName).dispatch();
}
else
@@ -292,7 +298,6 @@ void BookmarkController::handleMessage(MessageDeleteBookmark* message)
m_storageAccess->removeBookmark(message->bookmarkId);
cleanBookmarkCategories();
m_bookmarkCache.clear();
if (!getBookmarkForActiveToken())
{
@@ -327,7 +332,6 @@ void BookmarkController::handleMessage(MessageDeleteBookmarkForActiveTokens* mes
m_storageAccess->removeBookmark(bookmark->getId());
cleanBookmarkCategories();
m_bookmarkCache.clear();
m_hasBookmarkForActiveToken = false;
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
@@ -347,7 +351,6 @@ void BookmarkController::handleMessage(MessageEditBookmark* message)
m_storageAccess->updateBookmark(message->bookmarkId, message->displayName, message->comment, categoryName);
cleanBookmarkCategories();
m_bookmarkCache.clear();
getView<BookmarkView>()->update();
}
@@ -399,9 +402,9 @@ std::vector<std::shared_ptr<EdgeBookmark>> BookmarkController::getAllEdgeBookmar
std::vector<std::string> BookmarkController::getActiveNodeDisplayNames() const
{
std::vector<std::string> names;
for (const NameHierarchy& nameHierarchy: m_storageAccess->getNameHierarchiesForNodeIds(m_activeNodeIds))
for (Id nodeId : m_activeNodeIds)
{
names.push_back(nameHierarchy.getRawName());
names.push_back(getNodeDisplayName(nodeId));
}
return names;
}
@@ -421,11 +424,19 @@ std::vector<std::string> BookmarkController::getActiveEdgeDisplayNames() const
std::string BookmarkController::getNodeDisplayName(const Id nodeId) const
{
Node::NodeType type = m_storageAccess->getNodeTypeForNodeWithId(nodeId);
NameHierarchy nameHierarchy = m_storageAccess->getNameHierarchyForNodeId(nodeId);
return nameHierarchy.getRawName();
if (type == Node::NODE_FILE)
{
return FilePath(nameHierarchy.getQualifiedName()).fileName();
}
return nameHierarchy.getQualifiedName();
}
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getFilteredBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkFilter& filter) const
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getFilteredBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkFilter& filter) const
{
std::vector<std::shared_ptr<Bookmark>> result;
@@ -457,7 +468,8 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getFilteredBookmarks(
return result;
}
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getOrderedBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkOrder& order) const
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getOrderedBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkOrder& order) const
{
std::vector<std::shared_ptr<Bookmark>> result = bookmarks;
@@ -481,7 +493,8 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getOrderedBookmarks(c
return result;
}
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getDateOrderedBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getDateOrderedBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const
{
std::vector<std::shared_ptr<Bookmark>> result = bookmarks;
@@ -495,7 +508,8 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getDateOrderedBookmar
return result;
}
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getNameOrderedBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getNameOrderedBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const
{
std::vector<std::shared_ptr<Bookmark>> result = bookmarks;
@@ -511,6 +525,8 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getNameOrderedBookmar
void BookmarkController::cleanBookmarkCategories()
{
m_bookmarkCache.clear();
std::vector<std::shared_ptr<Bookmark>> bookmarks = getAllBookmarks();
for (const BookmarkCategory& category: getAllBookmarkCategories())
@@ -42,7 +42,8 @@ public:
virtual void clear();
std::vector<std::shared_ptr<Bookmark>> getBookmarks(const MessageDisplayBookmarks::BookmarkFilter& filter, const MessageDisplayBookmarks::BookmarkOrder& order) const;
std::vector<std::shared_ptr<Bookmark>> getBookmarks(
const MessageDisplayBookmarks::BookmarkFilter& filter, const MessageDisplayBookmarks::BookmarkOrder& order) const;
std::vector<std::string> getActiveTokenDisplayNames() const;
std::vector<BookmarkCategory> getAllBookmarkCategories() const;
@@ -86,10 +87,14 @@ private:
std::vector<std::string> getActiveEdgeDisplayNames() const;
std::string getNodeDisplayName(const Id id) const;
std::vector<std::shared_ptr<Bookmark>> getFilteredBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkFilter& filter) const;
std::vector<std::shared_ptr<Bookmark>> getOrderedBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkOrder& order) const;
std::vector<std::shared_ptr<Bookmark>> getDateOrderedBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const;
std::vector<std::shared_ptr<Bookmark>> getNameOrderedBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const;
std::vector<std::shared_ptr<Bookmark>> getFilteredBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkFilter& filter) const;
std::vector<std::shared_ptr<Bookmark>> getOrderedBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkOrder& order) const;
std::vector<std::shared_ptr<Bookmark>> getDateOrderedBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const;
std::vector<std::shared_ptr<Bookmark>> getNameOrderedBookmarks(
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const;
void cleanBookmarkCategories();
+3 -26
View File
@@ -46,40 +46,17 @@ void BookmarkView::handleMessage(MessageDisplayBookmarks* message)
void BookmarkView::handleMessage(MessageDisplayBookmarkCreator* message)
{
std::vector<std::string> names = getController()->getActiveTokenDisplayNames();
if (getController()->hasBookmarkForActiveToken())
{
std::vector<BookmarkCategory> categories = getController()->getAllBookmarkCategories();
displayBookmarkEditor(getController()->getBookmarkForActiveToken(), categories);
displayBookmarkEditor(getController()->getBookmarkForActiveToken(), getController()->getAllBookmarkCategories());
}
else
{
for (unsigned int i = 0; i < names.size(); i++)
{
std::string name = names[i];
// skip the first letter as to not insert a leading space
for (unsigned int i = 1; i < name.size(); i++)
{
if (std::isupper(name[i]))
{
name.insert(i, 1, ' ');
i++;
}
}
names[i] = name;
}
displayBookmarkCreator(names, getController()->getAllBookmarkCategories());
displayBookmarkCreator(getController()->getActiveTokenDisplayNames(), getController()->getAllBookmarkCategories());
}
}
void BookmarkView::handleMessage(MessageDisplayBookmarkEditor* message)
{
std::vector<BookmarkCategory> categories = getController()->getAllBookmarkCategories();
displayBookmarkEditor(message->bookmark, categories);
displayBookmarkEditor(message->bookmark, getController()->getAllBookmarkCategories());
}
-5
View File
@@ -625,11 +625,6 @@ StorageEdge PersistentStorage::getEdgeById(Id edgeId) const
return m_sqliteIndexStorage.getEdgeById(edgeId);
}
bool PersistentStorage::checkEdgeExists(Id edgeId) const
{
return m_sqliteIndexStorage.checkEdgeExists(edgeId);
}
std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLocations(
const std::string& searchTerm, bool caseSensitive
) const
-1
View File
@@ -103,7 +103,6 @@ public:
virtual Id getIdForEdge(
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const;
virtual StorageEdge getEdgeById(Id edgeId) const;
virtual bool checkEdgeExists(Id edgeId) const;
virtual std::shared_ptr<SourceLocationCollection> getFullTextSearchLocations(
const std::string& searchTerm, bool caseSensitive) const;
-21
View File
@@ -504,27 +504,6 @@ std::vector<StorageEdge> SqliteIndexStorage::getEdgesByTargetsType(const std::ve
return doGetAll<StorageEdge>("WHERE target_node_id IN (" + utility::join(utility::toStrings(targetIds), ',') + ") AND type == " + std::to_string(type));
}
bool SqliteIndexStorage::checkEdgeExists(Id edgeId) const
{
CppSQLite3Statement stmt = m_database.compileStatement(
("SELECT type FROM edge WHERE id == " + std::to_string(edgeId) + ";").c_str()
);
CppSQLite3Query q = executeQuery(stmt);
if (!q.eof())
{
const int type = q.getIntField(0, -1);
if (type != -1)
{
return true;
}
}
return false;
}
StorageNode SqliteIndexStorage::getNodeById(Id id) const
{
std::vector<StorageNode> candidates = doGetAll<StorageNode>("WHERE id = " + std::to_string(id));
-2
View File
@@ -67,8 +67,6 @@ public:
std::vector<StorageEdge> getEdgesByTargetType(Id targetId, int type) const;
std::vector<StorageEdge> getEdgesByTargetsType(const std::vector<Id>& targetIds, int type) const;
bool checkEdgeExists(Id edgeId) const;
StorageNode getNodeById(Id id) const;
StorageNode getNodeBySerializedName(const std::string& serializedName) const;
-1
View File
@@ -42,7 +42,6 @@ public:
virtual Id getIdForEdge(
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const = 0;
virtual StorageEdge getEdgeById(Id edgeId) const = 0;
virtual bool checkEdgeExists(Id edgeId) const = 0;
virtual std::shared_ptr<SourceLocationCollection> getFullTextSearchLocations(
const std::string& searchTerm, bool caseSensitive) const = 0;
@@ -114,16 +114,6 @@ StorageEdge StorageAccessProxy::getEdgeById(Id edgeId) const
return StorageEdge();
}
bool StorageAccessProxy::checkEdgeExists(Id edgeId) const
{
if (hasSubject())
{
return m_subject->checkEdgeExists(edgeId);
}
return false;
}
std::shared_ptr<SourceLocationCollection> StorageAccessProxy::getFullTextSearchLocations(
const std::string &searchTerm, bool caseSensitive) const
{
-1
View File
@@ -30,7 +30,6 @@ public:
virtual Id getIdForEdge(
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const;
virtual StorageEdge getEdgeById(Id edgeId) const;
virtual bool checkEdgeExists(Id edgeId) const;
virtual std::shared_ptr<SourceLocationCollection> getFullTextSearchLocations(
const std::string& searchTerm, bool caseSensitive) const;
@@ -14,7 +14,7 @@ public:
NODES,
EDGES
};
enum BookmarkOrder
{
NONE = 0,
@@ -30,6 +30,12 @@ public:
{
}
MessageDisplayBookmarks()
: filter(MessageDisplayBookmarks::BookmarkFilter::ALL)
, order(MessageDisplayBookmarks::BookmarkOrder::NONE)
{
}
static const std::string getStaticType()
{
return "MessageDisplayBookmarks";