42 m_list =
new wxListCtrl(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL );
43 m_list->AppendColumn(
_(
"Title" ) );
44 m_list->AppendColumn(
_(
"Time" ) );
45 m_list->SetColumnWidth( 0, FromDIP( 200 ) );
46 m_list->SetColumnWidth( 1, FromDIP( 150 ) );
48 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
49 sizer->Add(
m_list, 1, wxEXPAND );
67 if( !IsShownOnScreen() )
73 wxFileName hist( aProjectPath, wxS(
".history" ) );
75 git_repository* repo =
nullptr;
76 if( git_repository_open( &repo, hist.GetFullPath().mb_str().data() ) != 0 )
79 git_revwalk* walk =
nullptr;
80 if( git_revwalk_new( &walk, repo ) != 0 )
82 git_repository_free( repo );
86 if( git_revwalk_push_head( walk ) != 0 )
88 git_revwalk_free( walk );
89 git_repository_free( repo );
93 wxDateTime now = wxDateTime::Now();
96 while( git_revwalk_next( &oid, walk ) == 0 )
98 git_commit* commit =
nullptr;
99 if( git_commit_lookup( &commit, repo, &oid ) != 0 )
103 info.hash = wxString::FromUTF8( git_oid_tostr_s( &oid ) );
104 info.summary = wxString::FromUTF8( git_commit_summary( commit ) );
105 info.message = wxString::FromUTF8( git_commit_message( commit ) );
106 info.date = wxDateTime(
static_cast<time_t
>( git_commit_time( commit ) ) );
109 wxTimeSpan elapsed = now -
info.date;
112 if( elapsed.GetMinutes() < 1 )
114 timeStr =
_(
"Moments ago" );
116 else if( elapsed.GetMinutes() < 91 )
118 int minutes = elapsed.GetMinutes();
119 timeStr = wxString::Format(
_(
"%d minutes ago" ), minutes );
121 else if( elapsed.GetHours() < 24 )
123 int hours = elapsed.GetHours();
124 timeStr = wxString::Format(
_(
"%d hours ago" ), hours );
128 timeStr =
info.date.Format();
131 wxString title =
info.message.BeforeFirst(
'\n' );
132 long row =
m_list->InsertItem(
m_list->GetItemCount(), title );
133 m_list->SetItem( row, 1, timeStr );
136 if(
info.summary.StartsWith( wxS(
"Autosave" ) ) )
137 m_list->SetItemTextColour( row, wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
138 else if(
info.summary.StartsWith( wxS(
"Backup" ) ) )
139 m_list->SetItemTextColour( row, wxColour( 80, 120, 200 ) );
142 git_commit_free( commit );
145 git_revwalk_free( walk );
146 git_repository_free( repo );
LOCAL_HISTORY_PANE(KICAD_MANAGER_FRAME *aParent)
void OnRefreshTimer(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)