* 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
75 lines
1.7 KiB
C++
75 lines
1.7 KiB
C++
#ifndef QT_BOOKMARK_H
|
|
#define QT_BOOKMARK_H
|
|
|
|
#include <QFrame>
|
|
#include <QLabel>
|
|
#include <QPushButton>
|
|
#include <QTreeWidget>
|
|
|
|
#include "component/controller/BookmarkController.h"
|
|
#include "component/controller/helper/ControllerProxy.h"
|
|
#include "data/bookmark/Bookmark.h"
|
|
|
|
class Bookmark;
|
|
|
|
class QtBookmark
|
|
: public QFrame
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
QtBookmark(ControllerProxy<BookmarkController>* controllerProxy);
|
|
virtual ~QtBookmark();
|
|
|
|
void setBookmark(const std::shared_ptr<Bookmark> bookmark);
|
|
Id getBookmarkId() const;
|
|
|
|
QTreeWidgetItem* getTreeWidgetItem() const;
|
|
void setTreeWidgetItem(QTreeWidgetItem* treeWidgetItem);
|
|
|
|
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 elideButtonText();
|
|
|
|
private:
|
|
void updateArrow();
|
|
|
|
std::string getDateString() const;
|
|
|
|
ControllerProxy<BookmarkController>* m_controllerProxy;
|
|
|
|
QPushButton* m_activateButton;
|
|
QPushButton* m_editButton;
|
|
QPushButton* m_deleteButton;
|
|
QPushButton* m_toggleCommentButton;
|
|
|
|
QLabel* m_comment;
|
|
QLabel* m_dateLabel;
|
|
|
|
std::shared_ptr<Bookmark> m_bookmark;
|
|
|
|
// 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
|