KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PANEL_GIT_HISTORY Class Reference

The advanced git window's History page: filters above a list of commits beside the selected commit's detail, with what the commit did to a chosen file under the detail's file list. More...

#include <panel_git_history.h>

Inheritance diagram for PANEL_GIT_HISTORY:
PANEL_GIT_HISTORY_BASE

Public Member Functions

 PANEL_GIT_HISTORY (wxWindow *aParent, GIT_ADVANCED_DIALOG *aDialog, EDA_BASE_FRAME *aFrame)
 
 ~PANEL_GIT_HISTORY () override
 
void Populate ()
 Load the repository's recent commits in the background, up to the current window.
 
void SetBranches (const std::vector< KIGIT_BRANCH_INFO > &aBranches)
 Offer every branch in the branch filter, keeping the current choice.
 
void ShowHistoryForFile (const wxString &aPath)
 Narrow the list to the commits that changed aPath, a file or folder relative to the repository root.
 

Protected Attributes

wxSearchCtrl * m_historySearch
 
wxChoice * m_historyBranch
 
wxCheckBox * m_historyShowRefs
 
wxBoxSizer * m_historyPathRow
 
wxStaticText * m_historyPathLabel
 
wxButton * m_showAllButton
 
wxSplitterWindow * m_historySplitter
 
wxPanel * m_historyListPanel
 
wxDataViewListCtrl * m_historyList
 
wxPanel * m_commitDetail
 
wxStaticText * m_commitTitle
 
wxStaticBitmap * m_commitAvatar
 
wxStaticText * m_commitAuthor
 
wxTextCtrl * m_commitMessage
 
wxStaticText * m_commitStats
 
wxStaticText * m_commitFileCount
 
wxStaticText * m_commitAdded
 
wxStaticText * m_commitRemoved
 
wxSplitterWindow * m_detailSplitter
 
wxPanel * m_commitFilesPanel
 
wxListCtrl * m_commitFiles
 

Private Member Functions

void reloadHistory ()
 Restart the history at the first window after the search or branch filter changed.
 
void fillHistory (const std::vector< KIGIT_COMMIT_INFO > &aCommits, size_t aLimit)
 Apply a loaded history window, keeping the currently selected commit when possible.
 
KIGIT_HISTORY_FILTER historyFilter () const
 The search text and branch the page is narrowed to.
 
void showCommitDetail (const wxString &aHash)
 Fill the detail pane with aHash, or clear it when the hash is empty or gone.
 
void fillCommitDetail (const KIGIT_COMMIT_DETAIL &aDetail)
 
void clearCommitDetail ()
 
void showFileDiff (const wxString &aPath)
 Show what the selected commit did to aPath under the file list, or hide that area.
 
void hideFileDiff ()
 
void appendHistoryRows (const std::vector< KIGIT_COMMIT_INFO > &aCommits, size_t aFrom)
 Append rows for aCommits starting at aFrom, without clearing, so growing the history window keeps the scroll position.
 
void onHistoryScrollTick ()
 Grow the history window when the user has scrolled near its end.
 
void requestAvatar (const wxString &aEmail, int aDiameter)
 Start a background fetch of the contributor's web avatar for aEmail, if opted in and not already cached or requested.
 
void applyAvatar (const wxString &aEmail, int aDiameter, const std::string &aBytes)
 On the UI thread, decode the fetched avatar bytes and place the photo on every history row for aEmail.
 
void onRestoreVersion (const wxString &aCommitHash)
 Restore the project as it was at the given commit, recorded as a new commit on top of the current head.
 
void restoreVersion (const wxString &aCommitHash, const KIGIT::GIT_IDENTITY &aIdentity)
 

Private Attributes

GIT_ADVANCED_DIALOG * m_dialog
 
EDA_BASE_FRAME * m_frame
 
wxDataViewColumn * m_historyRefsColumn
 
GIT_FILE_DIFF_AREA * m_fileDiff
 
std::atomic< bool > m_avatarCancel { false }
 Set when the page goes, so a fetch still waiting on the network gives up rather than holding the close for its timeout.
 
std::vector< std::thread > m_avatarWorkers
 The avatar fetches this page started, joined before it goes.
 
std::vector< wxString > m_historyEmails
 Author email for each history row, so a fetched avatar can find its rows.
 
std::vector< bool > m_historyAtHead
 Whether each row's commit is the one HEAD points at.
 
std::map< wxString, wxBitmap > m_avatarCache
 Fetched web avatars, keyed by author email.
 
std::set< wxString > m_avatarRequested
 Emails whose avatar fetch was already started, so each is fetched at most once.
 
KIGIT_QUERY m_historyQuery
 Listing and selection have separate requests so choosing a commit does not cancel paging.
 
KIGIT_QUERY m_detailQuery
 
KIGIT_QUERY m_actionQuery
 Read action preconditions without delaying history selection or scrolling.
 
WX_DEBOUNCED_ACTION m_historySearchDebounce
 Waits for the user to pause typing in the search box before walking the history again.
 
wxTimer m_historyScrollTimer
 Polls whether the user scrolled near the end of the history, which is the one portable way to notice scrolling on every wxDataViewCtrl port, native ones included.
 
size_t m_historyLimit = 50
 How many commits the page currently shows at most. Grows as the user scrolls.
 
wxString m_historyBranchName
 The branch the list is narrowed to, or empty for every branch.
 
wxString m_historyPath
 The file or folder the history is narrowed to, or empty for all of it.
 
wxString m_detailHash
 The commit the detail pane shows, so a refresh can put the selection back on it.
 
wxString m_detailEmail
 Its author's email, so a web avatar that arrives later lands on the pane too.
 
wxString m_detailParent
 The first parent of the shown commit, which the diff area's before side names.
 
int m_historySashPos = 0
 Where the user left the sash, so the pane comes back at the same width.
 
int m_detailSashPos = 0
 Where the user left the sash between the file list and the diff area.
 
bool m_historyComplete = false
 True once a load returned fewer commits than asked for, meaning everything is shown.
 
bool m_fillingHistory = false
 True while the list is being refilled, when its selection events are its own.
 

Detailed Description

The advanced git window's History page: filters above a list of commits beside the selected commit's detail, with what the commit did to a chosen file under the detail's file list.

Definition at line 54 of file panel_git_history.h.

Constructor & Destructor Documentation

◆ PANEL_GIT_HISTORY()

PANEL_GIT_HISTORY::PANEL_GIT_HISTORY ( wxWindow * aParent,
GIT_ADVANCED_DIALOG * aDialog,
EDA_BASE_FRAME * aFrame )

◆ ~PANEL_GIT_HISTORY()

PANEL_GIT_HISTORY::~PANEL_GIT_HISTORY ( )
override

Member Function Documentation

◆ appendHistoryRows()

void PANEL_GIT_HISTORY::appendHistoryRows ( const std::vector< KIGIT_COMMIT_INFO > & aCommits,
size_t aFrom )
private

◆ applyAvatar()

void PANEL_GIT_HISTORY::applyAvatar ( const wxString & aEmail,
int aDiameter,
const std::string & aBytes )
private

On the UI thread, decode the fetched avatar bytes and place the photo on every history row for aEmail.

Does nothing when the bytes are empty (no web avatar).

Definition at line 911 of file panel_git_history.cpp.

References circle(), image, m_avatarCache, PANEL_GIT_HISTORY_BASE::m_commitAvatar, m_detailEmail, m_historyEmails, and PANEL_GIT_HISTORY_BASE::m_historyList.

Referenced by requestAvatar().

◆ clearCommitDetail()

◆ fillCommitDetail()

◆ fillHistory()

void PANEL_GIT_HISTORY::fillHistory ( const std::vector< KIGIT_COMMIT_INFO > & aCommits,
size_t aLimit )
private

Apply a loaded history window, keeping the currently selected commit when possible.

Definition at line 741 of file panel_git_history.cpp.

References appendHistoryRows(), m_detailHash, m_fillingHistory, m_historyAtHead, m_historyComplete, m_historyEmails, PANEL_GIT_HISTORY_BASE::m_historyList, m_historyScrollTimer, and showCommitDetail().

Referenced by Populate().

◆ hideFileDiff()

void PANEL_GIT_HISTORY::hideFileDiff ( )
private

◆ historyFilter()

KIGIT_HISTORY_FILTER PANEL_GIT_HISTORY::historyFilter ( ) const
private

The search text and branch the page is narrowed to.

Definition at line 495 of file panel_git_history.cpp.

References filter, m_historyBranchName, m_historyPath, and PANEL_GIT_HISTORY_BASE::m_historySearch.

Referenced by onHistoryScrollTick(), and Populate().

◆ onHistoryScrollTick()

void PANEL_GIT_HISTORY::onHistoryScrollTick ( )
private

◆ onRestoreVersion()

void PANEL_GIT_HISTORY::onRestoreVersion ( const wxString & aCommitHash)
private

Restore the project as it was at the given commit, recorded as a new commit on top of the current head.

Definition at line 947 of file panel_git_history.cpp.

References _, DisplayErrorMessage(), DisplayInfoMessage(), info, KIGIT_COMMON::IsHeadDetached(), KIGIT::PROJECT_GIT_UTILS::LfsRefusal(), m_actionQuery, m_dialog, m_frame, KIGIT::ReadGitIdentity(), and restoreVersion().

◆ Populate()

void PANEL_GIT_HISTORY::Populate ( )

Load the repository's recent commits in the background, up to the current window.

Definition at line 715 of file panel_git_history.cpp.

References fillHistory(), filter, KIGIT_COMMON::GetRecentCommits(), hideFileDiff(), historyFilter(), m_detailQuery, m_dialog, m_frame, m_historyLimit, m_historyQuery, and m_historyScrollTimer.

Referenced by reloadHistory(), and SetBranches().

◆ reloadHistory()

void PANEL_GIT_HISTORY::reloadHistory ( )
private

Restart the history at the first window after the search or branch filter changed.

Definition at line 505 of file panel_git_history.cpp.

References m_historyLimit, m_historySearchDebounce, and Populate().

Referenced by PANEL_GIT_HISTORY(), and ShowHistoryForFile().

◆ requestAvatar()

void PANEL_GIT_HISTORY::requestAvatar ( const wxString & aEmail,
int aDiameter )
private

Start a background fetch of the contributor's web avatar for aEmail, if opted in and not already cached or requested.

Definition at line 878 of file panel_git_history.cpp.

References applyAvatar(), m_avatarCache, m_avatarCancel, m_avatarRequested, and m_avatarWorkers.

Referenced by appendHistoryRows(), and fillCommitDetail().

◆ restoreVersion()

◆ SetBranches()

void PANEL_GIT_HISTORY::SetBranches ( const std::vector< KIGIT_BRANCH_INFO > & aBranches)

Offer every branch in the branch filter, keeping the current choice.

Definition at line 513 of file panel_git_history.cpp.

References _, PANEL_GIT_HISTORY_BASE::m_historyBranch, m_historyBranchName, and Populate().

◆ showCommitDetail()

void PANEL_GIT_HISTORY::showCommitDetail ( const wxString & aHash)
private

Fill the detail pane with aHash, or clear it when the hash is empty or gone.

Definition at line 538 of file panel_git_history.cpp.

References clearCommitDetail(), m_detailHash, m_detailQuery, m_dialog, and m_frame.

Referenced by fillHistory().

◆ showFileDiff()

void PANEL_GIT_HISTORY::showFileDiff ( const wxString & aPath)
private

Show what the selected commit did to aPath under the file list, or hide that area.

Definition at line 689 of file panel_git_history.cpp.

References _, hideFileDiff(), PANEL_GIT_HISTORY_BASE::m_commitFilesPanel, m_detailHash, m_detailParent, m_detailSashPos, PANEL_GIT_HISTORY_BASE::m_detailSplitter, m_fileDiff, m_frame, and path.

Referenced by fillCommitDetail().

◆ ShowHistoryForFile()

void PANEL_GIT_HISTORY::ShowHistoryForFile ( const wxString & aPath)

Narrow the list to the commits that changed aPath, a file or folder relative to the repository root.

Empty shows every commit again.

Definition at line 485 of file panel_git_history.cpp.

References m_historyPath, PANEL_GIT_HISTORY_BASE::m_historyPathLabel, PANEL_GIT_HISTORY_BASE::m_historyPathRow, and reloadHistory().

Member Data Documentation

◆ m_actionQuery

KIGIT_QUERY PANEL_GIT_HISTORY::m_actionQuery
private

Read action preconditions without delaying history selection or scrolling.

Definition at line 140 of file panel_git_history.h.

Referenced by onRestoreVersion(), restoreVersion(), and ~PANEL_GIT_HISTORY().

◆ m_avatarCache

std::map<wxString, wxBitmap> PANEL_GIT_HISTORY::m_avatarCache
private

Fetched web avatars, keyed by author email.

Definition at line 130 of file panel_git_history.h.

Referenced by appendHistoryRows(), applyAvatar(), fillCommitDetail(), and requestAvatar().

◆ m_avatarCancel

std::atomic<bool> PANEL_GIT_HISTORY::m_avatarCancel { false }
private

Set when the page goes, so a fetch still waiting on the network gives up rather than holding the close for its timeout.

Definition at line 117 of file panel_git_history.h.

Referenced by requestAvatar(), and ~PANEL_GIT_HISTORY().

◆ m_avatarRequested

std::set<wxString> PANEL_GIT_HISTORY::m_avatarRequested
private

Emails whose avatar fetch was already started, so each is fetched at most once.

Definition at line 133 of file panel_git_history.h.

Referenced by requestAvatar().

◆ m_avatarWorkers

std::vector<std::thread> PANEL_GIT_HISTORY::m_avatarWorkers
private

The avatar fetches this page started, joined before it goes.

Definition at line 120 of file panel_git_history.h.

Referenced by requestAvatar(), and ~PANEL_GIT_HISTORY().

◆ m_commitAdded

wxStaticText* PANEL_GIT_HISTORY_BASE::m_commitAdded
protectedinherited

◆ m_commitAuthor

wxStaticText* PANEL_GIT_HISTORY_BASE::m_commitAuthor
protectedinherited

◆ m_commitAvatar

wxStaticBitmap* PANEL_GIT_HISTORY_BASE::m_commitAvatar
protectedinherited

◆ m_commitDetail

wxPanel* PANEL_GIT_HISTORY_BASE::m_commitDetail
protectedinherited

◆ m_commitFileCount

wxStaticText* PANEL_GIT_HISTORY_BASE::m_commitFileCount
protectedinherited

◆ m_commitFiles

wxListCtrl* PANEL_GIT_HISTORY_BASE::m_commitFiles
protectedinherited

◆ m_commitFilesPanel

wxPanel* PANEL_GIT_HISTORY_BASE::m_commitFilesPanel
protectedinherited

◆ m_commitMessage

wxTextCtrl* PANEL_GIT_HISTORY_BASE::m_commitMessage
protectedinherited

◆ m_commitRemoved

wxStaticText* PANEL_GIT_HISTORY_BASE::m_commitRemoved
protectedinherited

◆ m_commitStats

wxStaticText* PANEL_GIT_HISTORY_BASE::m_commitStats
protectedinherited

◆ m_commitTitle

wxStaticText* PANEL_GIT_HISTORY_BASE::m_commitTitle
protectedinherited

◆ m_detailEmail

wxString PANEL_GIT_HISTORY::m_detailEmail
private

Its author's email, so a web avatar that arrives later lands on the pane too.

Definition at line 162 of file panel_git_history.h.

Referenced by applyAvatar(), clearCommitDetail(), and fillCommitDetail().

◆ m_detailHash

wxString PANEL_GIT_HISTORY::m_detailHash
private

The commit the detail pane shows, so a refresh can put the selection back on it.

Definition at line 159 of file panel_git_history.h.

Referenced by fillHistory(), showCommitDetail(), and showFileDiff().

◆ m_detailParent

wxString PANEL_GIT_HISTORY::m_detailParent
private

The first parent of the shown commit, which the diff area's before side names.

Definition at line 165 of file panel_git_history.h.

Referenced by fillCommitDetail(), and showFileDiff().

◆ m_detailQuery

KIGIT_QUERY PANEL_GIT_HISTORY::m_detailQuery
private

Definition at line 137 of file panel_git_history.h.

Referenced by Populate(), showCommitDetail(), and ~PANEL_GIT_HISTORY().

◆ m_detailSashPos

int PANEL_GIT_HISTORY::m_detailSashPos = 0
private

Where the user left the sash between the file list and the diff area.

Definition at line 171 of file panel_git_history.h.

Referenced by hideFileDiff(), and showFileDiff().

◆ m_detailSplitter

wxSplitterWindow* PANEL_GIT_HISTORY_BASE::m_detailSplitter
protectedinherited

◆ m_dialog

GIT_ADVANCED_DIALOG* PANEL_GIT_HISTORY::m_dialog
private

◆ m_fileDiff

GIT_FILE_DIFF_AREA* PANEL_GIT_HISTORY::m_fileDiff
private

Definition at line 113 of file panel_git_history.h.

Referenced by hideFileDiff(), PANEL_GIT_HISTORY(), and showFileDiff().

◆ m_fillingHistory

bool PANEL_GIT_HISTORY::m_fillingHistory = false
private

True while the list is being refilled, when its selection events are its own.

Definition at line 177 of file panel_git_history.h.

Referenced by fillCommitDetail(), and fillHistory().

◆ m_frame

◆ m_historyAtHead

std::vector<bool> PANEL_GIT_HISTORY::m_historyAtHead
private

Whether each row's commit is the one HEAD points at.

With every branch listed, the top row can belong to another branch, and only HEAD's commit can be amended.

Definition at line 127 of file panel_git_history.h.

Referenced by appendHistoryRows(), and fillHistory().

◆ m_historyBranch

wxChoice* PANEL_GIT_HISTORY_BASE::m_historyBranch
protectedinherited

◆ m_historyBranchName

wxString PANEL_GIT_HISTORY::m_historyBranchName
private

The branch the list is narrowed to, or empty for every branch.

Definition at line 153 of file panel_git_history.h.

Referenced by historyFilter(), and SetBranches().

◆ m_historyComplete

bool PANEL_GIT_HISTORY::m_historyComplete = false
private

True once a load returned fewer commits than asked for, meaning everything is shown.

Definition at line 174 of file panel_git_history.h.

Referenced by fillHistory(), and onHistoryScrollTick().

◆ m_historyEmails

std::vector<wxString> PANEL_GIT_HISTORY::m_historyEmails
private

Author email for each history row, so a fetched avatar can find its rows.

Definition at line 123 of file panel_git_history.h.

Referenced by appendHistoryRows(), applyAvatar(), and fillHistory().

◆ m_historyLimit

size_t PANEL_GIT_HISTORY::m_historyLimit = 50
private

How many commits the page currently shows at most. Grows as the user scrolls.

Definition at line 150 of file panel_git_history.h.

Referenced by onHistoryScrollTick(), Populate(), and reloadHistory().

◆ m_historyList

◆ m_historyListPanel

wxPanel* PANEL_GIT_HISTORY_BASE::m_historyListPanel
protectedinherited

◆ m_historyPath

wxString PANEL_GIT_HISTORY::m_historyPath
private

The file or folder the history is narrowed to, or empty for all of it.

Definition at line 156 of file panel_git_history.h.

Referenced by fillCommitDetail(), historyFilter(), and ShowHistoryForFile().

◆ m_historyPathLabel

wxStaticText* PANEL_GIT_HISTORY_BASE::m_historyPathLabel
protectedinherited

◆ m_historyPathRow

wxBoxSizer* PANEL_GIT_HISTORY_BASE::m_historyPathRow
protectedinherited

◆ m_historyQuery

KIGIT_QUERY PANEL_GIT_HISTORY::m_historyQuery
private

Listing and selection have separate requests so choosing a commit does not cancel paging.

Definition at line 136 of file panel_git_history.h.

Referenced by onHistoryScrollTick(), Populate(), and ~PANEL_GIT_HISTORY().

◆ m_historyRefsColumn

wxDataViewColumn* PANEL_GIT_HISTORY::m_historyRefsColumn
private

Definition at line 112 of file panel_git_history.h.

Referenced by PANEL_GIT_HISTORY().

◆ m_historySashPos

int PANEL_GIT_HISTORY::m_historySashPos = 0
private

Where the user left the sash, so the pane comes back at the same width.

Definition at line 168 of file panel_git_history.h.

Referenced by clearCommitDetail(), and fillCommitDetail().

◆ m_historyScrollTimer

wxTimer PANEL_GIT_HISTORY::m_historyScrollTimer
private

Polls whether the user scrolled near the end of the history, which is the one portable way to notice scrolling on every wxDataViewCtrl port, native ones included.

Definition at line 147 of file panel_git_history.h.

Referenced by fillHistory(), onHistoryScrollTick(), Populate(), and ~PANEL_GIT_HISTORY().

◆ m_historySearch

wxSearchCtrl* PANEL_GIT_HISTORY_BASE::m_historySearch
protectedinherited

◆ m_historySearchDebounce

WX_DEBOUNCED_ACTION PANEL_GIT_HISTORY::m_historySearchDebounce
private

Waits for the user to pause typing in the search box before walking the history again.

Definition at line 143 of file panel_git_history.h.

Referenced by PANEL_GIT_HISTORY(), reloadHistory(), and ~PANEL_GIT_HISTORY().

◆ m_historyShowRefs

wxCheckBox* PANEL_GIT_HISTORY_BASE::m_historyShowRefs
protectedinherited

Definition at line 46 of file panel_git_history_base.h.

Referenced by PANEL_GIT_HISTORY_BASE().

◆ m_historySplitter

wxSplitterWindow* PANEL_GIT_HISTORY_BASE::m_historySplitter
protectedinherited

◆ m_showAllButton

wxButton* PANEL_GIT_HISTORY_BASE::m_showAllButton
protectedinherited

Definition at line 49 of file panel_git_history_base.h.

Referenced by PANEL_GIT_HISTORY_BASE().


The documentation for this class was generated from the following files: