diff --git a/src/apps/haikudepot/server/WebAppInterface.h b/src/apps/haikudepot/server/WebAppInterface.h index 099cf77ab5..543aac1557 100644 --- a/src/apps/haikudepot/server/WebAppInterface.h +++ b/src/apps/haikudepot/server/WebAppInterface.h @@ -33,6 +33,10 @@ typedef List StringList; #define ERROR_CODE_LIMITEXCEEDED -32805 #define ERROR_CODE_AUTHORIZATIONRULECONFLICT -32806 +/*! This constant can be used to indicate the lack of a rating. */ + +#define RATING_NONE -1 + class WebAppInterface { public: diff --git a/src/apps/haikudepot/ui/RatePackageWindow.cpp b/src/apps/haikudepot/ui/RatePackageWindow.cpp index 13c74c744a..975a82cf3d 100644 --- a/src/apps/haikudepot/ui/RatePackageWindow.cpp +++ b/src/apps/haikudepot/ui/RatePackageWindow.cpp @@ -202,7 +202,8 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame, fModel(model), fRatingText(), fTextEditor(new TextEditor(), true), - fRating(-1.0f), + fRating(RATING_NONE), + fRatingDeterminate(false), fCommentLanguage(fModel.PreferredLanguage()), fWorkerThread(-1) { @@ -337,6 +338,7 @@ RatePackageWindow::MessageReceived(BMessage* message) switch (message->what) { case MSG_PACKAGE_RATED: message->FindFloat("rating", &fRating); + fRatingDeterminate = true; fSetRatingView->SetRatingDeterminate(true); fRatingDeterminateCheckBox->SetValue(B_CONTROL_ON); break; @@ -350,8 +352,9 @@ RatePackageWindow::MessageReceived(BMessage* message) break; case MSG_RATING_DETERMINATE_CHANGED: - fSetRatingView->SetRatingDeterminate( - fRatingDeterminateCheckBox->Value() == B_CONTROL_ON); + fRatingDeterminate = fRatingDeterminateCheckBox->Value() + == B_CONTROL_ON; + fSetRatingView->SetRatingDeterminate(fRatingDeterminate); break; case MSG_RATING_ACTIVE_CHANGED: @@ -520,14 +523,15 @@ RatePackageWindow::_RelayServerDataToUI(BMessage& response) double rating; if (response.FindDouble("rating", &rating) == B_OK) { fRating = (float)rating; + fRatingDeterminate = fRating >= 0.0f; fSetRatingView->SetPermanentRating(fRating); - fSetRatingView->SetRatingDeterminate(true); - fRatingDeterminateCheckBox->SetValue(B_CONTROL_ON); } else { - fSetRatingView->SetRatingDeterminate(false); - fRatingDeterminateCheckBox->SetValue(B_CONTROL_OFF); + fRatingDeterminate = false; } + fSetRatingView->SetRatingDeterminate(fRatingDeterminate); + fRatingDeterminateCheckBox->SetValue( + fRatingDeterminate ? B_CONTROL_ON : B_CONTROL_OFF); fRatingActiveCheckBox->SetValue(fRatingActive); fRatingActiveCheckBox->Show(); @@ -649,6 +653,9 @@ RatePackageWindow::_SendRatingThread() BString ratingID = fRatingID; bool active = fRatingActive; + if (!fRatingDeterminate) + rating = RATING_NONE; + const DepotInfo* depot = fModel.DepotForName(fPackage->DepotName()); if (depot != NULL) diff --git a/src/apps/haikudepot/ui/RatePackageWindow.h b/src/apps/haikudepot/ui/RatePackageWindow.h index b5c6889f79..04ca5f0183 100644 --- a/src/apps/haikudepot/ui/RatePackageWindow.h +++ b/src/apps/haikudepot/ui/RatePackageWindow.h @@ -53,6 +53,7 @@ private: TextDocumentRef fRatingText; TextEditorRef fTextEditor; float fRating; + bool fRatingDeterminate; BString fStability; StabilityRatingList fStabilityCodes; BString fCommentLanguage;