1 /* 2 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #include "idocument.h" 8 9 #include "icore.h" 10 #include "idocumentcontroller.h" 11 12 namespace KDevelop { 13 14 class IDocumentPrivate 15 { 16 public: IDocumentPrivate(KDevelop::ICore * core)17 inline explicit IDocumentPrivate(KDevelop::ICore *core) 18 : m_core(core), scriptWrapper(nullptr) 19 {} 20 21 KDevelop::ICore* m_core; 22 QObject *scriptWrapper; 23 QString m_prettyName; 24 25 /* Internal access to the wrapper script object */ getWrapper(IDocument * doc)26 static inline QObject *&getWrapper(IDocument *doc) 27 { 28 return doc->d_func()->scriptWrapper; 29 } 30 }; 31 32 /* This allows the scripting backend to register the scripting 33 wrapper. Not beautiful, but makes sure it doesn't expand to much code. 34 */ getWrapper(IDocument * doc)35QObject *&getWrapper(IDocument *doc) 36 { 37 return IDocumentPrivate::getWrapper(doc); 38 } 39 IDocument(KDevelop::ICore * core)40IDocument::IDocument( KDevelop::ICore* core ) 41 : d_ptr(new IDocumentPrivate(core)) 42 { 43 } 44 ~IDocument()45IDocument::~IDocument() 46 { 47 Q_D(IDocument); 48 49 delete d->scriptWrapper; 50 } 51 core()52KDevelop::ICore* IDocument::core() 53 { 54 Q_D(IDocument); 55 56 return d->m_core; 57 } 58 notifySaved()59void IDocument::notifySaved() 60 { 61 emit core()->documentController()->documentSaved(this); 62 } 63 notifyStateChanged()64void IDocument::notifyStateChanged() 65 { 66 emit core()->documentController()->documentStateChanged(this); 67 } 68 notifyActivated()69void IDocument::notifyActivated() 70 { 71 emit core()->documentController()->documentActivated(this); 72 } 73 notifyContentChanged()74void IDocument::notifyContentChanged() 75 { 76 emit core()->documentController()->documentContentChanged(this); 77 } 78 isTextDocument() const79bool IDocument::isTextDocument() const 80 { 81 return false; 82 } 83 notifyTextDocumentCreated()84void IDocument::notifyTextDocumentCreated() 85 { 86 emit core()->documentController()->textDocumentCreated(this); 87 } 88 textSelection() const89KTextEditor::Range IDocument::textSelection() const 90 { 91 return KTextEditor::Range::invalid(); 92 } 93 textLine() const94QString IDocument::textLine() const 95 { 96 return QString(); 97 } 98 textWord() const99QString IDocument::textWord() const 100 { 101 return QString(); 102 } 103 prettyName() const104QString IDocument::prettyName() const 105 { 106 Q_D(const IDocument); 107 108 return d->m_prettyName; 109 } 110 setPrettyName(const QString & name)111void IDocument::setPrettyName(const QString& name) 112 { 113 Q_D(IDocument); 114 115 d->m_prettyName = name; 116 } 117 notifyUrlChanged()118void IDocument::notifyUrlChanged() 119 { 120 emit core()->documentController()->documentUrlChanged(this); 121 } 122 notifyLoaded()123void IDocument::notifyLoaded() 124 { 125 emit core()->documentController()->documentLoadedPrepare(this); 126 emit core()->documentController()->documentLoaded(this); 127 } 128 activeTextView() const129KTextEditor::View* IDocument::activeTextView() const 130 { 131 return nullptr; 132 } 133 text(const KTextEditor::Range & range) const134QString KDevelop::IDocument::text(const KTextEditor::Range& range) const 135 { 136 Q_UNUSED(range); 137 return {}; 138 } 139 140 } 141 142