summaryrefslogtreecommitdiff
path: root/tagscene.h
blob: bb83da4f9369b78b33425f94a4edd15b081a86e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef TAGSCENE_H
#define TAGSCENE_H

#include "sqlitebackend.h"
#include "tagitem.h"
#include "numberator.h"

#include <QGraphicsPixmapItem>
#include <QGraphicsScene>



class TagScene : public QGraphicsScene
{
    Q_OBJECT

public:
    TagScene() : m_previewTag(new TagItem()) {}
    ~TagScene() { this->blockSignals(true); delete m_previewTag; }
    const QGraphicsPixmapItem *backgroundPixmapItem() const { return pix_it; }

public slots:
    void reloadPicture();
    void reloadScene();
    void selectTag(const Tag &tag);

    void setTool(ToolType tool);
    void abortTool();

    void setProject(SQLiteSaveFile *proj);

signals:
    void tagDoubleClicked(const Tag &tag);
    void imageLoaded();

protected:
    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;

private slots:
    void tagChanged(TagChange change, const Tag &tag);

private:
    void addTag(const Tag tag);

    SQLiteSaveFile *m_proj = nullptr;

    QGraphicsPixmapItem *pix_it = nullptr;
    QPixmap pix;
    QMap<long long int, TagItem*> tags;
    ToolType m_tool;
    enum TagToolState {
        TAG_TOOL_ANCHOR,
        TAG_TOOL_LABEL
    } m_tagToolState = TAG_TOOL_ANCHOR;
    TagItem *m_previewTag;
};

#endif // TAGSCENE_H