Commit 861230e3 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

KDevelop::IDocument: use via Q_INTERFACES

parent d6139ff7
......@@ -21,6 +21,7 @@
#ifndef KDEVPLATFORM_IDOCUMENT_H
#define KDEVPLATFORM_IDOCUMENT_H
#include <QObject>
#include <QUrl>
#include <QScopedPointer>
......@@ -218,5 +219,7 @@ private:
}
Q_DECLARE_INTERFACE(KDevelop::IDocument, "org.kdevelop.IDocument")
#endif
......@@ -108,7 +108,7 @@ public:
void removeDocument(Sublime::Document *doc)
{
const QList<QUrl> urlsForDoc = documents.keys(dynamic_cast<KDevelop::IDocument*>(doc));
const QList<QUrl> urlsForDoc = documents.keys(qobject_cast<KDevelop::IDocument*>(doc));
for (const QUrl& url : urlsForDoc) {
qCDebug(SHELL) << "destroying document" << doc;
documents.remove(url);
......@@ -741,7 +741,7 @@ void DocumentController::notifyDocumentClosed(Sublime::Document* doc_)
{
Q_D(DocumentController);
auto* doc = dynamic_cast<IDocument*>(doc_);
auto* doc = qobject_cast<IDocument*>(doc_);
Q_ASSERT(doc);
d->removeDocument(doc_);
......@@ -949,7 +949,7 @@ void DocumentController::closeAllOtherDocuments()
// Deal with saving unsaved solo views
QList<IDocument*> soloViews = documentsExclusivelyInWindow(qobject_cast<KDevelop::MainWindow*>(mw));
soloViews.removeAll(dynamic_cast<IDocument*>(activeView->document()));
soloViews.removeAll(qobject_cast<IDocument*>(activeView->document()));
if (!saveSomeDocuments(soloViews, IDocument::Default))
// User cancelled or other error
......@@ -969,7 +969,7 @@ IDocument* DocumentController::activeDocument() const
UiController *uiController = Core::self()->uiControllerInternal();
Sublime::MainWindow* mw = uiController->activeSublimeWindow();
if( !mw || !mw->activeView() ) return nullptr;
return dynamic_cast<IDocument*>(mw->activeView()->document());
return qobject_cast<IDocument*>(mw->activeView()->document());
}
KTextEditor::View* DocumentController::activeTextDocumentView() const
......
......@@ -152,7 +152,7 @@ void MainWindowPrivate::changeActiveView(Sublime::View *view)
if(!view)
return;
auto *doc = dynamic_cast<KDevelop::IDocument*>(view->document());
auto* doc = qobject_cast<KDevelop::IDocument*>(view->document());
if (doc)
{
doc->activate(view, m_mainWindow);
......
......@@ -42,6 +42,8 @@ and sets part widget to be a view widget.
*/
class KDEVPLATFORMSHELL_EXPORT PartDocument: public Sublime::UrlDocument, public KDevelop::IDocument {
Q_OBJECT
Q_INTERFACES(KDevelop::IDocument)
public:
PartDocument(const QUrl &url, ICore* core, const QString& preferredPart = QString() );
~PartDocument() override;
......
......@@ -173,7 +173,7 @@ void DocumentSwitcherPlugin::fillModel( Sublime::MainWindow* window )
continue;
}
QString itemText = slDoc->title();// file name
IDocument const* const doc = dynamic_cast<IDocument*>(v->document());
IDocument const* const doc = qobject_cast<IDocument*>(v->document());
IProject* project = nullptr;
if( doc )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment