data: bookmark refactoring

* implemented handling of aggregations in bookmarks
* split index Storage and bookmark storage
* each sqlite database has its own version now
* added bookmark tests
* fixed creating bookmark tables when project can be loaded but bookmark db does not exist
* fixed font size for bookmarkview tooltips
* using bookmark cache now
* using default category name when none specified by the user
* raising bookmark windows when they should be shown
* clearing a bookmark or category in the editor will now update the star icon accordingly
* non-persistent bookmarks use ids of nodes and edges now (instead of names)
* git ignore .srctrlbm files
This commit is contained in:
malte_langkabel
2017-04-17 10:55:59 +02:00
parent 6cd6552343
commit 2b24b88745
48 changed files with 2856 additions and 2981 deletions
+25 -22
View File
@@ -92,27 +92,30 @@ QtBookmark::~QtBookmark()
void QtBookmark::setBookmark(const std::shared_ptr<Bookmark> bookmark)
{
m_bookmark = bookmark;
m_activateButton->setText(bookmark->getDisplayName().c_str());
if (m_bookmark->isValid() == false)
if (bookmark)
{
m_activateButton->setEnabled(false);
m_editButton->setEnabled(false);
}
m_bookmark = bookmark;
if (m_bookmark->getComment().length() > 0)
{
m_comment->setText(m_bookmark->getComment().c_str());
m_toggleCommentButton->show();
}
else
{
m_toggleCommentButton->hide();
}
m_activateButton->setText(m_bookmark->getName().c_str());
m_dateLabel->setText(getDateString().c_str());
if (m_bookmark->isValid() == false)
{
m_activateButton->setEnabled(false);
m_editButton->setEnabled(false);
}
if (m_bookmark->getComment().length() > 0)
{
m_comment->setText(m_bookmark->getComment().c_str());
m_toggleCommentButton->show();
}
else
{
m_toggleCommentButton->hide();
}
m_dateLabel->setText(getDateString().c_str());
}
}
Id QtBookmark::getBookmarkId() const
@@ -169,7 +172,7 @@ void QtBookmark::resizeEvent(QResizeEvent* event)
return;
}
m_activateButton->setText(m_bookmark->getDisplayName().c_str());
m_activateButton->setText(m_bookmark->getName().c_str());
QTimer::singleShot(10, this, SLOT(elideButtonText()));
}
@@ -218,21 +221,21 @@ void QtBookmark::deleteClicked()
if (ret == 0) // QMessageBox::Yes)
{
MessageDeleteBookmark(m_bookmark->getId(), (dynamic_cast<EdgeBookmark*>(m_bookmark.get()) != NULL)).dispatch();
MessageDeleteBookmark(m_bookmark->getId()).dispatch();
}
}
void QtBookmark::elideButtonText()
{
m_activateButton->setText(m_activateButton->fontMetrics().elidedText(
m_bookmark->getDisplayName().c_str(), Qt::ElideMiddle, m_activateButton->width() - 16));
m_bookmark->getName().c_str(), Qt::ElideMiddle, m_activateButton->width() - 16));
}
void QtBookmark::handleMessage(MessageEditBookmark* message)
{
if (m_bookmark->getId() == message->bookmarkId)
{
m_bookmark->setDisplayName(message->displayName);
m_bookmark->setName(message->displayName);
m_bookmark->setComment(message->comment);
m_activateButton->setText(message->displayName.c_str());
+5 -2
View File
@@ -186,19 +186,21 @@ void QtBookmarkBar::doDisplayBookmarkCreator(const std::vector<std::string>& nam
bookmarkCreator->setDisplayName(displayName);
bookmarkCreator->setBookmarkCategories(categories);
bookmarkCreator->show();
bookmarkCreator->raise();
}
void QtBookmarkBar::doDisplayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories)
{
QtBookmarkCreator* bookmarkCreator = new QtBookmarkCreator(NULL, true, bookmark->getId());
bookmarkCreator->setupBookmarkCreator();
bookmarkCreator->setDisplayName(bookmark->getDisplayName());
bookmarkCreator->setDisplayName(bookmark->getName());
bookmarkCreator->setComment(bookmark->getComment());
bookmarkCreator->setBookmarkCategories(categories);
bookmarkCreator->setCurrentBookmarkCategory(bookmark->getCategory());
bookmarkCreator->setIsEdge((dynamic_cast<EdgeBookmark*>(bookmark.get()) != NULL));
bookmarkCreator->show();
bookmarkCreator->raise();
}
void QtBookmarkBar::doDisplayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
@@ -211,6 +213,7 @@ void QtBookmarkBar::doDisplayBookmarks(const std::vector<std::shared_ptr<Bookmar
m_bookmarkBrowser->setBookmarks(bookmarks);
m_bookmarkBrowser->show();
m_bookmarkBrowser->raise();
}
void QtBookmarkBar::doSetCreateButtonState(const BookmarkView::CreateButtonState& state)
@@ -248,4 +251,4 @@ void QtBookmarkBar::doSetCreateButtonState(const BookmarkView::CreateButtonState
void QtBookmarkBar::doEnableDisplayButton(bool enable)
{
m_showBookmarksButton->setEnabled(enable);
}
}
@@ -3,7 +3,7 @@
#include <QHBoxLayout>
#include <QMessageBox>
#include "utility/messaging/type/MessageDeleteBookmarkCategoryWithBookmarks.h"
#include "utility/messaging/type/MessageDeleteBookmarkCategory.h"
#include "utility/ResourcePaths.h"
#include "qt/utility/utilityQt.h"
@@ -142,6 +142,6 @@ void QtBookmarkCategory::deleteClicked()
if (ret == 0) // QMessageBox::Yes
{
MessageDeleteBookmarkCategoryWithBookmarks(m_id).dispatch();
MessageDeleteBookmarkCategory(m_id).dispatch();
}
}
+6 -6
View File
@@ -126,17 +126,17 @@ void QtBookmarkBrowser::setBookmarks(const std::vector<std::shared_ptr<Bookmark>
{
m_bookmarkTree->clear();
for (unsigned int i = 0; i < bookmarks.size(); i++)
for (std::shared_ptr<Bookmark> bookmark: bookmarks)
{
QtBookmark* bookmark = new QtBookmark();
bookmark->setBookmark(bookmarks[i]);
QtBookmark* qtBookmark = new QtBookmark();
qtBookmark->setBookmark(bookmark);
QTreeWidgetItem* top = findOrCreateTreeCategory(bookmarks[i]->getCategory());
QTreeWidgetItem* top = findOrCreateTreeCategory(bookmark->getCategory());
QTreeWidgetItem* treeWidgetItem = new QTreeWidgetItem(top);
m_bookmarkTree->setItemWidget(treeWidgetItem, 0, bookmark);
m_bookmarkTree->setItemWidget(treeWidgetItem, 0, qtBookmark);
top->addChild(treeWidgetItem);
bookmark->setTreeWidgetItem(top);
qtBookmark->setTreeWidgetItem(top);
top->setExpanded(true);
}