]> git.sven.stormbind.net Git - sven/vym.git/blob - src/branchitem.h
Replace Pierre as the maintainer
[sven/vym.git] / src / branchitem.h
1 #ifndef BRANCHITEM_H
2 #define BRANCHITEM_H
3
4 #include "mapitem.h"
5 #include "task.h"
6
7 #include <QList>
8
9 class QString;
10 class QGraphicsScene;
11 class BranchObj;
12 class Link;
13 class XLinkItem;
14
15 class BranchItem : public MapItem {
16   public:
17     enum LayoutHint { AutoPositioning, FreePositioning };
18
19     BranchItem(TreeItem *parent = nullptr);
20     virtual ~BranchItem();
21     virtual void clear();
22     virtual void copy(BranchItem *item);
23     virtual BranchItem *parentBranch();
24
25     virtual void insertBranch(int pos, BranchItem *branch);
26
27     virtual QString saveToDir(const QString &tmpdir, const QString &prefix,
28                               const QPointF &offset, QList<Link *> &tmpLinks);
29
30     virtual void updateVisibility();
31
32     virtual void setHeadingColor(
33         QColor color); //! Overloaded from TreeItem to update QGraphicsView
34
35   protected:
36     bool scrolled;      // true if all children are scrolled and thus invisible
37     bool tmpUnscrolled; // can only be true (temporary) for a scrolled subtree
38
39   public:
40     void updateTaskFlag();
41     void setTask(Task *t);
42     Task *getTask();
43
44   private:
45     Task *task;
46
47   public:
48     virtual void scroll();
49     virtual void unScroll();
50     virtual bool toggleScroll(); // scroll or unscroll
51     virtual bool isScrolled();   // returns scroll state
52     virtual bool hasScrolledParent(
53         BranchItem *start = NULL); // true, if any of the parents is scrolled
54     virtual bool tmpUnscroll(
55         BranchItem *start = NULL);   // unscroll scrolled parents temporary e.g.
56                                      // during "find" process
57     virtual bool resetTmpUnscroll(); // scroll all tmp scrolled parents again
58                                      // e.g. when unselecting
59     virtual void sortChildren(bool inverse = false); //! Sort children
60     virtual void setChildrenLayout(BranchItem::LayoutHint layoutHint);
61     virtual BranchItem::LayoutHint getChildrenLayout();
62
63   protected:
64     bool includeImagesVer;     //! include floatimages in bbox vertically
65     bool includeImagesHor;     //! include floatimages in bbox horizontally
66     bool includeChildren;      //! include children in frame
67     LayoutHint childrenLayout; //! should children be positioned freely?
68
69   public:
70     void setIncludeImagesVer(bool);
71     bool getIncludeImagesVer();
72     void setIncludeImagesHor(bool);
73     bool getIncludeImagesHor();
74     QString getIncludeImageAttr();
75     BranchItem *getFramedParentBranch(BranchItem *start);
76     void setFrameIncludeChildren(bool);
77     bool getFrameIncludeChildren();
78
79     QColor getBackgroundColor(BranchItem *start, bool checkInnerFrame = true);
80
81   protected:
82     int lastSelectedBranchNum;
83     int lastSelectedBranchNumAlt;
84
85   public:
86     virtual void
87     setLastSelectedBranch(); //! Set myself as last selected in parent
88     virtual void
89     setLastSelectedBranch(int i); //! Set last selected branch directly
90     virtual BranchItem *
91     getLastSelectedBranch(); //! Returns last selected branch usually
92     virtual BranchItem *
93     getLastSelectedBranchAlt(); //! Used to return last selected branch left of
94                                 //! a mapcenter
95
96   public:
97     TreeItem *findMapItem(
98         QPointF p,
99         TreeItem *excludeTI); //! search map for branches or images. Ignore
100                               //! excludeTI, where search is started
101
102     virtual void
103     updateStyles(const bool &keepFrame =
104                      false); //! update related fonts, parObjects, links, ...
105     virtual BranchObj *getBranchObj();
106     virtual BranchObj *createMapObj(
107         QGraphicsScene *scene); //! Create classic object in GraphicsView
108 };
109
110 #endif