/usr/include/KF5/KParts/kparts/readwritepart.h is in libkf5parts-dev 5.44.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | /* This file is part of the KDE project
Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
(C) 1999 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KPARTS_READWRITEPART_H
#define _KPARTS_READWRITEPART_H
#include <kparts/readonlypart.h>
namespace KParts
{
class ReadWritePartPrivate;
/**
* Base class for an "editor" part.
*
* This class handles network transparency for you.
* Anything that can open a URL, allow modifications, and save
* (to the same URL or a different one).
*
* A read-write part can be set to read-only mode, using setReadWrite().
*
* Part writers :
* Any part inheriting ReadWritePart should check isReadWrite
* before allowing any action that modifies the part.
* The part probably wants to reimplement setReadWrite, disable those
* actions. Don't forget to call the parent setReadWrite.
*/
class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
{
Q_OBJECT
KPARTS_DECLARE_PRIVATE(ReadWritePart)
public:
/**
* Constructor
* See parent constructor for instructions.
*/
explicit ReadWritePart(QObject *parent = nullptr);
/**
* Destructor
* Applications using a ReadWritePart should make sure, before
* destroying it, to call closeUrl().
* In KMainWindow::queryClose(), for instance, they should allow
* closing only if the return value of closeUrl() was true.
* This allows to cancel.
*/
virtual ~ReadWritePart();
/**
* @return true if the part is in read-write mode
*/
bool isReadWrite() const;
/**
* Changes the behavior of this part to readonly or readwrite.
* @param readwrite set to true to enable readwrite mode
*/
virtual void setReadWrite(bool readwrite = true);
/**
* @return true if the document has been modified.
*/
bool isModified() const;
/**
* If the document has been modified, ask the user to save changes.
* This method is meant to be called from KMainWindow::queryClose().
* It will also be called from closeUrl().
*
* @return true if closeUrl() can be called without the user losing
* important data, false if the user chooses to cancel.
*/
virtual bool queryClose();
/**
* Called when closing the current url (e.g. document), for instance
* when switching to another url (note that openUrl() calls it
* automatically in this case).
*
* If the current URL is not fully loaded yet, aborts loading.
*
* If isModified(), queryClose() will be called.
*
* @return false on cancel
*/
bool closeUrl() Q_DECL_OVERRIDE;
/**
* Call this method instead of the above if you need control if
* the save prompt is shown. For example, if you call queryClose()
* from KMainWindow::queryClose(), you would not want to prompt
* again when closing the url.
*
* Equivalent to promptToSave ? closeUrl() : ReadOnlyPart::closeUrl()
*/
virtual bool closeUrl(bool promptToSave);
/**
* Save the file to a new location.
*
* Calls save(), no need to reimplement
*/
virtual bool saveAs(const QUrl &url);
/**
* Sets the modified flag of the part.
*/
virtual void setModified(bool modified);
Q_SIGNALS:
/**
* set handled to true, if you don't want the default handling
* set abortClosing to true, if you handled the request,
* but for any reason don't want to allow closing the document
*/
void sigQueryClose(bool *handled, bool *abortClosing);
public Q_SLOTS:
/**
* Call setModified() whenever the contents get modified.
* This is a slot for convenience, since it simply calls setModified(true),
* so that you can connect it to a signal, like textChanged().
*/
void setModified();
/**
* Save the file in the location from which it was opened.
* You can connect this to the "save" action.
* Calls saveFile() and saveToUrl(), no need to reimplement.
*/
virtual bool save();
/**
* Waits for any pending upload job to finish and returns whether the
* last save() action was successful.
*/
bool waitSaveComplete();
protected:
/**
* Save to a local file.
* You need to implement it, to save to the local file.
* The framework takes care of re-uploading afterwards.
*
* @return true on success, false on failure.
* On failure the function should inform the user about the
* problem with an appropriate message box. Standard error
* messages can be constructed using KIO::buildErrorString()
* in combination with the error codes defined in kio/global.h
*/
virtual bool saveFile() = 0;
/**
* Save the file.
*
* Uploads the file, if @p url is remote.
* This will emit started(), and either completed() or canceled(),
* in case you want to provide feedback.
* @return true on success, false on failure.
*/
virtual bool saveToUrl();
private:
Q_PRIVATE_SLOT(d_func(), void _k_slotUploadFinished(KJob *job))
Q_DISABLE_COPY(ReadWritePart)
};
} // namespace
#endif
|