Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/shell/ktexteditorpluginintegration.cpp
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Line(s) | |||||
210 | QList<KTextEditor::MainWindow *> Application::mainWindows() const | 210 | QList<KTextEditor::MainWindow *> Application::mainWindows() const | ||
211 | { | 211 | { | ||
212 | return {activeMainWindow()}; | 212 | return {activeMainWindow()}; | ||
213 | } | 213 | } | ||
214 | 214 | | |||
215 | bool Application::closeDocument(KTextEditor::Document *document) const | 215 | bool Application::closeDocument(KTextEditor::Document *document) const | ||
216 | { | 216 | { | ||
217 | auto documentController = Core::self()->documentControllerInternal(); | 217 | auto documentController = Core::self()->documentControllerInternal(); | ||
218 | return documentController->closeDocument(document->url()); | 218 | for (auto doc : documentController->openDocuments()) { | ||
219 | if (doc->textDocument() == document) { | ||||
220 | return doc->close(); | ||||
221 | } | ||||
222 | } | ||||
223 | return false; | ||||
219 | } | 224 | } | ||
220 | 225 | | |||
221 | KTextEditor::Plugin *Application::plugin(const QString &id) const | 226 | KTextEditor::Plugin *Application::plugin(const QString &id) const | ||
222 | { | 227 | { | ||
223 | auto kdevPlugin = Core::self()->pluginController()->loadPlugin(id); | 228 | auto kdevPlugin = Core::self()->pluginController()->loadPlugin(id); | ||
224 | const auto plugin = dynamic_cast<Plugin*>(kdevPlugin); | 229 | const auto plugin = dynamic_cast<Plugin*>(kdevPlugin); | ||
225 | return plugin ? plugin->interface() : nullptr; | 230 | return plugin ? plugin->interface() : nullptr; | ||
226 | } | 231 | } | ||
227 | 232 | | |||
233 | QList<KTextEditor::Document *> Application::documents() | ||||
234 | { | ||||
235 | QList<KTextEditor::Document *> l; | ||||
236 | auto documentController = Core::self()->documentControllerInternal(); | ||||
237 | for (auto d : documentController->openDocuments()) { | ||||
238 | l << d->textDocument(); | ||||
239 | } | ||||
240 | return l; | ||||
241 | } | ||||
242 | | ||||
243 | KTextEditor::Document * Application::openUrl(const QUrl& url, const QString& encoding) | ||||
244 | { | ||||
245 | auto documentController = Core::self()->documentControllerInternal(); | ||||
246 | auto doc = url.isEmpty() ? documentController->openDocumentFromText(QString()) : documentController->openDocument(url); | ||||
247 | return doc->textDocument(); | ||||
248 | } | ||||
249 | | ||||
228 | MainWindow::MainWindow(KDevelop::MainWindow *mainWindow) | 250 | MainWindow::MainWindow(KDevelop::MainWindow *mainWindow) | ||
229 | : QObject(mainWindow) | 251 | : QObject(mainWindow) | ||
230 | , m_mainWindow(mainWindow) | 252 | , m_mainWindow(mainWindow) | ||
231 | , m_interface(new KTextEditor::MainWindow(this)) | 253 | , m_interface(new KTextEditor::MainWindow(this)) | ||
232 | , m_viewBarContainerLayout(new ViewBarStackedLayout) | 254 | , m_viewBarContainerLayout(new ViewBarStackedLayout) | ||
233 | { | 255 | { | ||
234 | auto viewBarContainer = m_mainWindow->viewBarContainer(); | 256 | auto viewBarContainer = m_mainWindow->viewBarContainer(); | ||
235 | viewBarContainer->setLayout(m_viewBarContainerLayout); | 257 | viewBarContainer->setLayout(m_viewBarContainerLayout); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 299 | { | |||
286 | return views; | 308 | return views; | ||
287 | } | 309 | } | ||
288 | 310 | | |||
289 | KTextEditor::View *MainWindow::activeView() const | 311 | KTextEditor::View *MainWindow::activeView() const | ||
290 | { | 312 | { | ||
291 | return toKteView(m_mainWindow->activeView()); | 313 | return toKteView(m_mainWindow->activeView()); | ||
292 | } | 314 | } | ||
293 | 315 | | |||
316 | KTextEditor::View *MainWindow::activateView(KTextEditor::Document *doc) | ||||
317 | { | ||||
318 | foreach (auto area, m_mainWindow->areas()) { | ||||
319 | foreach (auto view, area->views()) { | ||||
320 | if (auto kteView = toKteView(view)) { | ||||
321 | if (kteView->document() == doc) { | ||||
322 | m_mainWindow->activateView(view); | ||||
323 | return kteView; | ||||
324 | } | ||||
325 | } | ||||
326 | } | ||||
327 | } | ||||
328 | | ||||
329 | return activeView(); | ||||
330 | } | ||||
331 | | ||||
294 | QObject *MainWindow::pluginView(const QString &id) const | 332 | QObject *MainWindow::pluginView(const QString &id) const | ||
295 | { | 333 | { | ||
296 | return m_pluginViews.value(id); | 334 | return m_pluginViews.value(id); | ||
297 | } | 335 | } | ||
298 | 336 | | |||
299 | QWidget *MainWindow::createViewBar(KTextEditor::View *view) | 337 | QWidget *MainWindow::createViewBar(KTextEditor::View *view) | ||
300 | { | 338 | { | ||
301 | Q_UNUSED(view); | 339 | Q_UNUSED(view); | ||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |