File indexing completed on 2024-05-12 05:52:05

0001 /*
0002     SPDX-FileCopyrightText: 2022 Waqar Ahmed <waqar.17a@gmail.com>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 #pragma once
0006 
0007 #include <QMetaType>
0008 #include <QStringList>
0009 
0010 struct DiffParams {
0011     enum Flag {
0012         /** show stage action in context menu **/
0013         ShowStage = 1,
0014         /** show unstage action in context menu **/
0015         ShowUnstage = 2,
0016         /** show discard action in context menu **/
0017         ShowDiscard = 4,
0018         /** show filename with diff. Appears right before hunk heading **/
0019         ShowFileName = 8,
0020         /** show commit info with diff **/
0021         ShowCommitInfo = 16,
0022         /** Reload diff view whenever its widget is shown */
0023         ReloadOnShow = 32
0024     };
0025     Q_DECLARE_FLAGS(Flags, Flag)
0026     Q_FLAGS(Flags)
0027 
0028     /**
0029      * The tab title that will get shown in Kate.
0030      * If not specified, srcFile/destFile will be
0031      * used instead
0032      */
0033     QString tabTitle;
0034 
0035     /** Source File **/
0036     QString srcFile;
0037 
0038     /** Destination file **/
0039     QString destFile;
0040 
0041     /** Working dir i.e., to which
0042      * src/dest files belong and where
0043      * the command was run. This should
0044      * normally be your repo base path
0045      */
0046     QString workingDir;
0047 
0048     /**
0049      * The arguments that were passed to git
0050      * when this diff was generated
0051      */
0052     QStringList arguments;
0053 
0054     /**
0055      * These flags are used internally for e.g.,
0056      * for the context menu actions
0057      */
0058     Flags flags;
0059 
0060     void clear()
0061     {
0062         tabTitle = srcFile = destFile = workingDir = QString();
0063         arguments.clear();
0064         flags = {};
0065         updateStatusCallback = nullptr;
0066     }
0067 
0068     /**
0069      * Function call back that should update git status
0070      * This is called after Stage/Discard/Unstage actions
0071      */
0072     std::function<void()> updateStatusCallback;
0073 };
0074 Q_DECLARE_METATYPE(DiffParams)