summaryrefslogtreecommitdiff
path: root/src/main-view/RecordEditor.h
blob: 40b5dc5f1b43f72ea77cc9962d668d5fc429e93e (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
#ifndef RECORD_EDITOR_H
#define RECORD_EDITOR_H

#include <QtWidgets>

#include "FieldContentPainter.h"

class RecordEditor: public QTextEdit, public FieldContentPainter
{
Q_OBJECT

private:
    static const int ThumbnailSize = 25;
    static const int MinWidth = 150;
    static const int MaxWidth = 400;
    static const float EditorWidthIncrease;

public:
    RecordEditor(QWidget* parent, const QRect& cellRect);
    QRect getCellRect() const { return cellRect; }
    void startDrawing();
    void endDrawing();
    void drawText(const QString& text);
    void drawImage(const QString& filePath);
    void insertImage(int cursorPos, const QString& filePath);
    QString getText() const;

protected:
    QSize sizeHint() const;

private:
    int getEditorWidth() const;
    int getEditorHeight() const;
    void updatePos();
    bool textWrapped() const;
    void moveCursor(int cursorPos);

public slots:
    void updateEditor();

private:
    QRect cellRect;
    bool enabledSizeUpdates;
};
#endif