24#include <wx/datetime.h>
40 m_remotesList->AppendColumn(
_(
"Name" ), wxLIST_FORMAT_LEFT, FromDIP( 110 ) );
41 m_remotesList->AppendColumn(
_(
"URL" ), wxLIST_FORMAT_LEFT, FromDIP( 340 ) );
50 [
this]( wxListEvent& aEvent )
57 [
this]( wxListEvent& )
60 &&
m_remotesList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ) == -1 )
67 [
this]( wxCommandEvent& )
72 [
this]( wxCommandEvent& )
77 [
this]( wxCommandEvent& )
86 if( !
m_dialog->SessionStillCurrent() )
91 std::vector<std::pair<wxString, wxString>> remotes;
95 auto outcome = std::make_shared<OUTCOME>();
101 outcome->remotes = aCommon.GetRemotes();
102 outcome->fetched = aCommon.GetLastFetchTime();
106 if( !m_dialog->SessionStillCurrent() )
109 wxString selected = KIGIT::SelectedText( m_remotesList, 0 );
110 long selectRow = wxNOT_FOUND;
112 m_fillingRemotes = true;
113 m_remotesList->DeleteAllItems();
114 m_lastFetched = outcome->fetched;
116 for( const auto& [name, url] : outcome->remotes )
118 long idx = m_remotesList->InsertItem( m_remotesList->GetItemCount(), name );
119 m_remotesList->SetItem( idx, 1, url );
122 if( name == selected || ( selected.IsEmpty() && idx == 0 ) )
127 m_remoteCount->SetLabel( shown == 1 ?
_(
"1 remote" ) : wxString::Format(
_(
"%d remotes" ), shown ) );
129 if( selectRow != wxNOT_FOUND )
131 m_remotesList->SetItemState( selectRow, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
146 if( aRemote.IsEmpty() )
162 for(
long row = 0; row <
m_remotesList->GetItemCount(); ++row )
168 m_remoteTitle->SetLabel( wxString::Format(
_(
"Remote: %s" ), aRemote ) );
175 :
_(
"Not fetched yet." ) );
195 if( !aMutation( aCommon ) )
209 if( !
m_dialog->SessionStillCurrent() )
218 wxString url = dlg.
GetUrl();
225 wxString::Format(
_(
"Could not add remote '%s'." ),
name ) );
231 if( !
m_dialog->SessionStillCurrent() )
245 wxString url = dlg.
GetUrl();
257 wxString::Format(
_(
"Could not update remote '%s'." ),
name ) );
263 if( !
m_dialog->SessionStillCurrent() )
271 if( !
IsOK(
this, wxString::Format(
_(
"Remove remote '%s'?" ),
name ) ) )
279 wxString::Format(
_(
"Could not remove remote '%s'." ),
name ) );
Ask for a remote's name and URL, for adding one or for editing the URL of one that exists.
The base frame for deriving all KiCad main window classes.
The advanced Git window: a non-modal dialog with a top bar naming the repository and branch and a sid...
The project's git session.
bool RemoveRemote(const wxString &aName)
bool AddRemote(const wxString &aName, const wxString &aUrl)
void UpdateCurrentBranchInfo()
bool SetRemoteUrl(const wxString &aName, const wxString &aUrl)
wxStaticText * m_remoteTitle
wxSplitterWindow * m_remotesSplitter
PANEL_GIT_REMOTES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxListCtrl * m_remotesList
wxButton * m_addRemoteButton
wxStaticText * m_remoteFetched
wxPanel * m_remoteListPanel
wxButton * m_removeRemoteButton
wxButton * m_editUrlButton
wxStaticText * m_remoteCount
GIT_ADVANCED_DIALOG * m_dialog
PANEL_GIT_REMOTES(wxWindow *aParent, GIT_ADVANCED_DIALOG *aDialog, EDA_BASE_FRAME *aFrame)
KIGIT_QUERY m_listQuery
The list and its shared fetch timestamp are read together on a worker.
bool m_fillingRemotes
True while the list is being refilled, when its selection events are its own.
int m_remoteSashPos
Where the user left the sash between the list and its detail pane.
void Populate()
Fill the list from the repository's remotes. The repository is read on a worker.
void fillRemoteDetail(const wxString &aRemote, const wxDateTime &aFetched)
void runRemoteAction(const std::function< bool(KIGIT_COMMON &)> &aMutation, const wxString &aError)
Run a change to the remotes, then refresh the cached remote so a later push uses it.
void showRemoteDetail(const wxString &aRemote)
Fill the detail pane with aRemote, or hide it when the name is empty.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
This file is part of the common library.
Base window classes and related definitions.
void UnsplitKeepingSash(wxSplitterWindow *aSplitter, wxWindow *aPane, int &aSashPos)
Close a splitter's second pane, keeping the sash where the user left it for next time.
wxString SelectedText(wxListCtrl *aList, int aColumn)
The text of the selected row in a report list, or empty when nothing is selected.
wxString RelativeDate(const wxDateTime &aWhen)
"just now", "3 hours ago", or the ISO date once it is more than a month old.
void MarkDestructive(wxButton *aButton)
Paint a button's text the diff's red, for one that throws something away.