]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/versioncontrol/kversioncontrolplugin.h
Add clang-format and format code as in Frameworks
[dolphin.git] / src / views / versioncontrol / kversioncontrolplugin.h
index a3be381f3ff31de8e6c6645ec583447159861055..1a411145284211ef14fb5a30fffc9095d31e727c 100644 (file)
@@ -1,29 +1,18 @@
-/*****************************************************************************
- * Copyright (C) 2011 by Vishesh Yadav <vishesh3y@gmail.com>                 *
- * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>                 *
- *                                                                           *
- * This library is free software; you can redistribute it and/or             *
- * modify it under the terms of the GNU Library General Public               *
- * License version 2 as published by the Free Software Foundation.           *
- *                                                                           *
- * This library is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
- * Library General Public License for more details.                          *
- *                                                                           *
- * You should have received a copy of the GNU Library General Public License *
- * along with this library; see the file COPYING.LIB.  If not, write to      *
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,      *
- * Boston, MA 02110-1301, USA.                                               *
- *****************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Vishesh Yadav <vishesh3y@gmail.com>
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.0-only
+ */
 
 #ifndef KVERSIONCONTROLPLUGIN_H
 #define KVERSIONCONTROLPLUGIN_H
 
 #include <dolphinvcs_export.h>
 
-#include <QObject>
 #include <QAction>
+#include <QObject>
+
 class KFileItemList;
 class KFileItem;
 /**
@@ -34,14 +23,15 @@ class KFileItem;
  * steps are required (in the example below it is assumed that a plugin for
  * Subversion will be written):
  *
- * - Create a fileviewsvnplugin.desktop file with the following content:
+ * - Create a fileviewsvnplugin.json file with the following content:
  *   <code>
- *   [Desktop Entry]
- *   Type=Service
- *   Name=Subversion
- *   X-KDE-ServiceTypes=FileViewVersionControlPlugin
- *   MimeType=text/plain;
- *   X-KDE-Library=fileviewsvnplugin
+ *   {
+ *      "KPlugin": {
+ *          "Description": "The svn plugin",
+ *          "Name": "Svn"
+ *      }
+ *   }
+
  *   </code>
  *
  * - Create a class FileViewSvnPlugin derived from KVersionControlPlugin and
@@ -55,16 +45,13 @@ class KFileItem;
  * - Add the following lines at the top of fileviewsvnplugin.cpp:
  *   <code>
  *   #include <KPluginFactory>
- *   #include <KPluginLoader>
- *   K_PLUGIN_FACTORY(FileViewSvnPluginFactory, registerPlugin<FileViewSvnPlugin>();)
- *   K_EXPORT_PLUGIN(FileViewSvnPluginFactory("fileviewsvnplugin"))
+ *   K_PLUGIN_CLASS_WITH_JSON(FileViewSvnPlugin, "fileviewsvnplugin.json")
  *   </code>
  *
  * - Add the following lines to your CMakeLists.txt file:
  *   <code>
- *   kde4_add_plugin(fileviewsvnplugin fileviewsvnplugin.cpp)
- *   target_link_libraries(fileviewsvnplugin konq)
- *   install(FILES fileviewsvnplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+ *   kcoreaddons_add_plugin(fileviewsvnplugin SOURCES fileviewsvnplugin.cpp INSTALL_NAMESPACE "dolphin/vcs")
+ *   target_link_libraries(fileviewsvnplugin DolphinVcs)
  *   </code>
  *
  * General implementation notes:
@@ -86,8 +73,7 @@ class DOLPHINVCS_EXPORT KVersionControlPlugin : public QObject
     Q_OBJECT
 
 public:
-    enum ItemVersion
-    {
+    enum ItemVersion {
         /** The file is not under version control. */
         UnversionedVersion,
         /**
@@ -136,7 +122,7 @@ public:
          */
         IgnoredVersion,
         /**
-         * The file is is tracked by the version control system, but
+         * The file is tracked by the version control system, but
          * is missing in the directory (e.g. by deleted without using
          * a version control command).
          * @since 4.8
@@ -144,7 +130,7 @@ public:
         MissingVersion
     };
 
-    KVersionControlPlugin(QObjectparent = nullptr);
+    KVersionControlPlugin(QObject *parent = nullptr);
     ~KVersionControlPlugin() override;
 
     /**
@@ -154,13 +140,19 @@ public:
      */
     virtual QString fileName() const = 0;
 
+    /**
+     * Returns the path of the local repository root for the versioned directory
+     * Returns an empty QString when directory is not part of a working copy
+     */
+    virtual QString localRepositoryRoot(const QString &directory) const;
+
     /**
      * Is invoked whenever the version control
      * information will get retrieved for the directory
      * \p directory. It is assured that the directory
      * contains a trailing slash.
      */
-    virtual bool beginRetrieval(const QStringdirectory) = 0;
+    virtual bool beginRetrieval(const QString &directory) = 0;
 
     /**
      * Is invoked after the version control information has been
@@ -176,17 +168,21 @@ public:
      *         invoked before and that the file is part of the directory specified
      *         in beginRetrieval().
      */
-    virtual ItemVersion itemVersion(const KFileItem& item) const = 0;
+    virtual ItemVersion itemVersion(const KFileItem &item) const = 0;
+
+    /**
+     * @return List of actions that are available for the \p items in a version controlled
+     *         path.
+     */
+    virtual QList<QAction *> versionControlActions(const KFileItemList &items) const = 0;
 
     /**
-     * @return List of actions that are available for the items \p items.
-     *         It is recommended to keep the number of returned actions small
-     *         in case if an item is an unversioned directory that is not
-     *         inside the hierarchy tree of the version control system. This
-     *         prevents having a cluttered context menu for directories
-     *         outside the version control system.
+     * @return List of actions that are available for the out of version control
+     *         items \p items. It's opposed to the \p versionedActions. Common usage
+     *         is for clone/checkout actions.
+     * @since 21.04
      */
-    virtual QList<QAction*> actions(const KFileItemList& items) const = 0;
+    virtual QList<QAction *> outOfVersionControlActions(const KFileItemList &items) const = 0;
 
 Q_SIGNALS:
     /**
@@ -204,20 +200,19 @@ Q_SIGNALS:
      * Is emitted if an information message with the content \a msg
      * should be shown.
      */
-    void infoMessage(const QStringmsg);
+    void infoMessage(const QString &msg);
 
     /**
      * Is emitted if an error message with the content \a msg
      * should be shown.
      */
-    void errorMessage(const QStringmsg);
+    void errorMessage(const QString &msg);
 
     /**
      * Is emitted if an "operation completed" message with the content \a msg
      * should be shown.
      */
-    void operationCompletedMessage(const QStringmsg);
+    void operationCompletedMessage(const QString &msg);
 };
 
 #endif // KVERSIONCONTROLPLUGIN_H
-