xref: /haiku/src/apps/haikudepot/ui/RatePackageWindow.h (revision b31cb92f29fe89eaca84d173d0f70d38bf0c6a3d)
1 /*
2  * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
3  * Copyright 2018, 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 <Window.h>
10 
11 #include "Model.h"
12 #include "PackageInfo.h"
13 #include "TextDocument.h"
14 #include "TextEditor.h"
15 
16 
17 class BButton;
18 class BCheckBox;
19 class BMenuField;
20 class SetRatingView;
21 class TextDocumentView;
22 
23 
24 class RatePackageWindow : public BWindow {
25 public:
26 								RatePackageWindow(BWindow* parent, BRect frame,
27 									Model& model);
28 	virtual						~RatePackageWindow();
29 
30 	virtual	void				DispatchMessage(BMessage* message,
31 									BHandler *handler);
32 	virtual	void				MessageReceived(BMessage* message);
33 
34 			void				SetPackage(const PackageInfoRef& package);
35 
36 private:
37 			void				_RelayServerDataToUI(BMessage& result);
38 
39 			void				_SendRating();
40 
41 			void				_SetWorkerThread(thread_id thread);
42 
43 	static	int32				_QueryRatingThreadEntry(void* data);
44 			void				_QueryRatingThread();
45 
46 	static	int32				_SendRatingThreadEntry(void* data);
47 			void				_SendRatingThread();
48 
49 			void				_RefreshPackageData();
50 
51 private:
52 			Model&				fModel;
53 			TextDocumentRef		fRatingText;
54 			TextEditorRef		fTextEditor;
55 			float				fRating;
56 			BString				fStability;
57 			StabilityRatingList	fStabilityCodes;
58 			BString				fCommentLanguage;
59 			BString				fRatingID;
60 			bool				fRatingActive;
61 			PackageInfoRef		fPackage;
62 
63 			SetRatingView*		fSetRatingView;
64 			BCheckBox*			fRatingDeterminateCheckBox;
65 			BMenuField*			fStabilityField;
66 			BMenuField*			fCommentLanguageField;
67 			TextDocumentView*	fTextView;
68 			BCheckBox*			fRatingActiveCheckBox;
69 			BButton*			fCancelButton;
70 			BButton*			fSendButton;
71 
72 			thread_id			fWorkerThread;
73 };
74 
75 
76 #endif // RATE_PACKAGE_WINDOW_H
77