void TestShellDocumentOperation::testKateDocumentAndViewCreation() { //create one document IDocumentController *documentController = Core::self()->documentController(); documentController->openDocumentFromText(QLatin1String("")); QCOMPARE(documentController->openDocuments().count(), 1); //assure we have only one kate view for the newly created document KTextEditor::Document *doc = documentController->openDocuments().at(0)->textDocument(); QCOMPARE(doc->views().count(), 1); QCOMPARE(dynamic_cast<KTextEditor::MovingInterface*>(doc)->revision(), qint64(0)); //also assure the view's xmlgui is plugged in KParts::MainWindow *main = Core::self()->uiControllerInternal()->activeMainWindow(); QVERIFY(main); QVERIFY(main->guiFactory()->clients().contains(doc->views().at(0))); //KTextEditor::views is internally a QHash::keys() call: so the order of the views will vary const auto originalView = doc->views().at(0); //create the new view and activate it (using split action from mainwindow) QAction *splitAction = main->actionCollection()->action(QStringLiteral("split_vertical")); QVERIFY(splitAction); splitAction->trigger(); const auto viewList = doc->views(); QCOMPARE(viewList.count(), 2); const auto newlySplitView = originalView == viewList[0] ? viewList[1] : viewList[0]; //check that we did switch to the new xmlguiclient QVERIFY(!main->guiFactory()->clients().contains(originalView)); QVERIFY(main->guiFactory()->clients().contains(newlySplitView)); documentController->openDocuments().at(0)->close(IDocument::Discard); }
void Konsole::sync() { if(!KileConfig::syncConsoleDirWithTabs()) { return; } KTextEditor::Document *doc = m_ki->activeTextDocument(); KTextEditor::View *view = Q_NULLPTR; if(doc) { view = doc->views().first(); } if(view) { QString finame; QUrl url = view->document()->url(); if(url.path().isEmpty()) { return; } QFileInfo fic(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path()); if(fic.isReadable()) { setDirectory(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path()); } } }
KWrite::~KWrite() { guiFactory()->removeClient(m_view); winList.removeAll(this); KTextEditor::Document *doc = m_view->document(); delete m_view; // kill document, if last view is closed if (doc->views().isEmpty()) { docList.removeAll(doc); delete doc; } KSharedConfig::openConfig()->sync(); }