Warning, file /frameworks/ktexteditor/src/include/ktexteditor/modificationinterface.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2005 Christoph Cullmann <cullmann@kde.org>
0003 
0004     Documentation:
0005     SPDX-FileCopyrightText: 2005 Dominik Haumann <dhdev@gmx.de>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #ifndef KTEXTEDITOR_MODIFICATIONINTERFACE_H
0011 #define KTEXTEDITOR_MODIFICATIONINTERFACE_H
0012 
0013 #include <ktexteditor_export.h>
0014 
0015 #include <QObject>
0016 
0017 namespace KTextEditor
0018 {
0019 class Document;
0020 class View;
0021 
0022 /**
0023  * \class ModificationInterface modificationinterface.h <KTextEditor/ModificationInterface>
0024  *
0025  * \brief External modification extension interface for the Document.
0026  *
0027  * \ingroup kte_group_doc_extensions
0028  *
0029  * \section modiface_intro Introduction
0030  *
0031  * The class ModificationInterface provides methods to handle modifications
0032  * of all opened files caused by external programs. Whenever the
0033  * modified-on-disk state changes the signal modifiedOnDisk() is emitted
0034  * along with a ModifiedOnDiskReason. Set the state by calling
0035  * setModifiedOnDisk(). Whether the Editor should show warning dialogs to
0036  * inform the user about external modified files can be controlled with
0037  * setModifiedOnDiskWarning(). The slot modifiedOnDisk() is called to ask
0038  * the user what to do whenever a file was modified.
0039  *
0040  * \section modiface_access Accessing the ModificationInterface
0041  *
0042  * The ModificationInterface is supposed to be an extension interface for a
0043  * Document, i.e. the Document inherits the interface \e provided that the
0044  * used KTextEditor library implements the interface. Use qobject_cast to
0045  * access the interface:
0046  * \code
0047  * // doc is of type KTextEditor::Document*
0048  * auto iface = qobject_cast<KTextEditor::ModificationInterface*>(doc);
0049  *
0050  * if (iface) {
0051  *     // the implementation supports the interface
0052  *     // do stuff
0053  * } else {
0054  *     // the implementation does not support the interface
0055  * }
0056  * \endcode
0057  *
0058  * \see KTextEditor::Document
0059  * \author Christoph Cullmann \<cullmann@kde.org\>
0060  */
0061 class KTEXTEDITOR_EXPORT ModificationInterface
0062 {
0063 public:
0064     ModificationInterface();
0065 
0066     /**
0067      * Virtual destructor.
0068      */
0069     virtual ~ModificationInterface();
0070 
0071 public:
0072     /**
0073      * Reasons why a document is modified on disk.
0074      */
0075     enum ModifiedOnDiskReason {
0076         OnDiskUnmodified = 0, ///< Not modified
0077         OnDiskModified = 1, ///< The file was modified on disk
0078         OnDiskCreated = 2, ///< The file was created on disk
0079         OnDiskDeleted = 3 ///< The file was deleted on disk
0080     };
0081 
0082 public:
0083     /**
0084      * Set the document's modified-on-disk state to \p reason.
0085      * KTextEditor implementations should emit the signal modifiedOnDisk()
0086      * along with the reason. When the document is in a clean state again the
0087      * reason should be ModifiedOnDiskReason::OnDiskUnmodified.
0088      *
0089      * \param reason the modified-on-disk reason.
0090      * \see ModifiedOnDiskReason, modifiedOnDisk()
0091      */
0092     virtual void setModifiedOnDisk(ModifiedOnDiskReason reason) = 0;
0093 
0094     /**
0095      * Control, whether the editor should show a warning dialog whenever a file
0096      * was modified on disk. If \p on is \e true the editor will show warning
0097      * dialogs.
0098      * \param on controls, whether the editor should show a warning dialog for
0099      *        files modified on disk
0100      */
0101     virtual void setModifiedOnDiskWarning(bool on) = 0;
0102 
0103     /*
0104      * These stuff is implemented as SIGNALS in the real document
0105      */
0106 public:
0107     /**
0108      * This signal is emitted whenever the \p document changed its
0109      * modified-on-disk state.
0110      * \param document the Document object that represents the file on disk
0111      * \param isModified if \e true, the file was modified rather than created
0112      *        or deleted
0113      * \param reason the reason why the signal was emitted
0114      * \see setModifiedOnDisk()
0115      */
0116     virtual void modifiedOnDisk(KTextEditor::Document *document, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason) = 0;
0117 
0118 private:
0119     class ModificationInterfacePrivate *const d = nullptr;
0120 };
0121 
0122 }
0123 
0124 Q_DECLARE_INTERFACE(KTextEditor::ModificationInterface, "org.kde.KTextEditor.ModificationInterface")
0125 
0126 #endif