File indexing completed on 2024-04-28 11:21:00

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com>
0004 */
0005 
0006 #include "placeholderentry.h"
0007 
0008 #include <QPropertyAnimation>
0009 #include <QJsonObject>
0010 
0011 PlaceHolderEntry::PlaceHolderEntry(Worksheet* worksheet, QSizeF s)
0012     : WorksheetEntry(worksheet)
0013 {
0014     m_controlElement.hide();
0015     setSize(s);
0016 }
0017 
0018 int PlaceHolderEntry::type() const
0019 {
0020     return Type;
0021 }
0022 
0023 bool PlaceHolderEntry::isEmpty()
0024 {
0025     /*
0026     // This is counter-intuitive. isEmpty() is used to find out whether a new
0027     // CommandEntry needs to be appended, and a PlaceHolderEntry should never
0028     // prevent that.
0029     return false;
0030     */
0031     return true;
0032 }
0033 
0034 bool PlaceHolderEntry::acceptRichText()
0035 {
0036     return false;
0037 }
0038 
0039 void PlaceHolderEntry::setContent(const QString&)
0040 {
0041 }
0042 
0043 void PlaceHolderEntry::setContent(const QDomElement&, const KZip&)
0044 {
0045 }
0046 
0047 void PlaceHolderEntry::setContentFromJupyter(const QJsonObject& cell)
0048 {
0049     Q_UNUSED(cell);
0050     return;
0051 }
0052 
0053 QJsonValue PlaceHolderEntry::toJupyterJson()
0054 {
0055     return QJsonValue();
0056 }
0057 
0058 
0059 QDomElement PlaceHolderEntry::toXml(QDomDocument&, KZip*)
0060 {
0061     return QDomElement();
0062 }
0063 
0064 QString PlaceHolderEntry::toPlain(const QString&, const QString&, const QString&){
0065     return QString();
0066 }
0067 
0068 void PlaceHolderEntry::layOutForWidth(qreal entry_zone_x, qreal w, bool force)
0069 {
0070     Q_UNUSED(entry_zone_x);
0071     Q_UNUSED(w);
0072     Q_UNUSED(force);
0073 }
0074 
0075 bool PlaceHolderEntry::evaluate(EvaluationOption evalOp)
0076 {
0077     evaluateNext(evalOp);
0078     return true;
0079 }
0080 
0081 void PlaceHolderEntry::updateEntry()
0082 {
0083 }
0084 
0085 bool PlaceHolderEntry::wantToEvaluate()
0086 {
0087     return false;
0088 }
0089 
0090 void PlaceHolderEntry::changeSize(QSizeF s)
0091 {
0092     if (!worksheet()->animationsEnabled()) {
0093         setSize(s);
0094         worksheet()->updateEntrySize(this);
0095         return;
0096     }
0097     if (aboutToBeRemoved())
0098         return;
0099 
0100     if (animationActive())
0101         endAnimation();
0102 
0103     QPropertyAnimation* sizeAn = sizeChangeAnimation(s);
0104 
0105     sizeAn->setEasingCurve(QEasingCurve::InOutQuad);
0106     sizeAn->start(QAbstractAnimation::DeleteWhenStopped);
0107 }
0108