Changeset View
Changeset View
Standalone View
Standalone View
shell/documentcontroller.cpp
Show All 37 Lines | |||||
38 | #include <KIO/StatJob> | 38 | #include <KIO/StatJob> | ||
39 | #include <KJobWidgets> | 39 | #include <KJobWidgets> | ||
40 | #include <KLocalizedString> | 40 | #include <KLocalizedString> | ||
41 | #include <KMessageBox> | 41 | #include <KMessageBox> | ||
42 | #include <KProtocolInfo> | 42 | #include <KProtocolInfo> | ||
43 | #include <KRecentFilesAction> | 43 | #include <KRecentFilesAction> | ||
44 | #include <KTextEditor/Document> | 44 | #include <KTextEditor/Document> | ||
45 | #include <KTextEditor/View> | 45 | #include <KTextEditor/View> | ||
46 | #include <KTextEditor/AnnotationInterface> | | |||
47 | 46 | | |||
48 | #include <sublime/area.h> | 47 | #include <sublime/area.h> | ||
49 | #include <sublime/view.h> | 48 | #include <sublime/view.h> | ||
50 | #include <interfaces/iplugincontroller.h> | 49 | #include <interfaces/iplugincontroller.h> | ||
51 | #include <interfaces/iprojectcontroller.h> | 50 | #include <interfaces/iprojectcontroller.h> | ||
52 | #include <interfaces/ibuddydocumentfinder.h> | 51 | #include <interfaces/ibuddydocumentfinder.h> | ||
53 | #include <interfaces/iproject.h> | 52 | #include <interfaces/iproject.h> | ||
54 | #include <interfaces/iselectioncontroller.h> | 53 | #include <interfaces/iselectioncontroller.h> | ||
55 | #include <interfaces/context.h> | 54 | #include <interfaces/context.h> | ||
56 | #include <project/projectmodel.h> | 55 | #include <project/projectmodel.h> | ||
57 | #include <util/scopeddialog.h> | 56 | #include <util/scopeddialog.h> | ||
58 | #include <util/path.h> | 57 | #include <util/path.h> | ||
59 | 58 | | |||
60 | #include "core.h" | 59 | #include "core.h" | ||
61 | #include "mainwindow.h" | 60 | #include "mainwindow.h" | ||
62 | #include "textdocument.h" | 61 | #include "textdocument.h" | ||
63 | #include "uicontroller.h" | 62 | #include "uicontroller.h" | ||
64 | #include "partcontroller.h" | 63 | #include "partcontroller.h" | ||
65 | #include "savedialog.h" | 64 | #include "savedialog.h" | ||
66 | #include "debug.h" | 65 | #include "debug.h" | ||
67 | 66 | | |||
68 | #include <vcs/interfaces/ibasicversioncontrol.h> | | |||
69 | #include <vcs/vcspluginhelper.h> | | |||
70 | | ||||
71 | #define EMPTY_DOCUMENT_URL i18n("Untitled") | 67 | #define EMPTY_DOCUMENT_URL i18n("Untitled") | ||
72 | 68 | | |||
73 | namespace KDevelop | 69 | namespace KDevelop | ||
74 | { | 70 | { | ||
75 | 71 | | |||
76 | 72 | | |||
77 | struct DocumentControllerPrivate | 73 | struct DocumentControllerPrivate | ||
78 | { | 74 | { | ||
▲ Show 20 Lines • Show All 566 Lines • ▼ Show 20 Line(s) | 589 | { | |||
645 | action = d->closeAllOthers = ac->addAction( QStringLiteral("file_closeother") ); | 641 | action = d->closeAllOthers = ac->addAction( QStringLiteral("file_closeother") ); | ||
646 | action->setIcon(QIcon::fromTheme(QStringLiteral("document-close"))); | 642 | action->setIcon(QIcon::fromTheme(QStringLiteral("document-close"))); | ||
647 | ac->setDefaultShortcut(action, Qt::CTRL + Qt::SHIFT + Qt::Key_W ); | 643 | ac->setDefaultShortcut(action, Qt::CTRL + Qt::SHIFT + Qt::Key_W ); | ||
648 | action->setText(i18n( "Close All Ot&hers" ) ); | 644 | action->setText(i18n( "Close All Ot&hers" ) ); | ||
649 | connect( action, &QAction::triggered, this, &DocumentController::closeAllOtherDocuments ); | 645 | connect( action, &QAction::triggered, this, &DocumentController::closeAllOtherDocuments ); | ||
650 | action->setToolTip( i18n( "Close all other documents" ) ); | 646 | action->setToolTip( i18n( "Close all other documents" ) ); | ||
651 | action->setWhatsThis( i18n( "Close all open documents, with the exception of the currently active document." ) ); | 647 | action->setWhatsThis( i18n( "Close all open documents, with the exception of the currently active document." ) ); | ||
652 | action->setEnabled(false); | 648 | action->setEnabled(false); | ||
653 | | ||||
654 | action = ac->addAction( QStringLiteral("vcsannotate_current_document") ); | | |||
655 | connect( action, &QAction::triggered, this, &DocumentController::vcsAnnotateCurrentDocument ); | | |||
656 | action->setText( i18n( "Show Annotate on current document") ); | | |||
657 | action->setIconText( i18n( "Annotate" ) ); | | |||
658 | action->setIcon( QIcon::fromTheme(QStringLiteral("user-properties")) ); | | |||
659 | } | 649 | } | ||
660 | 650 | | |||
661 | void DocumentController::slotOpenDocument(const QUrl &url) | 651 | void DocumentController::slotOpenDocument(const QUrl &url) | ||
662 | { | 652 | { | ||
663 | openDocument(url); | 653 | openDocument(url); | ||
664 | } | 654 | } | ||
665 | 655 | | |||
666 | IDocument* DocumentController::openDocumentFromText( const QString& data ) | 656 | IDocument* DocumentController::openDocumentFromText( const QString& data ) | ||
▲ Show 20 Lines • Show All 533 Lines • ▼ Show 20 Line(s) | 1070 | { | |||
1200 | { | 1190 | { | ||
1201 | qCDebug(SHELL) << "unsplitting second"; | 1191 | qCDebug(SHELL) << "unsplitting second"; | ||
1202 | index->unsplit(index->second()); | 1192 | index->unsplit(index->second()); | ||
1203 | } | 1193 | } | ||
1204 | 1194 | | |||
1205 | return ret; | 1195 | return ret; | ||
1206 | } | 1196 | } | ||
1207 | 1197 | | |||
1208 | void DocumentController::vcsAnnotateCurrentDocument() | | |||
1209 | { | | |||
1210 | IDocument* doc = activeDocument(); | | |||
1211 | if (!doc) | | |||
1212 | return; | | |||
1213 | | ||||
1214 | QUrl url = doc->url(); | | |||
1215 | IProject* project = KDevelop::ICore::self()->projectController()->findProjectForUrl(url); | | |||
1216 | if(project && project->versionControlPlugin()) { | | |||
1217 | IBasicVersionControl* iface = project->versionControlPlugin()->extension<IBasicVersionControl>(); | | |||
1218 | auto helper = new VcsPluginHelper(project->versionControlPlugin(), iface); | | |||
1219 | connect(doc->textDocument(), &KTextEditor::Document::aboutToClose, | | |||
1220 | helper, static_cast<void(VcsPluginHelper::*)(KTextEditor::Document*)>(&VcsPluginHelper::disposeEventually)); | | |||
1221 | Q_ASSERT(qobject_cast<KTextEditor::AnnotationViewInterface*>(doc->activeTextView())); | | |||
1222 | // can't use new signal slot syntax here, AnnotationViewInterface is not a QObject | | |||
1223 | connect(doc->activeTextView(), SIGNAL(annotationBorderVisibilityChanged(View*,bool)), | | |||
1224 | helper, SLOT(disposeEventually(View*,bool))); | | |||
1225 | helper->addContextDocument(url); | | |||
1226 | helper->annotation(); | | |||
1227 | } | | |||
1228 | else { | | |||
1229 | KMessageBox::error(nullptr, i18n("Could not annotate the document because it is not " | | |||
1230 | "part of a version-controlled project.")); | | |||
1231 | } | | |||
1232 | } | | |||
1233 | | ||||
1234 | } | 1198 | } | ||
1235 | 1199 | | |||
1236 | #include "moc_documentcontroller.cpp" | 1200 | #include "moc_documentcontroller.cpp" |