File indexing completed on 2024-05-19 05:19:21

0001 /*
0002     kjots
0003 
0004     SPDX-FileCopyrightText: 1997 Christoph Neerfeld <Christoph.Neerfeld@home.ivm.de>
0005     SPDX-FileCopyrightText: 2002, 2003 Aaron J. Seigo <aseigo@kde.org>
0006     SPDX-FileCopyrightText: 2003 Stanislav Kljuhhin <crz@hot.ee>
0007     SPDX-FileCopyrightText: 2005-2006 Jaison Lee <lee.jaison@gmail.com>
0008     SPDX-FileCopyrightText: 2007-2008 Stephen Kelly <steveire@gmail.com>
0009 
0010     SPDX-License-Identifier: GPL-2.0-or-later
0011 */
0012 
0013 
0014 #ifndef KJOTSEDIT_H
0015 #define KJOTSEDIT_H
0016 
0017 #include <KRichTextWidget>
0018 #include <KPIMTextEdit/RichTextComposer>
0019 
0020 class QItemSelection;
0021 class QItemSelectionModel;
0022 
0023 class KActionCollection;
0024 
0025 class KJotsEdit : public KPIMTextEdit::RichTextComposer
0026 {
0027     Q_OBJECT
0028 public:
0029     explicit KJotsEdit(QWidget *parent, KActionCollection *m_actionCollection);
0030     ~KJotsEdit();
0031 
0032     bool canInsertFromMimeData(const QMimeData *) const override;
0033     void insertFromMimeData(const QMimeData *) override;
0034 
0035     /**
0036      * Load document based on @p index
0037      * Index can belong to some proxy model, in that case
0038      * it will be mapped to the ETM
0039      *
0040      * @returns true if loaded successfully
0041      */
0042     bool setModelIndex(const QModelIndex &index);
0043     /**
0044      * Returns the current modified state of the document
0045      */
0046     bool modified();
0047     /**
0048      * Returns whether currently opened document is locked
0049      */
0050     bool locked();
0051 
0052     /**
0053      * Prepares document for saving.
0054      *
0055      * Currently it includes providing it with embedded images
0056      * Note: savePage calls it explicitly
0057      */
0058     void prepareDocumentForSaving();
0059 
0060     void createActions(KActionCollection *ac);
0061     void setEnableActions(bool enable);
0062 protected:
0063     /* To be able to change cursor when hovering over links */
0064     void mouseMoveEvent(QMouseEvent *event) override;
0065     void leaveEvent(QEvent *event) override;
0066 
0067     /** Override to make ctrl+click follow links */
0068     void mousePressEvent(QMouseEvent *) override;
0069 
0070     void contextMenuEvent(QContextMenuEvent *event) override;
0071 
0072     void focusOutEvent(QFocusEvent *) override;
0073 
0074     bool event(QEvent *event) override;
0075 
0076     void tooltipEvent(QHelpEvent *event);
0077 
0078 public Q_SLOTS:
0079     void onAutoBullet();
0080     void onLinkify(void);
0081     void onAutoDecimal(void);
0082     void DecimalList(void);
0083 
0084     void savePage();
0085     void copySelectionIntoTitle();
0086 
0087 Q_SIGNALS:
0088     void linkClicked(const QUrl &url);
0089     void documentModified(bool modified);
0090 private:
0091     class Private;
0092     std::unique_ptr<Private> const d;
0093 
0094     void createAutoDecimalList();
0095     KActionCollection *m_actionCollection;
0096     bool allowAutoDecimal;
0097 
0098     bool m_cursorChanged = false;
0099 };
0100 
0101 #endif // __KJOTSEDIT_H
0102 /* ex: set tabstop=4 softtabstop=4 shiftwidth=4 expandtab: */