1 /* 2 * Copyright 2017 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Brian Hill 7 */ 8 #ifndef REPOSITORIES_VIEW_H 9 #define REPOSITORIES_VIEW_H 10 11 12 #include <ColumnListView.h> 13 #include <GroupView.h> 14 #include <String.h> 15 #include <StringView.h> 16 #include <View.h> 17 18 #include "RepositoriesSettings.h" 19 #include "RepoRow.h" 20 #include "TaskLooper.h" 21 22 23 class RepositoriesListView : public BColumnListView { 24 public: 25 RepositoriesListView(const char* name); 26 virtual void KeyDown(const char* bytes, int32 numBytes); 27 }; 28 29 30 class RepositoriesView : public BGroupView { 31 public: 32 RepositoriesView(); 33 ~RepositoriesView(); 34 virtual void AllAttached(); 35 virtual void AttachedToWindow(); 36 virtual void MessageReceived(BMessage*); 37 void AddManualRepository(BString url); 38 bool IsTaskRunning() { return fRunningTaskCount > 0; } 39 40 private: 41 // Message helpers 42 void _AddSelectedRowsToQueue(); 43 void _TaskStarted(RepoRow* rowItem, int16 count); 44 void _TaskCompleted(RepoRow* rowItem, int16 count, 45 BString& newName); 46 void _TaskCanceled(RepoRow* rowItem, int16 count); 47 void _ShowCompletedStatusIfDone(); 48 void _UpdateFromRepoConfig(RepoRow* rowItem); 49 50 // GUI functions 51 BString _GetPathIdentifier(BString urlPath); 52 status_t _EmptyList(); 53 void _InitList(); 54 void _RefreshList(); 55 void _UpdateListFromRoster(); 56 void _SaveList(); 57 RepoRow* _AddRepo(BString name, BString url, bool enabled); 58 void _FindSiblings(); 59 void _UpdateButtons(); 60 void _UpdateStatusView(); 61 62 RepositoriesSettings fSettings; 63 RepositoriesListView* fListView; 64 BView* fStatusContainerView; 65 BStringView* fListStatusView; 66 TaskLooper* fTaskLooper; 67 bool fShowCompletedStatus; 68 int fRunningTaskCount, fLastCompletedTimerId; 69 BButton* fAddButton; 70 BButton* fRemoveButton; 71 BButton* fEnableButton; 72 BButton* fDisableButton; 73 }; 74 75 76 #endif 77