xref: /haiku/src/preferences/repositories/RepositoriesView.h (revision 7457ccb4b2f4786525d3b7bda42598487d57ab7d)
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 	status_t				_EmptyList();
52 	void					_InitList();
53 	void					_RefreshList();
54 	void					_UpdateListFromRoster();
55 	void					_SaveList();
56 	RepoRow*				_AddRepo(BString name, BString url, bool enabled);
57 	void					_FindSiblings();
58 	void					_UpdateButtons();
59 	void					_UpdateStatusView();
60 
61 	RepositoriesSettings	fSettings;
62 	RepositoriesListView*	fListView;
63 	BView*					fStatusContainerView;
64 	BStringView*			fListStatusView;
65 	TaskLooper*				fTaskLooper;
66 	bool					fShowCompletedStatus;
67 	int						fRunningTaskCount, fLastCompletedTimerId;
68 	BButton*				fAddButton;
69 	BButton*				fRemoveButton;
70 	BButton*				fEnableButton;
71 	BButton*				fDisableButton;
72 };
73 
74 
75 #endif
76