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 ) );
52 [
this]( wxListEvent& aEvent )
59 [
this]( wxListEvent& )
62 &&
m_remotesList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ) == -1 )
69 [
this]( wxCommandEvent& )
74 [
this]( wxCommandEvent& )
79 [
this]( wxCommandEvent& )
88 if( !
m_dialog->SessionStillCurrent() )
93 std::vector<std::pair<wxString, wxString>> remotes;
97 auto outcome = std::make_shared<OUTCOME>();
103 outcome->remotes = aCommon.GetRemotes();
104 outcome->fetched = aCommon.GetLastFetchTime();
108 if( !m_dialog->SessionStillCurrent() )
111 wxString selected = KIGIT::SelectedText( m_remotesList, 0 );
112 long selectRow = wxNOT_FOUND;
114 m_fillingRemotes = true;
115 m_remotesList->DeleteAllItems();
116 m_lastFetched = outcome->fetched;
118 for( const auto& [name, url] : outcome->remotes )
120 long idx = m_remotesList->InsertItem( m_remotesList->GetItemCount(), name );
121 m_remotesList->SetItem( idx, 1, url );
124 if( name == selected || ( selected.IsEmpty() && idx == 0 ) )
129 m_remoteCount->SetLabel( wxString::Format( wxPLURAL(
"%d remote",
"%d remotes", shown ), shown ) );
131 if( selectRow != wxNOT_FOUND )
133 m_remotesList->SetItemState( selectRow, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
148 if( aRemote.IsEmpty() )
164 for(
long row = 0; row <
m_remotesList->GetItemCount(); ++row )
170 m_remoteTitle->SetLabel( wxString::Format(
_(
"Remote: %s" ), aRemote ) );
177 :
_(
"Not fetched yet." ) );
197 if( !aMutation( aCommon ) )
211 if( !
m_dialog->SessionStillCurrent() )
220 wxString url = dlg.
GetUrl();
227 wxString::Format(
_(
"Could not add remote '%s'." ),
name ) );
233 if( !
m_dialog->SessionStillCurrent() )
247 wxString url = dlg.
GetUrl();
259 wxString::Format(
_(
"Could not update remote '%s'." ),
name ) );
265 if( !
m_dialog->SessionStillCurrent() )
273 if( !
IsOK(
this, wxString::Format(
_(
"Remove remote '%s'?" ),
name ) ) )
281 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.
wxString GetRemoteName() const
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
WX_SPLITTER_WINDOW * 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 KeepDetailWidth(WX_SPLITTER_WINDOW *aSplitter)
Keep a split detail pane at the width its controls need, against both a narrow window and a dragged s...
void MarkDestructive(wxButton *aButton)
Paint a button's text the diff's red, for one that throws something away.