File indexing completed on 2022-12-06 18:50:23

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com>
0004 */
0005 
0006 #ifndef TEXTRESULTITEM_H
0007 #define TEXTRESULTITEM_H
0008 
0009 #include "resultitem.h"
0010 #include "worksheettextitem.h"
0011 
0012 namespace Cantor {
0013     class LatexResult;
0014 }
0015 
0016 class TextResultItem : public WorksheetTextItem, public ResultItem
0017 {
0018   Q_OBJECT
0019   public:
0020     explicit TextResultItem(WorksheetEntry*, Cantor::Result*);
0021     ~TextResultItem() override = default;
0022 
0023     using WorksheetTextItem::setGeometry;
0024     double setGeometry(double x, double y, double w) override;
0025     void populateMenu(QMenu*, QPointF) override;
0026 
0027     void update() override;
0028 
0029     void setLatex(Cantor::LatexResult*);
0030     QTextImageFormat toFormat(const QImage&, const QString& latex);
0031 
0032     double width() const override;
0033     double height() const override;
0034 
0035     void deleteLater() override;
0036 
0037   Q_SIGNALS:
0038     void collapseActionSizeChanged();
0039 
0040   protected Q_SLOTS:
0041     void toggleLatexCode();
0042     void showHtml();
0043     void showHtmlSource();
0044     void showPlain();
0045     void saveResult();
0046 
0047   protected:
0048     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
0049     int visibleLineCount();
0050     void collapseExtraLines();
0051 
0052   protected:
0053     bool m_isCollapsed{false};
0054     bool m_userCollapseOverride{false};
0055     int m_widthWhenCollapsed{0};
0056 };
0057 
0058 #endif //TEXTRESULTITEM_H