Commit e3aa3412 authored by Alexander Semke's avatar Alexander Semke
Browse files

More forward declarations and member initializations in the header and

in the constructor in a couple of classes.
parent 17da7ae3
Pipeline #62994 canceled with stage
......@@ -7,6 +7,7 @@
#include "worksheet.h"
#include "worksheetentry.h"
#include "worksheettoolbutton.h"
#include "worksheetview.h"
#include <QGraphicsProxyWidget>
......
......@@ -5,17 +5,17 @@
#include "animationresultitem.h"
#include "commandentry.h"
#include "worksheetview.h"
#include "lib/result.h"
#include "lib/animationresult.h"
#include <QDebug>
#include <QFileDialog>
#include <QMovie>
#include <KLocalizedString>
AnimationResultItem::AnimationResultItem(QGraphicsObject* parent, Cantor::Result* result)
: WorksheetImageItem(parent), ResultItem(result), m_height(0), m_movie(nullptr)
: WorksheetImageItem(parent), ResultItem(result)
{
update();
}
......@@ -45,7 +45,7 @@ void AnimationResultItem::populateMenu(QMenu* menu, QPointF pos)
menu->addAction(QIcon::fromTheme(QLatin1String("media-playback-stop")), i18n("Stop"),
this, SLOT(stopMovie()));
}
qDebug() << "populate Menu";
emit menuCreated(menu, mapToParent(pos));
}
......@@ -112,7 +112,6 @@ void AnimationResultItem::saveResult()
{
Cantor::Result* res = result();
const QString& filename=QFileDialog::getSaveFileName(worksheet()->worksheetView(), i18n("Save result"), QString(), res->mimeType());
qDebug()<<"saving result to "<<filename;
res->save(filename);
}
......
......@@ -47,8 +47,8 @@ class AnimationResultItem : public WorksheetImageItem, public ResultItem
void updateSize(QSize);
private:
double m_height;
QMovie* m_movie;
double m_height{0.};
QMovie* m_movie{nullptr};
};
#endif //ANIMATIONRESULTITEM_H
......
......@@ -8,6 +8,7 @@
#include "commandentry.h"
#include "resultitem.h"
#include "loadedexpression.h"
#include "worksheetview.h"
#include "lib/jupyterutils.h"
#include "lib/result.h"
#include "lib/helpresult.h"
......@@ -28,6 +29,7 @@
#include <QJsonArray>
#include <QJsonObject>
#include <QTextDocumentFragment>
#include <QPainter>
#include <KLocalizedString>
#include <KColorScheme>
......
......@@ -4,16 +4,17 @@
*/
#include "hierarchyentry.h"
#include "settings.h"
#include "worksheettextitem.h"
#include "worksheetview.h"
#include "lib/jupyterutils.h"
#include "settings.h"
#include <QJsonObject>
#include <QRegularExpression>
#include <QDrag>
#include <QBitmap>
#include <QMimeData>
#include <QPainter>
#include <QDebug>
#include <KLocalizedString>
......
......@@ -5,11 +5,10 @@
#include "horizontalruleentry.h"
#include <QApplication>
#include <QPainter>
#include <QPropertyAnimation>
#include <QJsonObject>
#include <QApplication>
#include <QDebug>
#include <KLocalizedString>
......
......@@ -4,11 +4,11 @@
*/
#include "imageentry.h"
#include "worksheetimageitem.h"
#include "actionbar.h"
#include "worksheetimageitem.h"
#include "worksheetview.h"
#include "lib/jupyterutils.h"
#include <KLocalizedString>
#include <QDebug>
#include <QDir>
#include <QMenu>
......@@ -17,6 +17,9 @@
#include <QJsonObject>
#include <QStandardPaths>
#include <KLocalizedString>
#include <KZip>
ImageEntry::ImageEntry(Worksheet* worksheet) : WorksheetEntry(worksheet)
{
m_imageItem = nullptr;
......
......@@ -5,6 +5,7 @@
#include "imageresultitem.h"
#include "commandentry.h"
#include "worksheetview.h"
#include "lib/imageresult.h"
#include "lib/epsresult.h"
......@@ -12,7 +13,6 @@
#include <KLocalizedString>
#include <QFileDialog>
#include <QDebug>
ImageResultItem::ImageResultItem(QGraphicsObject* parent, Cantor::Result* result)
: WorksheetImageItem(parent), ResultItem(result)
......@@ -32,7 +32,6 @@ void ImageResultItem::populateMenu(QMenu* menu, QPointF pos)
ResultItem::addCommonActions(this, menu);
menu->addSeparator();
qDebug() << "populate Menu";
emit menuCreated(menu, mapToParent(pos));
}
......@@ -86,8 +85,7 @@ double ImageResultItem::height() const
void ImageResultItem::saveResult()
{
Cantor::Result* res = result();
const QString& filename=QFileDialog::getSaveFileName(worksheet()->worksheetView(), i18n("Save result"), QString(), res->mimeType());
qDebug()<<"saving result to "<<filename;
const QString& filename = QFileDialog::getSaveFileName(worksheet()->worksheetView(), i18n("Save result"), QString(), res->mimeType());
res->save(filename);
}
......
......@@ -23,6 +23,8 @@
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>
#include <KZip>
#include <KLocalizedString>
LatexEntry::LatexEntry(Worksheet* worksheet) : WorksheetEntry(worksheet), m_textItem(new WorksheetTextItem(this, Qt::TextEditorInteraction))
......
......@@ -5,6 +5,11 @@
*/
#include "markdownentry.h"
#include "jupyterutils.h"
#include "mathrender.h"
#include <config-cantor.h>
#include "settings.h"
#include "worksheetview.h"
#include <QJsonArray>
#include <QJsonObject>
......@@ -12,21 +17,19 @@
#include <QImage>
#include <QImageReader>
#include <QBuffer>
#include <KLocalizedString>
#include <QDebug>
#include <QKeyEvent>
#include <QRegularExpression>
#include <QStandardPaths>
#include <QDir>
#include <QFileDialog>
#include <KMessageBox>
#include <QClipboard>
#include <QMimeData>
#include <QGraphicsSceneDragDropEvent>
#include "jupyterutils.h"
#include "mathrender.h"
#include <config-cantor.h>
#include "settings.h"
#include <KLocalizedString>
#include <KZip>
#include <KMessageBox>
#ifdef Discount_FOUND
extern "C" {
......
......@@ -8,25 +8,20 @@
#include "worksheet.h"
#include "worksheetentry.h"
#include "worksheettextitem.h"
#include "worksheetview.h"
#include <KLocalizedString>
#include <QIcon>
#include <QMenu>
#include <QDebug>
SearchBar::SearchBar(QWidget* parent, Worksheet* worksheet) : QWidget(parent)
SearchBar::SearchBar(QWidget* parent, Worksheet* worksheet) : QWidget(parent),
m_stdUi(new Ui::StandardSearchBar()),
m_worksheet(worksheet),
m_searchFlags{WorksheetEntry::SearchAll}
{
m_worksheet = worksheet;
m_stdUi = new Ui::StandardSearchBar();
m_extUi = nullptr;
setupStdUi();
m_qtFlags = {};
setStartCursor(worksheet->worksheetCursor());
setCurrentCursor(m_startCursor);
m_atBeginning = false;
m_atEnd = false;
m_notFound = false;
m_searchFlags = WorksheetEntry::SearchAll;
}
SearchBar::~SearchBar()
......@@ -51,9 +46,9 @@ void SearchBar::showStandard()
delete m_extUi;
m_extUi = nullptr;
foreach(QObject* child, children()) {
for (auto* child : children())
delete child;
}
delete layout();
m_stdUi = new Ui::StandardSearchBar();
setupStdUi();
......@@ -66,9 +61,9 @@ void SearchBar::showExtended()
delete m_stdUi;
m_stdUi = nullptr;
foreach(QObject* child, children()) {
for (auto* child : children())
delete child;
}
delete layout();
m_extUi = new Ui::ExtendedSearchBar();
setupExtUi();
......@@ -150,7 +145,6 @@ void SearchBar::searchForward(bool skipFirstChar)
if (skipFirstChar) {
QTextCursor c = m_currentCursor.textCursor();
c.movePosition(QTextCursor::NextCharacter);
qDebug() << c.position();
setCurrentCursor(WorksheetCursor(m_currentCursor.entry(),
m_currentCursor.textItem(), c));
}
......@@ -483,5 +477,3 @@ Worksheet* SearchBar::worksheet()
{
return m_worksheet;
}
......@@ -7,7 +7,6 @@
#define SEARCHBAR_H
#include <QWidget>
#include <QList>
#include <QTextDocument>
#include "ui_standardsearchbar.h"
......@@ -25,7 +24,7 @@ class SearchBar : public QWidget
{
Q_OBJECT
public:
SearchBar(QWidget* parent, Worksheet* worksheet);
SearchBar(QWidget*, Worksheet*);
~SearchBar() override;
void showStandard();
......@@ -45,8 +44,8 @@ class SearchBar : public QWidget
void on_previous_clicked();
void on_replace_clicked();
void on_replaceAll_clicked();
void on_pattern_textChanged(const QString& p);
void on_replacement_textChanged(const QString& r);
void on_pattern_textChanged(const QString&);
void on_replacement_textChanged(const QString&);
void on_addFlag_clicked();
void on_removeFlag_clicked();
void on_matchCase_toggled(bool b);
......@@ -60,7 +59,7 @@ class SearchBar : public QWidget
private:
void updateSearchLocations();
void fillLocationsMenu(QMenu* menu, int flags);
void fillLocationsMenu(QMenu*, int flags);
void setupStdUi();
void setupExtUi();
......@@ -68,8 +67,8 @@ class SearchBar : public QWidget
void setStatus(QString);
void clearStatus();
void setStartCursor(WorksheetCursor cursor);
void setCurrentCursor(WorksheetCursor cursor);
void setStartCursor(WorksheetCursor);
void setCurrentCursor(WorksheetCursor);
Worksheet* worksheet();
......@@ -78,7 +77,7 @@ class SearchBar : public QWidget
private:
Ui::StandardSearchBar* m_stdUi;
Ui::ExtendedSearchBar* m_extUi;
Ui::ExtendedSearchBar* m_extUi{nullptr};
WorksheetCursor m_startCursor;
WorksheetCursor m_currentCursor;
......@@ -89,9 +88,9 @@ class SearchBar : public QWidget
QTextDocument::FindFlags m_qtFlags;
unsigned int m_searchFlags;
bool m_atBeginning;
bool m_atEnd;
bool m_notFound;
bool m_atBeginning{false};
bool m_atEnd{false};
bool m_notFound{false};
};
#endif // SEARCHBAR_H
......
......@@ -14,6 +14,7 @@
#include "../worksheet.h"
#include "../session.h"
#include "../worksheetentry.h"
#include "../worksheetview.h"
#include "../textentry.h"
#include "../markdownentry.h"
#include "../commandentry.h"
......
......@@ -10,6 +10,7 @@
#include "latexrenderer.h"
#include "lib/jupyterutils.h"
#include "mathrender.h"
#include "worksheetview.h"
#include "settings.h"
......
......@@ -14,6 +14,7 @@
#include "mathrendertask.h"
#include "config-cantor.h"
#include "settings.h"
#include "worksheetview.h"
#include <QDebug>
#include <QFileDialog>
......
......@@ -6,18 +6,36 @@
*/
#include "worksheet.h"
#include "commandentry.h"
#include "hierarchyentry.h"
#include "horizontalruleentry.h"
#include "imageentry.h"
#include "latexentry.h"
#include "markdownentry.h"
#include "pagebreakentry.h"
#include "placeholderentry.h"
#include "settings.h"
#include "textentry.h"
#include "worksheetview.h"
#include "lib/jupyterutils.h"
#include "lib/backend.h"
#include "lib/extension.h"
#include "lib/helpresult.h"
#include "lib/session.h"
#include "lib/defaulthighlighter.h"
#include <config-cantor.h>
#include <QtGlobal>
#include <QApplication>
#include <QBuffer>
#include <QDebug>
#include <QDrag>
#include <QGraphicsWidget>
#include <QGraphicsSceneMouseEvent>
#include <QJsonArray>
#include <QJsonDocument>
#include <QPrinter>
#include <QRegularExpression>
#include <QTimer>
#include <QXmlQuery>
#include <QJsonArray>
#include <QJsonDocument>
#include <KMessageBox>
#include <KActionCollection>
......@@ -25,27 +43,7 @@
#include <KFontSizeAction>
#include <KToggleAction>
#include <KLocalizedString>
#include <QRegularExpression>
#include <QElapsedTimer>
#include "settings.h"
#include "commandentry.h"
#include "textentry.h"
#include "markdownentry.h"
#include "latexentry.h"
#include "imageentry.h"
#include "pagebreakentry.h"
#include "placeholderentry.h"
#include "horizontalruleentry.h"
#include "hierarchyentry.h"
#include "lib/jupyterutils.h"
#include "lib/backend.h"
#include "lib/extension.h"
#include "lib/helpresult.h"
#include "lib/session.h"
#include "lib/defaulthighlighter.h"
#include <config-cantor.h>
#include <KZip>
const double Worksheet::LeftMargin = 4;
const double Worksheet::RightMargin = 4;
......@@ -53,28 +51,11 @@ const double Worksheet::TopMargin = 12;
const double Worksheet::EntryCursorLength = 30;
const double Worksheet::EntryCursorWidth = 2;
Worksheet::Worksheet(Cantor::Backend* backend, QWidget* parent, bool useDeafultWorksheetParameters)
: QGraphicsScene(parent)
Worksheet::Worksheet(Cantor::Backend* backend, QWidget* parent, bool useDefaultWorksheetParameters)
: QGraphicsScene(parent),
m_cursorItemTimer(new QTimer(this)),
m_useDefaultWorksheetParameters(useDefaultWorksheetParameters)
{
m_session = nullptr;
m_highlighter = nullptr;
m_firstEntry = nullptr;
m_lastEntry = nullptr;
m_lastFocusedTextItem = nullptr;
m_dragEntry = nullptr;
m_placeholderEntry = nullptr;
m_dragScrollTimer = nullptr;
m_choosenCursorEntry = nullptr;
m_isCursorEntryAfterLastEntry = false;
m_useDefaultWorksheetParameters = useDeafultWorksheetParameters;
m_viewWidth = 0;
m_maxWidth = 0;
m_maxPromptWidth = 0;
m_entryCursorItem = addLine(0,0,0,0);
const QColor& color = (palette().color(QPalette::Base).lightness() < 128) ? Qt::white : Qt::black;
......@@ -83,14 +64,9 @@ Worksheet::Worksheet(Cantor::Backend* backend, QWidget* parent, bool useDeafultW
m_entryCursorItem->setPen(pen);
m_entryCursorItem->hide();
m_cursorItemTimer = new QTimer(this);
connect(m_cursorItemTimer, &QTimer::timeout, this, &Worksheet::animateEntryCursor);
m_cursorItemTimer->start(500);
m_jupyterMetadata = nullptr;
m_hierarchyMaxDepth = 0;
if (backend)
initSession(backend);
}
......
......@@ -2,24 +2,18 @@
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com>
SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com>
SPDX-FileCopyrightText: 2017-2021 Alexander Semke <alexander.semke@web.de>
*/
#ifndef WORKSHEET_H
#define WORKSHEET_H
#include <QGraphicsScene>
#include <QDomElement>
#include <QGraphicsLinearLayout>
#include <QGraphicsObject>
#include <QSyntaxHighlighter>
#include <QGraphicsRectItem>
#include <QVector>
#include <QQueue>
#include <KZip>
#include <QMenu>
#include "worksheetview.h"
#include "lib/renderer.h"
#include "mathrender.h"
#include "worksheetcursor.h"
......@@ -31,17 +25,20 @@ namespace Cantor {
}
class WorksheetEntry;
class WorksheetView;
class HierarchyEntry;
class PlaceHolderEntry;
class WorksheetTextItem;
class QAction;
class QDrag;
class QMenu;
class QPrinter;
class KActionCollection;
class KToggleAction;
class KFontAction;
class KFontSizeAction;
class KZip;
class Worksheet : public QGraphicsScene
{
......@@ -52,7 +49,7 @@ class Worksheet : public QGraphicsScene
JupyterNotebook
};
Worksheet(Cantor::Backend* backend, QWidget* parent, bool useDeafultWorksheetParameters = true);
Worksheet(Cantor::Backend*, QWidget*, bool useDeafultWorksheetParameters = true);
~Worksheet() override;
Cantor::Session* session();
......@@ -74,12 +71,12 @@ class Worksheet : public QGraphicsScene
void setModified();
void startDrag(WorksheetEntry* entry, QDrag* drag);
void startDragWithHierarchy(HierarchyEntry* entry, QDrag* drag, QSizeF responsibleZoneSize);
void startDrag(WorksheetEntry*, QDrag*);
void startDragWithHierarchy(HierarchyEntry*, QDrag*, QSizeF responsibleZoneSize);
void createActions(KActionCollection*);
QMenu* createContextMenu();
void populateMenu(QMenu* menu, QPointF pos);
void populateMenu(QMenu*, QPointF);
Cantor::Renderer* renderer();
MathRenderer* mathRenderer();
bool isEmpty();
......@@ -91,8 +88,8 @@ class Worksheet : public QGraphicsScene
WorksheetTextItem* currentTextItem();
WorksheetTextItem* lastFocusedTextItem();
WorksheetEntry* cutSubentriesForHierarchy(HierarchyEntry* hierarchyEntry);
void insertSubentriesForHierarchy(HierarchyEntry* hierarchyEntry, WorksheetEntry* storedSubentriesBegin);
WorksheetEntry* cutSubentriesForHierarchy(HierarchyEntry*);
void insertSubentriesForHierarchy(HierarchyEntry*, WorksheetEntry*);
WorksheetCursor worksheetCursor();
void setWorksheetCursor(const WorksheetCursor&);
......@@ -112,15 +109,15 @@ class Worksheet : public QGraphicsScene
void setViewSize(qreal w, qreal h, qreal s, bool forceUpdate = false);
/// Second information stream
void setRequestedWidth(QGraphicsObject* object, qreal width);
void removeRequestedWidth(QGraphicsObject* object);
void setRequestedWidth(QGraphicsObject*, qreal width);
void removeRequestedWidth(QGraphicsObject*);
bool isShortcut(const QKeySequence&);
void setType(Worksheet::Type type);
void setType(Worksheet::Type);
Worksheet::Type type() const;
void notifyEntryFocus(WorksheetEntry* entry);
void notifyEntryFocus(WorksheetEntry*);
// richtext
struct RichTextInfo {
......@@ -134,11 +131,11 @@ class Worksheet : public QGraphicsScene
};
public:
static int typeForTagName(const QString& tag);
static int typeForTagName(const QString&);
public Q_SLOTS:
WorksheetEntry* appendCommandEntry();
void appendCommandEntry(const QString& text);
void appendCommandEntry(const QString&);
WorksheetEntry* appendTextEntry();
WorksheetEntry* appendMarkdownEntry();
WorksheetEntry* appendImageEntry();
......@@ -148,7 +145,7 @@ class Worksheet : public QGraphicsScene
WorksheetEntry* appendHierarchyEntry();
WorksheetEntry* insertCommandEntry(WorksheetEntry* current = nullptr);
void insertCommandEntry(const QString& text);
void insertCommandEntry(const QString&);
WorksheetEntry* insertTextEntry(WorksheetEntry* current = nullptr);
WorksheetEntry* insertMarkdownEntry(WorksheetEntry* current = nullptr);
WorksheetEntry* insertImageEntry(WorksheetEntry* current = nullptr);
......@@ -194,14 +191,14 @@ class Worksheet : public QGraphicsScene
QDomDocument toXML(KZip* archive = nullptr);
void save(const QString& filename);
void save(const QString&);
void save(QIODevice*);
QByteArray saveToByteArray();
void savePlain(const QString& filename);
void saveLatex(const QString& filename);
void savePlain(const QString&);
void saveLatex(const QString&);
bool load(QIODevice*);
void load(QByteArray* data);
bool load(const QString& filename);
void load(QByteArray*);
bool load(const QString&);
void gotResult(Cantor::Expression* expr = nullptr);