logic: Use ControllerProxy in Bookmarking UI classes instead of messaging
* changed ControllerProxy to template class * allow passing method pointers and arguments to ControllerProxy * replaced some messages with ControllerProxy calls * moved logic from BookmarkView into BookmarkController
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
/bin/app/data/projects/ignored/
|
/bin/app/data/projects/ignored/
|
||||||
/bin/app/data/java/lib/
|
/bin/app/data/java/lib/
|
||||||
|
/bin/app/data/java/*.jar
|
||||||
/bin/app/user/log/
|
/bin/app/user/log/
|
||||||
/bin/app/user/ApplicationSettings.xml
|
/bin/app/user/ApplicationSettings.xml
|
||||||
/bin/app/user/window_settings.ini
|
/bin/app/user/window_settings.ini
|
||||||
|
|||||||
@@ -383,17 +383,10 @@ add_files(
|
|||||||
utility/messaging/type/MessageClearStatusView.h
|
utility/messaging/type/MessageClearStatusView.h
|
||||||
utility/messaging/type/MessageCodeReference.h
|
utility/messaging/type/MessageCodeReference.h
|
||||||
utility/messaging/type/MessageColorSchemeTest.h
|
utility/messaging/type/MessageColorSchemeTest.h
|
||||||
utility/messaging/type/MessageCreateBookmark.h
|
|
||||||
utility/messaging/type/MessageCreateBookmarkCategory.h
|
|
||||||
utility/messaging/type/MessageDeactivateEdge.h
|
utility/messaging/type/MessageDeactivateEdge.h
|
||||||
utility/messaging/type/MessageDeleteBookmark.h
|
|
||||||
utility/messaging/type/MessageDeleteBookmarkCategory.h
|
|
||||||
utility/messaging/type/MessageDeleteBookmarkForActiveTokens.h
|
|
||||||
utility/messaging/type/MessageDispatchWhenLicenseValid.h
|
utility/messaging/type/MessageDispatchWhenLicenseValid.h
|
||||||
utility/messaging/type/MessageDisplayBookmarkCreator.h
|
utility/messaging/type/MessageDisplayBookmarkCreator.h
|
||||||
utility/messaging/type/MessageDisplayBookmarkEditor.h
|
|
||||||
utility/messaging/type/MessageDisplayBookmarks.h
|
utility/messaging/type/MessageDisplayBookmarks.h
|
||||||
utility/messaging/type/MessageEditBookmark.h
|
|
||||||
utility/messaging/type/MessageEnteredLicense.h
|
utility/messaging/type/MessageEnteredLicense.h
|
||||||
utility/messaging/type/MessageErrorFilterChanged.h
|
utility/messaging/type/MessageErrorFilterChanged.h
|
||||||
utility/messaging/type/MessageFind.h
|
utility/messaging/type/MessageFind.h
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
#include "BookmarkController.h"
|
#include "BookmarkController.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "component/view/BookmarkView.h"
|
#include "component/view/BookmarkView.h"
|
||||||
|
|
||||||
#include "data/access/StorageAccess.h"
|
#include "data/access/StorageAccess.h"
|
||||||
#include "data/bookmark/Bookmark.h"
|
#include "data/bookmark/Bookmark.h"
|
||||||
|
#include "data/bookmark/EdgeBookmark.h"
|
||||||
|
#include "data/bookmark/NodeBookmark.h"
|
||||||
|
|
||||||
#include "utility/messaging/type/MessageActivateEdge.h"
|
#include "utility/messaging/type/MessageActivateEdge.h"
|
||||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||||
|
|
||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
#include "utility/utilityString.h"
|
#include "utility/utilityString.h"
|
||||||
#include "utility/utility.h"
|
#include "utility/utility.h"
|
||||||
|
|
||||||
#include "data/bookmark/EdgeBookmark.h"
|
|
||||||
#include "data/bookmark/NodeBookmark.h"
|
|
||||||
|
|
||||||
const std::string BookmarkController::s_edgeSeperatorToken = " => ";
|
const std::string BookmarkController::s_edgeSeperatorToken = " => ";
|
||||||
const std::string BookmarkController::s_defaultCategoryName = "default";
|
const std::string BookmarkController::s_defaultCategoryName = "default";
|
||||||
|
|
||||||
BookmarkController::BookmarkController(StorageAccess* storageAccess)
|
BookmarkController::BookmarkController(StorageAccess* storageAccess)
|
||||||
: m_storageAccess(storageAccess)
|
: m_storageAccess(storageAccess)
|
||||||
, m_bookmarkCache(storageAccess)
|
, m_bookmarkCache(storageAccess)
|
||||||
|
, m_filter(Bookmark::FILTER_ALL)
|
||||||
|
, m_order(Bookmark::ORDER_DATE_DESCENDING)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,18 +36,326 @@ void BookmarkController::clear()
|
|||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CANNOT_CREATE);
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CANNOT_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getBookmarks(
|
void BookmarkController::displayBookmarks()
|
||||||
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) << "\"");
|
getView<BookmarkView>()->displayBookmarks(getBookmarks(m_filter, m_order));
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> bookmarks = getAllBookmarks();
|
void BookmarkController::displayBookmarksFor(Bookmark::BookmarkFilter filter, Bookmark::BookmarkOrder order)
|
||||||
|
{
|
||||||
|
if (filter != Bookmark::FILTER_UNKNOWN)
|
||||||
|
{
|
||||||
|
m_filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
bookmarks = getFilteredBookmarks(bookmarks, filter);
|
if (order != Bookmark::ORDER_NONE)
|
||||||
|
{
|
||||||
|
m_order = order;
|
||||||
|
}
|
||||||
|
|
||||||
bookmarks = getOrderedBookmarks(bookmarks, order);
|
displayBookmarks();
|
||||||
|
}
|
||||||
|
|
||||||
return bookmarks;
|
void BookmarkController::createBookmark(
|
||||||
|
const std::string& name, const std::string& comment, const std::string& category, Id nodeId
|
||||||
|
){
|
||||||
|
LOG_INFO_STREAM(<< "Attempting to create new bookmark");
|
||||||
|
|
||||||
|
BookmarkCategory bookmarkCategory(0, category.empty() ? s_defaultCategoryName : category);
|
||||||
|
|
||||||
|
if (!m_activeEdgeIds.empty())
|
||||||
|
{
|
||||||
|
LOG_INFO_STREAM(<< "Creating Edge Bookmark");
|
||||||
|
|
||||||
|
EdgeBookmark bookmark(0, name, comment, TimeStamp::now(), bookmarkCategory);
|
||||||
|
bookmark.setEdgeIds(m_activeEdgeIds);
|
||||||
|
|
||||||
|
if (!m_activeNodeIds.empty())
|
||||||
|
{
|
||||||
|
bookmark.setActiveNodeId(m_activeNodeIds.front());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_ERROR("Cannot create bookmark for edge if no active node exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_storageAccess->addEdgeBookmark(bookmark);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_INFO_STREAM(<< "Creating Node Bookmark");
|
||||||
|
|
||||||
|
NodeBookmark bookmark(0, name, comment, TimeStamp::now(), bookmarkCategory);
|
||||||
|
if (nodeId)
|
||||||
|
{
|
||||||
|
bookmark.addNodeId(nodeId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bookmark.setNodeIds(m_activeNodeIds);
|
||||||
|
}
|
||||||
|
m_storageAccess->addNodeBookmark(bookmark);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bookmarkCache.clear();
|
||||||
|
|
||||||
|
if (!nodeId || (m_activeNodeIds.size() == 1 && m_activeNodeIds[0] == nodeId))
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::editBookmark(
|
||||||
|
Id bookmarkId, const std::string& name, const std::string& comment, const std::string& category
|
||||||
|
){
|
||||||
|
LOG_INFO_STREAM(<< "Attempting to update Bookmark " << bookmarkId);
|
||||||
|
|
||||||
|
m_storageAccess->updateBookmark(bookmarkId, name, comment, category.size() ? category : s_defaultCategoryName);
|
||||||
|
|
||||||
|
cleanBookmarkCategories();
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::deleteBookmark(Id bookmarkId)
|
||||||
|
{
|
||||||
|
LOG_INFO_STREAM(<< "Attempting to delete Bookmark " << bookmarkId);
|
||||||
|
|
||||||
|
m_storageAccess->removeBookmark(bookmarkId);
|
||||||
|
|
||||||
|
cleanBookmarkCategories();
|
||||||
|
|
||||||
|
if (!getBookmarkForActiveToken())
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::deleteBookmarkCategory(Id categoryId)
|
||||||
|
{
|
||||||
|
m_storageAccess->removeBookmarkCategory(categoryId);
|
||||||
|
|
||||||
|
m_bookmarkCache.clear();
|
||||||
|
|
||||||
|
if (!getBookmarkForActiveToken())
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::deleteBookmarkForActiveTokens()
|
||||||
|
{
|
||||||
|
if (std::shared_ptr<Bookmark> bookmark = getBookmarkForActiveToken())
|
||||||
|
{
|
||||||
|
LOG_INFO_STREAM(<< "Deleting bookmark " << bookmark->getName());
|
||||||
|
|
||||||
|
m_storageAccess->removeBookmark(bookmark->getId());
|
||||||
|
|
||||||
|
cleanBookmarkCategories();
|
||||||
|
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_WARNING_STREAM(<< "No Bookmark to delete for active tokens.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::activateBookmark(const std::shared_ptr<Bookmark> bookmark)
|
||||||
|
{
|
||||||
|
LOG_INFO_STREAM(<< "Attempting to activate Bookmark");
|
||||||
|
|
||||||
|
if (std::shared_ptr<EdgeBookmark> edgeBookmark = std::dynamic_pointer_cast<EdgeBookmark>(bookmark))
|
||||||
|
{
|
||||||
|
if (!edgeBookmark->getEdgeIds().empty())
|
||||||
|
{
|
||||||
|
const Id firstEdgeId = edgeBookmark->getEdgeIds().front();
|
||||||
|
const StorageEdge storageEdge = m_storageAccess->getEdgeById(firstEdgeId);
|
||||||
|
|
||||||
|
const NameHierarchy sourceName = m_storageAccess->getNameHierarchyForNodeId(storageEdge.sourceNodeId);
|
||||||
|
const NameHierarchy targetName = m_storageAccess->getNameHierarchyForNodeId(storageEdge.targetNodeId);
|
||||||
|
|
||||||
|
if (edgeBookmark->getEdgeIds().size() == 1)
|
||||||
|
{
|
||||||
|
Id activeNodeId = edgeBookmark->getActiveNodeId();
|
||||||
|
if (activeNodeId)
|
||||||
|
{
|
||||||
|
MessageActivateNodes activateNodes;
|
||||||
|
activateNodes.addNode(activeNodeId, m_storageAccess->getNameHierarchyForNodeId(activeNodeId));
|
||||||
|
activateNodes.dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageActivateEdge(firstEdgeId, Edge::intToType(storageEdge.type), sourceName, targetName).dispatch();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageActivateEdge activateEdge(0, Edge::EdgeType::EDGE_AGGREGATION, sourceName, targetName);
|
||||||
|
for (const Id aggregatedEdgeId: edgeBookmark->getEdgeIds())
|
||||||
|
{
|
||||||
|
activateEdge.aggregationIds.push_back(aggregatedEdgeId);
|
||||||
|
}
|
||||||
|
activateEdge.dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_ERROR_STREAM(<< "Failed to activate bookmark, did not find edges to activate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (std::shared_ptr<NodeBookmark> nodeBookmark = std::dynamic_pointer_cast<NodeBookmark>(bookmark))
|
||||||
|
{
|
||||||
|
MessageActivateNodes activateNodes;
|
||||||
|
|
||||||
|
for (Id nodeId: nodeBookmark->getNodeIds())
|
||||||
|
{
|
||||||
|
activateNodes.addNode(nodeId, m_storageAccess->getNameHierarchyForNodeId(nodeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
activateNodes.dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::showBookmarkCreator(Id nodeId)
|
||||||
|
{
|
||||||
|
if (!canCreateBookmark() && !nodeId)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BookmarkView* view = getView<BookmarkView>();
|
||||||
|
|
||||||
|
if (nodeId)
|
||||||
|
{
|
||||||
|
std::shared_ptr<Bookmark> bookmark = getBookmarkForNodeId(nodeId);
|
||||||
|
if (bookmark != nullptr)
|
||||||
|
{
|
||||||
|
view->displayBookmarkEditor(bookmark, getAllBookmarkCategories());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view->displayBookmarkCreator(getDisplayNamesForNodeId(nodeId), getAllBookmarkCategories(), nodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::shared_ptr<Bookmark> bookmark = getBookmarkForActiveToken();
|
||||||
|
if (bookmark != nullptr)
|
||||||
|
{
|
||||||
|
view->displayBookmarkEditor(bookmark, getAllBookmarkCategories());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view->displayBookmarkCreator(getActiveTokenDisplayNames(), getAllBookmarkCategories(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::showBookmarkEditor(const std::shared_ptr<Bookmark> bookmark)
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->displayBookmarkEditor(bookmark, getAllBookmarkCategories());
|
||||||
|
}
|
||||||
|
|
||||||
|
BookmarkController::BookmarkCache::BookmarkCache(StorageAccess* storageAccess)
|
||||||
|
: m_storageAccess(storageAccess)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::BookmarkCache::clear()
|
||||||
|
{
|
||||||
|
m_nodeBookmarksValid = false;
|
||||||
|
m_edgeBookmarksValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<NodeBookmark> BookmarkController::BookmarkCache::getAllNodeBookmarks()
|
||||||
|
{
|
||||||
|
if (!m_nodeBookmarksValid)
|
||||||
|
{
|
||||||
|
m_nodeBookmarks = m_storageAccess->getAllNodeBookmarks();
|
||||||
|
m_nodeBookmarksValid = true;
|
||||||
|
}
|
||||||
|
return m_nodeBookmarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<EdgeBookmark> BookmarkController::BookmarkCache::getAllEdgeBookmarks()
|
||||||
|
{
|
||||||
|
if (!m_edgeBookmarksValid)
|
||||||
|
{
|
||||||
|
m_edgeBookmarks = m_storageAccess->getAllEdgeBookmarks();
|
||||||
|
m_edgeBookmarksValid = true;
|
||||||
|
}
|
||||||
|
return m_edgeBookmarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::handleMessage(MessageActivateAll* message)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::handleMessage(MessageActivateBookmark* message)
|
||||||
|
{
|
||||||
|
activateBookmark(message->bookmark);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::handleMessage(MessageActivateTokens* message)
|
||||||
|
{
|
||||||
|
m_activeEdgeIds.clear();
|
||||||
|
|
||||||
|
if (message->isEdge || message->isAggregation)
|
||||||
|
{
|
||||||
|
m_activeEdgeIds = message->tokenIds;
|
||||||
|
|
||||||
|
if (getBookmarkForActiveToken())
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!message->isEdge)
|
||||||
|
{
|
||||||
|
m_activeNodeIds = message->tokenIds;
|
||||||
|
|
||||||
|
if (getBookmarkForActiveToken())
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::handleMessage(MessageDisplayBookmarks* message)
|
||||||
|
{
|
||||||
|
displayBookmarksFor(message->filter, message->order);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::handleMessage(MessageDisplayBookmarkCreator* message)
|
||||||
|
{
|
||||||
|
showBookmarkCreator(message->nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::handleMessage(MessageFinishedParsing* message)
|
||||||
|
{
|
||||||
|
m_bookmarkCache.clear();
|
||||||
|
getView<BookmarkView>()->enableDisplayBookmarks(true);
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookmarkController::handleMessage(MessageShowErrors* message)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> BookmarkController::getActiveTokenDisplayNames() const
|
std::vector<std::string> BookmarkController::getActiveTokenDisplayNames() const
|
||||||
@@ -117,259 +425,6 @@ bool BookmarkController::canCreateBookmark() const
|
|||||||
return m_activeNodeIds.size() || m_activeEdgeIds.size();
|
return m_activeNodeIds.size() || m_activeEdgeIds.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarkController::BookmarkCache::BookmarkCache(StorageAccess* storageAccess)
|
|
||||||
: m_storageAccess(storageAccess)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::BookmarkCache::clear()
|
|
||||||
{
|
|
||||||
m_nodeBookmarksValid = false;
|
|
||||||
m_edgeBookmarksValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<NodeBookmark> BookmarkController::BookmarkCache::getAllNodeBookmarks()
|
|
||||||
{
|
|
||||||
if (!m_nodeBookmarksValid)
|
|
||||||
{
|
|
||||||
m_nodeBookmarks = m_storageAccess->getAllNodeBookmarks();
|
|
||||||
m_nodeBookmarksValid = true;
|
|
||||||
}
|
|
||||||
return m_nodeBookmarks;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<EdgeBookmark> BookmarkController::BookmarkCache::getAllEdgeBookmarks()
|
|
||||||
{
|
|
||||||
if (!m_edgeBookmarksValid)
|
|
||||||
{
|
|
||||||
m_edgeBookmarks = m_storageAccess->getAllEdgeBookmarks();
|
|
||||||
m_edgeBookmarksValid = true;
|
|
||||||
}
|
|
||||||
return m_edgeBookmarks;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageActivateAll* message)
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageActivateBookmark* message)
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "Attempting to activate Bookmark");
|
|
||||||
|
|
||||||
if (std::shared_ptr<EdgeBookmark> bookmark = std::dynamic_pointer_cast<EdgeBookmark>(message->bookmark))
|
|
||||||
{
|
|
||||||
if (!bookmark->getEdgeIds().empty())
|
|
||||||
{
|
|
||||||
const Id firstEdgeId = bookmark->getEdgeIds().front();
|
|
||||||
const StorageEdge storageEdge = m_storageAccess->getEdgeById(firstEdgeId);
|
|
||||||
|
|
||||||
const NameHierarchy sourceName = m_storageAccess->getNameHierarchyForNodeId(storageEdge.sourceNodeId);
|
|
||||||
const NameHierarchy targetName = m_storageAccess->getNameHierarchyForNodeId(storageEdge.targetNodeId);
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
MessageActivateEdge activateEdge(0, Edge::EdgeType::EDGE_AGGREGATION, sourceName, targetName);
|
|
||||||
for (const Id aggregatedEdgeId: bookmark->getEdgeIds())
|
|
||||||
{
|
|
||||||
activateEdge.aggregationIds.push_back(aggregatedEdgeId);
|
|
||||||
}
|
|
||||||
activateEdge.dispatch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_ERROR_STREAM(<< "Failed to activate bookmark, did not find edges to activate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (std::shared_ptr<NodeBookmark> bookmark = std::dynamic_pointer_cast<NodeBookmark>(message->bookmark))
|
|
||||||
{
|
|
||||||
MessageActivateNodes activateNodes;
|
|
||||||
|
|
||||||
for (Id nodeId: bookmark->getNodeIds())
|
|
||||||
{
|
|
||||||
activateNodes.addNode(nodeId, m_storageAccess->getNameHierarchyForNodeId(nodeId));
|
|
||||||
}
|
|
||||||
|
|
||||||
activateNodes.dispatch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageActivateTokens* message)
|
|
||||||
{
|
|
||||||
m_activeEdgeIds.clear();
|
|
||||||
|
|
||||||
if (message->isEdge || message->isAggregation)
|
|
||||||
{
|
|
||||||
m_activeEdgeIds = message->tokenIds;
|
|
||||||
|
|
||||||
if (getBookmarkForActiveToken())
|
|
||||||
{
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!message->isEdge)
|
|
||||||
{
|
|
||||||
m_activeNodeIds = message->tokenIds;
|
|
||||||
|
|
||||||
if (getBookmarkForActiveToken())
|
|
||||||
{
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageCreateBookmark* message)
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "Attempting to create new bookmark");
|
|
||||||
|
|
||||||
BookmarkCategory category(0, message->categoryName.empty() ? s_defaultCategoryName : message->categoryName);
|
|
||||||
|
|
||||||
if (!m_activeEdgeIds.empty())
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "Creating Edge Bookmark");
|
|
||||||
|
|
||||||
EdgeBookmark bookmark(0, message->displayName, message->comment, TimeStamp::now(), category);
|
|
||||||
bookmark.setEdgeIds(m_activeEdgeIds);
|
|
||||||
|
|
||||||
if (!m_activeNodeIds.empty())
|
|
||||||
{
|
|
||||||
bookmark.setActiveNodeId(m_activeNodeIds.front());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_ERROR("Cannot create bookmark for edge if no active node exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
m_storageAccess->addEdgeBookmark(bookmark);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "Creating Node Bookmark");
|
|
||||||
|
|
||||||
NodeBookmark bookmark(0, message->displayName, message->comment, TimeStamp::now(), category);
|
|
||||||
if (message->nodeId)
|
|
||||||
{
|
|
||||||
bookmark.addNodeId(message->nodeId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bookmark.setNodeIds(m_activeNodeIds);
|
|
||||||
}
|
|
||||||
m_storageAccess->addNodeBookmark(bookmark);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bookmarkCache.clear();
|
|
||||||
|
|
||||||
if (!message->nodeId || (m_activeNodeIds.size() == 1 && m_activeNodeIds[0] == message->nodeId))
|
|
||||||
{
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
getView<BookmarkView>()->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageCreateBookmarkCategory* message)
|
|
||||||
{
|
|
||||||
const std::string& categoryName = message->name.empty() ? s_defaultCategoryName : message->name;
|
|
||||||
LOG_INFO_STREAM(<< "Attempting to create new Bookmark category \"" << categoryName << "\"");
|
|
||||||
m_storageAccess->addBookmarkCategory(categoryName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageDeleteBookmark* message)
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "Attempting to delete Bookmark " << std::to_string(message->bookmarkId));
|
|
||||||
|
|
||||||
m_storageAccess->removeBookmark(message->bookmarkId);
|
|
||||||
|
|
||||||
cleanBookmarkCategories();
|
|
||||||
|
|
||||||
if (!getBookmarkForActiveToken())
|
|
||||||
{
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
getView<BookmarkView>()->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageDeleteBookmarkCategory* message)
|
|
||||||
{
|
|
||||||
m_storageAccess->removeBookmarkCategory(message->categoryId);
|
|
||||||
|
|
||||||
m_bookmarkCache.clear();
|
|
||||||
|
|
||||||
if (!getBookmarkForActiveToken())
|
|
||||||
{
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
getView<BookmarkView>()->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageDeleteBookmarkForActiveTokens* message)
|
|
||||||
{
|
|
||||||
if (std::shared_ptr<Bookmark> bookmark = getBookmarkForActiveToken())
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "Deleting bookmark " << bookmark->getName());
|
|
||||||
|
|
||||||
m_storageAccess->removeBookmark(bookmark->getId());
|
|
||||||
|
|
||||||
cleanBookmarkCategories();
|
|
||||||
|
|
||||||
getView<BookmarkView>()->setCreateButtonState(BookmarkView::CreateButtonState::CAN_CREATE);
|
|
||||||
getView<BookmarkView>()->update();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_WARNING_STREAM(<< "No Bookmark to delete for active tokens.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageEditBookmark* message)
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "Attempting to update Bookmark " << std::to_string(message->bookmarkId));
|
|
||||||
|
|
||||||
const std::string& categoryName = message->categoryName.empty() ? s_defaultCategoryName : message->categoryName;
|
|
||||||
m_storageAccess->updateBookmark(message->bookmarkId, message->displayName, message->comment, categoryName);
|
|
||||||
|
|
||||||
cleanBookmarkCategories();
|
|
||||||
|
|
||||||
getView<BookmarkView>()->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageFinishedParsing* message)
|
|
||||||
{
|
|
||||||
m_bookmarkCache.clear();
|
|
||||||
getView<BookmarkView>()->enableDisplayBookmarks(true);
|
|
||||||
|
|
||||||
getView<BookmarkView>()->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkController::handleMessage(MessageShowErrors* message)
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getAllBookmarks() const
|
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getAllBookmarks() const
|
||||||
{
|
{
|
||||||
LOG_INFO_STREAM(<< "Retrieving all bookmarks");
|
LOG_INFO_STREAM(<< "Retrieving all bookmarks");
|
||||||
@@ -408,6 +463,17 @@ std::vector<std::shared_ptr<EdgeBookmark>> BookmarkController::getAllEdgeBookmar
|
|||||||
return bookmarks;
|
return bookmarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getBookmarks(
|
||||||
|
Bookmark::BookmarkFilter filter, Bookmark::BookmarkOrder order
|
||||||
|
) const {
|
||||||
|
LOG_INFO_STREAM(<< "Retrieving bookmarks with filter \"" << filter << "\" and order \"" << order << "\"");
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<Bookmark>> bookmarks = getAllBookmarks();
|
||||||
|
bookmarks = getFilteredBookmarks(bookmarks, filter);
|
||||||
|
bookmarks = getOrderedBookmarks(bookmarks, order);
|
||||||
|
return bookmarks;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> BookmarkController::getActiveNodeDisplayNames() const
|
std::vector<std::string> BookmarkController::getActiveNodeDisplayNames() const
|
||||||
{
|
{
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
@@ -445,15 +511,15 @@ std::string BookmarkController::getNodeDisplayName(const Id nodeId) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getFilteredBookmarks(
|
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getFilteredBookmarks(
|
||||||
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkFilter& filter) const
|
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, Bookmark::BookmarkFilter filter) const
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<Bookmark>> result;
|
std::vector<std::shared_ptr<Bookmark>> result;
|
||||||
|
|
||||||
if (filter == MessageDisplayBookmarks::BookmarkFilter::ALL)
|
if (filter == Bookmark::FILTER_ALL)
|
||||||
{
|
{
|
||||||
return bookmarks;
|
return bookmarks;
|
||||||
}
|
}
|
||||||
else if (filter == MessageDisplayBookmarks::BookmarkFilter::NODES)
|
else if (filter == Bookmark::FILTER_NODES)
|
||||||
{
|
{
|
||||||
for (const std::shared_ptr<Bookmark>& bookmark: bookmarks)
|
for (const std::shared_ptr<Bookmark>& bookmark: bookmarks)
|
||||||
{
|
{
|
||||||
@@ -463,7 +529,7 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getFilteredBookmarks(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (filter == MessageDisplayBookmarks::BookmarkFilter::EDGES)
|
else if (filter == Bookmark::FILTER_EDGES)
|
||||||
{
|
{
|
||||||
for (const std::shared_ptr<Bookmark>& bookmark: bookmarks)
|
for (const std::shared_ptr<Bookmark>& bookmark: bookmarks)
|
||||||
{
|
{
|
||||||
@@ -478,23 +544,23 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getFilteredBookmarks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getOrderedBookmarks(
|
std::vector<std::shared_ptr<Bookmark>> BookmarkController::getOrderedBookmarks(
|
||||||
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkOrder& order) const
|
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, Bookmark::BookmarkOrder order) const
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<Bookmark>> result = bookmarks;
|
std::vector<std::shared_ptr<Bookmark>> result = bookmarks;
|
||||||
|
|
||||||
if (order == MessageDisplayBookmarks::BookmarkOrder::DATE_ASCENDING)
|
if (order == Bookmark::ORDER_DATE_ASCENDING)
|
||||||
{
|
{
|
||||||
return getDateOrderedBookmarks(result, true);
|
return getDateOrderedBookmarks(result, true);
|
||||||
}
|
}
|
||||||
else if (order == MessageDisplayBookmarks::BookmarkOrder::DATE_DESCENDING)
|
else if (order == Bookmark::ORDER_DATE_DESCENDING)
|
||||||
{
|
{
|
||||||
return getDateOrderedBookmarks(result, false);
|
return getDateOrderedBookmarks(result, false);
|
||||||
}
|
}
|
||||||
else if (order == MessageDisplayBookmarks::BookmarkOrder::NAME_ASCENDING)
|
else if (order == Bookmark::ORDER_NAME_ASCENDING)
|
||||||
{
|
{
|
||||||
return getNameOrderedBookmarks(result, true);
|
return getNameOrderedBookmarks(result, true);
|
||||||
}
|
}
|
||||||
else if (order == MessageDisplayBookmarks::BookmarkOrder::NAME_DESCENDING)
|
else if (order == Bookmark::ORDER_NAME_DESCENDING)
|
||||||
{
|
{
|
||||||
return getNameOrderedBookmarks(result, false);
|
return getNameOrderedBookmarks(result, false);
|
||||||
}
|
}
|
||||||
@@ -588,3 +654,22 @@ bool BookmarkController::bookmarkNameCompare(const std::shared_ptr<Bookmark> a,
|
|||||||
|
|
||||||
return aName.length() < bName.length();
|
return aName.length() < bName.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BookmarkController::update()
|
||||||
|
{
|
||||||
|
BookmarkView* view = getView<BookmarkView>();
|
||||||
|
if (view->bookmarkBrowserIsVisible())
|
||||||
|
{
|
||||||
|
view->displayBookmarks(getBookmarks(m_filter, m_order));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<Bookmark>> bookmarks = getBookmarks(Bookmark::FILTER_ALL, Bookmark::ORDER_DATE_DESCENDING);
|
||||||
|
|
||||||
|
const size_t maxBookmarkMenuCount = 20;
|
||||||
|
if (bookmarks.size() > maxBookmarkMenuCount)
|
||||||
|
{
|
||||||
|
bookmarks.resize(maxBookmarkMenuCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
Application::getInstance()->updateBookmarks(bookmarks);
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,13 +9,8 @@
|
|||||||
#include "utility/messaging/type/MessageActivateAll.h"
|
#include "utility/messaging/type/MessageActivateAll.h"
|
||||||
#include "utility/messaging/type/MessageActivateBookmark.h"
|
#include "utility/messaging/type/MessageActivateBookmark.h"
|
||||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||||
#include "utility/messaging/type/MessageCreateBookmark.h"
|
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
|
||||||
#include "utility/messaging/type/MessageCreateBookmarkCategory.h"
|
|
||||||
#include "utility/messaging/type/MessageDeleteBookmark.h"
|
|
||||||
#include "utility/messaging/type/MessageDeleteBookmarkCategory.h"
|
|
||||||
#include "utility/messaging/type/MessageDeleteBookmarkForActiveTokens.h"
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
||||||
#include "utility/messaging/type/MessageEditBookmark.h"
|
|
||||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||||
#include "utility/messaging/type/MessageShowErrors.h"
|
#include "utility/messaging/type/MessageShowErrors.h"
|
||||||
|
|
||||||
@@ -28,12 +23,8 @@ class BookmarkController
|
|||||||
, public MessageListener<MessageActivateAll>
|
, public MessageListener<MessageActivateAll>
|
||||||
, public MessageListener<MessageActivateBookmark>
|
, public MessageListener<MessageActivateBookmark>
|
||||||
, public MessageListener<MessageActivateTokens>
|
, public MessageListener<MessageActivateTokens>
|
||||||
, public MessageListener<MessageCreateBookmark>
|
, public MessageListener<MessageDisplayBookmarkCreator>
|
||||||
, public MessageListener<MessageCreateBookmarkCategory>
|
, public MessageListener<MessageDisplayBookmarks>
|
||||||
, public MessageListener<MessageDeleteBookmark>
|
|
||||||
, public MessageListener<MessageDeleteBookmarkCategory>
|
|
||||||
, public MessageListener<MessageDeleteBookmarkForActiveTokens>
|
|
||||||
, public MessageListener<MessageEditBookmark>
|
|
||||||
, public MessageListener<MessageFinishedParsing>
|
, public MessageListener<MessageFinishedParsing>
|
||||||
, public MessageListener<MessageShowErrors>
|
, public MessageListener<MessageShowErrors>
|
||||||
{
|
{
|
||||||
@@ -43,18 +34,20 @@ public:
|
|||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> getBookmarks(
|
void displayBookmarks();
|
||||||
const MessageDisplayBookmarks::BookmarkFilter& filter, const MessageDisplayBookmarks::BookmarkOrder& order) const;
|
void displayBookmarksFor(Bookmark::BookmarkFilter filter, Bookmark::BookmarkOrder order);
|
||||||
|
|
||||||
std::vector<std::string> getActiveTokenDisplayNames() const;
|
void createBookmark(const std::string& name, const std::string& comment, const std::string& category, Id nodeId);
|
||||||
std::vector<std::string> getDisplayNamesForNodeId(Id nodeId) const;
|
void editBookmark(Id bookmarkId, const std::string& name, const std::string& comment, const std::string& category);
|
||||||
|
|
||||||
std::vector<BookmarkCategory> getAllBookmarkCategories() const;
|
void deleteBookmark(Id bookmarkId);
|
||||||
|
void deleteBookmarkCategory(Id categoryId);
|
||||||
|
void deleteBookmarkForActiveTokens();
|
||||||
|
|
||||||
std::shared_ptr<Bookmark> getBookmarkForActiveToken() const;
|
void activateBookmark(const std::shared_ptr<Bookmark> bookmark);
|
||||||
std::shared_ptr<Bookmark> getBookmarkForNodeId(Id nodeId) const;
|
|
||||||
|
|
||||||
bool canCreateBookmark() const;
|
void showBookmarkCreator(Id nodeId = 0);
|
||||||
|
void showBookmarkEditor(const std::shared_ptr<Bookmark> bookmark);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class BookmarkCache
|
class BookmarkCache
|
||||||
@@ -78,27 +71,35 @@ private:
|
|||||||
virtual void handleMessage(MessageActivateAll* message);
|
virtual void handleMessage(MessageActivateAll* message);
|
||||||
virtual void handleMessage(MessageActivateBookmark* message);
|
virtual void handleMessage(MessageActivateBookmark* message);
|
||||||
virtual void handleMessage(MessageActivateTokens* message);
|
virtual void handleMessage(MessageActivateTokens* message);
|
||||||
virtual void handleMessage(MessageCreateBookmark* message);
|
virtual void handleMessage(MessageDisplayBookmarkCreator* message);
|
||||||
virtual void handleMessage(MessageCreateBookmarkCategory* message);
|
virtual void handleMessage(MessageDisplayBookmarks* message);
|
||||||
virtual void handleMessage(MessageDeleteBookmark* message);
|
|
||||||
virtual void handleMessage(MessageDeleteBookmarkCategory* message);
|
|
||||||
virtual void handleMessage(MessageDeleteBookmarkForActiveTokens* message);
|
|
||||||
virtual void handleMessage(MessageEditBookmark* message);
|
|
||||||
virtual void handleMessage(MessageFinishedParsing* message);
|
virtual void handleMessage(MessageFinishedParsing* message);
|
||||||
virtual void handleMessage(MessageShowErrors* message);
|
virtual void handleMessage(MessageShowErrors* message);
|
||||||
|
|
||||||
|
std::vector<std::string> getActiveTokenDisplayNames() const;
|
||||||
|
std::vector<std::string> getDisplayNamesForNodeId(Id nodeId) const;
|
||||||
|
|
||||||
|
std::vector<BookmarkCategory> getAllBookmarkCategories() const;
|
||||||
|
|
||||||
|
std::shared_ptr<Bookmark> getBookmarkForActiveToken() const;
|
||||||
|
std::shared_ptr<Bookmark> getBookmarkForNodeId(Id nodeId) const;
|
||||||
|
|
||||||
|
bool canCreateBookmark() const;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> getAllBookmarks() const;
|
std::vector<std::shared_ptr<Bookmark>> getAllBookmarks() const;
|
||||||
std::vector<std::shared_ptr<NodeBookmark>> getAllNodeBookmarks() const;
|
std::vector<std::shared_ptr<NodeBookmark>> getAllNodeBookmarks() const;
|
||||||
std::vector<std::shared_ptr<EdgeBookmark>> getAllEdgeBookmarks() const;
|
std::vector<std::shared_ptr<EdgeBookmark>> getAllEdgeBookmarks() const;
|
||||||
|
std::vector<std::shared_ptr<Bookmark>> getBookmarks(
|
||||||
|
Bookmark::BookmarkFilter filter, Bookmark::BookmarkOrder order) const;
|
||||||
|
|
||||||
std::vector<std::string> getActiveNodeDisplayNames() const;
|
std::vector<std::string> getActiveNodeDisplayNames() const;
|
||||||
std::vector<std::string> getActiveEdgeDisplayNames() const;
|
std::vector<std::string> getActiveEdgeDisplayNames() const;
|
||||||
std::string getNodeDisplayName(const Id id) const;
|
std::string getNodeDisplayName(const Id id) const;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> getFilteredBookmarks(
|
std::vector<std::shared_ptr<Bookmark>> getFilteredBookmarks(
|
||||||
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkFilter& filter) const;
|
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, Bookmark::BookmarkFilter filter) const;
|
||||||
std::vector<std::shared_ptr<Bookmark>> getOrderedBookmarks(
|
std::vector<std::shared_ptr<Bookmark>> getOrderedBookmarks(
|
||||||
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const MessageDisplayBookmarks::BookmarkOrder& order) const;
|
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, Bookmark::BookmarkOrder order) const;
|
||||||
std::vector<std::shared_ptr<Bookmark>> getDateOrderedBookmarks(
|
std::vector<std::shared_ptr<Bookmark>> getDateOrderedBookmarks(
|
||||||
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const;
|
const std::vector<std::shared_ptr<Bookmark>>& bookmarks, const bool ascending) const;
|
||||||
std::vector<std::shared_ptr<Bookmark>> getNameOrderedBookmarks(
|
std::vector<std::shared_ptr<Bookmark>> getNameOrderedBookmarks(
|
||||||
@@ -109,6 +110,8 @@ private:
|
|||||||
static bool bookmarkDateCompare(const std::shared_ptr<Bookmark> a, const std::shared_ptr<Bookmark> b);
|
static bool bookmarkDateCompare(const std::shared_ptr<Bookmark> a, const std::shared_ptr<Bookmark> b);
|
||||||
static bool bookmarkNameCompare(const std::shared_ptr<Bookmark> a, const std::shared_ptr<Bookmark> b);
|
static bool bookmarkNameCompare(const std::shared_ptr<Bookmark> a, const std::shared_ptr<Bookmark> b);
|
||||||
|
|
||||||
|
void update();
|
||||||
|
|
||||||
static const std::string s_edgeSeperatorToken;
|
static const std::string s_edgeSeperatorToken;
|
||||||
static const std::string s_defaultCategoryName;
|
static const std::string s_defaultCategoryName;
|
||||||
|
|
||||||
@@ -117,6 +120,9 @@ private:
|
|||||||
|
|
||||||
std::vector<Id> m_activeNodeIds;
|
std::vector<Id> m_activeNodeIds;
|
||||||
std::vector<Id> m_activeEdgeIds;
|
std::vector<Id> m_activeEdgeIds;
|
||||||
|
|
||||||
|
Bookmark::BookmarkFilter m_filter;
|
||||||
|
Bookmark::BookmarkOrder m_order;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOOKMARK_CONTROLLER_H
|
#endif // BOOKMARK_CONTROLLER_H
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "component/view/View.h"
|
#include "component/view/View.h"
|
||||||
|
|
||||||
|
template <typename ControllerType>
|
||||||
class ControllerProxy
|
class ControllerProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -15,7 +16,6 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ControllerType>
|
|
||||||
void execute(std::function<void(ControllerType*)> callback)
|
void execute(std::function<void(ControllerType*)> callback)
|
||||||
{
|
{
|
||||||
ControllerType* controller = m_view->getController<ControllerType>();
|
ControllerType* controller = m_view->getController<ControllerType>();
|
||||||
@@ -25,16 +25,27 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ControllerType>
|
|
||||||
void executeAsTask(std::function<void(ControllerType*)> callback)
|
void executeAsTask(std::function<void(ControllerType*)> callback)
|
||||||
{
|
{
|
||||||
ControllerType* controller = m_view->getController<ControllerType>();
|
ControllerType* controller = m_view->getController<ControllerType>();
|
||||||
if (controller)
|
if (controller)
|
||||||
{
|
{
|
||||||
Task::dispatch(std::make_shared<TaskLambda>(
|
Task::dispatch(std::make_shared<TaskLambda>(
|
||||||
[callback, controller]()
|
std::bind(callback, controller)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FuncType, typename... Args>
|
||||||
|
void executeAsTaskWithArgs(FuncType callback, const Args... args)
|
||||||
|
{
|
||||||
|
ControllerType* controller = m_view->getController<ControllerType>();
|
||||||
|
if (controller)
|
||||||
|
{
|
||||||
|
Task::dispatch(std::make_shared<TaskLambda>(
|
||||||
|
[func = std::bind(callback, controller, args...)]()
|
||||||
{
|
{
|
||||||
callback(controller);
|
func();
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
#include "component/view/BookmarkView.h"
|
#include "component/view/BookmarkView.h"
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "component/controller/BookmarkController.h"
|
#include "component/controller/BookmarkController.h"
|
||||||
|
|
||||||
BookmarkView::BookmarkView(ViewLayout* viewLayout)
|
BookmarkView::BookmarkView(ViewLayout* viewLayout)
|
||||||
: View(viewLayout)
|
: View(viewLayout)
|
||||||
, m_filter(MessageDisplayBookmarks::BookmarkFilter::ALL)
|
|
||||||
, m_order(MessageDisplayBookmarks::BookmarkOrder::DATE_DESCENDING)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,84 +16,7 @@ std::string BookmarkView::getName() const
|
|||||||
return "BookmarkView";
|
return "BookmarkView";
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::update()
|
|
||||||
{
|
|
||||||
if (bookmarkBrowserIsVisible())
|
|
||||||
{
|
|
||||||
displayBookmarks(getController()->getBookmarks(m_filter, m_order));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Bookmark>> bookmarks = getController()->getBookmarks(
|
|
||||||
MessageDisplayBookmarks::BookmarkFilter::ALL,
|
|
||||||
MessageDisplayBookmarks::BookmarkOrder::DATE_DESCENDING
|
|
||||||
);
|
|
||||||
|
|
||||||
const size_t maxBookmarkMenuCount = 20;
|
|
||||||
if (bookmarks.size() > maxBookmarkMenuCount)
|
|
||||||
{
|
|
||||||
bookmarks.resize(maxBookmarkMenuCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
Application::getInstance()->updateBookmarks(bookmarks);
|
|
||||||
}
|
|
||||||
|
|
||||||
BookmarkController* BookmarkView::getController()
|
BookmarkController* BookmarkView::getController()
|
||||||
{
|
{
|
||||||
return View::getController<BookmarkController>();
|
return View::getController<BookmarkController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkView::handleMessage(MessageDisplayBookmarks* message)
|
|
||||||
{
|
|
||||||
if (bookmarkBrowserIsVisible() == true)
|
|
||||||
{
|
|
||||||
m_filter = message->filter;
|
|
||||||
m_order = message->order;
|
|
||||||
|
|
||||||
displayBookmarks(getController()->getBookmarks(message->filter, message->order));
|
|
||||||
}
|
|
||||||
|
|
||||||
displayBookmarks(getController()->getBookmarks(m_filter, m_order));
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkView::handleMessage(MessageDisplayBookmarkCreator* message)
|
|
||||||
{
|
|
||||||
if (!getController()->canCreateBookmark() && !message->nodeId)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message->nodeId)
|
|
||||||
{
|
|
||||||
if (getController()->getBookmarkForNodeId(message->nodeId) != nullptr)
|
|
||||||
{
|
|
||||||
displayBookmarkEditor(
|
|
||||||
getController()->getBookmarkForNodeId(message->nodeId),
|
|
||||||
getController()->getAllBookmarkCategories()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
displayBookmarkCreator(
|
|
||||||
getController()->getDisplayNamesForNodeId(message->nodeId),
|
|
||||||
getController()->getAllBookmarkCategories(),
|
|
||||||
message->nodeId
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (getController()->getBookmarkForActiveToken() != nullptr)
|
|
||||||
{
|
|
||||||
displayBookmarkEditor(getController()->getBookmarkForActiveToken(), getController()->getAllBookmarkCategories());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
displayBookmarkCreator(getController()->getActiveTokenDisplayNames(), getController()->getAllBookmarkCategories(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BookmarkView::handleMessage(MessageDisplayBookmarkEditor* message)
|
|
||||||
{
|
|
||||||
displayBookmarkEditor(message->bookmark, getController()->getAllBookmarkCategories());
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,22 +1,13 @@
|
|||||||
#ifndef BOOKMARK_VIEW_H
|
#ifndef BOOKMARK_VIEW_H
|
||||||
#define BOOKMARK_VIEW_H
|
#define BOOKMARK_VIEW_H
|
||||||
|
|
||||||
#include "data/bookmark/Bookmark.h"
|
|
||||||
|
|
||||||
#include "component/view/View.h"
|
#include "component/view/View.h"
|
||||||
|
#include "data/bookmark/Bookmark.h"
|
||||||
#include "utility/messaging/MessageListener.h"
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarkEditor.h"
|
|
||||||
|
|
||||||
class BookmarkController;
|
class BookmarkController;
|
||||||
|
|
||||||
class BookmarkView
|
class BookmarkView
|
||||||
: public View
|
: public View
|
||||||
, public MessageListener<MessageDisplayBookmarks>
|
|
||||||
, public MessageListener<MessageDisplayBookmarkCreator>
|
|
||||||
, public MessageListener<MessageDisplayBookmarkEditor>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BookmarkView(ViewLayout* viewLayout);
|
BookmarkView(ViewLayout* viewLayout);
|
||||||
@@ -32,25 +23,18 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual void setCreateButtonState(const CreateButtonState& state) = 0;
|
virtual void setCreateButtonState(const CreateButtonState& state) = 0;
|
||||||
virtual void enableDisplayBookmarks(bool enable) = 0;
|
|
||||||
|
|
||||||
virtual void update();
|
virtual void displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks) = 0;
|
||||||
|
virtual void displayBookmarkEditor(
|
||||||
|
std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories) = 0;
|
||||||
|
virtual void displayBookmarkCreator(
|
||||||
|
const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories, Id nodeId) = 0;
|
||||||
|
virtual void enableDisplayBookmarks(bool enable) = 0;
|
||||||
|
|
||||||
virtual bool bookmarkBrowserIsVisible() const = 0;
|
virtual bool bookmarkBrowserIsVisible() const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BookmarkController* getController();
|
BookmarkController* getController();
|
||||||
|
|
||||||
virtual void handleMessage(MessageDisplayBookmarks* message);
|
|
||||||
virtual void handleMessage(MessageDisplayBookmarkCreator* message);
|
|
||||||
virtual void handleMessage(MessageDisplayBookmarkEditor* message);
|
|
||||||
|
|
||||||
virtual void displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks) = 0;
|
|
||||||
virtual void displayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories, Id nodeId) = 0;
|
|
||||||
virtual void displayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories) = 0;
|
|
||||||
|
|
||||||
MessageDisplayBookmarks::BookmarkFilter m_filter;
|
|
||||||
MessageDisplayBookmarks::BookmarkOrder m_order;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOOKMARK_VIEW_H
|
#endif // BOOKMARK_VIEW_H
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "component/view/ViewLayout.h"
|
#include "component/view/ViewLayout.h"
|
||||||
|
|
||||||
class ViewWidgetWrapper;
|
class ViewWidgetWrapper;
|
||||||
|
|
||||||
|
template <typename ControllerType>
|
||||||
class ControllerProxy;
|
class ControllerProxy;
|
||||||
|
|
||||||
class View
|
class View
|
||||||
@@ -44,7 +46,8 @@ protected:
|
|||||||
void setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper);
|
void setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend ControllerProxy;
|
template <typename ControllerType>
|
||||||
|
friend class ControllerProxy;
|
||||||
|
|
||||||
Component* m_component;
|
Component* m_component;
|
||||||
ViewLayout* const m_viewLayout;
|
ViewLayout* const m_viewLayout;
|
||||||
|
|||||||
@@ -12,6 +12,23 @@
|
|||||||
class Bookmark
|
class Bookmark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum BookmarkFilter
|
||||||
|
{
|
||||||
|
FILTER_UNKNOWN = 0,
|
||||||
|
FILTER_ALL,
|
||||||
|
FILTER_NODES,
|
||||||
|
FILTER_EDGES
|
||||||
|
};
|
||||||
|
|
||||||
|
enum BookmarkOrder
|
||||||
|
{
|
||||||
|
ORDER_NONE = 0,
|
||||||
|
ORDER_DATE_ASCENDING,
|
||||||
|
ORDER_DATE_DESCENDING,
|
||||||
|
ORDER_NAME_ASCENDING,
|
||||||
|
ORDER_NAME_DESCENDING
|
||||||
|
};
|
||||||
|
|
||||||
Bookmark(const Id id, const std::string& name, const std::string& comment, const TimeStamp& timeStamp, const BookmarkCategory& category);
|
Bookmark(const Id id, const std::string& name, const std::string& comment, const TimeStamp& timeStamp, const BookmarkCategory& category);
|
||||||
virtual ~Bookmark();
|
virtual ~Bookmark();
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
#ifndef MESSAGE_CREATE_BOOKMARK_H
|
|
||||||
#define MESSAGE_CREATE_BOOKMARK_H
|
|
||||||
|
|
||||||
#include "utility/messaging/Message.h"
|
|
||||||
|
|
||||||
class MessageCreateBookmark
|
|
||||||
: public Message<MessageCreateBookmark>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessageCreateBookmark(const std::string& comment, const std::string& displayName, const std::string& categoryName, Id nodeId)
|
|
||||||
: comment(comment)
|
|
||||||
, displayName(displayName)
|
|
||||||
, categoryName(categoryName)
|
|
||||||
, nodeId(nodeId)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~MessageCreateBookmark()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
|
||||||
{
|
|
||||||
return "MessageCreateBookmark";
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string comment;
|
|
||||||
const std::string displayName;
|
|
||||||
const std::string categoryName;
|
|
||||||
const Id nodeId;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MESSAGE_CREATE_BOOKMARK_H
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#ifndef MESSAGE_CREATE_BOOKMARK_CATEGORY_H
|
|
||||||
#define MESSAGE_CREATE_BOOKMARK_CATEGORY_H
|
|
||||||
|
|
||||||
#include "utility/messaging/Message.h"
|
|
||||||
|
|
||||||
class MessageCreateBookmarkCategory
|
|
||||||
: public Message<MessageCreateBookmarkCategory>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessageCreateBookmarkCategory(const std::string& name)
|
|
||||||
: name(name)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
|
||||||
{
|
|
||||||
return "MessageCreateBookmarkCategory";
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string name;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MESSAGE_CREATE_BOOKMARK_CATEGORY_H
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#ifndef MESSAGE_DELETE_BOOKMARK_H
|
|
||||||
#define MESSAGE_DELETE_BOOKMARK_H
|
|
||||||
|
|
||||||
#include "utility/messaging/Message.h"
|
|
||||||
#include "utility/types.h"
|
|
||||||
|
|
||||||
class MessageDeleteBookmark
|
|
||||||
: public Message<MessageDeleteBookmark>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessageDeleteBookmark(const Id bookmarkId)
|
|
||||||
: bookmarkId(bookmarkId)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~MessageDeleteBookmark()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
|
||||||
{
|
|
||||||
return "MessageDeleteBookmark";
|
|
||||||
}
|
|
||||||
|
|
||||||
const Id bookmarkId;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MESSAGE_DELETE_BOOKMARK_H
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#ifndef MESSAGE_DELETE_BOOKMARK_CATEGORY_H
|
|
||||||
#define MESSAGE_DELETE_BOOKMARK_CATEGORY_H
|
|
||||||
|
|
||||||
#include "utility/messaging/Message.h"
|
|
||||||
#include "utility/types.h"
|
|
||||||
|
|
||||||
class MessageDeleteBookmarkCategory
|
|
||||||
: public Message<MessageDeleteBookmarkCategory>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessageDeleteBookmarkCategory(const Id id)
|
|
||||||
: categoryId(id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~MessageDeleteBookmarkCategory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
|
||||||
{
|
|
||||||
return "MessageDeleteBookmarkCategory";
|
|
||||||
}
|
|
||||||
|
|
||||||
const Id categoryId;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MESSAGE_DELETE_BOOKMARK_CATEGORY_H
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#ifndef MESSAGE_DELETE_BOOKMARK_FOR_ACTIVE_TOKENS
|
|
||||||
#define MESSAGE_DELETE_BOOKMARK_FOR_ACTIVE_TOKENS
|
|
||||||
|
|
||||||
#include "utility/messaging/Message.h"
|
|
||||||
|
|
||||||
class MessageDeleteBookmarkForActiveTokens
|
|
||||||
: public Message<MessageDeleteBookmarkForActiveTokens>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessageDeleteBookmarkForActiveTokens()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~MessageDeleteBookmarkForActiveTokens()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
|
||||||
{
|
|
||||||
return "MessageDeleteBookmarkForActiveTokens";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MESSAGE_DELETE_BOOKMARK_FOR_ACTIVE_TOKENS
|
|
||||||
@@ -7,12 +7,7 @@ class MessageDisplayBookmarkCreator
|
|||||||
: public Message<MessageDisplayBookmarkCreator>
|
: public Message<MessageDisplayBookmarkCreator>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MessageDisplayBookmarkCreator()
|
MessageDisplayBookmarkCreator(Id nodeId = 0)
|
||||||
: nodeId(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageDisplayBookmarkCreator(Id nodeId)
|
|
||||||
: nodeId(nodeId)
|
: nodeId(nodeId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -22,7 +17,7 @@ public:
|
|||||||
return "MessageDisplayBookmarkCreator";
|
return "MessageDisplayBookmarkCreator";
|
||||||
}
|
}
|
||||||
|
|
||||||
Id nodeId;
|
const Id nodeId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_DISPLAY_BOOKMARK_CREATOR_H
|
#endif // MESSAGE_DISPLAY_BOOKMARK_CREATOR_H
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#ifndef MESSAGE_DISPLAY_BOOKMARK_EDITOR_H
|
|
||||||
#define MESSAGE_DISPLAY_BOOKMARK_EDITOR_H
|
|
||||||
|
|
||||||
#include "data/bookmark/Bookmark.h"
|
|
||||||
|
|
||||||
#include "utility/messaging/Message.h"
|
|
||||||
|
|
||||||
class MessageDisplayBookmarkEditor
|
|
||||||
: public Message<MessageDisplayBookmarkEditor>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessageDisplayBookmarkEditor(std::shared_ptr<Bookmark> bookmark)
|
|
||||||
: bookmark(bookmark)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
|
||||||
{
|
|
||||||
return "MessageDisplayBookmarkEditor";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<Bookmark> bookmark;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MESSAGE_DISPLAY_BOOKMARK_EDITOR_H
|
|
||||||
@@ -1,48 +1,29 @@
|
|||||||
#ifndef MESSAGE_DISPLAY_BOOKMARKS_H
|
#ifndef MESSAGE_DISPLAY_BOOKMARKS_H
|
||||||
#define MESSAGE_DISPLAY_BOOKMARKS_H
|
#define MESSAGE_DISPLAY_BOOKMARKS_H
|
||||||
|
|
||||||
|
#include "data/bookmark/Bookmark.h"
|
||||||
#include "utility/messaging/Message.h"
|
#include "utility/messaging/Message.h"
|
||||||
|
|
||||||
class MessageDisplayBookmarks
|
class MessageDisplayBookmarks
|
||||||
: public Message<MessageDisplayBookmarks>
|
: public Message<MessageDisplayBookmarks>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum BookmarkFilter
|
MessageDisplayBookmarks(
|
||||||
{
|
Bookmark::BookmarkFilter filter = Bookmark::FILTER_UNKNOWN,
|
||||||
UNKNOWN = 0,
|
Bookmark::BookmarkOrder order = Bookmark::ORDER_NONE
|
||||||
ALL,
|
)
|
||||||
NODES,
|
|
||||||
EDGES
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BookmarkOrder
|
|
||||||
{
|
|
||||||
NONE = 0,
|
|
||||||
DATE_ASCENDING,
|
|
||||||
DATE_DESCENDING,
|
|
||||||
NAME_ASCENDING,
|
|
||||||
NAME_DESCENDING
|
|
||||||
};
|
|
||||||
|
|
||||||
MessageDisplayBookmarks(const BookmarkFilter& filter, const BookmarkOrder& order)
|
|
||||||
: filter(filter)
|
: filter(filter)
|
||||||
, order(order)
|
, order(order)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDisplayBookmarks()
|
|
||||||
: filter(MessageDisplayBookmarks::BookmarkFilter::ALL)
|
|
||||||
, order(MessageDisplayBookmarks::BookmarkOrder::NONE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
static const std::string getStaticType()
|
||||||
{
|
{
|
||||||
return "MessageDisplayBookmarks";
|
return "MessageDisplayBookmarks";
|
||||||
}
|
}
|
||||||
|
|
||||||
const BookmarkFilter filter;
|
const Bookmark::BookmarkFilter filter;
|
||||||
const BookmarkOrder order;
|
const Bookmark::BookmarkOrder order;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_DISPLAY_BOOKMARKS_H
|
#endif // MESSAGE_DISPLAY_BOOKMARKS_H
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#ifndef MESSAGE_EDIT_BOOKMARK_H
|
|
||||||
#define MESSAGE_EDIT_BOOKMARK_H
|
|
||||||
|
|
||||||
#include "utility/messaging/Message.h"
|
|
||||||
#include "utility/types.h"
|
|
||||||
|
|
||||||
class MessageEditBookmark
|
|
||||||
: public Message<MessageEditBookmark>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessageEditBookmark(Id id, const std::string& comment, const std::string& displayName, const std::string& categoryName)
|
|
||||||
: bookmarkId(id)
|
|
||||||
, comment(comment)
|
|
||||||
, displayName(displayName)
|
|
||||||
, categoryName(categoryName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~MessageEditBookmark()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string getStaticType()
|
|
||||||
{
|
|
||||||
return "MessageEditBookmark";
|
|
||||||
}
|
|
||||||
|
|
||||||
const Id bookmarkId;
|
|
||||||
const std::string comment;
|
|
||||||
const std::string displayName;
|
|
||||||
const std::string categoryName;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MESSAGE_EDIT_BOOKMARK_H
|
|
||||||
@@ -6,15 +6,12 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "utility/messaging/type/MessageActivateBookmark.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "utility/messaging/type/MessageDeleteBookmark.h"
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarkEditor.h"
|
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
|
|
||||||
#include "qt/utility/utilityQt.h"
|
QtBookmark::QtBookmark(ControllerProxy<BookmarkController>* controllerProxy)
|
||||||
|
: m_controllerProxy(controllerProxy)
|
||||||
QtBookmark::QtBookmark()
|
, m_treeWidgetItem(NULL)
|
||||||
: m_treeWidgetItem(NULL)
|
|
||||||
, m_arrowImageName("arrow_line_down.png")
|
, m_arrowImageName("arrow_line_down.png")
|
||||||
, m_hovered(false)
|
, m_hovered(false)
|
||||||
, m_ignoreNextResize(false)
|
, m_ignoreNextResize(false)
|
||||||
@@ -202,12 +199,12 @@ void QtBookmark::leaveEvent(QEvent *event)
|
|||||||
|
|
||||||
void QtBookmark::activateClicked()
|
void QtBookmark::activateClicked()
|
||||||
{
|
{
|
||||||
MessageActivateBookmark(m_bookmark).dispatch();
|
m_controllerProxy->executeAsTaskWithArgs(&BookmarkController::activateBookmark, m_bookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtBookmark::editClicked()
|
void QtBookmark::editClicked()
|
||||||
{
|
{
|
||||||
MessageDisplayBookmarkEditor(m_bookmark).dispatch();
|
m_controllerProxy->executeAsTaskWithArgs(&BookmarkController::showBookmarkEditor, m_bookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtBookmark::deleteClicked()
|
void QtBookmark::deleteClicked()
|
||||||
@@ -222,7 +219,7 @@ void QtBookmark::deleteClicked()
|
|||||||
|
|
||||||
if (ret == 0) // QMessageBox::Yes)
|
if (ret == 0) // QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
MessageDeleteBookmark(m_bookmark->getId()).dispatch();
|
m_controllerProxy->executeAsTaskWithArgs(&BookmarkController::deleteBookmark, m_bookmark->getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
|
#include "component/controller/BookmarkController.h"
|
||||||
|
#include "component/controller/helper/ControllerProxy.h"
|
||||||
#include "data/bookmark/Bookmark.h"
|
#include "data/bookmark/Bookmark.h"
|
||||||
|
|
||||||
class Bookmark;
|
class Bookmark;
|
||||||
@@ -16,7 +18,7 @@ class QtBookmark
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtBookmark();
|
QtBookmark(ControllerProxy<BookmarkController>* controllerProxy);
|
||||||
virtual ~QtBookmark();
|
virtual ~QtBookmark();
|
||||||
|
|
||||||
void setBookmark(const std::shared_ptr<Bookmark> bookmark);
|
void setBookmark(const std::shared_ptr<Bookmark> bookmark);
|
||||||
@@ -46,6 +48,8 @@ private:
|
|||||||
|
|
||||||
std::string getDateString() const;
|
std::string getDateString() const;
|
||||||
|
|
||||||
|
ControllerProxy<BookmarkController>* m_controllerProxy;
|
||||||
|
|
||||||
QPushButton* m_activateButton;
|
QPushButton* m_activateButton;
|
||||||
QPushButton* m_editButton;
|
QPushButton* m_editButton;
|
||||||
QPushButton* m_deleteButton;
|
QPushButton* m_deleteButton;
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
#include "QtBookmarkCategory.h"
|
#include "QtBookmarkCategory.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QPushButton>
|
||||||
#include "utility/messaging/type/MessageDeleteBookmarkCategory.h"
|
#include <QTreeWidget>
|
||||||
#include "utility/ResourcePaths.h"
|
|
||||||
|
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
|
#include "utility/ResourcePaths.h"
|
||||||
|
|
||||||
QtBookmarkCategory::QtBookmarkCategory()
|
QtBookmarkCategory::QtBookmarkCategory(ControllerProxy<BookmarkController>* controllerProxy)
|
||||||
: m_id(0)
|
: m_controllerProxy(controllerProxy)
|
||||||
|
, m_id(0)
|
||||||
{
|
{
|
||||||
setObjectName("bookmark_category");
|
setObjectName("bookmark_category");
|
||||||
|
|
||||||
@@ -125,6 +127,6 @@ void QtBookmarkCategory::deleteClicked()
|
|||||||
|
|
||||||
if (ret == 0) // QMessageBox::Yes
|
if (ret == 0) // QMessageBox::Yes
|
||||||
{
|
{
|
||||||
MessageDeleteBookmarkCategory(m_id).dispatch();
|
m_controllerProxy->executeAsTaskWithArgs(&BookmarkController::deleteBookmarkCategory, m_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,22 @@
|
|||||||
#define QT_BOOKMARK_CATEGORY_H
|
#define QT_BOOKMARK_CATEGORY_H
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QLabel>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QTreeWidget>
|
|
||||||
|
|
||||||
|
#include "component/controller/BookmarkController.h"
|
||||||
|
#include "component/controller/helper/ControllerProxy.h"
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QPushButton;
|
||||||
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
class QtBookmarkCategory
|
class QtBookmarkCategory
|
||||||
: public QFrame
|
: public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtBookmarkCategory();
|
QtBookmarkCategory(ControllerProxy<BookmarkController>* controllerProxy);
|
||||||
~QtBookmarkCategory();
|
~QtBookmarkCategory();
|
||||||
|
|
||||||
void setName(const std::string& name);
|
void setName(const std::string& name);
|
||||||
@@ -38,6 +41,8 @@ private slots:
|
|||||||
void deleteClicked();
|
void deleteClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ControllerProxy<BookmarkController>* m_controllerProxy;
|
||||||
|
|
||||||
QLabel* m_name;
|
QLabel* m_name;
|
||||||
Id m_id;
|
Id m_id;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "component/controller/helper/ControllerProxy.h"
|
|
||||||
#include "component/controller/ScreenSearchController.h"
|
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
|
|
||||||
@@ -30,7 +28,7 @@ bool QtFocusInFilter::eventFilter(QObject* obj, QEvent* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QtScreenSearchBox::QtScreenSearchBox(ControllerProxy* controllerProxy, QWidget* parent)
|
QtScreenSearchBox::QtScreenSearchBox(ControllerProxy<ScreenSearchController>* controllerProxy, QWidget* parent)
|
||||||
: QFrame(parent)
|
: QFrame(parent)
|
||||||
, m_controllerProxy(controllerProxy)
|
, m_controllerProxy(controllerProxy)
|
||||||
{
|
{
|
||||||
@@ -195,7 +193,7 @@ void QtScreenSearchBox::searchQueryChanged()
|
|||||||
|
|
||||||
void QtScreenSearchBox::findMatches()
|
void QtScreenSearchBox::findMatches()
|
||||||
{
|
{
|
||||||
m_controllerProxy->executeAsTask<ScreenSearchController>(
|
m_controllerProxy->executeAsTask(
|
||||||
[this](ScreenSearchController* controller)
|
[this](ScreenSearchController* controller)
|
||||||
{
|
{
|
||||||
std::set<std::string> responderNames;
|
std::set<std::string> responderNames;
|
||||||
@@ -236,12 +234,7 @@ void QtScreenSearchBox::nextPressed()
|
|||||||
|
|
||||||
void QtScreenSearchBox::activateMatch(bool next)
|
void QtScreenSearchBox::activateMatch(bool next)
|
||||||
{
|
{
|
||||||
m_controllerProxy->executeAsTask<ScreenSearchController>(
|
m_controllerProxy->executeAsTaskWithArgs(&ScreenSearchController::activateMatch, next);
|
||||||
[next, this](ScreenSearchController* controller)
|
|
||||||
{
|
|
||||||
controller->activateMatch(next);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtScreenSearchBox::updateMatchLabel()
|
void QtScreenSearchBox::updateMatchLabel()
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
class ControllerProxy;
|
#include "component/controller/helper/ControllerProxy.h"
|
||||||
|
#include "component/controller/ScreenSearchController.h"
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
@@ -33,7 +35,7 @@ class QtScreenSearchBox
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtScreenSearchBox(ControllerProxy* controllerProxy, QWidget* parent = nullptr);
|
QtScreenSearchBox(ControllerProxy<ScreenSearchController>* controllerProxy, QWidget* parent = nullptr);
|
||||||
virtual ~QtScreenSearchBox();
|
virtual ~QtScreenSearchBox();
|
||||||
|
|
||||||
void refreshStyle();
|
void refreshStyle();
|
||||||
@@ -62,7 +64,7 @@ private:
|
|||||||
|
|
||||||
void updateMatchLabel();
|
void updateMatchLabel();
|
||||||
|
|
||||||
ControllerProxy* m_controllerProxy;
|
ControllerProxy<ScreenSearchController>* m_controllerProxy;
|
||||||
|
|
||||||
QLineEdit* m_searchBox;
|
QLineEdit* m_searchBox;
|
||||||
QPushButton* m_matchLabel;
|
QPushButton* m_matchLabel;
|
||||||
|
|||||||
@@ -11,16 +11,12 @@
|
|||||||
#include "qt/window/QtBookmarkBrowser.h"
|
#include "qt/window/QtBookmarkBrowser.h"
|
||||||
#include "qt/view/QtMainView.h"
|
#include "qt/view/QtMainView.h"
|
||||||
#include "qt/window/QtMainWindow.h"
|
#include "qt/window/QtMainWindow.h"
|
||||||
|
|
||||||
#include "utility/messaging/type/MessageDeleteBookmarkForActiveTokens.h"
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
|
|
||||||
#include "utility/ResourcePaths.h"
|
|
||||||
|
|
||||||
#include "settings/ApplicationSettings.h"
|
#include "settings/ApplicationSettings.h"
|
||||||
|
#include "utility/ResourcePaths.h"
|
||||||
|
|
||||||
QtBookmarkView::QtBookmarkView(ViewLayout* viewLayout)
|
QtBookmarkView::QtBookmarkView(ViewLayout* viewLayout)
|
||||||
: BookmarkView(viewLayout)
|
: BookmarkView(viewLayout)
|
||||||
|
, m_controllerProxy(this)
|
||||||
, m_bookmarkBrowser(nullptr)
|
, m_bookmarkBrowser(nullptr)
|
||||||
, m_createButtonState(BookmarkView::CreateButtonState::CANNOT_CREATE)
|
, m_createButtonState(BookmarkView::CreateButtonState::CANNOT_CREATE)
|
||||||
{
|
{
|
||||||
@@ -116,6 +112,85 @@ void QtBookmarkView::setCreateButtonState(const CreateButtonState& state)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtBookmarkView::displayBookmarkCreator(
|
||||||
|
const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories, Id nodeId
|
||||||
|
){
|
||||||
|
m_onQtThread(
|
||||||
|
[=]()
|
||||||
|
{
|
||||||
|
QtBookmarkCreator* bookmarkCreator = new QtBookmarkCreator(
|
||||||
|
&m_controllerProxy,
|
||||||
|
dynamic_cast<QtMainView*>(dynamic_cast<View*>(getViewLayout())->getViewLayout())->getMainWindow()
|
||||||
|
);
|
||||||
|
bookmarkCreator->setupBookmarkCreator();
|
||||||
|
|
||||||
|
std::string displayName = "";
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < names.size(); i++)
|
||||||
|
{
|
||||||
|
displayName += names[i];
|
||||||
|
|
||||||
|
if (i < names.size() - 1)
|
||||||
|
{
|
||||||
|
displayName += "; ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bookmarkCreator->setDisplayName(displayName);
|
||||||
|
bookmarkCreator->setBookmarkCategories(categories);
|
||||||
|
bookmarkCreator->setNodeId(nodeId);
|
||||||
|
|
||||||
|
bookmarkCreator->show();
|
||||||
|
bookmarkCreator->raise();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtBookmarkView::displayBookmarkEditor(
|
||||||
|
std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories
|
||||||
|
){
|
||||||
|
m_onQtThread(
|
||||||
|
[=]()
|
||||||
|
{
|
||||||
|
QtBookmarkCreator* bookmarkCreator = new QtBookmarkCreator(
|
||||||
|
&m_controllerProxy,
|
||||||
|
dynamic_cast<QtMainView*>(dynamic_cast<View*>(getViewLayout())->getViewLayout())->getMainWindow(),
|
||||||
|
bookmark->getId()
|
||||||
|
);
|
||||||
|
|
||||||
|
bookmarkCreator->setupBookmarkCreator();
|
||||||
|
bookmarkCreator->setDisplayName(bookmark->getName());
|
||||||
|
bookmarkCreator->setComment(bookmark->getComment());
|
||||||
|
bookmarkCreator->setBookmarkCategories(categories);
|
||||||
|
bookmarkCreator->setCurrentBookmarkCategory(bookmark->getCategory());
|
||||||
|
|
||||||
|
bookmarkCreator->show();
|
||||||
|
bookmarkCreator->raise();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtBookmarkView::displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||||
|
{
|
||||||
|
m_onQtThread(
|
||||||
|
[=]()
|
||||||
|
{
|
||||||
|
if (m_bookmarkBrowser == nullptr)
|
||||||
|
{
|
||||||
|
m_bookmarkBrowser = new QtBookmarkBrowser(
|
||||||
|
&m_controllerProxy,
|
||||||
|
dynamic_cast<QtMainView*>(dynamic_cast<View*>(getViewLayout())->getViewLayout())->getMainWindow()
|
||||||
|
);
|
||||||
|
m_bookmarkBrowser->setupBookmarkBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bookmarkBrowser->setBookmarks(bookmarks);
|
||||||
|
m_bookmarkBrowser->show();
|
||||||
|
m_bookmarkBrowser->raise();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void QtBookmarkView::enableDisplayBookmarks(bool enable)
|
void QtBookmarkView::enableDisplayBookmarks(bool enable)
|
||||||
{
|
{
|
||||||
m_onQtThread(
|
m_onQtThread(
|
||||||
@@ -142,7 +217,7 @@ void QtBookmarkView::createBookmarkClicked()
|
|||||||
{
|
{
|
||||||
if (m_createButtonState == BookmarkView::CreateButtonState::CAN_CREATE)
|
if (m_createButtonState == BookmarkView::CreateButtonState::CAN_CREATE)
|
||||||
{
|
{
|
||||||
MessageDisplayBookmarkCreator().dispatch();
|
m_controllerProxy.executeAsTaskWithArgs(&BookmarkController::showBookmarkCreator, 0);
|
||||||
}
|
}
|
||||||
else if (m_createButtonState == BookmarkView::CreateButtonState::ALREADY_CREATED)
|
else if (m_createButtonState == BookmarkView::CreateButtonState::ALREADY_CREATED)
|
||||||
{
|
{
|
||||||
@@ -158,89 +233,24 @@ void QtBookmarkView::createBookmarkClicked()
|
|||||||
|
|
||||||
if (ret == 0) // QMessageBox::Yes
|
if (ret == 0) // QMessageBox::Yes
|
||||||
{
|
{
|
||||||
MessageDisplayBookmarkCreator().dispatch();
|
m_controllerProxy.executeAsTaskWithArgs(&BookmarkController::showBookmarkCreator, 0);
|
||||||
}
|
}
|
||||||
else if (ret == 1)
|
else if (ret == 1)
|
||||||
{
|
{
|
||||||
MessageDeleteBookmarkForActiveTokens().dispatch();
|
m_controllerProxy.executeAsTask(&BookmarkController::deleteBookmarkForActiveTokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtBookmarkView::showBookmarksClicked()
|
void QtBookmarkView::showBookmarksClicked()
|
||||||
{
|
{
|
||||||
MessageDisplayBookmarks().dispatch();
|
m_controllerProxy.executeAsTask(&BookmarkController::displayBookmarks);
|
||||||
}
|
|
||||||
|
|
||||||
void QtBookmarkView::displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
|
||||||
{
|
|
||||||
m_onQtThread(
|
|
||||||
[=]()
|
|
||||||
{
|
|
||||||
if (m_bookmarkBrowser == nullptr)
|
|
||||||
{
|
|
||||||
m_bookmarkBrowser = new QtBookmarkBrowser(dynamic_cast<QtMainView*>(dynamic_cast<View*>(getViewLayout())->getViewLayout())->getMainWindow());
|
|
||||||
m_bookmarkBrowser->setupBookmarkBrowser();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bookmarkBrowser->setBookmarks(bookmarks);
|
|
||||||
m_bookmarkBrowser->show();
|
|
||||||
m_bookmarkBrowser->raise();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtBookmarkView::displayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories, Id nodeId)
|
|
||||||
{
|
|
||||||
m_onQtThread(
|
|
||||||
[=]()
|
|
||||||
{
|
|
||||||
QtBookmarkCreator* bookmarkCreator = new QtBookmarkCreator(dynamic_cast<QtMainView*>(dynamic_cast<View*>(getViewLayout())->getViewLayout())->getMainWindow());
|
|
||||||
bookmarkCreator->setupBookmarkCreator();
|
|
||||||
|
|
||||||
std::string displayName = "";
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < names.size(); i++)
|
|
||||||
{
|
|
||||||
displayName += names[i];
|
|
||||||
|
|
||||||
if (i < names.size() - 1)
|
|
||||||
{
|
|
||||||
displayName += "; ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bookmarkCreator->setDisplayName(displayName);
|
|
||||||
bookmarkCreator->setBookmarkCategories(categories);
|
|
||||||
bookmarkCreator->setNodeId(nodeId);
|
|
||||||
|
|
||||||
bookmarkCreator->show();
|
|
||||||
bookmarkCreator->raise();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtBookmarkView::displayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories)
|
|
||||||
{
|
|
||||||
m_onQtThread(
|
|
||||||
[=]()
|
|
||||||
{
|
|
||||||
QtBookmarkCreator* bookmarkCreator = new QtBookmarkCreator(dynamic_cast<QtMainView*>(dynamic_cast<View*>(getViewLayout())->getViewLayout())->getMainWindow(), true, bookmark->getId());
|
|
||||||
bookmarkCreator->setupBookmarkCreator();
|
|
||||||
bookmarkCreator->setDisplayName(bookmark->getName());
|
|
||||||
bookmarkCreator->setComment(bookmark->getComment());
|
|
||||||
bookmarkCreator->setBookmarkCategories(categories);
|
|
||||||
bookmarkCreator->setCurrentBookmarkCategory(bookmark->getCategory());
|
|
||||||
|
|
||||||
bookmarkCreator->show();
|
|
||||||
bookmarkCreator->raise();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtBookmarkView::setStyleSheet()
|
void QtBookmarkView::setStyleSheet()
|
||||||
{
|
{
|
||||||
m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css"))).c_str());
|
m_widget->setStyleSheet(utility::getStyleSheet(
|
||||||
|
ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css"))).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtBookmarkView::refreshStyle()
|
void QtBookmarkView::refreshStyle()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef QT_BOOKMARK_VIEW_H
|
#ifndef QT_BOOKMARK_VIEW_H
|
||||||
#define QT_BOOKMARK_VIEW_H
|
#define QT_BOOKMARK_VIEW_H
|
||||||
|
|
||||||
|
#include "component/controller/BookmarkController.h"
|
||||||
|
#include "component/controller/helper/ControllerProxy.h"
|
||||||
#include "component/view/BookmarkView.h"
|
#include "component/view/BookmarkView.h"
|
||||||
|
|
||||||
#include "qt/utility/QtThreadedFunctor.h"
|
#include "qt/utility/QtThreadedFunctor.h"
|
||||||
@@ -25,6 +27,13 @@ public:
|
|||||||
virtual void refreshView();
|
virtual void refreshView();
|
||||||
|
|
||||||
virtual void setCreateButtonState(const CreateButtonState& state);
|
virtual void setCreateButtonState(const CreateButtonState& state);
|
||||||
|
|
||||||
|
virtual void displayBookmarkCreator(
|
||||||
|
const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories, Id nodeId);
|
||||||
|
virtual void displayBookmarkEditor(
|
||||||
|
std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories);
|
||||||
|
|
||||||
|
virtual void displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||||
virtual void enableDisplayBookmarks(bool enable);
|
virtual void enableDisplayBookmarks(bool enable);
|
||||||
|
|
||||||
virtual bool bookmarkBrowserIsVisible() const;
|
virtual bool bookmarkBrowserIsVisible() const;
|
||||||
@@ -34,13 +43,10 @@ private slots:
|
|||||||
void showBookmarksClicked();
|
void showBookmarksClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
|
||||||
virtual void displayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories, Id nodeId);
|
|
||||||
virtual void displayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories);
|
|
||||||
|
|
||||||
void setStyleSheet();
|
void setStyleSheet();
|
||||||
void refreshStyle();
|
void refreshStyle();
|
||||||
|
|
||||||
|
ControllerProxy<BookmarkController> m_controllerProxy;
|
||||||
QtThreadedLambdaFunctor m_onQtThread;
|
QtThreadedLambdaFunctor m_onQtThread;
|
||||||
|
|
||||||
QFrame* m_widget;
|
QFrame* m_widget;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
#include "component/controller/ScreenSearchController.h"
|
|
||||||
#include "qt/element/QtScreenSearchBox.h"
|
#include "qt/element/QtScreenSearchBox.h"
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "qt/view/QtMainView.h"
|
#include "qt/view/QtMainView.h"
|
||||||
@@ -89,10 +88,5 @@ void QtScreenSearchView::hide()
|
|||||||
m_bar->hide();
|
m_bar->hide();
|
||||||
m_widget->setMatchCount(0);
|
m_widget->setMatchCount(0);
|
||||||
|
|
||||||
m_controllerProxy.executeAsTask<ScreenSearchController>(
|
m_controllerProxy.executeAsTask(&ScreenSearchController::clearMatches);
|
||||||
[](ScreenSearchController* controller)
|
|
||||||
{
|
|
||||||
controller->clearMatches();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define QT_SCREEN_SEARCH_VIEW_H
|
#define QT_SCREEN_SEARCH_VIEW_H
|
||||||
|
|
||||||
#include "component/controller/helper/ControllerProxy.h"
|
#include "component/controller/helper/ControllerProxy.h"
|
||||||
|
#include "component/controller/ScreenSearchController.h"
|
||||||
#include "component/view/ScreenSearchView.h"
|
#include "component/view/ScreenSearchView.h"
|
||||||
#include "qt/utility/QtThreadedFunctor.h"
|
#include "qt/utility/QtThreadedFunctor.h"
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ public slots:
|
|||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ControllerProxy m_controllerProxy;
|
ControllerProxy<ScreenSearchController> m_controllerProxy;
|
||||||
QtThreadedLambdaFunctor m_onQtThread;
|
QtThreadedLambdaFunctor m_onQtThread;
|
||||||
|
|
||||||
QtScreenSearchBox* m_widget;
|
QtScreenSearchBox* m_widget;
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "data/bookmark/Bookmark.h"
|
|
||||||
#include "qt/element/QtBookmark.h"
|
#include "qt/element/QtBookmark.h"
|
||||||
#include "qt/element/QtBookmarkCategory.h"
|
#include "qt/element/QtBookmarkCategory.h"
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
|
|
||||||
QtBookmarkBrowser::QtBookmarkBrowser(QWidget* parent)
|
QtBookmarkBrowser::QtBookmarkBrowser(ControllerProxy<BookmarkController>* controllerProxy, QWidget* parent)
|
||||||
: QtWindow(false, parent)
|
: QtWindow(false, parent)
|
||||||
|
, m_controllerProxy(controllerProxy)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +79,11 @@ void QtBookmarkBrowser::setupBookmarkBrowser()
|
|||||||
m_orderNames.push_back("Date des.");
|
m_orderNames.push_back("Date des.");
|
||||||
|
|
||||||
m_orderComboBox = new QComboBox(this);
|
m_orderComboBox = new QComboBox(this);
|
||||||
// m_orderComboBox->setToolTip("Select Bookmark Order");
|
|
||||||
m_orderComboBox->addItem(m_orderNames[0].c_str());
|
m_orderComboBox->addItem(m_orderNames[0].c_str());
|
||||||
m_orderComboBox->addItem(m_orderNames[1].c_str());
|
m_orderComboBox->addItem(m_orderNames[1].c_str());
|
||||||
m_orderComboBox->addItem(m_orderNames[2].c_str());
|
m_orderComboBox->addItem(m_orderNames[2].c_str());
|
||||||
m_orderComboBox->addItem(m_orderNames[3].c_str());
|
m_orderComboBox->addItem(m_orderNames[3].c_str());
|
||||||
|
m_orderComboBox->setCurrentIndex(3);
|
||||||
m_orderComboBox->setObjectName("order_box");
|
m_orderComboBox->setObjectName("order_box");
|
||||||
headerLayout->addWidget(m_orderComboBox);
|
headerLayout->addWidget(m_orderComboBox);
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ void QtBookmarkBrowser::setBookmarks(const std::vector<std::shared_ptr<Bookmark>
|
|||||||
|
|
||||||
for (const std::shared_ptr<Bookmark>& bookmark : bookmarks)
|
for (const std::shared_ptr<Bookmark>& bookmark : bookmarks)
|
||||||
{
|
{
|
||||||
QtBookmark* qtBookmark = new QtBookmark();
|
QtBookmark* qtBookmark = new QtBookmark(m_controllerProxy);
|
||||||
qtBookmark->setBookmark(bookmark);
|
qtBookmark->setBookmark(bookmark);
|
||||||
|
|
||||||
QTreeWidgetItem* categoryItem = findOrCreateTreeCategory(bookmark->getCategory());
|
QTreeWidgetItem* categoryItem = findOrCreateTreeCategory(bookmark->getCategory());
|
||||||
@@ -184,7 +184,10 @@ void QtBookmarkBrowser::handleNext()
|
|||||||
|
|
||||||
void QtBookmarkBrowser::filterOrOrderChanged(const QString& text)
|
void QtBookmarkBrowser::filterOrOrderChanged(const QString& text)
|
||||||
{
|
{
|
||||||
MessageDisplayBookmarks(getSelectedFilter(), getSelectedOrder()).dispatch();
|
Bookmark::BookmarkFilter filter = getSelectedFilter();
|
||||||
|
Bookmark::BookmarkOrder order = getSelectedOrder();
|
||||||
|
|
||||||
|
m_controllerProxy->executeAsTaskWithArgs(&BookmarkController::displayBookmarksFor, filter, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtBookmarkBrowser::treeItemClicked(QTreeWidgetItem* item, int column)
|
void QtBookmarkBrowser::treeItemClicked(QTreeWidgetItem* item, int column)
|
||||||
@@ -204,45 +207,45 @@ void QtBookmarkBrowser::treeItemClicked(QTreeWidgetItem* item, int column)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDisplayBookmarks::BookmarkFilter QtBookmarkBrowser::getSelectedFilter()
|
Bookmark::BookmarkFilter QtBookmarkBrowser::getSelectedFilter()
|
||||||
{
|
{
|
||||||
std::string text = m_filterComboBox->currentText().toStdString();
|
std::string text = m_filterComboBox->currentText().toStdString();
|
||||||
|
|
||||||
if (text == "Nodes")
|
if (text == "Nodes")
|
||||||
{
|
{
|
||||||
return MessageDisplayBookmarks::BookmarkFilter::NODES;
|
return Bookmark::FILTER_NODES;
|
||||||
}
|
}
|
||||||
else if (text == "Edges")
|
else if (text == "Edges")
|
||||||
{
|
{
|
||||||
return MessageDisplayBookmarks::BookmarkFilter::EDGES;
|
return Bookmark::FILTER_EDGES;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MessageDisplayBookmarks::BookmarkFilter::ALL;
|
return Bookmark::FILTER_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDisplayBookmarks::BookmarkOrder QtBookmarkBrowser::getSelectedOrder()
|
Bookmark::BookmarkOrder QtBookmarkBrowser::getSelectedOrder()
|
||||||
{
|
{
|
||||||
std::string orderString = m_orderComboBox->currentText().toStdString(); // m_orderButton->text().toStdString();
|
std::string orderString = m_orderComboBox->currentText().toStdString();
|
||||||
|
|
||||||
if (orderString == m_orderNames[0])
|
if (orderString == m_orderNames[0])
|
||||||
{
|
{
|
||||||
return MessageDisplayBookmarks::BookmarkOrder::DATE_DESCENDING;
|
return Bookmark::ORDER_NAME_ASCENDING;
|
||||||
}
|
}
|
||||||
else if (orderString == m_orderNames[1])
|
else if (orderString == m_orderNames[1])
|
||||||
{
|
{
|
||||||
return MessageDisplayBookmarks::BookmarkOrder::DATE_ASCENDING;
|
return Bookmark::ORDER_NAME_DESCENDING;
|
||||||
}
|
}
|
||||||
else if (orderString == m_orderNames[2])
|
else if (orderString == m_orderNames[2])
|
||||||
{
|
{
|
||||||
return MessageDisplayBookmarks::BookmarkOrder::NAME_DESCENDING;
|
return Bookmark::ORDER_DATE_ASCENDING;
|
||||||
}
|
}
|
||||||
else if (orderString == m_orderNames[3])
|
else if (orderString == m_orderNames[3])
|
||||||
{
|
{
|
||||||
return MessageDisplayBookmarks::BookmarkOrder::NAME_ASCENDING;
|
return Bookmark::ORDER_DATE_DESCENDING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return MessageDisplayBookmarks::BookmarkOrder::NONE;
|
return Bookmark::ORDER_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +261,7 @@ QTreeWidgetItem* QtBookmarkBrowser::findOrCreateTreeCategory(const BookmarkCateg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtBookmarkCategory* categoryItem = new QtBookmarkCategory();
|
QtBookmarkCategory* categoryItem = new QtBookmarkCategory(m_controllerProxy);
|
||||||
if (category.getName().length() > 0)
|
if (category.getName().length() > 0)
|
||||||
{
|
{
|
||||||
categoryItem->setName(category.getName());
|
categoryItem->setName(category.getName());
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
|
#include "component/controller/BookmarkController.h"
|
||||||
|
#include "component/controller/helper/ControllerProxy.h"
|
||||||
|
#include "data/bookmark/Bookmark.h"
|
||||||
#include "qt/window/QtWindow.h"
|
#include "qt/window/QtWindow.h"
|
||||||
|
|
||||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
|
||||||
|
|
||||||
class Bookmark;
|
|
||||||
class BookmarkCategory;
|
|
||||||
class QtBookmark;
|
class QtBookmark;
|
||||||
|
|
||||||
class QtBookmarkBrowser
|
class QtBookmarkBrowser
|
||||||
@@ -19,7 +18,7 @@ class QtBookmarkBrowser
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtBookmarkBrowser(QWidget* parent = nullptr);
|
QtBookmarkBrowser(ControllerProxy<BookmarkController>* controllerProxy, QWidget* parent = nullptr);
|
||||||
~QtBookmarkBrowser();
|
~QtBookmarkBrowser();
|
||||||
|
|
||||||
void setupBookmarkBrowser();
|
void setupBookmarkBrowser();
|
||||||
@@ -36,11 +35,13 @@ private slots:
|
|||||||
void treeItemClicked(QTreeWidgetItem* item, int column);
|
void treeItemClicked(QTreeWidgetItem* item, int column);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageDisplayBookmarks::BookmarkFilter getSelectedFilter();
|
Bookmark::BookmarkFilter getSelectedFilter();
|
||||||
MessageDisplayBookmarks::BookmarkOrder getSelectedOrder();
|
Bookmark::BookmarkOrder getSelectedOrder();
|
||||||
|
|
||||||
QTreeWidgetItem* findOrCreateTreeCategory(const BookmarkCategory& category);
|
QTreeWidgetItem* findOrCreateTreeCategory(const BookmarkCategory& category);
|
||||||
|
|
||||||
|
ControllerProxy<BookmarkController>* m_controllerProxy;
|
||||||
|
|
||||||
QTreeWidget* m_bookmarkTree;
|
QTreeWidget* m_bookmarkTree;
|
||||||
|
|
||||||
QComboBox* m_filterComboBox;
|
QComboBox* m_filterComboBox;
|
||||||
|
|||||||
@@ -1,24 +1,20 @@
|
|||||||
#include "QtBookmarkCreator.h"
|
#include "QtBookmarkCreator.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QComboBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QTextEdit>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "data/bookmark/BookmarkCategory.h"
|
#include "data/bookmark/BookmarkCategory.h"
|
||||||
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "utility/messaging/type/MessageCreateBookmark.h"
|
|
||||||
#include "utility/messaging/type/MessageCreateBookmarkCategory.h"
|
|
||||||
#include "utility/messaging/type/MessageEditBookmark.h"
|
|
||||||
#include "utility/messaging/type/MessageStatus.h"
|
#include "utility/messaging/type/MessageStatus.h"
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
|
|
||||||
#include "qt/utility/utilityQt.h"
|
QtBookmarkCreator::QtBookmarkCreator(ControllerProxy<BookmarkController>* controllerProxy, QWidget* parent, Id bookmarkId)
|
||||||
|
|
||||||
QtBookmarkCreator::QtBookmarkCreator(QWidget* parent, bool edit, Id id)
|
|
||||||
: QtWindow(false, parent)
|
: QtWindow(false, parent)
|
||||||
, m_edit(edit)
|
, m_controllerProxy(controllerProxy)
|
||||||
, m_bookmarkId(id)
|
, m_editBookmarkId(bookmarkId)
|
||||||
, m_categoryCount(0)
|
|
||||||
, m_nodeId(0)
|
, m_nodeId(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -34,7 +30,7 @@ void QtBookmarkCreator::setupBookmarkCreator()
|
|||||||
|
|
||||||
{
|
{
|
||||||
// title
|
// title
|
||||||
QLabel* title = new QLabel(m_edit ? "Edit Bookmark" : "Create Bookmark");
|
QLabel* title = new QLabel(m_editBookmarkId ? "Edit Bookmark" : "Create Bookmark");
|
||||||
title->setObjectName("creator_title_label");
|
title->setObjectName("creator_title_label");
|
||||||
layout->addWidget(title);
|
layout->addWidget(title);
|
||||||
|
|
||||||
@@ -86,17 +82,13 @@ void QtBookmarkCreator::setupBookmarkCreator()
|
|||||||
m_categoryBox->setInsertPolicy(QComboBox::InsertPolicy::InsertAtTop);
|
m_categoryBox->setInsertPolicy(QComboBox::InsertPolicy::InsertAtTop);
|
||||||
layout->addWidget(m_categoryBox);
|
layout->addWidget(m_categoryBox);
|
||||||
|
|
||||||
connect(m_categoryBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &QtBookmarkCreator::onComboBoxIndexChanged);
|
|
||||||
|
|
||||||
m_categoryCount = m_categoryBox->count();
|
|
||||||
|
|
||||||
layout->addSpacing(20);
|
layout->addSpacing(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
layout->addLayout(createButtons());
|
layout->addLayout(createButtons());
|
||||||
setPreviousVisible(false);
|
setPreviousVisible(false);
|
||||||
updateNextButton(m_edit ? "Save" : "Create");
|
updateNextButton(m_editBookmarkId ? "Save" : "Create");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -166,21 +158,22 @@ void QtBookmarkCreator::resizeEvent(QResizeEvent* event)
|
|||||||
|
|
||||||
void QtBookmarkCreator::handleNext()
|
void QtBookmarkCreator::handleNext()
|
||||||
{
|
{
|
||||||
QString qComment = m_commentBox->toPlainText();
|
std::string name = m_displayName->text().toStdString();
|
||||||
QString qDisplayName = m_displayName->text();
|
std::string comment = m_commentBox->toPlainText().toStdString();
|
||||||
QString qCategory = m_categoryBox->currentText();
|
std::string category = m_categoryBox->currentText().toStdString();
|
||||||
|
|
||||||
if (m_edit)
|
if (m_editBookmarkId)
|
||||||
{
|
{
|
||||||
MessageEditBookmark(
|
m_controllerProxy->executeAsTaskWithArgs(
|
||||||
m_bookmarkId, qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString()).dispatch();
|
&BookmarkController::editBookmark, m_editBookmarkId, name, comment, category);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageCreateBookmark(qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString(), m_nodeId).dispatch();
|
m_controllerProxy->executeAsTaskWithArgs(
|
||||||
}
|
&BookmarkController::createBookmark, name, comment, category, m_nodeId);
|
||||||
|
|
||||||
MessageStatus("Creating Bookmark for active Token").dispatch();
|
MessageStatus("Creating Bookmark for active Token").dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -194,15 +187,3 @@ void QtBookmarkCreator::onNameChanged(const QString& text)
|
|||||||
{
|
{
|
||||||
setNextEnabled(text.length() > 0);
|
setNextEnabled(text.length() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtBookmarkCreator::onComboBoxIndexChanged(int index)
|
|
||||||
{
|
|
||||||
if (m_categoryBox->count() > m_categoryCount)
|
|
||||||
{
|
|
||||||
std::string categoryName = m_categoryBox->currentText().toStdString();
|
|
||||||
|
|
||||||
MessageCreateBookmarkCategory(categoryName).dispatch();
|
|
||||||
|
|
||||||
m_categoryCount = m_categoryBox->count();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
#ifndef QT_BOOKMARK_CREATOR_H
|
#ifndef QT_BOOKMARK_CREATOR_H
|
||||||
#define QT_BOOKMARK_CREATOR_H
|
#define QT_BOOKMARK_CREATOR_H
|
||||||
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QTextEdit>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "component/controller/BookmarkController.h"
|
||||||
|
#include "component/controller/helper/ControllerProxy.h"
|
||||||
#include "qt/window/QtWindow.h"
|
#include "qt/window/QtWindow.h"
|
||||||
|
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
class BookmarkCategory;
|
class BookmarkCategory;
|
||||||
|
class QComboBox;
|
||||||
|
class QLineEdit;
|
||||||
|
class QTextEdit;
|
||||||
|
|
||||||
class QtBookmarkCreator
|
class QtBookmarkCreator
|
||||||
: public QtWindow
|
: public QtWindow
|
||||||
@@ -18,7 +19,7 @@ class QtBookmarkCreator
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtBookmarkCreator(QWidget* parent = nullptr, bool edit = false, Id id = 0);
|
QtBookmarkCreator(ControllerProxy<BookmarkController>* controllerProxy, QWidget* parent = nullptr, Id bookmarkId = 0);
|
||||||
~QtBookmarkCreator();
|
~QtBookmarkCreator();
|
||||||
|
|
||||||
void setupBookmarkCreator();
|
void setupBookmarkCreator();
|
||||||
@@ -41,18 +42,16 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onNameChanged(const QString& text);
|
void onNameChanged(const QString& text);
|
||||||
void onComboBoxIndexChanged(int index);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_edit;
|
ControllerProxy<BookmarkController>* m_controllerProxy;
|
||||||
Id m_bookmarkId; // important for editing
|
|
||||||
|
const Id m_editBookmarkId;
|
||||||
|
|
||||||
QLineEdit* m_displayName;
|
QLineEdit* m_displayName;
|
||||||
QTextEdit* m_commentBox;
|
QTextEdit* m_commentBox;
|
||||||
QComboBox* m_categoryBox;
|
QComboBox* m_categoryBox;
|
||||||
|
|
||||||
int m_categoryCount;
|
|
||||||
|
|
||||||
Id m_nodeId;
|
Id m_nodeId;
|
||||||
|
|
||||||
QWidget* m_headerBackground;
|
QWidget* m_headerBackground;
|
||||||
|
|||||||
@@ -540,6 +540,8 @@ void QtProjectWizzard::duplicateSelectedSourceGroup()
|
|||||||
case SOURCE_GROUP_CXX_CDB:
|
case SOURCE_GROUP_CXX_CDB:
|
||||||
newSourceGroup = std::make_shared<SourceGroupSettingsCxxCdb>(*dynamic_cast<SourceGroupSettingsCxxCdb*>(oldSourceGroup.get()));
|
newSourceGroup = std::make_shared<SourceGroupSettingsCxxCdb>(*dynamic_cast<SourceGroupSettingsCxxCdb*>(oldSourceGroup.get()));
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
newSourceGroup->setId(utility::getUuidString());
|
newSourceGroup->setId(utility::getUuidString());
|
||||||
|
|||||||
Reference in New Issue
Block a user