39 m_list =
new wxListCtrl(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
40 wxLC_REPORT | wxLC_SINGLE_SEL );
41 m_list->AppendColumn(
_(
"Title" ) );
42 m_list->AppendColumn(
_(
"Time" ) );
43 m_list->SetColumnWidth( 0, 200 );
44 m_list->SetColumnWidth( 1, 120 );
46 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
47 sizer->Add(
m_list, 1, wxEXPAND );
75 std::lock_guard<std::mutex> lock(
m_mutex );
80 wxFileName hist( aProjectPath, wxS(
".history" ) );
82 git_repository* repo =
nullptr;
83 if( git_repository_open( &repo, hist.GetFullPath().mb_str().data() ) != 0 )
86 git_revwalk* walk =
nullptr;
87 if( git_revwalk_new( &walk, repo ) != 0 )
89 git_repository_free( repo );
93 if( git_revwalk_push_head( walk ) != 0 )
95 git_revwalk_free( walk );
96 git_repository_free( repo );
100 wxDateTime now = wxDateTime::Now();
103 while( git_revwalk_next( &oid, walk ) == 0 )
105 git_commit* commit =
nullptr;
106 if( git_commit_lookup( &commit, repo, &oid ) != 0 )
110 info.hash = wxString::FromUTF8( git_oid_tostr_s( &oid ) );
111 info.summary = wxString::FromUTF8( git_commit_summary( commit ) );
112 info.message = wxString::FromUTF8( git_commit_message( commit ) );
113 info.date = wxDateTime(
static_cast<time_t
>( git_commit_time( commit ) ) );
116 wxTimeSpan elapsed = now -
info.date;
119 if( elapsed.GetMinutes() < 1 )
121 timeStr =
_(
"Moments ago" );
123 else if( elapsed.GetMinutes() < 91 )
125 int minutes = elapsed.GetMinutes();
126 timeStr = wxString::Format(
_(
"%d minutes ago" ), minutes );
128 else if( elapsed.GetHours() < 24 )
130 int hours = elapsed.GetHours();
131 timeStr = wxString::Format(
_(
"%d hours ago" ), hours );
135 timeStr =
info.date.FormatISOCombined();
139 m_list->SetItem( row, 1, timeStr );
141 if(
info.summary.StartsWith( wxS(
"Autosave" ) ) )
142 m_list->SetItemBackgroundColour( row, wxColour( 230, 255, 230 ) );
143 else if(
info.summary.StartsWith( wxS(
"Backup" ) ) )
144 m_list->SetItemBackgroundColour( row, wxColour( 230, 230, 255 ) );
147 git_commit_free( commit );
150 git_revwalk_free( walk );
151 git_repository_free( repo );
LOCAL_HISTORY_PANE(KICAD_MANAGER_FRAME *aParent)
void OnLeave(wxMouseEvent &aEvent)
void OnRefreshTimer(wxTimerEvent &aEvent)
void OnTimer(wxTimerEvent &aEvent)
void OnRightClick(wxListEvent &aEvent)
KICAD_MANAGER_FRAME * m_frame
void RefreshHistory(const wxString &aProjectPath)
void OnRefreshEvent(wxCommandEvent &aEvent)
std::vector< LOCAL_COMMIT_INFO > m_commits
void OnMotion(wxMouseEvent &aEvent)
wxDEFINE_EVENT(EVT_LOCAL_HISTORY_REFRESH, wxCommandEvent)