ui: Fixed layout of QtBookmarkBrowser
* fixed window size and resizing * fixed layout and spacing * removed focus rects on Mac * fixed filter dropdown style for Mac * reuse button handling from QtWindow * use different colors for category and bookmark rows * allow clicking full row for expansion * show edit and delete button only on hover * ellide bookmark name when little space
This commit is contained in:
@@ -455,13 +455,4 @@
|
||||
<hover>#878787</hover>
|
||||
<text>#878787</text>
|
||||
</tab>
|
||||
|
||||
<bookmark>
|
||||
<button>
|
||||
<icon>black</icon>
|
||||
<icon_disabled>#FDFDFD</icon_disabled>
|
||||
<icon_hover>white</icon_hover>
|
||||
</button>
|
||||
</bookmark>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -422,13 +422,4 @@
|
||||
<active>grey</active>
|
||||
</table_line_2>
|
||||
</table>
|
||||
|
||||
<bookmark>
|
||||
<button>
|
||||
<icon>black</icon>
|
||||
<icon_disabled>#FDFDFD</icon_disabled>
|
||||
<icon_hover>white</icon_hover>
|
||||
</button>
|
||||
</bookmark>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -429,13 +429,4 @@
|
||||
<hover>#878787</hover>
|
||||
<text>#878787</text>
|
||||
</tab>
|
||||
|
||||
<bookmark>
|
||||
<button>
|
||||
<icon>black</icon>
|
||||
<icon_disabled>#FDFDFD</icon_disabled>
|
||||
<icon_hover>white</icon_hover>
|
||||
</button>
|
||||
</bookmark>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
/* General settings */
|
||||
* {
|
||||
font-size: 16px;
|
||||
/* font-family: "<setting:font_name>"; */
|
||||
}
|
||||
|
||||
#header {
|
||||
background-color: #2E3C86;
|
||||
}
|
||||
|
||||
#body {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
/* window */
|
||||
|
||||
|
||||
/* header */
|
||||
/* Bookmark browser header */
|
||||
|
||||
#header_background {
|
||||
background-color: #2E3C86;
|
||||
@@ -23,132 +11,92 @@
|
||||
border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
#filter_box, #order_box {
|
||||
/* background-color: #227abf;
|
||||
color: white; */
|
||||
max-width: 100px;
|
||||
min-width: 100px;
|
||||
margin-left: 50px;
|
||||
margin-right: 100px;
|
||||
}
|
||||
|
||||
#title {
|
||||
color: white;
|
||||
font-size: <setting:font_size+8>px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-top: 40px;
|
||||
margin-left: 30px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
#filter_label, #order_label {
|
||||
color: white;
|
||||
font-size: <setting:font_size+6>px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-top: 65px;
|
||||
margin-left: 40px;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
/* body */
|
||||
#filter_box, #order_box {
|
||||
/*margin-left: 20px;*/
|
||||
}
|
||||
|
||||
/* Bookmark browser body */
|
||||
|
||||
#bookmark_tree {
|
||||
border: none;
|
||||
border-top: 1px solid #DFDFDF;
|
||||
border-bottom: 1px solid #DFDFDF;
|
||||
margin: 0px;
|
||||
margin-top: 50px;
|
||||
margin-bottom: 25px;
|
||||
max-width: 532px;
|
||||
max-height: 460px;
|
||||
min-width: 500px;
|
||||
min-height: 200px;
|
||||
background-color: white;
|
||||
alternate-background-color: #dadada; /* color every single line alternating, however I want to color complete categories alternating */
|
||||
}
|
||||
|
||||
/* Bookmark category */
|
||||
|
||||
#bookmark_category {
|
||||
background: #297BBD;
|
||||
border-bottom: 1px solid white;
|
||||
padding: 1px 10px 0px 5px;
|
||||
}
|
||||
|
||||
#bookmark_category:hover {
|
||||
background: #2C85CC;
|
||||
}
|
||||
|
||||
#category_name {
|
||||
font-size: <setting:font_size+6>px;
|
||||
}
|
||||
|
||||
#bookmark_category {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
#bookmark {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
#close_button {
|
||||
min-width: 150px;
|
||||
max-width: 150px;
|
||||
}
|
||||
|
||||
#close_button {
|
||||
margin-right: 20px;
|
||||
background-color: white;
|
||||
color: black;
|
||||
border-color: black;
|
||||
}
|
||||
|
||||
#close_button:hover {
|
||||
background: #2E3C86;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
/* bookmark category */
|
||||
|
||||
#bookmark_category {
|
||||
margin-left: 15px;
|
||||
margin-right: 50px;
|
||||
}
|
||||
|
||||
#category_expand_button {
|
||||
#category_expand_button, #category_delete_button, #comment_button, #edit_button, #delete_button {
|
||||
border: none;
|
||||
background: transparent;
|
||||
min-width: 30px;
|
||||
max-width: 30px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
#category_delete_button {
|
||||
min-width: 30px;
|
||||
max-width: 30px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* bookmark */
|
||||
/* Bookmark */
|
||||
|
||||
#bookmark {
|
||||
margin-left: 15px;
|
||||
margin-right: 50px;
|
||||
padding: 3px 10px 3px 23px;
|
||||
background: white;
|
||||
border-bottom: 1px solid #DFDFDF;
|
||||
}
|
||||
|
||||
#comment_button {
|
||||
background: transparent;
|
||||
#bookmark_comment {
|
||||
font-size: 12px;
|
||||
margin: 3px 0px 3px 26px;
|
||||
}
|
||||
|
||||
#activate_button {
|
||||
background: white;
|
||||
border: none;
|
||||
min-width: 30px;
|
||||
max-width: 30px;
|
||||
border-radius: 8px;
|
||||
color: black;
|
||||
font-size: 16px;
|
||||
padding: 3px 8px 2px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#comment_button:hover {
|
||||
color: #2D3C86;
|
||||
}
|
||||
|
||||
#edit_button {
|
||||
min-width: 30px;
|
||||
max-width: 30px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
#delete_button {
|
||||
min-width: 30px;
|
||||
max-width: 30px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
#activate_button:hover {
|
||||
color: white;
|
||||
background: #2D3C86;
|
||||
}
|
||||
|
||||
#date_label {
|
||||
font-size: <setting:font_size>px;
|
||||
min-width: 100px;
|
||||
max-width: 100px;
|
||||
margin: 3px 5px 0px;
|
||||
font-size: 12px;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
/* Search bar buttons */
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
#include "QtBookmark.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "qt/window/QtBookmarkCreator.h"
|
||||
|
||||
#include "data/bookmark/EdgeBookmark.h"
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "utility/messaging/type/MessageActivateBookmark.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarkEditor.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "data/bookmark/EdgeBookmark.h"
|
||||
#include "qt/window/QtBookmarkCreator.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtBookmark::QtBookmark()
|
||||
: m_treeWidgetItem(NULL)
|
||||
, m_arrowImageName("arrow_right.png")
|
||||
, m_hovered(false)
|
||||
, m_ignoreNextResize(false)
|
||||
{
|
||||
setObjectName("bookmark");
|
||||
|
||||
m_layout = new QVBoxLayout();
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(m_layout);
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
|
||||
QHBoxLayout* buttonsLayout = new QHBoxLayout();
|
||||
buttonsLayout->setSpacing(0);
|
||||
@@ -33,67 +36,60 @@ QtBookmark::QtBookmark()
|
||||
m_toggleCommentButton = new QPushButton();
|
||||
m_toggleCommentButton->setObjectName("comment_button");
|
||||
m_toggleCommentButton->setToolTip("Show Comment");
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
m_toggleCommentButton->setIconSize(QSize(10, 10));
|
||||
utility::setWidgetRetainsSpaceWhenHidden(m_toggleCommentButton);
|
||||
buttonsLayout->addWidget(m_toggleCommentButton);
|
||||
|
||||
m_dateLabel = new QLabel();
|
||||
m_dateLabel->setObjectName("date_label");
|
||||
m_dateLabel->setText("n/a");
|
||||
buttonsLayout->addWidget(m_dateLabel);
|
||||
updateArrow();
|
||||
|
||||
m_activateButton = new QPushButton();
|
||||
m_activateButton->setObjectName("activate_button");
|
||||
m_activateButton->setToolTip("Activate bookmark");
|
||||
m_activateButton->setText("Bookmark");
|
||||
m_activateButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
buttonsLayout->addWidget(m_activateButton);
|
||||
|
||||
m_dateLabel = new QLabel();
|
||||
m_dateLabel->setObjectName("date_label");
|
||||
buttonsLayout->addWidget(m_dateLabel);
|
||||
|
||||
buttonsLayout->addStretch();
|
||||
|
||||
m_editButton = new QPushButton();
|
||||
m_editButton->setObjectName("edit_button");
|
||||
m_editButton->setToolTip("Edit bookmark");
|
||||
m_editButton->setText("Edit");
|
||||
m_editButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
m_editButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_edit_icon.png").c_str()));
|
||||
utility::setWidgetRetainsSpaceWhenHidden(m_editButton);
|
||||
m_editButton->hide();
|
||||
buttonsLayout->addWidget(m_editButton);
|
||||
|
||||
m_deleteButton = new QPushButton();
|
||||
m_deleteButton->setObjectName("delete_button");
|
||||
m_deleteButton->setToolTip("Delete bookmark");
|
||||
m_deleteButton->setText("Delete");
|
||||
m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_delete_icon.png").c_str()));
|
||||
utility::setWidgetRetainsSpaceWhenHidden(m_deleteButton);
|
||||
m_deleteButton->hide();
|
||||
buttonsLayout->addWidget(m_deleteButton);
|
||||
|
||||
m_layout->addLayout(buttonsLayout);
|
||||
layout->addLayout(buttonsLayout);
|
||||
|
||||
m_comment = new QLabel();
|
||||
m_comment->setText("no comment");
|
||||
m_comment->hide();
|
||||
m_comment = new QLabel("");
|
||||
m_comment->setObjectName("bookmark_comment");
|
||||
m_comment->setWordWrap(true);
|
||||
m_layout->addWidget(m_comment);
|
||||
|
||||
m_comment->hide();
|
||||
layout->addWidget(m_comment);
|
||||
|
||||
connect(m_activateButton, SIGNAL(clicked()), this, SLOT(activateClicked()));
|
||||
connect(m_editButton, SIGNAL(clicked()), this, SLOT(editClicked()));
|
||||
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
|
||||
connect(m_toggleCommentButton, SIGNAL(clicked()), this, SLOT(commentToggled()));
|
||||
|
||||
refreshStyle();
|
||||
}
|
||||
|
||||
QtBookmark::~QtBookmark()
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmark::setName(const std::string& name)
|
||||
{
|
||||
m_activateButton->setText(name.c_str());
|
||||
}
|
||||
|
||||
std::string QtBookmark::getName() const
|
||||
{
|
||||
return m_bookmark->getDisplayName();
|
||||
}
|
||||
|
||||
void QtBookmark::setBookmark(const std::shared_ptr<Bookmark> bookmark)
|
||||
{
|
||||
m_bookmark = bookmark;
|
||||
@@ -109,11 +105,14 @@ void QtBookmark::setBookmark(const std::shared_ptr<Bookmark> bookmark)
|
||||
if (m_bookmark->getComment().length() > 0)
|
||||
{
|
||||
m_comment->setText(m_bookmark->getComment().c_str());
|
||||
m_activateButton->setToolTip(bookmark->getComment().c_str());
|
||||
m_toggleCommentButton->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_toggleCommentButton->hide();
|
||||
}
|
||||
m_dateLabel->setText(getDateString().c_str());
|
||||
|
||||
getDateString();
|
||||
m_dateLabel->setText(getDateString().c_str());
|
||||
}
|
||||
|
||||
Id QtBookmark::getBookmarkId() const
|
||||
@@ -131,31 +130,72 @@ void QtBookmark::setTreeWidgetItem(QTreeWidgetItem* treeWidgetItem)
|
||||
m_treeWidgetItem = treeWidgetItem;
|
||||
}
|
||||
|
||||
void QtBookmark::refreshStyle()
|
||||
void QtBookmark::commentToggled()
|
||||
{
|
||||
if (m_editButton != NULL)
|
||||
if (!m_toggleCommentButton->isVisible())
|
||||
{
|
||||
m_editButton->setText("");
|
||||
m_editButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_edit_icon.png").c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_deleteButton != NULL)
|
||||
m_ignoreNextResize = true;
|
||||
|
||||
if (m_comment->isVisible() == false)
|
||||
{
|
||||
m_deleteButton->setText("");
|
||||
m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_delete_icon.png").c_str()));
|
||||
m_arrowImageName = "arrow_down.png";
|
||||
m_comment->show();
|
||||
m_comment->setMinimumHeight(m_comment->heightForWidth(m_comment->width()));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arrowImageName = "arrow_right.png";
|
||||
m_comment->hide();
|
||||
}
|
||||
|
||||
if (m_toggleCommentButton != NULL)
|
||||
updateArrow();
|
||||
|
||||
// forces the parent tree view to rescale
|
||||
if (m_treeWidgetItem)
|
||||
{
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_toggleCommentButton->setIconSize(QSize(10, 10));
|
||||
m_treeWidgetItem->setExpanded(false);
|
||||
m_treeWidgetItem->setExpanded(true);
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmark::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
if (m_ignoreNextResize)
|
||||
{
|
||||
m_ignoreNextResize = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_activateButton->setText(m_bookmark->getDisplayName().c_str());
|
||||
QTimer::singleShot(10, this, SLOT(elideButtonText()));
|
||||
}
|
||||
|
||||
void QtBookmark::showEvent(QShowEvent* event)
|
||||
{
|
||||
elideButtonText();
|
||||
}
|
||||
|
||||
void QtBookmark::enterEvent(QEvent *event)
|
||||
{
|
||||
m_editButton->show();
|
||||
m_deleteButton->show();
|
||||
|
||||
m_hovered = true;
|
||||
updateArrow();
|
||||
}
|
||||
|
||||
void QtBookmark::leaveEvent(QEvent *event)
|
||||
{
|
||||
m_editButton->hide();
|
||||
m_deleteButton->hide();
|
||||
|
||||
m_hovered = false;
|
||||
updateArrow();
|
||||
}
|
||||
|
||||
void QtBookmark::activateClicked()
|
||||
{
|
||||
MessageActivateBookmark(m_bookmark).dispatch();
|
||||
@@ -182,39 +222,10 @@ void QtBookmark::deleteClicked()
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmark::commentToggled()
|
||||
void QtBookmark::elideButtonText()
|
||||
{
|
||||
// std::string text = m_toggleCommentButton->text().toStdString();
|
||||
|
||||
if (m_comment->isVisible() == false)
|
||||
{
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_toggleCommentButton->setIconSize(QSize(10, 10));
|
||||
m_comment->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_toggleCommentButton->setIconSize(QSize(10, 10));
|
||||
m_comment->hide();
|
||||
}
|
||||
|
||||
// forces the parent tree view to rescale
|
||||
if (m_treeWidgetItem)
|
||||
{
|
||||
m_treeWidgetItem->setExpanded(false);
|
||||
m_treeWidgetItem->setExpanded(true);
|
||||
}
|
||||
m_activateButton->setText(m_activateButton->fontMetrics().elidedText(
|
||||
m_bookmark->getDisplayName().c_str(), Qt::ElideMiddle, m_activateButton->width() - 16));
|
||||
}
|
||||
|
||||
void QtBookmark::handleMessage(MessageEditBookmark* message)
|
||||
@@ -228,6 +239,12 @@ void QtBookmark::handleMessage(MessageEditBookmark* message)
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmark::updateArrow()
|
||||
{
|
||||
QPixmap pixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/" + m_arrowImageName).c_str());
|
||||
m_toggleCommentButton->setIcon(QIcon(utility::colorizePixmap(pixmap, m_hovered ? "black" : "#707070")));
|
||||
}
|
||||
|
||||
std::string QtBookmark::getDateString() const
|
||||
{
|
||||
std::string result = "n/a";
|
||||
@@ -248,7 +265,7 @@ std::string QtBookmark::getDateString() const
|
||||
{
|
||||
result = "today";
|
||||
}
|
||||
else if(creationDate.deltaDays(TimePoint::now()) == 1) // yesterday
|
||||
else if (creationDate.deltaDays(TimePoint::now()) == 1) // yesterday
|
||||
{
|
||||
result = "yesterday";
|
||||
}
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
#define QT_BOOKMARK_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageDeleteBookmark.h"
|
||||
@@ -26,31 +23,35 @@ public:
|
||||
QtBookmark();
|
||||
virtual ~QtBookmark();
|
||||
|
||||
void setName(const std::string& name);
|
||||
std::string getName() const;
|
||||
|
||||
void setBookmark(const std::shared_ptr<Bookmark> bookmark);
|
||||
|
||||
Id getBookmarkId() const;
|
||||
|
||||
QTreeWidgetItem* getTreeWidgetItem() const;
|
||||
void setTreeWidgetItem(QTreeWidgetItem* treeWidgetItem);
|
||||
|
||||
void refreshStyle();
|
||||
public slots:
|
||||
void commentToggled();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
virtual void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void activateClicked();
|
||||
void editClicked();
|
||||
void deleteClicked();
|
||||
void commentToggled();
|
||||
void elideButtonText();
|
||||
|
||||
private:
|
||||
void handleMessage(MessageEditBookmark* message);
|
||||
void handleMessage(MessageEditBookmark* message) override;
|
||||
|
||||
void updateArrow();
|
||||
|
||||
std::string getDateString() const;
|
||||
|
||||
QVBoxLayout* m_layout;
|
||||
|
||||
QPushButton* m_activateButton;
|
||||
QPushButton* m_editButton;
|
||||
QPushButton* m_deleteButton;
|
||||
@@ -61,8 +62,15 @@ private:
|
||||
|
||||
std::shared_ptr<Bookmark> m_bookmark;
|
||||
|
||||
QTreeWidgetItem* m_treeWidgetItem; // pointer to the bookmark category item in the treeView, allows to refresh tree view when a node changes in size (e.g. toggle comment)
|
||||
// not a nice solution to the problem, but couldn't find anything better yet (sizeHintChanged signal can't be emitted here...)
|
||||
// pointer to the bookmark category item in the treeView, allows to refresh tree view when a node changes in size
|
||||
// (e.g. toggle comment). Not a nice solution to the problem, but couldn't find anything better yet.
|
||||
// (sizeHintChanged signal can't be emitted here...)
|
||||
QTreeWidgetItem* m_treeWidgetItem;
|
||||
|
||||
std::string m_arrowImageName;
|
||||
bool m_hovered;
|
||||
|
||||
bool m_ignoreNextResize;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_H
|
||||
#endif // QT_BOOKMARK_H
|
||||
|
||||
@@ -1,52 +1,48 @@
|
||||
#include "QtBookmarkCategory.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "utility/messaging/type/MessageDeleteBookmarkCategoryWithBookmarks.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtBookmarkCategory::QtBookmarkCategory()
|
||||
: m_layout(NULL)
|
||||
, m_name(NULL)
|
||||
, m_deleteButton(NULL)
|
||||
, m_treeItem(NULL)
|
||||
, m_id(-1)
|
||||
: m_id(0)
|
||||
{
|
||||
setObjectName("bookmark_category");
|
||||
|
||||
m_layout = new QHBoxLayout();
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(m_layout);
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
|
||||
m_expandButton = new QPushButton();
|
||||
m_expandButton->setObjectName("category_expand_button");
|
||||
m_expandButton->setToolTip("Show/Hide bookmarks in this category");
|
||||
m_expandButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_expandButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
m_layout->addWidget(m_expandButton);
|
||||
m_expandButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png").c_str()));
|
||||
m_expandButton->setIconSize(QSize(8, 8));
|
||||
layout->addWidget(m_expandButton);
|
||||
|
||||
connect(m_expandButton, SIGNAL(clicked()), this, SLOT(expandClicked()));
|
||||
|
||||
m_name = new QLabel();
|
||||
m_name->setObjectName("category_name");
|
||||
m_name->setText("");
|
||||
m_layout->addWidget(m_name);
|
||||
layout->addWidget(m_name);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
m_deleteButton = new QPushButton();
|
||||
m_deleteButton->setObjectName("category_delete_button");
|
||||
m_deleteButton->setToolTip("Delete this Bookmark Category and the containing Bookmarks");
|
||||
// m_deleteButton->setText("Delete");
|
||||
m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_delete_icon.png").c_str()));
|
||||
m_layout->addWidget(m_deleteButton);
|
||||
utility::setWidgetRetainsSpaceWhenHidden(m_deleteButton);
|
||||
m_deleteButton->hide();
|
||||
layout->addWidget(m_deleteButton);
|
||||
|
||||
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
|
||||
}
|
||||
@@ -96,17 +92,13 @@ void QtBookmarkCategory::updateArrow()
|
||||
{
|
||||
if (m_treeItem->isExpanded())
|
||||
{
|
||||
m_expandButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
QPixmap pixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png").c_str());
|
||||
m_expandButton->setIcon(QIcon(utility::colorizePixmap(pixmap, "white")));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_expandButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
QPixmap pixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png").c_str());
|
||||
m_expandButton->setIcon(QIcon(utility::colorizePixmap(pixmap, "white")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,6 +120,16 @@ void QtBookmarkCategory::expandClicked()
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::enterEvent(QEvent *event)
|
||||
{
|
||||
m_deleteButton->show();
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::leaveEvent(QEvent *event)
|
||||
{
|
||||
m_deleteButton->hide();
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::deleteClicked()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
@@ -142,4 +144,4 @@ void QtBookmarkCategory::deleteClicked()
|
||||
{
|
||||
MessageDeleteBookmarkCategoryWithBookmarks(m_id).dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
#define QT_BOOKMARK_CATEGORY_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTreeWidget>
|
||||
|
||||
@@ -29,20 +27,24 @@ public:
|
||||
|
||||
void updateArrow();
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
void expandClicked();
|
||||
|
||||
protected:
|
||||
virtual void enterEvent(QEvent *event);
|
||||
virtual void leaveEvent(QEvent *event);
|
||||
|
||||
private slots:
|
||||
void deleteClicked();
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout;
|
||||
QLabel* m_name;
|
||||
Id m_id;
|
||||
|
||||
QPushButton* m_expandButton;
|
||||
QPushButton* m_deleteButton;
|
||||
|
||||
QTreeWidgetItem* m_treeItem; // store a pointer to the 'parent' tree item to enable the custom expand button
|
||||
|
||||
Id m_id;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_CATEGORY_H
|
||||
#endif // QT_BOOKMARK_CATEGORY_H
|
||||
|
||||
@@ -28,6 +28,13 @@ namespace utility
|
||||
widget->setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
void setWidgetRetainsSpaceWhenHidden(QWidget* widget)
|
||||
{
|
||||
QSizePolicy pol = widget->sizePolicy();
|
||||
pol.setRetainSizeWhenHidden(true);
|
||||
widget->setSizePolicy(pol);
|
||||
}
|
||||
|
||||
void loadFontsFromDirectory(const std::string& path, const std::string& extension)
|
||||
{
|
||||
std::vector<std::string> extensions;
|
||||
|
||||
@@ -12,6 +12,8 @@ class QWidget;
|
||||
namespace utility
|
||||
{
|
||||
void setWidgetBackgroundColor(QWidget* widget, const std::string& color);
|
||||
void setWidgetRetainsSpaceWhenHidden(QWidget* widget);
|
||||
|
||||
void loadFontsFromDirectory(const std::string& path, const std::string& extension = ".otf");
|
||||
|
||||
std::string getStyleSheet(const std::string& path);
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
#include "QtBookmarkBrowser.h"
|
||||
|
||||
#include "qt/element/QtBookmark.h"
|
||||
#include "qt/element/QtBookmarkCategory.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "data/bookmark/Bookmark.h"
|
||||
|
||||
#include "qt/element/QtBookmark.h"
|
||||
#include "qt/element/QtBookmarkCategory.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtBookmarkBrowser::QtBookmarkBrowser(QWidget* parent)
|
||||
: QtWindow(parent)
|
||||
, m_headerBackground(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -21,126 +23,116 @@ QtBookmarkBrowser::~QtBookmarkBrowser()
|
||||
|
||||
void QtBookmarkBrowser::setupBookmarkBrowser()
|
||||
{
|
||||
m_layout = new QHBoxLayout();
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(m_layout);
|
||||
|
||||
m_headerBackground = new QWidget(m_window);
|
||||
m_headerBackground->setObjectName("header_background");
|
||||
m_headerBackground->setGeometry(0, 0, 0, 0);
|
||||
m_headerBackground->show();
|
||||
m_headerBackground->lower();
|
||||
|
||||
m_headerLayout = new QVBoxLayout(this);
|
||||
m_headerLayout->setObjectName("header");
|
||||
m_headerLayout->setSpacing(0);
|
||||
m_headerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_headerLayout->setAlignment(Qt::AlignTop);
|
||||
m_layout->addLayout(m_headerLayout);
|
||||
|
||||
m_bodyLayout = new QVBoxLayout(this);
|
||||
m_bodyLayout->setObjectName("body");
|
||||
m_bodyLayout->setSpacing(0);
|
||||
m_bodyLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_bodyLayout->setAlignment(Qt::AlignLeft);
|
||||
m_layout->addLayout(m_bodyLayout);
|
||||
|
||||
m_title = new QLabel(this);
|
||||
m_title->setObjectName("title");
|
||||
m_title->setText("Bookmarks");
|
||||
m_headerLayout->addWidget(m_title);
|
||||
|
||||
m_filterLabel = new QLabel(this);
|
||||
m_filterLabel->setObjectName("filter_label");
|
||||
m_filterLabel->setText("Show:");
|
||||
m_headerLayout->addWidget(m_filterLabel);
|
||||
|
||||
m_filterComboBox = new QComboBox(this);
|
||||
m_filterComboBox->addItem("All");
|
||||
m_filterComboBox->addItem("Nodes");
|
||||
m_filterComboBox->addItem("Edges");
|
||||
m_filterComboBox->setObjectName("filter_box");
|
||||
m_headerLayout->addWidget(m_filterComboBox);
|
||||
|
||||
connect(m_filterComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(filterBoxChanged(const QString&)));
|
||||
|
||||
m_orderLabel = new QLabel(this);
|
||||
m_orderLabel->setObjectName("order_label");
|
||||
m_orderLabel->setText("Sort by:");
|
||||
m_headerLayout->addWidget(m_orderLabel);
|
||||
|
||||
m_orderNames.push_back("Date des.");
|
||||
m_orderNames.push_back("Date asc.");
|
||||
m_orderNames.push_back("Name des.");
|
||||
m_orderNames.push_back("Name asc.");
|
||||
m_currentOrderIndex = 0;
|
||||
|
||||
m_orderComboBox = new QComboBox(this);
|
||||
// m_orderComboBox->setToolTip("Select Bookmark Order");
|
||||
m_orderComboBox->addItem(m_orderNames[0].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[1].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[2].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[3].c_str());
|
||||
m_orderComboBox->setObjectName("order_box");
|
||||
m_headerLayout->addWidget(m_orderComboBox);
|
||||
|
||||
connect(m_orderComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(orderBoxChanged(const QString&)));
|
||||
|
||||
|
||||
m_headerLayout->addWidget(m_orderComboBox);
|
||||
|
||||
m_bookmarkTree = new QTreeWidget();
|
||||
m_bookmarkTree->setObjectName("bookmark_tree");
|
||||
m_bookmarkTree->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
|
||||
m_bookmarkTree->header()->close();
|
||||
m_bookmarkTree->setAlternatingRowColors(true);
|
||||
m_bookmarkTree->setIndentation(0);
|
||||
m_bookmarkTree->setHeaderLabel("Bookmarks");
|
||||
|
||||
connect(m_bookmarkTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(itemExpanded(QTreeWidgetItem*)));
|
||||
connect(m_bookmarkTree, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(itemCollapsed(QTreeWidgetItem*)));
|
||||
|
||||
// m_bookmarkTree->icon
|
||||
|
||||
m_bodyLayout->addWidget(m_bookmarkTree);
|
||||
|
||||
m_closeButton = new QPushButton(this);
|
||||
m_closeButton->setObjectName("windowButton");
|
||||
m_closeButton->setToolTip("Close Window");
|
||||
m_closeButton->setText("Close");
|
||||
m_closeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_bodyLayout->addWidget(m_closeButton);
|
||||
m_bodyLayout->setAlignment(m_closeButton, Qt::AlignRight);
|
||||
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
|
||||
|
||||
setFixedSize(QSize(790, 600));
|
||||
|
||||
setStyleSheet((
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css")
|
||||
).c_str());
|
||||
|
||||
m_headerBackground->setGeometry(0, 0, 247, size().height()-20);
|
||||
m_headerBackground = new QWidget(m_window);
|
||||
m_headerBackground->setObjectName("header_background");
|
||||
m_headerBackground->setGeometry(0, 0, 0, 0);
|
||||
m_headerBackground->lower();
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
|
||||
{
|
||||
QVBoxLayout* headerLayout = new QVBoxLayout();
|
||||
headerLayout->setSpacing(0);
|
||||
headerLayout->setContentsMargins(30, 35, 25, 35);
|
||||
headerLayout->setAlignment(Qt::AlignTop);
|
||||
layout->addLayout(headerLayout);
|
||||
|
||||
headerLayout->addStrut(150);
|
||||
|
||||
QLabel* title = new QLabel("Bookmarks");
|
||||
title->setObjectName("title");
|
||||
headerLayout->addWidget(title);
|
||||
|
||||
headerLayout->addSpacing(40);
|
||||
|
||||
QLabel* filterLabel = new QLabel("Show:");
|
||||
filterLabel->setObjectName("filter_label");
|
||||
headerLayout->addWidget(filterLabel);
|
||||
|
||||
m_filterComboBox = new QComboBox();
|
||||
m_filterComboBox->addItem("All");
|
||||
m_filterComboBox->addItem("Nodes");
|
||||
m_filterComboBox->addItem("Edges");
|
||||
m_filterComboBox->setObjectName("filter_box");
|
||||
headerLayout->addWidget(m_filterComboBox);
|
||||
|
||||
connect(m_filterComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(filterOrOrderChanged(const QString&)));
|
||||
|
||||
headerLayout->addSpacing(40);
|
||||
|
||||
QLabel* orderLabel = new QLabel("Sort by:");
|
||||
orderLabel->setObjectName("order_label");
|
||||
headerLayout->addWidget(orderLabel);
|
||||
|
||||
m_orderNames.push_back("Date des.");
|
||||
m_orderNames.push_back("Date asc.");
|
||||
m_orderNames.push_back("Name des.");
|
||||
m_orderNames.push_back("Name asc.");
|
||||
|
||||
m_orderComboBox = new QComboBox(this);
|
||||
// m_orderComboBox->setToolTip("Select Bookmark Order");
|
||||
m_orderComboBox->addItem(m_orderNames[0].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[1].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[2].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[3].c_str());
|
||||
m_orderComboBox->setObjectName("order_box");
|
||||
headerLayout->addWidget(m_orderComboBox);
|
||||
|
||||
connect(m_orderComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(filterOrOrderChanged(const QString&)));
|
||||
}
|
||||
|
||||
{
|
||||
QVBoxLayout* bodyLayout = new QVBoxLayout();
|
||||
bodyLayout->setSpacing(0);
|
||||
bodyLayout->setContentsMargins(0, 30, 6, 35);
|
||||
bodyLayout->setAlignment(Qt::AlignLeft);
|
||||
layout->addLayout(bodyLayout);
|
||||
|
||||
m_bookmarkTree = new QTreeWidget();
|
||||
m_bookmarkTree->setObjectName("bookmark_tree");
|
||||
m_bookmarkTree->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
m_bookmarkTree->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
|
||||
m_bookmarkTree->header()->close();
|
||||
m_bookmarkTree->setIndentation(0);
|
||||
m_bookmarkTree->setHeaderLabel("Bookmarks");
|
||||
|
||||
connect(m_bookmarkTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(categoryExpansionChanged(QTreeWidgetItem*)));
|
||||
connect(m_bookmarkTree, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(categoryExpansionChanged(QTreeWidgetItem*)));
|
||||
connect(m_bookmarkTree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(treeItemClicked(QTreeWidgetItem*, int)));
|
||||
|
||||
bodyLayout->addWidget(m_bookmarkTree);
|
||||
|
||||
bodyLayout->addSpacing(15);
|
||||
|
||||
QHBoxLayout* buttonLayout = createButtons();
|
||||
buttonLayout->setContentsMargins(0, 0, 35, 0);
|
||||
bodyLayout->addLayout(buttonLayout);
|
||||
setPreviousVisible(false);
|
||||
setCloseVisible(false);
|
||||
updateNextButton("Close");
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::setBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
m_bookmarkTree->clear();
|
||||
// m_bookmarkTree->adjustSize();
|
||||
|
||||
for (unsigned int i = 0; i < bookmarks.size(); i++)
|
||||
{
|
||||
QtBookmark* bookmark = new QtBookmark();
|
||||
bookmark->setName(bookmarks[i]->getDisplayName());
|
||||
bookmark->setBookmark(bookmarks[i]);
|
||||
|
||||
QTreeWidgetItem* top = findOrCreateTreeCategory(bookmarks[i]->getCategory().getName(), bookmarks[i]->getCategory().getId());
|
||||
QTreeWidgetItem* top = findOrCreateTreeCategory(bookmarks[i]->getCategory());
|
||||
QTreeWidgetItem* treeWidgetItem = new QTreeWidgetItem(top);
|
||||
// treeWidgetItem->setText(0, bookmarks[i]->getDisplayName().c_str());
|
||||
treeWidgetItem->setSizeHint(0, bookmark->minimumSizeHint());
|
||||
m_bookmarkTree->setItemWidget(treeWidgetItem, 0, bookmark);
|
||||
top->addChild(treeWidgetItem);
|
||||
|
||||
@@ -150,51 +142,51 @@ void QtBookmarkBrowser::setBookmarks(const std::vector<std::shared_ptr<Bookmark>
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::closeButtonClicked()
|
||||
void QtBookmarkBrowser::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
try
|
||||
{
|
||||
close();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string message = e.what();
|
||||
QtWindow::resizeEvent(event);
|
||||
|
||||
LOG_ERROR(message);
|
||||
}
|
||||
m_headerBackground->setGeometry(0, 0, 200, m_window->size().height());
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::filterBoxChanged(const QString& text)
|
||||
void QtBookmarkBrowser::handleClose()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::handleNext()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::filterOrOrderChanged(const QString& text)
|
||||
{
|
||||
MessageDisplayBookmarks(getSelectedFilter(), getSelectedOrder()).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::orderBoxChanged(const QString& text)
|
||||
void QtBookmarkBrowser::categoryExpansionChanged(QTreeWidgetItem* item)
|
||||
{
|
||||
MessageDisplayBookmarks(getSelectedFilter(), getSelectedOrder()).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::itemExpanded(QTreeWidgetItem* item)
|
||||
{
|
||||
QWidget* widget = m_bookmarkTree->itemWidget(item, 0);
|
||||
|
||||
QtBookmarkCategory* category = dynamic_cast<QtBookmarkCategory*>(widget);
|
||||
|
||||
QtBookmarkCategory* category = dynamic_cast<QtBookmarkCategory*>(m_bookmarkTree->itemWidget(item, 0));
|
||||
if (category != NULL)
|
||||
{
|
||||
category->updateArrow();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::itemCollapsed(QTreeWidgetItem* item)
|
||||
void QtBookmarkBrowser::treeItemClicked(QTreeWidgetItem* item, int column)
|
||||
{
|
||||
QWidget* widget = m_bookmarkTree->itemWidget(item, 0);
|
||||
|
||||
QtBookmarkCategory* category = dynamic_cast<QtBookmarkCategory*>(widget);
|
||||
|
||||
QtBookmarkCategory* category = dynamic_cast<QtBookmarkCategory*>(m_bookmarkTree->itemWidget(item, 0));
|
||||
if (category != NULL)
|
||||
{
|
||||
category->updateArrow();
|
||||
category->expandClicked();
|
||||
return;
|
||||
}
|
||||
|
||||
QtBookmark* bookmark = dynamic_cast<QtBookmark*>(m_bookmarkTree->itemWidget(item, 0));
|
||||
if (bookmark != NULL)
|
||||
{
|
||||
bookmark->commentToggled();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,37 +242,35 @@ MessageDisplayBookmarks::BookmarkOrder QtBookmarkBrowser::getSelectedOrder()
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem* QtBookmarkBrowser::findOrCreateTreeCategory(const std::string& name, const Id id)
|
||||
QTreeWidgetItem* QtBookmarkBrowser::findOrCreateTreeCategory(const BookmarkCategory& category)
|
||||
{
|
||||
for (int i = 0; i < m_bookmarkTree->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem* item = m_bookmarkTree->topLevelItem(i);
|
||||
|
||||
if (item->whatsThis(0).toStdString() == name)
|
||||
if (item->whatsThis(0).toStdString() == category.getName())
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
QtBookmarkCategory* category = new QtBookmarkCategory();
|
||||
if (name.length() > 0)
|
||||
QtBookmarkCategory* categoryItem = new QtBookmarkCategory();
|
||||
if (category.getName().length() > 0)
|
||||
{
|
||||
category->setName(name);
|
||||
categoryItem->setName(category.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
category->setName("No Category");
|
||||
categoryItem->setName("No Category");
|
||||
}
|
||||
category->setId(id);
|
||||
categoryItem->setId(category.getId());
|
||||
|
||||
QTreeWidgetItem* newItem = new QTreeWidgetItem(m_bookmarkTree);
|
||||
newItem->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
||||
newItem->setSizeHint(0, category->minimumSizeHint());
|
||||
newItem->setWhatsThis(0, name.c_str());
|
||||
category->setTreeWidgetItem(newItem);
|
||||
newItem->setWhatsThis(0, category.getName().c_str());
|
||||
|
||||
m_bookmarkTree->setItemWidget(newItem, 0, category);
|
||||
categoryItem->setTreeWidgetItem(newItem);
|
||||
|
||||
m_bookmarkTree->setItemWidget(newItem, 0, categoryItem);
|
||||
m_bookmarkTree->addTopLevelItem(newItem);
|
||||
|
||||
return newItem;
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
#ifndef QT_BOOKMARK_BROWSER_H
|
||||
#define QT_BOOKMARK_BROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QTreeWidget>
|
||||
|
||||
@@ -21,6 +13,7 @@
|
||||
#include "utility/messaging/type/MessageEditBookmark.h"
|
||||
|
||||
class Bookmark;
|
||||
class BookmarkCategory;
|
||||
class QtBookmark;
|
||||
|
||||
class QtBookmarkBrowser
|
||||
@@ -37,36 +30,31 @@ public:
|
||||
void setupBookmarkBrowser();
|
||||
void setBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void handleClose() override;
|
||||
virtual void handleNext() override;
|
||||
|
||||
private slots:
|
||||
void closeButtonClicked();
|
||||
void filterBoxChanged(const QString& text);
|
||||
void orderBoxChanged(const QString& text);
|
||||
void itemExpanded(QTreeWidgetItem* item);
|
||||
void itemCollapsed(QTreeWidgetItem* item);
|
||||
void filterOrOrderChanged(const QString& text);
|
||||
void categoryExpansionChanged(QTreeWidgetItem* item);
|
||||
void treeItemClicked(QTreeWidgetItem* item, int column);
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageDeleteBookmark* message);
|
||||
virtual void handleMessage(MessageEditBookmark* message);
|
||||
virtual void handleMessage(MessageDeleteBookmark* message) override;
|
||||
virtual void handleMessage(MessageEditBookmark* message) override;
|
||||
|
||||
MessageDisplayBookmarks::BookmarkFilter getSelectedFilter();
|
||||
MessageDisplayBookmarks::BookmarkOrder getSelectedOrder();
|
||||
|
||||
QTreeWidgetItem* findOrCreateTreeCategory(const std::string& name, const Id id);
|
||||
|
||||
QHBoxLayout* m_layout;
|
||||
QVBoxLayout* m_headerLayout;
|
||||
QVBoxLayout* m_bodyLayout;
|
||||
QTreeWidgetItem* findOrCreateTreeCategory(const BookmarkCategory& category);
|
||||
|
||||
QTreeWidget* m_bookmarkTree;
|
||||
QPushButton* m_closeButton;
|
||||
|
||||
QLabel* m_title;
|
||||
QLabel* m_filterLabel;
|
||||
QLabel* m_orderLabel;
|
||||
QComboBox* m_filterComboBox;
|
||||
QComboBox* m_orderComboBox;
|
||||
std::vector<std::string> m_orderNames;
|
||||
int m_currentOrderIndex;
|
||||
|
||||
QWidget* m_headerBackground;
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
void setIsEdge(const bool isEdge);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void handleNext() override;
|
||||
virtual void handleClose() override;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
#include "utility/messaging/type/MessageFind.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
@@ -383,6 +384,9 @@ void QtMainWindow::showStartScreen()
|
||||
}
|
||||
|
||||
|
||||
// MessageDisplayBookmarks(MessageDisplayBookmarks::BookmarkFilter::ALL, MessageDisplayBookmarks::BookmarkOrder::NONE).dispatch();
|
||||
// return;
|
||||
|
||||
QtStartScreen* startScreen = createWindow<QtStartScreen>();
|
||||
startScreen->setupStartScreen(licenseValid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user