xref: /haiku/src/apps/haikudepot/ui/PackageListView.h (revision 46b7da1f4f40f7157d74fc7fb26ff9ec7f2416f2)
1 /*
2  * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
3  * Copyright 2013, Rene Gollent <rene@gollent.com>.
4  * Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>
5  * All rights reserved. Distributed under the terms of the MIT License.
6  */
7 #ifndef PACKAGE_LIST_VIEW_H
8 #define PACKAGE_LIST_VIEW_H
9 
10 
11 #include <ColumnListView.h>
12 #include <ColumnTypes.h>
13 #include <Locker.h>
14 #include <util/OpenHashTable.h>
15 
16 #include "Model.h"
17 #include "PackageInfo.h"
18 
19 
20 class PackageRow;
21 class PackageListener;
22 class WorkStatusView;
23 
24 
25 class PackageListView : public BColumnListView {
26 public:
27 								PackageListView(Model* model);
28 	virtual						~PackageListView();
29 
30 	virtual void				AttachedToWindow();
31 	virtual	void				AllAttached();
32 
33 	virtual	void				MessageReceived(BMessage* message);
34 
35 	virtual void				SelectionChanged();
36 
37 	virtual void				Clear();
38 			void				AddPackage(const PackageInfoRef& package);
39 			void				RemovePackage(const PackageInfoRef& package);
40 
41 			void				SelectPackage(const PackageInfoRef& package);
42 
43 			void				AttachWorkStatusView(WorkStatusView* view);
44 
45 private:
46 			PackageRow*			_FindRow(const PackageInfoRef& package);
47 			PackageRow*			_FindRow(const BString& packageName);
48 
49 private:
50 			class ItemCountView;
51 			struct RowByNameHashDefinition;
52 			typedef BOpenHashTable<RowByNameHashDefinition> RowByNameTable;
53 
54 			Model*				fModel;
55 			ItemCountView*		fItemCountView;
56 			PackageListener*	fPackageListener;
57 			RowByNameTable*		fRowByNameTable;
58 
59 			WorkStatusView*		fWorkStatusView;
60 
61 			bool				fIgnoreSelectionChanged;
62 };
63 
64 #endif // PACKAGE_LIST_VIEW_H
65