2021-01-11 15:31:58 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
|
|
|
|
|
#include "Widgets/SCompoundWidget.h"
|
|
|
|
|
#include "Widgets/Views/STreeView.h"
|
|
|
|
|
|
|
|
|
|
#include "ISourceControlProvider.h"
|
2021-02-04 17:41:41 -04:00
|
|
|
#include "SSourceControlCommon.h"
|
2021-01-11 15:31:58 -04:00
|
|
|
|
2021-01-13 20:52:07 -04:00
|
|
|
class SChangelistTree : public STreeView<FChangelistTreeItemPtr>
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
virtual void Private_SetItemSelection(FChangelistTreeItemPtr TheItem, bool bShouldBeSelected, bool bWasUserDirected = false) override;
|
|
|
|
|
};
|
2021-01-11 15:31:58 -04:00
|
|
|
|
|
|
|
|
class SSourceControlChangelistsWidget : public SCompoundWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SLATE_BEGIN_ARGS(SSourceControlChangelistsWidget) {}
|
|
|
|
|
SLATE_END_ARGS()
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor.
|
|
|
|
|
*/
|
|
|
|
|
SSourceControlChangelistsWidget();
|
|
|
|
|
|
|
|
|
|
/** Constructs the widget */
|
|
|
|
|
void Construct(const FArguments& InArgs);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TSharedRef<SChangelistTree> CreateTreeviewWidget();
|
|
|
|
|
|
|
|
|
|
TSharedRef<ITableRow> OnGenerateRow(FChangelistTreeItemPtr InTreeItem, const TSharedRef<STableViewBase>& OwnerTable);
|
|
|
|
|
void OnGetChildren(FChangelistTreeItemPtr InParent, TArray<FChangelistTreeItemPtr>& OutChildren);
|
|
|
|
|
|
2021-01-18 15:31:14 -04:00
|
|
|
FReply OnFilesDragged(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent);
|
|
|
|
|
|
2021-01-13 16:50:22 -04:00
|
|
|
void RequestRefresh();
|
2021-01-11 15:31:58 -04:00
|
|
|
void Refresh();
|
2021-01-13 16:50:22 -04:00
|
|
|
void ClearChangelistsTree();
|
2021-01-11 15:31:58 -04:00
|
|
|
|
2021-01-18 09:42:33 -04:00
|
|
|
TSharedPtr<SWidget> OnOpenContextMenu();
|
|
|
|
|
|
|
|
|
|
/** Returns the currently selected changelist state ptr or null in invalid cases */
|
|
|
|
|
FSourceControlChangelistStatePtr GetCurrentChangelistState();
|
2021-06-14 15:25:20 -04:00
|
|
|
FUncontrolledChangelistStatePtr GetCurrentUncontrolledChangelistState();
|
2021-01-18 09:42:33 -04:00
|
|
|
FSourceControlChangelistPtr GetCurrentChangelist();
|
2021-01-26 09:19:24 -04:00
|
|
|
FSourceControlChangelistStatePtr GetChangelistStateFromSelection();
|
|
|
|
|
FSourceControlChangelistPtr GetChangelistFromSelection();
|
2021-01-18 09:42:33 -04:00
|
|
|
|
|
|
|
|
/** Returns list of currently selected files */
|
|
|
|
|
TArray<FString> GetSelectedFiles();
|
|
|
|
|
|
2021-06-14 15:25:20 -04:00
|
|
|
/**
|
|
|
|
|
* Splits selected files between Controlled and Uncontrolled files.
|
|
|
|
|
* @param OutControlledFiles Selected source controlled files will be added to this array.
|
|
|
|
|
* @param OutUncontrolledFiles Selected uncontrolled files will be added to this array.
|
|
|
|
|
*/
|
|
|
|
|
void GetSelectedFiles(TArray<FString>& OutControlledFiles, TArray<FString>& OutUncontrolledFiles);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Splits selected files between Controlled and Uncontrolled files.
|
|
|
|
|
* @param OutControlledFileStates Selected source controlled file states will be added to this array.
|
|
|
|
|
* @param OutUncontrolledFileStates Selected uncontrolled file states will be added to this array.
|
|
|
|
|
*/
|
|
|
|
|
void GetSelectedFileStates(TArray<FSourceControlStateRef>& OutControlledFileStates, TArray<FSourceControlStateRef>& OutUncontrolledFileStates);
|
|
|
|
|
|
2021-01-26 09:19:24 -04:00
|
|
|
/** Returns list of currently selected shelved files */
|
|
|
|
|
TArray<FString> GetSelectedShelvedFiles();
|
|
|
|
|
|
2021-06-14 15:25:20 -04:00
|
|
|
/**
|
|
|
|
|
* Check if the type given as argument is a parent of selected items.
|
|
|
|
|
* @param ParentType The parent type to look for.
|
|
|
|
|
* @return True of ParentType is a parent of selected items.
|
|
|
|
|
*/
|
|
|
|
|
bool IsParentOfSelection(const IChangelistTreeItem::TreeItemType ParentType) const;
|
|
|
|
|
|
2021-01-19 14:50:23 -04:00
|
|
|
/** Changelist operations */
|
2021-01-18 09:42:33 -04:00
|
|
|
void OnNewChangelist();
|
|
|
|
|
void OnDeleteChangelist();
|
|
|
|
|
bool CanDeleteChangelist();
|
|
|
|
|
void OnEditChangelist();
|
|
|
|
|
void OnSubmitChangelist();
|
|
|
|
|
bool CanSubmitChangelist();
|
2021-08-11 15:40:41 -04:00
|
|
|
void OnValidateChangelist();
|
|
|
|
|
bool CanValidateChangelist();
|
2021-01-18 09:42:33 -04:00
|
|
|
|
2021-01-19 14:50:23 -04:00
|
|
|
/** Changelist & File operations */
|
|
|
|
|
void OnRevertUnchanged();
|
2021-01-27 16:11:25 -04:00
|
|
|
bool CanRevertUnchanged();
|
2021-01-19 14:50:23 -04:00
|
|
|
void OnRevert();
|
2021-01-27 16:11:25 -04:00
|
|
|
bool CanRevert();
|
2021-01-26 09:19:24 -04:00
|
|
|
void OnShelve();
|
|
|
|
|
|
|
|
|
|
/** Changelist & shelved files operations */
|
|
|
|
|
void OnUnshelve();
|
|
|
|
|
void OnDeleteShelvedFiles();
|
2021-01-19 14:50:23 -04:00
|
|
|
|
|
|
|
|
/** Files operations */
|
2021-03-24 08:29:57 -04:00
|
|
|
void OnMoveFiles();
|
2021-01-19 14:50:23 -04:00
|
|
|
void OnLocateFile();
|
|
|
|
|
bool CanLocateFile();
|
|
|
|
|
void OnShowHistory();
|
|
|
|
|
void OnDiffAgainstDepot();
|
|
|
|
|
bool CanDiffAgainstDepot();
|
|
|
|
|
|
2021-01-26 09:19:24 -04:00
|
|
|
/** Shelved files operations */
|
|
|
|
|
void OnDiffAgainstWorkspace();
|
|
|
|
|
bool CanDiffAgainstWorkspace();
|
|
|
|
|
|
2021-01-13 11:07:12 -04:00
|
|
|
void OnSourceControlStateChanged();
|
|
|
|
|
void OnSourceControlProviderChanged(ISourceControlProvider& OldProvider, ISourceControlProvider& NewProvider);
|
2021-01-13 16:50:22 -04:00
|
|
|
void OnChangelistsStatusUpdated(const FSourceControlOperationRef& InOperation, ECommandResult::Type InType);
|
|
|
|
|
|
|
|
|
|
virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
|
2021-01-13 11:07:12 -04:00
|
|
|
|
2021-01-11 15:31:58 -04:00
|
|
|
private:
|
2021-01-26 10:56:16 -04:00
|
|
|
struct ExpandedState
|
|
|
|
|
{
|
|
|
|
|
bool bChangelistExpanded;
|
|
|
|
|
bool bShelveExpanded;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void SaveExpandedState(TMap<FSourceControlChangelistStateRef, ExpandedState>& ExpandedStates) const;
|
|
|
|
|
void RestoreExpandedState(const TMap<FSourceControlChangelistStateRef, ExpandedState>& ExpandedStates);
|
2021-01-11 15:31:58 -04:00
|
|
|
|
2021-01-27 15:28:56 -04:00
|
|
|
TSharedRef<SWidget> MakeToolBar();
|
|
|
|
|
|
2021-04-19 11:21:23 -04:00
|
|
|
/**
|
2021-04-26 09:23:26 -04:00
|
|
|
* Returns a new changelist description if needed, appending validation tag.
|
2021-04-19 11:21:23 -04:00
|
|
|
*
|
|
|
|
|
* @param bInValidationResult The result of the validation step
|
|
|
|
|
* @param InOriginalChangelistDescription Description of the changelist before modification
|
|
|
|
|
*
|
|
|
|
|
* @return The new changelist description
|
|
|
|
|
*/
|
2021-04-26 09:23:26 -04:00
|
|
|
FText UpdateChangelistDescriptionToSubmitIfNeeded(const bool bInValidationResult, const FText& InOriginalChangelistDescription) const;
|
2021-04-19 11:21:23 -04:00
|
|
|
|
|
|
|
|
/** Returns true if the provided changelist description contains a validation tag. */
|
|
|
|
|
bool HasValidationTag(const FText& InChangelistDescription) const;
|
|
|
|
|
|
|
|
|
|
/** Executes an operation to updates the changelist description of the provided changelist with a new description. */
|
|
|
|
|
void EditChangelistDescription(const FText& InNewChangelistDescription, const FSourceControlChangelistStatePtr& InChangelistState) const;
|
|
|
|
|
|
2021-01-27 15:28:56 -04:00
|
|
|
private:
|
2021-04-19 11:21:23 -04:00
|
|
|
/** Tag to append to a changelist that passed validation */
|
|
|
|
|
static const FText ChangelistValidatedTag;
|
|
|
|
|
|
2021-01-11 15:31:58 -04:00
|
|
|
/** Changelists (root nodes) */
|
|
|
|
|
TArray<FChangelistTreeItemPtr> ChangelistsNodes;
|
|
|
|
|
|
|
|
|
|
/** Changelist treeview widget */
|
|
|
|
|
TSharedPtr<SChangelistTree> TreeView;
|
|
|
|
|
|
2021-01-13 11:07:12 -04:00
|
|
|
/** Source control state changed delegate handle */
|
|
|
|
|
FDelegateHandle SourceControlStateChangedDelegateHandle;
|
2021-01-13 16:50:22 -04:00
|
|
|
|
2021-05-26 18:15:46 -04:00
|
|
|
/** Uncontrolled Changelist changed delegate handle */
|
|
|
|
|
FDelegateHandle UncontrolledChangelistChangedDelegateHandle;
|
|
|
|
|
|
2021-01-13 16:50:22 -04:00
|
|
|
bool bShouldRefresh;
|
2021-03-24 08:29:57 -04:00
|
|
|
|
|
|
|
|
void StartRefreshStatus();
|
|
|
|
|
void TickRefreshStatus(double InDeltaTime);
|
|
|
|
|
void EndRefreshStatus();
|
|
|
|
|
|
|
|
|
|
FText RefreshStatus;
|
|
|
|
|
bool bIsRefreshing;
|
|
|
|
|
double RefreshStatusTimeElapsed;
|
2021-01-11 15:31:58 -04:00
|
|
|
};
|