diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
commit | d24f813f3f2a05c112e803e4256b53535895fc98 (patch) | |
tree | 601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/main-view/RecordEditor.h |
Diffstat (limited to 'src/main-view/RecordEditor.h')
-rw-r--r-- | src/main-view/RecordEditor.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main-view/RecordEditor.h b/src/main-view/RecordEditor.h new file mode 100644 index 0000000..40b5dc5 --- /dev/null +++ b/src/main-view/RecordEditor.h @@ -0,0 +1,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 + |