| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <wx/panel.h> |
| 4 |
#include <wx/stattext.h> |
| 5 |
#include <wx/timer.h> |
| 6 |
#include <mutex> |
| 7 |
#include <future> |
| 8 |
#include <sigc++/trackable.h> |
| 9 |
|
| 10 |
#include "imap.h" |
| 11 |
#include "../Algorithm.h" |
| 12 |
#include "../Repository.h" |
| 13 |
#include "wxutil/XmlResourceBasedWidget.h" |
| 14 |
#include "wxutil/menu/PopupMenu.h" |
| 15 |
|
| 16 |
namespace vcs |
| 17 |
{ |
| 18 |
|
| 19 |
namespace ui |
| 20 |
{ |
| 21 |
|
| 22 |
class VcsStatus final : |
| 23 |
public wxEvtHandler, |
| 24 |
public wxutil::XmlResourceBasedWidget, |
| 25 |
public sigc::trackable |
| 26 |
{ |
| 27 |
private: |
| 28 |
wxPanel* _panel; |
| 29 |
|
| 30 |
wxTimer _fetchTimer; |
| 31 |
wxTimer _statusTimer; |
| 32 |
std::mutex _taskLock; |
| 33 |
bool _taskInProgress; |
| 34 |
std::future<void> _repositoryTask; |
| 35 |
std::future<void> _mapFileTask; |
| 36 |
|
| 37 |
std::shared_ptr<git::Repository> _repository; |
| 38 |
|
| 39 |
wxStaticText* _remoteStatus; |
| 40 |
wxStaticText* _mapStatus; |
| 41 |
|
| 42 |
std::unique_ptr<wxutil::PopupMenu> _popupMenu; |
| 43 |
|
| 44 |
public: |
| 45 |
static constexpr const char* const Name = "VcsStatusBarWidget"; |
| 46 |
|
| 47 |
VcsStatus(wxWindow* parent); |
| 48 |
~VcsStatus(); |
| 49 |
|
| 50 |
wxWindow* getWidget(); |
| 51 |
|
| 52 |
void setRepository(const std::shared_ptr<git::Repository>& repository); |
| 53 |
|
| 54 |
void startFetchTask(); |
| 55 |
|
| 56 |
private: |
| 57 |
void createPopupMenu(); |
| 58 |
void restartFetchTimer(); |
| 59 |
void onIntervalReached(wxTimerEvent& ev); |
| 60 |
void onIdle(wxIdleEvent& ev); |
| 61 |
void performFetch(std::shared_ptr<git::Repository> repository); |
| 62 |
void performSync(std::shared_ptr<git::Repository> repository); |
| 63 |
bool canSync(); |
| 64 |
void performCommit(); |
| 65 |
bool canCommit(); |
| 66 |
void performMapFileStatusCheck(std::shared_ptr<git::Repository> repository); |
| 67 |
void updateMapFileStatus(); |
| 68 |
void onMapEvent(IMap::MapEvent ev); |
| 69 |
void setMapFileStatus(const std::string& status); |
| 70 |
void setRemoteStatus(const git::RemoteStatus& status); |
| 71 |
void analyseRemoteStatus(std::shared_ptr<git::Repository> repository); |
| 72 |
|
| 73 |
std::string getRepositoryRelativePath(const std::string& path, const std::shared_ptr<git::Repository>& repository); |
| 74 |
}; |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
} |