File indexing completed on 2024-04-28 05:49:10

0001 /*
0002     SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "quickdialog.h"
0010 
0011 class QTreeView;
0012 class QLineEdit;
0013 class BranchesDialogModel;
0014 class QAction;
0015 class StashFilterModel;
0016 class KActionCollection;
0017 class QStandardItemModel;
0018 class QProcess;
0019 
0020 namespace KTextEditor
0021 {
0022 class MainWindow;
0023 }
0024 
0025 namespace GitUtils
0026 {
0027 struct CheckoutResult;
0028 }
0029 
0030 enum class StashMode : uint8_t {
0031     None = 0,
0032     Stash,
0033     StashKeepIndex,
0034     StashUntrackIncluded,
0035     StashPopLast,
0036     StashPop,
0037     StashDrop,
0038     StashApply,
0039     StashApplyLast,
0040     ShowStashContent,
0041 };
0042 
0043 class StashDialog : public HUDDialog
0044 {
0045     Q_OBJECT
0046 public:
0047     StashDialog(QWidget *parent, QWidget *window, const QString &gitPath);
0048 
0049     void openDialog(StashMode mode);
0050 
0051     Q_SIGNAL void message(const QString &msg, bool warn);
0052     Q_SIGNAL void done();
0053     Q_SIGNAL void showStashDiff(const QByteArray &diff);
0054 
0055 protected Q_SLOTS:
0056     void slotReturnPressed(const QModelIndex &index) override;
0057 
0058 private:
0059     QProcess *gitp(const QStringList &arguments);
0060     void stash(bool keepIndex, bool includeUntracked);
0061     void getStashList();
0062     void popStash(const QString &index, const QString &command = QStringLiteral("pop"));
0063     void applyStash(const QString &index);
0064     void dropStash(const QString &index);
0065     void showStash(const QString &index);
0066 
0067     QString m_gitPath;
0068     QString m_projectPath;
0069     StashMode m_currentMode = StashMode::None;
0070 };