xref: /haiku/src/apps/haikudepot/ui/RatePackageWindow.h (revision dd2a1e350b303b855a50fd64e6cb55618be1ae6a)
1 /*
2  * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
3  * Copyright 2018-2024, Andrew Lindesay <apl@lindesay.co.nz>.
4  * All rights reserved. Distributed under the terms of the MIT License.
5  */
6 #ifndef RATE_PACKAGE_WINDOW_H
7 #define RATE_PACKAGE_WINDOW_H
8 
9 #include <vector>
10 
11 #include <PopUpMenu.h>
12 #include <Window.h>
13 
14 #include "Model.h"
15 #include "PackageInfo.h"
16 #include "TextDocument.h"
17 #include "TextEditor.h"
18 
19 
20 class BButton;
21 class BCheckBox;
22 class BMenuField;
23 class SetRatingView;
24 class TextDocumentView;
25 
26 
27 class RatePackageWindow : public BWindow {
28 public:
29 								RatePackageWindow(BWindow* parent, BRect frame,
30 									Model& model);
31 	virtual						~RatePackageWindow();
32 
33 	virtual	void				DispatchMessage(BMessage* message,
34 									BHandler *handler);
35 	virtual	void				MessageReceived(BMessage* message);
36 
37 			void				SetPackage(const PackageInfoRef& package);
38 
39 private:
40 			void				_InitLanguagesMenu(BPopUpMenu* menu);
41 			void				_InitStabilitiesMenu(BPopUpMenu* menu);
42 			void				_MarkStabilityInMenu(BString* code);
43 
44 			void				_RelayServerDataToUI(BMessage& result);
45 
46 			void				_SendRating();
47 
48 			void				_SetWorkerThread(thread_id thread);
49 
50 	static	int32				_QueryRatingThreadEntry(void* data);
51 			void				_QueryRatingThread();
52 
53 	static	int32				_SendRatingThreadEntry(void* data);
54 			void				_SendRatingThread();
55 
56 			void				_RefreshPackageData();
57 
58 private:
59 			Model&				fModel;
60 			TextDocumentRef		fRatingText;
61 			TextEditorRef		fTextEditor;
62 			float				fRating;
63 			bool				fRatingDeterminate;
64 			BString				fStabilityCode;
65 			BString				fCommentLanguageId;
66 			BString				fRatingID;
67 			bool				fRatingActive;
68 			PackageInfoRef		fPackage;
69 
70 			SetRatingView*		fSetRatingView;
71 			BCheckBox*			fRatingDeterminateCheckBox;
72 			BMenuField*			fStabilityField;
73 			BMenuField*			fCommentLanguageField;
74 			TextDocumentView*	fTextView;
75 			BCheckBox*			fRatingActiveCheckBox;
76 			BButton*			fCancelButton;
77 			BButton*			fSendButton;
78 
79 			thread_id			fWorkerThread;
80 };
81 
82 
83 #endif // RATE_PACKAGE_WINDOW_H
84