File indexing completed on 2024-04-28 11:20:57
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com> 0004 */ 0005 0006 #ifndef IMAGEENTRY_H 0007 #define IMAGEENTRY_H 0008 0009 #include "worksheetentry.h" 0010 #include "imagesettingsdialog.h" 0011 0012 #include <QString> 0013 0014 class Worksheet; 0015 class ActionBar; 0016 class WorksheetImageItem; 0017 class QFileSystemWatcher; 0018 class QGraphicsSceneMouseEvent; 0019 0020 class ImageEntry : public WorksheetEntry 0021 { 0022 Q_OBJECT 0023 0024 public: 0025 explicit ImageEntry(Worksheet* worksheet); 0026 ~ImageEntry() override = default; 0027 0028 enum {Type = UserType + 4}; 0029 int type() const override; 0030 0031 bool isEmpty() override; 0032 bool acceptRichText() override; 0033 void setContent(const QString& content) override; 0034 void setContent(const QDomElement& content, const KZip& file) override; 0035 void setContentFromJupyter(const QJsonObject & cell) override; 0036 QDomElement toXml(QDomDocument& doc, KZip* archive) override; 0037 QJsonValue toJupyterJson() override; 0038 QString toPlain(const QString& commandSep, const QString& commentStartingSeq, const QString& commentEndingSeq) override; 0039 0040 QSizeF imageSize(const ImageSize& imgSize); 0041 0042 void layOutForWidth(qreal entry_zone_x, qreal w, bool force = false) override; 0043 0044 public Q_SLOTS: 0045 bool evaluate(WorksheetEntry::EvaluationOption evalOp = FocusNext) override; 0046 void updateEntry() override; 0047 0048 void populateMenu(QMenu* menu, QPointF pos) override; 0049 void startConfigDialog(); 0050 void setImageData(const QString& path, const ImageSize& displaySize, 0051 const ImageSize& printSize, bool useDisplaySizeForPrinting); 0052 0053 protected: 0054 bool wantToEvaluate() override; 0055 bool wantFocus() override; 0056 qreal height(); 0057 0058 QString latexSizeString(const ImageSize& imgSize); 0059 void addActionsToBar(ActionBar* actionBar) override; 0060 0061 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override; 0062 0063 private: 0064 QString m_imagePath; 0065 QString m_fileName; 0066 ImageSize m_displaySize; 0067 ImageSize m_printSize; 0068 bool m_useDisplaySizeForPrinting; 0069 WorksheetImageItem* m_imageItem; 0070 WorksheetTextItem* m_textItem; 0071 QFileSystemWatcher* m_imageWatcher; 0072 }; 0073 0074 #endif /* IMAGEENTRY_H */