[haiku-commits] haiku: hrev47914 - src/apps/haikudepot

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 26 Sep 2014 21:44:47 +0200 (CEST)

hrev47914 adds 3 changesets to branch 'master'
old head: a4a9dade68cfaf4e7d420ccb97d3acba43d39943
new head: 91778eaa8195ff74c13a0194c5e91a8791db4a46
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=91778ea+%5Ea4a9dad

----------------------------------------------------------------------------

967a281: HaikuDepot: Definition for stability rating

5c4c4e2: HaikuDepot: UI for selecting a stability rating...
  
  ... in the rating window. Not functional.

91778ea: HaikuDepot: Added Cancel button to rating window.
  
  Also, no need to have the Send button as a class member.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 139 insertions(+), 9 deletions(-)
src/apps/haikudepot/PackageInfo.cpp       | 52 +++++++++++++++++++++
src/apps/haikudepot/PackageInfo.h         | 25 +++++++++++
src/apps/haikudepot/RatePackageWindow.cpp | 65 +++++++++++++++++++++++++--
src/apps/haikudepot/RatePackageWindow.h   |  6 +--

############################################################################

Commit:      967a2818310ba5d8871b8eceb98d0f51689433f1
URL:         http://cgit.haiku-os.org/haiku/commit/?id=967a281
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Fri Sep 26 19:38:20 2014 UTC

HaikuDepot: Definition for stability rating

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/PackageInfo.cpp 
b/src/apps/haikudepot/PackageInfo.cpp
index 5efae93..762d900 100644
--- a/src/apps/haikudepot/PackageInfo.cpp
+++ b/src/apps/haikudepot/PackageInfo.cpp
@@ -469,6 +469,58 @@ RatingSummary::operator!=(const RatingSummary& other) const
 }
 
 
+// #pragma mark - StabilityRating
+
+
+StabilityRating::StabilityRating()
+       :
+       fLabel(),
+       fName()
+{
+}
+
+
+StabilityRating::StabilityRating(const BString& label,
+               const BString& name)
+       :
+       fLabel(label),
+       fName(name)
+{
+}
+
+
+StabilityRating::StabilityRating(const StabilityRating& other)
+       :
+       fLabel(other.fLabel),
+       fName(other.fName)
+{
+}
+
+
+StabilityRating&
+StabilityRating::operator=(const StabilityRating& other)
+{
+       fLabel = other.fLabel;
+       fName = other.fName;
+       return *this;
+}
+
+
+bool
+StabilityRating::operator==(const StabilityRating& other) const
+{
+       return fLabel == other.fLabel
+               && fName == other.fName;
+}
+
+
+bool
+StabilityRating::operator!=(const StabilityRating& other) const
+{
+       return !(*this == other);
+}
+
+
 // #pragma mark - PublisherInfo
 
 
diff --git a/src/apps/haikudepot/PackageInfo.h 
b/src/apps/haikudepot/PackageInfo.h
index f54646a..e903851 100644
--- a/src/apps/haikudepot/PackageInfo.h
+++ b/src/apps/haikudepot/PackageInfo.h
@@ -147,6 +147,31 @@ public:
 };
 
 
+class StabilityRating {
+public:
+                                                               
StabilityRating();
+                                                               StabilityRating(
+                                                                       const 
BString& label,
+                                                                       const 
BString& name);
+                                                               
StabilityRating(const StabilityRating& other);
+
+                       StabilityRating&        operator=(const 
StabilityRating& other);
+                       bool                            operator==(const 
StabilityRating& other) const;
+                       bool                            operator!=(const 
StabilityRating& other) const;
+
+                       const BString&          Label() const
+                                                                       { 
return fLabel; }
+                       const BString&          Name() const
+                                                                       { 
return fName; }
+private:
+                       BString                         fLabel;
+                       BString                         fName;
+};
+
+
+typedef List<StabilityRating, false> StabilityRatingList;
+
+
 class PublisherInfo {
 public:
                                                                PublisherInfo();

############################################################################

Commit:      5c4c4e2ec605c16fa46ecbeb02790432b74d6687
URL:         http://cgit.haiku-os.org/haiku/commit/?id=5c4c4e2
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Fri Sep 26 19:38:57 2014 UTC

HaikuDepot: UI for selecting a stability rating...

... in the rating window. Not functional.

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/RatePackageWindow.cpp 
b/src/apps/haikudepot/RatePackageWindow.cpp
index ecf92b0..9792b72 100644
--- a/src/apps/haikudepot/RatePackageWindow.cpp
+++ b/src/apps/haikudepot/RatePackageWindow.cpp
@@ -12,6 +12,9 @@
 #include <Catalog.h>
 #include <Button.h>
 #include <LayoutBuilder.h>
+#include <MenuField.h>
+#include <MenuItem.h>
+#include <PopUpMenu.h>
 #include <ScrollView.h>
 
 #include "MarkupParser.h"
@@ -23,7 +26,8 @@
 
 
 enum {
-       MSG_SEND                        = 'send'
+       MSG_SEND                                = 'send',
+       MSG_STABILITY_SELECTED  = 'stbl'
 };
 
 //! Layouts the scrollbar so it looks nice with no border and the document
@@ -80,6 +84,19 @@ public:
 };
 
 
+static void
+add_stabilities_to_menu(const StabilityRatingList& stabilities, BMenu* menu)
+{
+       for (int i = 0; i < stabilities.CountItems(); i++) {
+               const StabilityRating& stability = stabilities.ItemAtFast(i);
+               BMessage* message = new BMessage(MSG_STABILITY_SELECTED);
+               message->AddString("name", stability.Name());
+               BMenuItem* item = new BMenuItem(stability.Label(), message);
+               menu->AddItem(item);
+       }
+}
+
+
 RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame)
        :
        BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Your rating"),
@@ -103,12 +120,39 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, 
BRect frame)
        textView->SetTextDocument(fRatingText);
        textView->SetTextEditor(TextEditorRef(new TextEditor(), true));
 
+       // Construct stability rating popup
+       // Construct repository popup
+       BPopUpMenu* stabilityMenu = new BPopUpMenu(B_TRANSLATE("Stability"));
+       BMenuField* stabilityRatingField = new BMenuField("stability",
+               B_TRANSLATE("Stability:"), stabilityMenu);
+       
+       StabilityRatingList stabilities;
+       stabilities.Add(StabilityRating(
+               B_TRANSLATE("Not specified"), "UNSPECIFIED"));
+       stabilities.Add(StabilityRating(
+               B_TRANSLATE("Mostly stable"), "MOSTLY_STABLE"));
+       stabilities.Add(StabilityRating(
+               B_TRANSLATE("Stable"), "STABLE"));
+       stabilities.Add(StabilityRating(
+               B_TRANSLATE("Not stable, but usable"), "USABLE"));
+       stabilities.Add(StabilityRating(
+               B_TRANSLATE("Unstable"), "UNSTABLE"));
+       stabilities.Add(StabilityRating(
+               B_TRANSLATE("Does not start"), "DOES_NOT_START"));
+       
+       add_stabilities_to_menu(stabilities, stabilityMenu);
+       stabilityMenu->SetTargetForItems(this);
+       
+       fStability = stabilities.ItemAt(0).Name();
+       stabilityMenu->ItemAt(0)->SetMarked(true);
+
        fSendButton = new BButton("send", B_TRANSLATE("Send"),
                new BMessage(MSG_SEND));
 
        // Build layout
        BLayoutBuilder::Group<>(this, B_VERTICAL)
                .Add(textScrollView)
+               .Add(stabilityRatingField)
                .AddGroup(B_HORIZONTAL)
                        .AddGlue()
                        .Add(fSendButton)
@@ -130,6 +174,9 @@ RatePackageWindow::MessageReceived(BMessage* message)
                case MSG_SEND:
                        _SendRating();
                        break;
+               case MSG_STABILITY_SELECTED:
+                       message->FindString("name", &fStability);
+                       break;
 
                default:
                        BWindow::MessageReceived(message);
@@ -141,7 +188,10 @@ RatePackageWindow::MessageReceived(BMessage* message)
 void
 RatePackageWindow::SetPackage(const PackageInfoRef& package)
 {
-       // TODO: Just remember which package the rating is for.
+       fPackage = package;
+       // TODO: See if the user already made a rating for this package,
+       // pre-fill the UI with that rating. When sending the rating, replace
+       // the old one.
 }
 
 
diff --git a/src/apps/haikudepot/RatePackageWindow.h 
b/src/apps/haikudepot/RatePackageWindow.h
index c3082a1..b5bf8ec 100644
--- a/src/apps/haikudepot/RatePackageWindow.h
+++ b/src/apps/haikudepot/RatePackageWindow.h
@@ -12,7 +12,7 @@
 
 
 class BButton;
-class TextDocumentView;
+class BMenuField;
 
 
 class RatePackageWindow : public BWindow {
@@ -29,6 +29,7 @@ private:
 
 private:
                        TextDocumentRef         fRatingText;
+                       BString                         fStability;
                        BButton*                        fSendButton;
                        PackageInfoRef          fPackage;
 };

############################################################################

Revision:    hrev47914
Commit:      91778eaa8195ff74c13a0194c5e91a8791db4a46
URL:         http://cgit.haiku-os.org/haiku/commit/?id=91778ea
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Fri Sep 26 19:45:50 2014 UTC

HaikuDepot: Added Cancel button to rating window.

Also, no need to have the Send button as a class member.

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/RatePackageWindow.cpp 
b/src/apps/haikudepot/RatePackageWindow.cpp
index 9792b72..6c922c6 100644
--- a/src/apps/haikudepot/RatePackageWindow.cpp
+++ b/src/apps/haikudepot/RatePackageWindow.cpp
@@ -146,7 +146,10 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, 
BRect frame)
        fStability = stabilities.ItemAt(0).Name();
        stabilityMenu->ItemAt(0)->SetMarked(true);
 
-       fSendButton = new BButton("send", B_TRANSLATE("Send"),
+       BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
+               new BMessage(B_QUIT_REQUESTED));
+
+       BButton* sendButton = new BButton("send", B_TRANSLATE("Send"),
                new BMessage(MSG_SEND));
 
        // Build layout
@@ -155,10 +158,14 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, 
BRect frame)
                .Add(stabilityRatingField)
                .AddGroup(B_HORIZONTAL)
                        .AddGlue()
-                       .Add(fSendButton)
+                       .Add(cancelButton)
+                       .Add(sendButton)
                .End()
                .SetInsets(B_USE_DEFAULT_SPACING)
        ;
+
+       // NOTE: Do not make Send the default button. The user might want
+       // to type line-breaks instead of sending when hitting RETURN.
 }
 
 
diff --git a/src/apps/haikudepot/RatePackageWindow.h 
b/src/apps/haikudepot/RatePackageWindow.h
index b5bf8ec..5a20e7b 100644
--- a/src/apps/haikudepot/RatePackageWindow.h
+++ b/src/apps/haikudepot/RatePackageWindow.h
@@ -11,10 +11,6 @@
 #include "TextDocument.h"
 
 
-class BButton;
-class BMenuField;
-
-
 class RatePackageWindow : public BWindow {
 public:
                                                                
RatePackageWindow(BWindow* parent, BRect frame);
@@ -30,7 +26,6 @@ private:
 private:
                        TextDocumentRef         fRatingText;
                        BString                         fStability;
-                       BButton*                        fSendButton;
                        PackageInfoRef          fPackage;
 };
 


Other related posts:

  • » [haiku-commits] haiku: hrev47914 - src/apps/haikudepot - superstippi