38#
if wxCHECK_VERSION( 3, 3, 2 )
44 m_list =
new wxListCtrl(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
45 wxLC_REPORT | wxLC_SINGLE_SEL );
46 m_list->AppendColumn(
_(
"Title" ) );
47 m_list->AppendColumn(
_(
"Time" ) );
48 m_list->SetColumnWidth( 0, 200 );
49 m_list->SetColumnWidth( 1, 120 );
51 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
52 sizer->Add(
m_list, 1, wxEXPAND );
80 if( !IsShownOnScreen() )
83 std::lock_guard<std::mutex> lock(
m_mutex );
88 wxFileName hist( aProjectPath, wxS(
".history" ) );
90 git_repository* repo =
nullptr;
91 if( git_repository_open( &repo, hist.GetFullPath().mb_str().data() ) != 0 )
94 git_revwalk* walk =
nullptr;
95 if( git_revwalk_new( &walk, repo ) != 0 )
97 git_repository_free( repo );
101 if( git_revwalk_push_head( walk ) != 0 )
103 git_revwalk_free( walk );
104 git_repository_free( repo );
108 wxDateTime now = wxDateTime::Now();
111 while( git_revwalk_next( &oid, walk ) == 0 )
113 git_commit* commit =
nullptr;
114 if( git_commit_lookup( &commit, repo, &oid ) != 0 )
118 info.hash = wxString::FromUTF8( git_oid_tostr_s( &oid ) );
119 info.summary = wxString::FromUTF8( git_commit_summary( commit ) );
120 info.message = wxString::FromUTF8( git_commit_message( commit ) );
121 info.date = wxDateTime(
static_cast<time_t
>( git_commit_time( commit ) ) );
124 wxTimeSpan elapsed = now -
info.date;
127 if( elapsed.GetMinutes() < 1 )
129 timeStr =
_(
"Moments ago" );
131 else if( elapsed.GetMinutes() < 91 )
133 int minutes = elapsed.GetMinutes();
134 timeStr = wxString::Format(
_(
"%d minutes ago" ), minutes );
136 else if( elapsed.GetHours() < 24 )
138 int hours = elapsed.GetHours();
139 timeStr = wxString::Format(
_(
"%d hours ago" ), hours );
143 timeStr =
info.date.FormatISOCombined();
147 m_list->SetItem( row, 1, timeStr );
149 if(
info.summary.StartsWith( wxS(
"Autosave" ) ) )
150 m_list->SetItemBackgroundColour( row, wxColour( 230, 255, 230 ) );
151 else if(
info.summary.StartsWith( wxS(
"Backup" ) ) )
152 m_list->SetItemBackgroundColour( row, wxColour( 230, 230, 255 ) );
155 git_commit_free( commit );
158 git_revwalk_free( walk );
159 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)