/usr/include/kdevplatform/interfaces/idocument.h is in kdevelop-dev 4:5.2.1-1ubuntu4.
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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | /***************************************************************************
* Copyright 2006 Hamish Rodda <rodda@kde.org> *
* Copyright 2007 Alexander Dymo <adymo@kdevelop.org> *
* Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
* *
* This program 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 program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef KDEVPLATFORM_IDOCUMENT_H
#define KDEVPLATFORM_IDOCUMENT_H
#include <QUrl>
#include <QScopedPointer>
#include "interfacesexport.h"
namespace KParts { class Part; class MainWindow; }
namespace KTextEditor {
class Cursor;
class Document;
class Range;
class View;
}
namespace Sublime{ class View; }
class QMimeType;
class QWidget;
namespace KDevelop {
class ICore;
/**
* A single document being edited by the IDE.
*
* The base class for tracking a document. It contains the URL,
* the part, and any associated metadata for the document.
*
* The advantages are:
* - an easier key for use in maps and the like
* - a value which does not change when the filename changes
* - clearer distinction in the code between an open document and a url
* (which may or may not be open)
*/
class KDEVPLATFORMINTERFACES_EXPORT IDocument {
public:
virtual ~IDocument();
/**Document state.*/
enum DocumentState
{
Clean, /**< Document is not touched.*/
Modified, /**< Document is modified inside the IDE.*/
Dirty, /**< Document is modified by an external process.*/
DirtyAndModified /**< Document is modified inside the IDE and at the same time by an external process.*/
};
enum DocumentSaveMode
{
Default = 0x0 /**< standard save mode, gives a warning message if the file was modified outside the editor */,
Silent = 0x1 /**< silent save mode, doesn't warn the user if the file was modified outside the editor */,
Discard = 0x2 /**< discard mode, don't save any unchanged data */
};
/**
* Returns the URL of this document.
*/
virtual QUrl url() const = 0;
/**
* Returns the mimetype of the document.
*/
virtual QMimeType mimeType() const = 0;
/**
* Returns the part for given @p view if this document is a KPart document or 0 otherwise.
*/
virtual KParts::Part* partForView(QWidget *view) const = 0;
/**
* Returns whether this document is a text document.
*/
virtual bool isTextDocument() const;
/**
* Set a 'pretty' name for this document. That name will be used when displaying the document in the UI,
* instead of the filename and/or path.
* @param name The pretty name to use. Give an empty name to reset.
* */
virtual void setPrettyName(QString name);
/**
* returns the pretty name of this document that was set through setPrettyName(...).
* If no pretty name was set, an empty string is returned.
* */
virtual QString prettyName() const;
/**
* Returns the text editor, if this is a text document or 0 otherwise.
*/
virtual KTextEditor::Document* textDocument() const = 0;
/**
* Saves the document.
* @return true if the document was saved, false otherwise
*/
virtual bool save(DocumentSaveMode mode = Default) = 0;
/**
* Reloads the document.
*/
virtual void reload() = 0;
/**
* Requests that the document be closed.
*
* \returns whether the document was successfully closed.
*/
virtual bool close(DocumentSaveMode mode = Default) = 0;
/**
* Enquires whether this document is currently active in the currently active mainwindow.
*/
virtual bool isActive() const = 0;
/**
* Checks the state of this document.
* @return The document state.
*/
virtual DocumentState state() const = 0;
/**
* Access the current text cursor position, if possible.
*
* \returns the current text cursor position, or an invalid cursor otherwise.
*/
virtual KTextEditor::Cursor cursorPosition() const = 0;
/**
* Set the current text cursor position, if possible.
*
* \param cursor new cursor position.
*/
virtual void setCursorPosition(const KTextEditor::Cursor &cursor) = 0;
/**
* Retrieve the current text selection, if one exists.
*
* \returns the current text selection
*/
virtual KTextEditor::Range textSelection() const;
/**
* Set the current text selection, if possible.
*
* \param range new cursor position.
*/
virtual void setTextSelection(const KTextEditor::Range &range) = 0;
/**
* @returns the text in a given range
*/
virtual QString text(const KTextEditor::Range &range) const;
/**
* Retrieve the current text line, if one exists.
*
* @returns the current text line
*/
virtual QString textLine() const;
/**
* Retrieve the current text word, if one exists.
*
* @returns the current text word
*/
virtual QString textWord() const;
/**
* Performs document activation actions if any.
* This needs to call notifyActivated()
*/
virtual void activate(Sublime::View *activeView, KParts::MainWindow *mainWindow) = 0;
/**
* @returns the active text view in case it's a text document and it has one.
*/
virtual KTextEditor::View* activeTextView() const;
protected:
ICore* core();
explicit IDocument( ICore* );
void notifySaved();
void notifyStateChanged();
void notifyActivated();
void notifyContentChanged();
void notifyTextDocumentCreated();
void notifyUrlChanged();
void notifyLoaded();
private:
const QScopedPointer<class IDocumentPrivate> d;
friend class IDocumentPrivate;
};
}
#endif
|