File indexing completed on 2024-04-28 04:39:52
0001 /* 0002 SPDX-FileCopyrightText: 2012 André Stein <andre.stein@rwth-aachen.de> 0003 SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KDEVPLATFORM_PLUGIN_SWITCHTOBUDDYPLUGIN_H 0009 #define KDEVPLATFORM_PLUGIN_SWITCHTOBUDDYPLUGIN_H 0010 0011 #include <interfaces/iplugin.h> 0012 0013 #include <QVariantList> 0014 0015 /** 0016 * @short Implements a context menu extension in an editor context which provides 0017 * an action that allows switching to associated buddy documents. 0018 * 0019 * Using the @c IBuddyDocumentFinder interface, the current document's 0020 * language plugin provides potential buddy candidates. Depending on their 0021 * existence on the file system the @c SwitchToBuddyPlugin 0022 * enables a 'Switch To XXX' action which opens that buddy document 0023 * using the @c IDocumentController. 0024 * 0025 * If a language plugin either doesn't provide the @c IBuddyDocumentFinder 0026 * interface or no buddy exists on the file system, no context menu 0027 * extension is performed. 0028 * 0029 * @see IBuddyDocumentFinder 0030 * @see IDocumentController 0031 */ 0032 class SwitchToBuddyPlugin : public KDevelop::IPlugin 0033 { 0034 Q_OBJECT 0035 public: 0036 explicit SwitchToBuddyPlugin( QObject *parent, const QVariantList & = QVariantList()); 0037 ~SwitchToBuddyPlugin() override; 0038 0039 KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context, QWidget* parent) override; 0040 void createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions) override; 0041 0042 private Q_SLOTS: 0043 /** 0044 * Context menu slot which switches to the QUrl provided 0045 * in the data part of the sending QAction. 0046 */ 0047 void switchToBuddy(const QString& url); 0048 0049 /** 0050 * Switch between header and source files 0051 */ 0052 void switchHeaderSource(); 0053 0054 /** 0055 * @brief Switch between definitions and declarations 0056 * 0057 * E.g. if the cursor in the currently active view points to an implementation file 0058 * this shortcut will open the header document (or any buddy file). 0059 * 0060 * Furthermore, if the cursor points to a definition, and the buddy document contains its declaration, 0061 * the cursor will be also set to the declaration's position when the buddy document is opened 0062 */ 0063 void switchDefinitionDeclaration(); 0064 }; 0065 0066 0067 #endif // KDEVPLATFORM_PLUGIN_SWITCHTOBUDDYPLUGIN_H