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 MessageReceived(BMessage* message); 34 35 void SetPackage(const PackageInfoRef& package); 36 37 private: 38 void _InitLanguagesMenu(BPopUpMenu* menu); 39 void _InitStabilitiesMenu(BPopUpMenu* menu); 40 void _MarkStabilityInMenu(BString* code); 41 42 void _RelayServerDataToUI(BMessage& result); 43 44 void _SendRating(); 45 46 void _SetWorkerThread(thread_id thread); 47 48 static int32 _QueryRatingThreadEntry(void* data); 49 void _QueryRatingThread(); 50 51 static int32 _SendRatingThreadEntry(void* data); 52 void _SendRatingThread(); 53 54 void _RefreshPackageData(); 55 56 private: 57 Model& fModel; 58 TextDocumentRef fRatingText; 59 TextEditorRef fTextEditor; 60 float fRating; 61 bool fRatingDeterminate; 62 BString fStabilityCode; 63 BString fCommentLanguageId; 64 BString fRatingID; 65 bool fRatingActive; 66 PackageInfoRef fPackage; 67 68 SetRatingView* fSetRatingView; 69 BCheckBox* fRatingDeterminateCheckBox; 70 BMenuField* fStabilityField; 71 BMenuField* fCommentLanguageField; 72 TextDocumentView* fTextView; 73 BCheckBox* fRatingActiveCheckBox; 74 BButton* fCancelButton; 75 BButton* fSendButton; 76 77 thread_id fWorkerThread; 78 }; 79 80 81 #endif // RATE_PACKAGE_WINDOW_H 82