[haiku-commits] haiku: hrev47918 - in src/apps/haikudepot: . ui model ui_generic

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 27 Sep 2014 23:14:40 +0200 (CEST)

hrev47918 adds 10 changesets to branch 'master'
old head: 1d38b7a86a2659897f86ceac63c871f03a0e678d
new head: 83f46c7198f03c981cb985f8901744ef53b8ab6d
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=83f46c7+%5E1d38b7a

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

11d1700: HaikuDepot: Exract RatingView into its own source and header

2e19e8f: HaikuDepot: Extracted SharedBitmap into its own files

04c9d57: HaikuDepot: Organized source into sub-folders

823d2b8: HaikuDepot: Split generic and specific UI classes
  
  * Also fixed placement of PackageManager which I must have
    dropped into the wrong folder by accident.

63269a6: HaikuDepot: Allow RatingView to be wider than MinSize().

c28b830: HaikuDepot: Add actual rating to RatePackageWindow.
  
  Implemented SetRatingView based on RatingView. It previews the rating
  when hovering and makes it permanent when clicked.

6bede50: HaikuDepot: Define StringList type for convenience.

4ff3d17: HaikuDepot: Put supported languages into a StringList
  
  * Added TODO to retrieve the list from the web-app, there is already an
    API for it. For now, the hard-coded list matches the web-app's and the
    next change in this regard will be to support any known language.
  * Make the list accessible.

da504db: HaikuDepot: Allow to set the rating comment's language.

83f46c7: HaikuDepot: Handle BMessage for rating comment language

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

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

43 files changed, 631 insertions(+), 421 deletions(-)
src/apps/haikudepot/Jamfile                      |   4 +-
.../haikudepot/{ => model}/DecisionProvider.cpp  |   0
.../haikudepot/{ => model}/DecisionProvider.h    |   0
.../haikudepot/{ => model}/JobStateListener.cpp  |   0
.../haikudepot/{ => model}/JobStateListener.h    |   0
src/apps/haikudepot/{ => model}/Model.cpp        |  18 +-
src/apps/haikudepot/{ => model}/Model.h          |   4 +
.../haikudepot/{ => model}/PackageAction.cpp     |   0
src/apps/haikudepot/{ => model}/PackageAction.h  |   0
.../{ => model}/PackageActionHandler.cpp         |   0
.../{ => model}/PackageActionHandler.h           |   0
src/apps/haikudepot/{ => model}/PackageInfo.cpp  | 265 ------------------
src/apps/haikudepot/{ => model}/PackageInfo.h    |  52 +---
.../{ => model}/PackageInfoListener.cpp          |   0
.../haikudepot/{ => model}/PackageInfoListener.h |   0
.../haikudepot/{ => model}/PackageManager.cpp    |   0
src/apps/haikudepot/{ => model}/PackageManager.h |   0
.../haikudepot/{ => model}/WebAppInterface.cpp   |   0
.../haikudepot/{ => model}/WebAppInterface.h     |   0
src/apps/haikudepot/{ => ui}/App.cpp             |   0
src/apps/haikudepot/{ => ui}/App.h               |   0
src/apps/haikudepot/{ => ui}/FilterView.cpp      |   0
src/apps/haikudepot/{ => ui}/FilterView.h        |   0
src/apps/haikudepot/{ => ui}/MainWindow.cpp      |   5 +-
src/apps/haikudepot/{ => ui}/MainWindow.h        |   0
src/apps/haikudepot/{ => ui}/PackageInfoView.cpp |  94 +------
src/apps/haikudepot/{ => ui}/PackageInfoView.h   |   2 +-
src/apps/haikudepot/{ => ui}/PackageListView.cpp |   0
src/apps/haikudepot/{ => ui}/PackageListView.h   |   0
.../haikudepot/{ => ui}/RatePackageWindow.cpp    | 116 +++++++-
src/apps/haikudepot/{ => ui}/RatePackageWindow.h |   6 +-
src/apps/haikudepot/{ => ui}/UserLoginWindow.cpp |   0
src/apps/haikudepot/{ => ui}/UserLoginWindow.h   |   0
.../haikudepot/{ => ui_generic}/BitmapButton.cpp |   0
.../haikudepot/{ => ui_generic}/BitmapButton.h   |   0
.../haikudepot/{ => ui_generic}/BitmapView.cpp   |   0
.../haikudepot/{ => ui_generic}/BitmapView.h     |   0
src/apps/haikudepot/ui_generic/RatingView.cpp    | 114 ++++++++
src/apps/haikudepot/ui_generic/RatingView.h      |  35 +++
src/apps/haikudepot/ui_generic/SharedBitmap.cpp  | 274 +++++++++++++++++++
src/apps/haikudepot/ui_generic/SharedBitmap.h    |  63 +++++
src/apps/haikudepot/{ => ui_generic}/support.cpp |   0
src/apps/haikudepot/{ => ui_generic}/support.h   |   0

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

Commit:      11d170047e9cdd9d2620c6ff7a6231371e8034ec
URL:         http://cgit.haiku-os.org/haiku/commit/?id=11d1700
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 19:12:26 2014 UTC

HaikuDepot: Exract RatingView into its own source and header

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

diff --git a/src/apps/haikudepot/Jamfile b/src/apps/haikudepot/Jamfile
index eeac625..03e5ff3 100644
--- a/src/apps/haikudepot/Jamfile
+++ b/src/apps/haikudepot/Jamfile
@@ -52,6 +52,7 @@ Application HaikuDepot :
        PackageListView.cpp
        PackageManager.cpp
        RatePackageWindow.cpp
+       RatingView.cpp
        support.cpp
        UserLoginWindow.cpp
        WebAppInterface.cpp
diff --git a/src/apps/haikudepot/PackageInfoView.cpp 
b/src/apps/haikudepot/PackageInfoView.cpp
index 1eb0520..1dd7b9c 100644
--- a/src/apps/haikudepot/PackageInfoView.cpp
+++ b/src/apps/haikudepot/PackageInfoView.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013, Stephan Aßmus <superstippi@xxxxxx>.
+ * Copyright 2013-214, Stephan Aßmus <superstippi@xxxxxx>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 
@@ -31,6 +31,7 @@
 #include "MarkupParser.h"
 #include "PackageActionHandler.h"
 #include "PackageManager.h"
+#include "RatingView.h"
 #include "TextDocumentView.h"
 #include "TextView.h"
 
@@ -232,93 +233,6 @@ private:
 // #pragma mark - rating stats
 
 
-class RatingView : public BView {
-public:
-       RatingView()
-               :
-               BView("package rating view", B_WILL_DRAW),
-               fStarBitmap(501),
-               fRating(-1.0f)
-       {
-               SetViewColor(B_TRANSPARENT_COLOR);
-               SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-       }
-
-       virtual ~RatingView()
-       {
-       }
-
-       virtual void AttachedToWindow()
-       {
-               BView* parent = Parent();
-               if (parent != NULL)
-                       SetLowColor(parent->ViewColor());
-       }
-
-       virtual void Draw(BRect updateRect)
-       {
-               FillRect(updateRect, B_SOLID_LOW);
-
-               if (fRating < 0.0f)
-                       return;
-
-               const BBitmap* star = fStarBitmap.Bitmap(SharedBitmap::SIZE_16);
-               if (star == NULL) {
-                       fprintf(stderr, "No star icon found in application 
resources.\n");
-                       return;
-               }
-
-               SetDrawingMode(B_OP_OVER);
-
-               float x = 0;
-               for (int i = 0; i < 5; i++) {
-                       DrawBitmap(star, BPoint(x, 0));
-                       x += 16 + 2;
-               }
-
-               if (fRating >= 5.0f)
-                       return;
-
-               SetDrawingMode(B_OP_OVER);
-
-               BRect rect(Bounds());
-               rect.left = ceilf(rect.left + (fRating / 5.0f) * rect.Width());
-
-               rgb_color color = LowColor();
-               color.alpha = 190;
-               SetHighColor(color);
-
-               SetDrawingMode(B_OP_ALPHA);
-               FillRect(rect, B_SOLID_HIGH);
-       }
-
-       virtual BSize MinSize()
-       {
-               return BSize(16 * 5 + 2 * 4, 16 + 2);
-       }
-
-       virtual BSize PreferredSize()
-       {
-               return MinSize();
-       }
-
-       virtual BSize MaxSize()
-       {
-               return MinSize();
-       }
-
-       void SetRating(float rating)
-       {
-               fRating = rating;
-               Invalidate();
-       }
-
-private:
-       SharedBitmap    fStarBitmap;
-       float                   fRating;
-};
-
-
 class DiagramBarView : public BView {
 public:
        DiagramBarView()
@@ -436,7 +350,7 @@ class TransitReportingRatingView : public RatingView, 
public BInvoker {
 public:
        TransitReportingRatingView(BMessage* transitMessage)
                :
-               RatingView(),
+               RatingView("package rating view"),
                fTransitMessage(transitMessage)
        {
        }
@@ -1024,7 +938,7 @@ public:
                fNameView->SetExplicitMaxSize(
                        BSize(nameFont.StringWidth("xxxxxxxxxxxxxxxxxxxxxx"), 
B_SIZE_UNSET));
 
-               fRatingView = new RatingView();
+               fRatingView = new RatingView("package rating view");
                fRatingView->SetRating(rating.Rating());
 
                BString ratingLabel;
diff --git a/src/apps/haikudepot/PackageInfoView.h 
b/src/apps/haikudepot/PackageInfoView.h
index de03f5e..64b2618 100644
--- a/src/apps/haikudepot/PackageInfoView.h
+++ b/src/apps/haikudepot/PackageInfoView.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013, Stephan Aßmus <superstippi@xxxxxx>.
+ * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 #ifndef PACKAGE_INFO_VIEW_H
diff --git a/src/apps/haikudepot/RatingView.cpp 
b/src/apps/haikudepot/RatingView.cpp
new file mode 100644
index 0000000..af62126
--- /dev/null
+++ b/src/apps/haikudepot/RatingView.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+
+#include "RatingView.h"
+
+
+RatingView::RatingView(const char* name)
+       :
+       BView(name, B_WILL_DRAW),
+       fStarBitmap(501),
+       fRating(-1.0f)
+{
+       SetViewColor(B_TRANSPARENT_COLOR);
+       SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+}
+
+
+RatingView::~RatingView()
+{
+}
+
+
+void
+RatingView::AttachedToWindow()
+{
+       BView* parent = Parent();
+       if (parent != NULL)
+               SetLowColor(parent->ViewColor());
+}
+
+
+void
+RatingView::Draw(BRect updateRect)
+{
+       FillRect(updateRect, B_SOLID_LOW);
+
+       if (fRating < 0.0f)
+               return;
+
+       const BBitmap* star = fStarBitmap.Bitmap(SharedBitmap::SIZE_16);
+       if (star == NULL) {
+               fprintf(stderr, "No star icon found in application 
resources.\n");
+               return;
+       }
+
+       SetDrawingMode(B_OP_OVER);
+
+       float x = 0;
+       for (int i = 0; i < 5; i++) {
+               DrawBitmap(star, BPoint(x, 0));
+               x += 16 + 2;
+       }
+
+       if (fRating >= 5.0f)
+               return;
+
+       SetDrawingMode(B_OP_OVER);
+
+       BRect rect(Bounds());
+       rect.left = ceilf(rect.left + (fRating / 5.0f) * rect.Width());
+
+       rgb_color color = LowColor();
+       color.alpha = 190;
+       SetHighColor(color);
+
+       SetDrawingMode(B_OP_ALPHA);
+       FillRect(rect, B_SOLID_HIGH);
+}
+
+
+BSize
+RatingView::MinSize()
+{
+       return BSize(16 * 5 + 2 * 4, 16 + 2);
+}
+
+
+BSize
+RatingView::PreferredSize()
+{
+       return MinSize();
+}
+
+
+BSize
+RatingView::MaxSize()
+{
+       return MinSize();
+}
+
+
+void
+RatingView::SetRating(float rating)
+{
+       fRating = rating;
+       Invalidate();
+}
+
+
+float
+RatingView::Rating() const
+{
+       return fRating;
+}
+
diff --git a/src/apps/haikudepot/RatingView.h b/src/apps/haikudepot/RatingView.h
new file mode 100644
index 0000000..73eb013
--- /dev/null
+++ b/src/apps/haikudepot/RatingView.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef RATING_VIEW_H
+#define RATING_VIEW_H
+
+
+#include <View.h>
+
+#include "PackageInfo.h"
+
+
+class RatingView : public BView {
+public:
+                                                               
RatingView(const char* name);
+       virtual                                         ~RatingView();
+
+       virtual void                            AttachedToWindow();
+       virtual void                            Draw(BRect updateRect);
+
+       virtual BSize                           MinSize();
+       virtual BSize                           PreferredSize();
+       virtual BSize                           MaxSize();
+
+                       void                            SetRating(float rating);
+                       float                           Rating() const;
+
+private:
+                       SharedBitmap            fStarBitmap;
+                       float                           fRating;
+};
+
+
+#endif // RATING_VIEW_H

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

Commit:      2e19e8fc639dd64b12c103d6c826982b70e92ef3
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2e19e8f
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 19:28:54 2014 UTC

HaikuDepot: Extracted SharedBitmap into its own files

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

diff --git a/src/apps/haikudepot/Jamfile b/src/apps/haikudepot/Jamfile
index 03e5ff3..34421b8 100644
--- a/src/apps/haikudepot/Jamfile
+++ b/src/apps/haikudepot/Jamfile
@@ -54,6 +54,7 @@ Application HaikuDepot :
        RatePackageWindow.cpp
        RatingView.cpp
        support.cpp
+       SharedBitmap.cpp
        UserLoginWindow.cpp
        WebAppInterface.cpp
 
diff --git a/src/apps/haikudepot/PackageInfo.cpp 
b/src/apps/haikudepot/PackageInfo.cpp
index 762d900..9bb7cca 100644
--- a/src/apps/haikudepot/PackageInfo.cpp
+++ b/src/apps/haikudepot/PackageInfo.cpp
@@ -8,272 +8,7 @@
 
 #include <stdio.h>
 
-#include <Application.h>
-#include <Bitmap.h>
-#include <DataIO.h>
-#include <IconUtils.h>
-#include <MimeType.h>
 #include <package/PackageFlags.h>
-#include <Resources.h>
-#include <TranslationUtils.h>
-
-#include "support.h"
-
-
-// #pragma mark - SharedBitmap
-
-
-SharedBitmap::SharedBitmap(BBitmap* bitmap)
-       :
-       BReferenceable(),
-       fResourceID(-1),
-       fBuffer(NULL),
-       fSize(0),
-       fMimeType()
-{
-       fBitmap[0] = bitmap;
-       fBitmap[1] = NULL;
-       fBitmap[2] = NULL;
-}
-
-
-SharedBitmap::SharedBitmap(int32 resourceID)
-       :
-       BReferenceable(),
-       fResourceID(resourceID),
-       fBuffer(NULL),
-       fSize(0),
-       fMimeType()
-{
-       fBitmap[0] = NULL;
-       fBitmap[1] = NULL;
-       fBitmap[2] = NULL;
-}
-
-
-SharedBitmap::SharedBitmap(const char* mimeType)
-       :
-       BReferenceable(),
-       fResourceID(-1),
-       fBuffer(NULL),
-       fSize(0),
-       fMimeType(mimeType)
-{
-       fBitmap[0] = NULL;
-       fBitmap[1] = NULL;
-       fBitmap[2] = NULL;
-}
-
-
-SharedBitmap::SharedBitmap(BPositionIO& data)
-       :
-       BReferenceable(),
-       fResourceID(-1),
-       fBuffer(NULL),
-       fSize(0),
-       fMimeType()
-{
-       status_t status = data.GetSize(&fSize);
-       const off_t kMaxSize = 128 * 1024;
-       if (status == B_OK && fSize > 0 && fSize <= kMaxSize) {
-               fBuffer = new(std::nothrow) uint8[fSize];
-               if (fBuffer != NULL) {
-                       data.Seek(0, SEEK_SET);
-                       
-                       off_t bytesRead = 0;
-                       size_t chunkSize = std::min((off_t)4096, fSize);
-                       while (bytesRead < fSize) {
-                               ssize_t read = data.Read(fBuffer + bytesRead, 
chunkSize);
-                               if (read > 0)
-                                       bytesRead += read;
-                               else
-                                       break;
-                       }
-       
-                       if (bytesRead != fSize) {
-                               delete[] fBuffer;
-                               fBuffer = NULL;
-                               fSize = 0;
-                       }
-               } else
-                       fSize = 0;
-       } else {
-               fprintf(stderr, "SharedBitmap(): Stream too large: %" B_PRIi64
-                       ", max: %" B_PRIi64 "\n", fSize, kMaxSize);
-       }
-
-       fBitmap[0] = NULL;
-       fBitmap[1] = NULL;
-       fBitmap[2] = NULL;
-}
-
-
-SharedBitmap::~SharedBitmap()
-{
-       delete fBitmap[0];
-       delete fBitmap[1];
-       delete fBitmap[2];
-       delete[] fBuffer;
-}
-
-
-const BBitmap*
-SharedBitmap::Bitmap(Size which)
-{
-       if (fResourceID == -1 && fMimeType.Length() == 0 && fBuffer == NULL)
-               return fBitmap[0];
-
-       int32 index = 0;
-       int32 size = 16;
-
-       switch (which) {
-               default:
-               case SIZE_16:
-                       break;
-
-               case SIZE_32:
-                       index = 1;
-                       size = 32;
-                       break;
-               case SIZE_64:
-                       index = 2;
-                       size = 64;
-                       break;
-       }
-
-       if (fBitmap[index] == NULL) {
-               if (fResourceID >= 0)
-                       fBitmap[index] = _CreateBitmapFromResource(size);
-               else if (fBuffer != NULL)
-                       fBitmap[index] = _CreateBitmapFromBuffer(size);
-               else if (fMimeType.Length() > 0)
-                       fBitmap[index] = _CreateBitmapFromMimeType(size);
-       }
-
-       return fBitmap[index];
-}
-
-
-BBitmap*
-SharedBitmap::_CreateBitmapFromResource(int32 size) const
-{
-       BResources resources;
-       status_t status = get_app_resources(resources);
-       if (status != B_OK)
-               return NULL;
-
-       size_t dataSize;
-       const void* data = resources.LoadResource(B_VECTOR_ICON_TYPE, 
fResourceID,
-               &dataSize);
-       if (data != NULL)
-               return _LoadIconFromBuffer(data, dataSize, size);
-
-       data = resources.LoadResource(B_MESSAGE_TYPE, fResourceID, &dataSize);
-       if (data != NULL)
-               return _LoadBitmapFromBuffer(data, dataSize);
-
-       return NULL;
-}
-
-
-BBitmap*
-SharedBitmap::_CreateBitmapFromBuffer(int32 size) const
-{
-       BBitmap* bitmap = _LoadIconFromBuffer(fBuffer, fSize, size);
-       
-       if (bitmap == NULL)
-               bitmap = _LoadBitmapFromBuffer(fBuffer, fSize);
-
-       return bitmap;
-}
-
-
-BBitmap*
-SharedBitmap::_CreateBitmapFromMimeType(int32 size) const
-{
-       BMimeType mimeType(fMimeType.String());
-       status_t status = mimeType.InitCheck();
-       if (status != B_OK)
-               return NULL;
-
-       BBitmap* bitmap = new BBitmap(BRect(0, 0, size - 1, size - 1), 0, 
B_RGBA32);
-       status = bitmap->InitCheck();
-       if (status == B_OK)
-               status = mimeType.GetIcon(bitmap, B_MINI_ICON);
-
-       if (status != B_OK) {
-               delete bitmap;
-               bitmap = NULL;
-       }
-
-       return bitmap;
-}
-
-
-BBitmap*
-SharedBitmap::_LoadBitmapFromBuffer(const void* buffer, size_t size) const
-{
-       BMemoryIO stream(buffer, size);
-
-       // Try to read as an archived bitmap.
-       BBitmap* bitmap = _LoadArchivedBitmapFromStream(stream);
-       
-       if (bitmap == NULL) {
-               // Try to read as a translator bitmap
-               stream.Seek(0, SEEK_SET);
-               bitmap = _LoadTranslatorBitmapFromStream(stream);
-       }
-
-       if (bitmap != NULL) {
-               status_t status = bitmap->InitCheck();
-               if (status != B_OK) {
-                       delete bitmap;
-                       bitmap = NULL;
-               }
-       }
-
-       return bitmap;
-}
-
-
-BBitmap*
-SharedBitmap::_LoadArchivedBitmapFromStream(BPositionIO& stream) const
-{
-       BMessage archive;
-       status_t status = archive.Unflatten(&stream);
-       if (status != B_OK)
-               return NULL;
-
-       return new BBitmap(&archive);
-}
-
-
-BBitmap*
-SharedBitmap::_LoadTranslatorBitmapFromStream(BPositionIO& stream) const
-{
-       return BTranslationUtils::GetBitmap(&stream);
-}
-
-
-BBitmap*
-SharedBitmap::_LoadIconFromBuffer(const void* data, size_t dataSize,
-       int32 size) const
-{
-       BBitmap* bitmap = new BBitmap(BRect(0, 0, size - 1, size - 1), 0,
-               B_RGBA32);
-       status_t status = bitmap->InitCheck();
-       if (status == B_OK) {
-               status = BIconUtils::GetVectorIcon(
-                       reinterpret_cast<const uint8*>(data), dataSize, bitmap);
-       };
-
-       if (status != B_OK) {
-               delete bitmap;
-               bitmap = NULL;
-       }
-
-       return bitmap;
-}
 
 
 // #pragma mark - UserInfo
diff --git a/src/apps/haikudepot/PackageInfo.h 
b/src/apps/haikudepot/PackageInfo.h
index e903851..64bc150 100644
--- a/src/apps/haikudepot/PackageInfo.h
+++ b/src/apps/haikudepot/PackageInfo.h
@@ -13,54 +13,7 @@
 
 #include "List.h"
 #include "PackageInfoListener.h"
-
-
-class BBitmap;
-class BPositionIO;
-
-
-class SharedBitmap : public BReferenceable {
-public:
-               enum Size {
-                       SIZE_ANY = -1,
-                       SIZE_16 = 0,
-                       SIZE_32 = 1,
-                       SIZE_64 = 2
-               };
-
-                                                               
SharedBitmap(BBitmap* bitmap);
-                                                               
SharedBitmap(int32 resourceID);
-                                                               
SharedBitmap(const char* mimeType);
-                                                               
SharedBitmap(BPositionIO& data);
-                                                               ~SharedBitmap();
-
-                       const BBitmap*          Bitmap(Size which);
-
-private:
-                       BBitmap*                        
_CreateBitmapFromResource(int32 size) const;
-                       BBitmap*                        
_CreateBitmapFromBuffer(int32 size) const;
-                       BBitmap*                        
_CreateBitmapFromMimeType(int32 size) const;
-
-                       BBitmap*                        
_LoadBitmapFromBuffer(const void* buffer,
-                                                                       size_t 
dataSize) const;
-                       BBitmap*                        
_LoadArchivedBitmapFromStream(
-                                                                       
BPositionIO& stream) const;
-                       BBitmap*                        
_LoadTranslatorBitmapFromStream(
-                                                                       
BPositionIO& stream) const;
-                       BBitmap*                        
_LoadIconFromBuffer(const void* buffer,
-                                                                       size_t 
dataSize, int32 size) const;
-
-private:
-                       int32                           fResourceID;
-                       uint8*                          fBuffer;
-                       off_t                           fSize;
-                       BString                         fMimeType;
-                       BBitmap*                        fBitmap[3];
-};
-
-
-typedef BReference<SharedBitmap> BitmapRef;
-typedef List<BitmapRef, false> BitmapList;
+#include "SharedBitmap.h"
 
 
 class UserInfo {
diff --git a/src/apps/haikudepot/RatingView.cpp 
b/src/apps/haikudepot/RatingView.cpp
index af62126..ab97cb1 100644
--- a/src/apps/haikudepot/RatingView.cpp
+++ b/src/apps/haikudepot/RatingView.cpp
@@ -6,6 +6,8 @@
 
 #include "RatingView.h"
 
+#include <stdio.h>
+
 
 RatingView::RatingView(const char* name)
        :
diff --git a/src/apps/haikudepot/RatingView.h b/src/apps/haikudepot/RatingView.h
index 73eb013..3f439ea 100644
--- a/src/apps/haikudepot/RatingView.h
+++ b/src/apps/haikudepot/RatingView.h
@@ -8,7 +8,7 @@
 
 #include <View.h>
 
-#include "PackageInfo.h"
+#include "SharedBitmap.h"
 
 
 class RatingView : public BView {
diff --git a/src/apps/haikudepot/SharedBitmap.cpp 
b/src/apps/haikudepot/SharedBitmap.cpp
new file mode 100644
index 0000000..70374ff
--- /dev/null
+++ b/src/apps/haikudepot/SharedBitmap.cpp
@@ -0,0 +1,274 @@
+/*
+ * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#include "SharedBitmap.h"
+
+#include <algorithm>
+#include <stdio.h>
+
+#include <Application.h>
+#include <Bitmap.h>
+#include <DataIO.h>
+#include <IconUtils.h>
+#include <Message.h>
+#include <MimeType.h>
+#include <Resources.h>
+#include <TranslationUtils.h>
+
+#include "support.h"
+
+
+SharedBitmap::SharedBitmap(BBitmap* bitmap)
+       :
+       BReferenceable(),
+       fResourceID(-1),
+       fBuffer(NULL),
+       fSize(0),
+       fMimeType()
+{
+       fBitmap[0] = bitmap;
+       fBitmap[1] = NULL;
+       fBitmap[2] = NULL;
+}
+
+
+SharedBitmap::SharedBitmap(int32 resourceID)
+       :
+       BReferenceable(),
+       fResourceID(resourceID),
+       fBuffer(NULL),
+       fSize(0),
+       fMimeType()
+{
+       fBitmap[0] = NULL;
+       fBitmap[1] = NULL;
+       fBitmap[2] = NULL;
+}
+
+
+SharedBitmap::SharedBitmap(const char* mimeType)
+       :
+       BReferenceable(),
+       fResourceID(-1),
+       fBuffer(NULL),
+       fSize(0),
+       fMimeType(mimeType)
+{
+       fBitmap[0] = NULL;
+       fBitmap[1] = NULL;
+       fBitmap[2] = NULL;
+}
+
+
+SharedBitmap::SharedBitmap(BPositionIO& data)
+       :
+       BReferenceable(),
+       fResourceID(-1),
+       fBuffer(NULL),
+       fSize(0),
+       fMimeType()
+{
+       status_t status = data.GetSize(&fSize);
+       const off_t kMaxSize = 128 * 1024;
+       if (status == B_OK && fSize > 0 && fSize <= kMaxSize) {
+               fBuffer = new(std::nothrow) uint8[fSize];
+               if (fBuffer != NULL) {
+                       data.Seek(0, SEEK_SET);
+                       
+                       off_t bytesRead = 0;
+                       size_t chunkSize = std::min((off_t)4096, fSize);
+                       while (bytesRead < fSize) {
+                               ssize_t read = data.Read(fBuffer + bytesRead, 
chunkSize);
+                               if (read > 0)
+                                       bytesRead += read;
+                               else
+                                       break;
+                       }
+       
+                       if (bytesRead != fSize) {
+                               delete[] fBuffer;
+                               fBuffer = NULL;
+                               fSize = 0;
+                       }
+               } else
+                       fSize = 0;
+       } else {
+               fprintf(stderr, "SharedBitmap(): Stream too large: %" B_PRIi64
+                       ", max: %" B_PRIi64 "\n", fSize, kMaxSize);
+       }
+
+       fBitmap[0] = NULL;
+       fBitmap[1] = NULL;
+       fBitmap[2] = NULL;
+}
+
+
+SharedBitmap::~SharedBitmap()
+{
+       delete fBitmap[0];
+       delete fBitmap[1];
+       delete fBitmap[2];
+       delete[] fBuffer;
+}
+
+
+const BBitmap*
+SharedBitmap::Bitmap(Size which)
+{
+       if (fResourceID == -1 && fMimeType.Length() == 0 && fBuffer == NULL)
+               return fBitmap[0];
+
+       int32 index = 0;
+       int32 size = 16;
+
+       switch (which) {
+               default:
+               case SIZE_16:
+                       break;
+
+               case SIZE_32:
+                       index = 1;
+                       size = 32;
+                       break;
+               case SIZE_64:
+                       index = 2;
+                       size = 64;
+                       break;
+       }
+
+       if (fBitmap[index] == NULL) {
+               if (fResourceID >= 0)
+                       fBitmap[index] = _CreateBitmapFromResource(size);
+               else if (fBuffer != NULL)
+                       fBitmap[index] = _CreateBitmapFromBuffer(size);
+               else if (fMimeType.Length() > 0)
+                       fBitmap[index] = _CreateBitmapFromMimeType(size);
+       }
+
+       return fBitmap[index];
+}
+
+
+BBitmap*
+SharedBitmap::_CreateBitmapFromResource(int32 size) const
+{
+       BResources resources;
+       status_t status = get_app_resources(resources);
+       if (status != B_OK)
+               return NULL;
+
+       size_t dataSize;
+       const void* data = resources.LoadResource(B_VECTOR_ICON_TYPE, 
fResourceID,
+               &dataSize);
+       if (data != NULL)
+               return _LoadIconFromBuffer(data, dataSize, size);
+
+       data = resources.LoadResource(B_MESSAGE_TYPE, fResourceID, &dataSize);
+       if (data != NULL)
+               return _LoadBitmapFromBuffer(data, dataSize);
+
+       return NULL;
+}
+
+
+BBitmap*
+SharedBitmap::_CreateBitmapFromBuffer(int32 size) const
+{
+       BBitmap* bitmap = _LoadIconFromBuffer(fBuffer, fSize, size);
+       
+       if (bitmap == NULL)
+               bitmap = _LoadBitmapFromBuffer(fBuffer, fSize);
+
+       return bitmap;
+}
+
+
+BBitmap*
+SharedBitmap::_CreateBitmapFromMimeType(int32 size) const
+{
+       BMimeType mimeType(fMimeType.String());
+       status_t status = mimeType.InitCheck();
+       if (status != B_OK)
+               return NULL;
+
+       BBitmap* bitmap = new BBitmap(BRect(0, 0, size - 1, size - 1), 0, 
B_RGBA32);
+       status = bitmap->InitCheck();
+       if (status == B_OK)
+               status = mimeType.GetIcon(bitmap, B_MINI_ICON);
+
+       if (status != B_OK) {
+               delete bitmap;
+               bitmap = NULL;
+       }
+
+       return bitmap;
+}
+
+
+BBitmap*
+SharedBitmap::_LoadBitmapFromBuffer(const void* buffer, size_t size) const
+{
+       BMemoryIO stream(buffer, size);
+
+       // Try to read as an archived bitmap.
+       BBitmap* bitmap = _LoadArchivedBitmapFromStream(stream);
+       
+       if (bitmap == NULL) {
+               // Try to read as a translator bitmap
+               stream.Seek(0, SEEK_SET);
+               bitmap = _LoadTranslatorBitmapFromStream(stream);
+       }
+
+       if (bitmap != NULL) {
+               status_t status = bitmap->InitCheck();
+               if (status != B_OK) {
+                       delete bitmap;
+                       bitmap = NULL;
+               }
+       }
+
+       return bitmap;
+}
+
+
+BBitmap*
+SharedBitmap::_LoadArchivedBitmapFromStream(BPositionIO& stream) const
+{
+       BMessage archive;
+       status_t status = archive.Unflatten(&stream);
+       if (status != B_OK)
+               return NULL;
+
+       return new BBitmap(&archive);
+}
+
+
+BBitmap*
+SharedBitmap::_LoadTranslatorBitmapFromStream(BPositionIO& stream) const
+{
+       return BTranslationUtils::GetBitmap(&stream);
+}
+
+
+BBitmap*
+SharedBitmap::_LoadIconFromBuffer(const void* data, size_t dataSize,
+       int32 size) const
+{
+       BBitmap* bitmap = new BBitmap(BRect(0, 0, size - 1, size - 1), 0,
+               B_RGBA32);
+       status_t status = bitmap->InitCheck();
+       if (status == B_OK) {
+               status = BIconUtils::GetVectorIcon(
+                       reinterpret_cast<const uint8*>(data), dataSize, bitmap);
+       };
+
+       if (status != B_OK) {
+               delete bitmap;
+               bitmap = NULL;
+       }
+
+       return bitmap;
+}
+
diff --git a/src/apps/haikudepot/SharedBitmap.h 
b/src/apps/haikudepot/SharedBitmap.h
new file mode 100644
index 0000000..7269466
--- /dev/null
+++ b/src/apps/haikudepot/SharedBitmap.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef SHARED_BITMAP_H
+#define SHARED_BITMAP_H
+
+
+#include <Referenceable.h>
+#include <String.h>
+
+#include "List.h"
+
+
+class BBitmap;
+class BPositionIO;
+
+
+class SharedBitmap : public BReferenceable {
+public:
+               enum Size {
+                       SIZE_ANY = -1,
+                       SIZE_16 = 0,
+                       SIZE_32 = 1,
+                       SIZE_64 = 2
+               };
+
+                                                               
SharedBitmap(BBitmap* bitmap);
+                                                               
SharedBitmap(int32 resourceID);
+                                                               
SharedBitmap(const char* mimeType);
+                                                               
SharedBitmap(BPositionIO& data);
+                                                               ~SharedBitmap();
+
+                       const BBitmap*          Bitmap(Size which);
+
+private:
+                       BBitmap*                        
_CreateBitmapFromResource(int32 size) const;
+                       BBitmap*                        
_CreateBitmapFromBuffer(int32 size) const;
+                       BBitmap*                        
_CreateBitmapFromMimeType(int32 size) const;
+
+                       BBitmap*                        
_LoadBitmapFromBuffer(const void* buffer,
+                                                                       size_t 
dataSize) const;
+                       BBitmap*                        
_LoadArchivedBitmapFromStream(
+                                                                       
BPositionIO& stream) const;
+                       BBitmap*                        
_LoadTranslatorBitmapFromStream(
+                                                                       
BPositionIO& stream) const;
+                       BBitmap*                        
_LoadIconFromBuffer(const void* buffer,
+                                                                       size_t 
dataSize, int32 size) const;
+
+private:
+                       int32                           fResourceID;
+                       uint8*                          fBuffer;
+                       off_t                           fSize;
+                       BString                         fMimeType;
+                       BBitmap*                        fBitmap[3];
+};
+
+
+typedef BReference<SharedBitmap> BitmapRef;
+typedef List<BitmapRef, false> BitmapList;
+
+
+#endif // SHARED_BITMAP_H

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

Commit:      04c9d578d85baa79584c1c40c61cc73ca58d527b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=04c9d57
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 19:37:38 2014 UTC

HaikuDepot: Organized source into sub-folders

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

diff --git a/src/apps/haikudepot/Jamfile b/src/apps/haikudepot/Jamfile
index 34421b8..38a5ac6 100644
--- a/src/apps/haikudepot/Jamfile
+++ b/src/apps/haikudepot/Jamfile
@@ -4,7 +4,7 @@ UsePrivateHeaders interface shared package ;
 
 # source directories
 local sourceDirs =
-       textview
+       model textview ui
 ;
 
 local sourceDir ;
diff --git a/src/apps/haikudepot/DecisionProvider.cpp 
b/src/apps/haikudepot/model/DecisionProvider.cpp
similarity index 100%
rename from src/apps/haikudepot/DecisionProvider.cpp
rename to src/apps/haikudepot/model/DecisionProvider.cpp
diff --git a/src/apps/haikudepot/DecisionProvider.h 
b/src/apps/haikudepot/model/DecisionProvider.h
similarity index 100%
rename from src/apps/haikudepot/DecisionProvider.h
rename to src/apps/haikudepot/model/DecisionProvider.h
diff --git a/src/apps/haikudepot/JobStateListener.cpp 
b/src/apps/haikudepot/model/JobStateListener.cpp
similarity index 100%
rename from src/apps/haikudepot/JobStateListener.cpp
rename to src/apps/haikudepot/model/JobStateListener.cpp
diff --git a/src/apps/haikudepot/JobStateListener.h 
b/src/apps/haikudepot/model/JobStateListener.h
similarity index 100%
rename from src/apps/haikudepot/JobStateListener.h
rename to src/apps/haikudepot/model/JobStateListener.h
diff --git a/src/apps/haikudepot/Model.cpp b/src/apps/haikudepot/model/Model.cpp
similarity index 100%
rename from src/apps/haikudepot/Model.cpp
rename to src/apps/haikudepot/model/Model.cpp
diff --git a/src/apps/haikudepot/Model.h b/src/apps/haikudepot/model/Model.h
similarity index 100%
rename from src/apps/haikudepot/Model.h
rename to src/apps/haikudepot/model/Model.h
diff --git a/src/apps/haikudepot/PackageAction.cpp 
b/src/apps/haikudepot/model/PackageAction.cpp
similarity index 100%
rename from src/apps/haikudepot/PackageAction.cpp
rename to src/apps/haikudepot/model/PackageAction.cpp
diff --git a/src/apps/haikudepot/PackageAction.h 
b/src/apps/haikudepot/model/PackageAction.h
similarity index 100%
rename from src/apps/haikudepot/PackageAction.h
rename to src/apps/haikudepot/model/PackageAction.h
diff --git a/src/apps/haikudepot/PackageActionHandler.cpp 
b/src/apps/haikudepot/model/PackageActionHandler.cpp
similarity index 100%
rename from src/apps/haikudepot/PackageActionHandler.cpp
rename to src/apps/haikudepot/model/PackageActionHandler.cpp
diff --git a/src/apps/haikudepot/PackageActionHandler.h 
b/src/apps/haikudepot/model/PackageActionHandler.h
similarity index 100%
rename from src/apps/haikudepot/PackageActionHandler.h
rename to src/apps/haikudepot/model/PackageActionHandler.h
diff --git a/src/apps/haikudepot/PackageInfo.cpp 
b/src/apps/haikudepot/model/PackageInfo.cpp
similarity index 100%
rename from src/apps/haikudepot/PackageInfo.cpp
rename to src/apps/haikudepot/model/PackageInfo.cpp
diff --git a/src/apps/haikudepot/PackageInfo.h 
b/src/apps/haikudepot/model/PackageInfo.h
similarity index 100%
rename from src/apps/haikudepot/PackageInfo.h
rename to src/apps/haikudepot/model/PackageInfo.h
diff --git a/src/apps/haikudepot/PackageInfoListener.cpp 
b/src/apps/haikudepot/model/PackageInfoListener.cpp
similarity index 100%
rename from src/apps/haikudepot/PackageInfoListener.cpp
rename to src/apps/haikudepot/model/PackageInfoListener.cpp
diff --git a/src/apps/haikudepot/PackageInfoListener.h 
b/src/apps/haikudepot/model/PackageInfoListener.h
similarity index 100%
rename from src/apps/haikudepot/PackageInfoListener.h
rename to src/apps/haikudepot/model/PackageInfoListener.h
diff --git a/src/apps/haikudepot/WebAppInterface.cpp 
b/src/apps/haikudepot/model/WebAppInterface.cpp
similarity index 100%
rename from src/apps/haikudepot/WebAppInterface.cpp
rename to src/apps/haikudepot/model/WebAppInterface.cpp
diff --git a/src/apps/haikudepot/WebAppInterface.h 
b/src/apps/haikudepot/model/WebAppInterface.h
similarity index 100%
rename from src/apps/haikudepot/WebAppInterface.h
rename to src/apps/haikudepot/model/WebAppInterface.h
diff --git a/src/apps/haikudepot/App.cpp b/src/apps/haikudepot/ui/App.cpp
similarity index 100%
rename from src/apps/haikudepot/App.cpp
rename to src/apps/haikudepot/ui/App.cpp
diff --git a/src/apps/haikudepot/App.h b/src/apps/haikudepot/ui/App.h
similarity index 100%
rename from src/apps/haikudepot/App.h
rename to src/apps/haikudepot/ui/App.h
diff --git a/src/apps/haikudepot/BitmapButton.cpp 
b/src/apps/haikudepot/ui/BitmapButton.cpp
similarity index 100%
rename from src/apps/haikudepot/BitmapButton.cpp
rename to src/apps/haikudepot/ui/BitmapButton.cpp
diff --git a/src/apps/haikudepot/BitmapButton.h 
b/src/apps/haikudepot/ui/BitmapButton.h
similarity index 100%
rename from src/apps/haikudepot/BitmapButton.h
rename to src/apps/haikudepot/ui/BitmapButton.h
diff --git a/src/apps/haikudepot/BitmapView.cpp 
b/src/apps/haikudepot/ui/BitmapView.cpp
similarity index 100%
rename from src/apps/haikudepot/BitmapView.cpp
rename to src/apps/haikudepot/ui/BitmapView.cpp
diff --git a/src/apps/haikudepot/BitmapView.h 
b/src/apps/haikudepot/ui/BitmapView.h
similarity index 100%
rename from src/apps/haikudepot/BitmapView.h
rename to src/apps/haikudepot/ui/BitmapView.h
diff --git a/src/apps/haikudepot/FilterView.cpp 
b/src/apps/haikudepot/ui/FilterView.cpp
similarity index 100%
rename from src/apps/haikudepot/FilterView.cpp
rename to src/apps/haikudepot/ui/FilterView.cpp
diff --git a/src/apps/haikudepot/FilterView.h 
b/src/apps/haikudepot/ui/FilterView.h
similarity index 100%
rename from src/apps/haikudepot/FilterView.h
rename to src/apps/haikudepot/ui/FilterView.h
diff --git a/src/apps/haikudepot/MainWindow.cpp 
b/src/apps/haikudepot/ui/MainWindow.cpp
similarity index 100%
rename from src/apps/haikudepot/MainWindow.cpp
rename to src/apps/haikudepot/ui/MainWindow.cpp
diff --git a/src/apps/haikudepot/MainWindow.h 
b/src/apps/haikudepot/ui/MainWindow.h
similarity index 100%
rename from src/apps/haikudepot/MainWindow.h
rename to src/apps/haikudepot/ui/MainWindow.h
diff --git a/src/apps/haikudepot/PackageInfoView.cpp 
b/src/apps/haikudepot/ui/PackageInfoView.cpp
similarity index 100%
rename from src/apps/haikudepot/PackageInfoView.cpp
rename to src/apps/haikudepot/ui/PackageInfoView.cpp
diff --git a/src/apps/haikudepot/PackageInfoView.h 
b/src/apps/haikudepot/ui/PackageInfoView.h
similarity index 100%
rename from src/apps/haikudepot/PackageInfoView.h
rename to src/apps/haikudepot/ui/PackageInfoView.h
diff --git a/src/apps/haikudepot/PackageListView.cpp 
b/src/apps/haikudepot/ui/PackageListView.cpp
similarity index 100%
rename from src/apps/haikudepot/PackageListView.cpp
rename to src/apps/haikudepot/ui/PackageListView.cpp
diff --git a/src/apps/haikudepot/PackageListView.h 
b/src/apps/haikudepot/ui/PackageListView.h
similarity index 100%
rename from src/apps/haikudepot/PackageListView.h
rename to src/apps/haikudepot/ui/PackageListView.h
diff --git a/src/apps/haikudepot/PackageManager.cpp 
b/src/apps/haikudepot/ui/PackageManager.cpp
similarity index 100%
rename from src/apps/haikudepot/PackageManager.cpp
rename to src/apps/haikudepot/ui/PackageManager.cpp
diff --git a/src/apps/haikudepot/PackageManager.h 
b/src/apps/haikudepot/ui/PackageManager.h
similarity index 100%
rename from src/apps/haikudepot/PackageManager.h
rename to src/apps/haikudepot/ui/PackageManager.h
diff --git a/src/apps/haikudepot/RatePackageWindow.cpp 
b/src/apps/haikudepot/ui/RatePackageWindow.cpp
similarity index 100%
rename from src/apps/haikudepot/RatePackageWindow.cpp
rename to src/apps/haikudepot/ui/RatePackageWindow.cpp
diff --git a/src/apps/haikudepot/RatePackageWindow.h 
b/src/apps/haikudepot/ui/RatePackageWindow.h
similarity index 100%
rename from src/apps/haikudepot/RatePackageWindow.h
rename to src/apps/haikudepot/ui/RatePackageWindow.h
diff --git a/src/apps/haikudepot/RatingView.cpp 
b/src/apps/haikudepot/ui/RatingView.cpp
similarity index 100%
rename from src/apps/haikudepot/RatingView.cpp
rename to src/apps/haikudepot/ui/RatingView.cpp
diff --git a/src/apps/haikudepot/RatingView.h 
b/src/apps/haikudepot/ui/RatingView.h
similarity index 100%
rename from src/apps/haikudepot/RatingView.h
rename to src/apps/haikudepot/ui/RatingView.h
diff --git a/src/apps/haikudepot/SharedBitmap.cpp 
b/src/apps/haikudepot/ui/SharedBitmap.cpp
similarity index 100%
rename from src/apps/haikudepot/SharedBitmap.cpp
rename to src/apps/haikudepot/ui/SharedBitmap.cpp
diff --git a/src/apps/haikudepot/SharedBitmap.h 
b/src/apps/haikudepot/ui/SharedBitmap.h
similarity index 100%
rename from src/apps/haikudepot/SharedBitmap.h
rename to src/apps/haikudepot/ui/SharedBitmap.h
diff --git a/src/apps/haikudepot/UserLoginWindow.cpp 
b/src/apps/haikudepot/ui/UserLoginWindow.cpp
similarity index 100%
rename from src/apps/haikudepot/UserLoginWindow.cpp
rename to src/apps/haikudepot/ui/UserLoginWindow.cpp
diff --git a/src/apps/haikudepot/UserLoginWindow.h 
b/src/apps/haikudepot/ui/UserLoginWindow.h
similarity index 100%
rename from src/apps/haikudepot/UserLoginWindow.h
rename to src/apps/haikudepot/ui/UserLoginWindow.h
diff --git a/src/apps/haikudepot/support.cpp 
b/src/apps/haikudepot/ui/support.cpp
similarity index 100%
rename from src/apps/haikudepot/support.cpp
rename to src/apps/haikudepot/ui/support.cpp
diff --git a/src/apps/haikudepot/support.h b/src/apps/haikudepot/ui/support.h
similarity index 100%
rename from src/apps/haikudepot/support.h
rename to src/apps/haikudepot/ui/support.h

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

Commit:      823d2b88e963cd51d30b7b7dcc22b6d32f685600
URL:         http://cgit.haiku-os.org/haiku/commit/?id=823d2b8
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 20:03:10 2014 UTC

HaikuDepot: Split generic and specific UI classes

* Also fixed placement of PackageManager which I must have
  dropped into the wrong folder by accident.

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

diff --git a/src/apps/haikudepot/Jamfile b/src/apps/haikudepot/Jamfile
index 38a5ac6..e40c09c 100644
--- a/src/apps/haikudepot/Jamfile
+++ b/src/apps/haikudepot/Jamfile
@@ -4,7 +4,7 @@ UsePrivateHeaders interface shared package ;
 
 # source directories
 local sourceDirs =
-       model textview ui
+       model textview ui ui_generic
 ;
 
 local sourceDir ;
diff --git a/src/apps/haikudepot/ui/PackageManager.cpp 
b/src/apps/haikudepot/model/PackageManager.cpp
similarity index 100%
rename from src/apps/haikudepot/ui/PackageManager.cpp
rename to src/apps/haikudepot/model/PackageManager.cpp
diff --git a/src/apps/haikudepot/ui/PackageManager.h 
b/src/apps/haikudepot/model/PackageManager.h
similarity index 100%
rename from src/apps/haikudepot/ui/PackageManager.h
rename to src/apps/haikudepot/model/PackageManager.h
diff --git a/src/apps/haikudepot/ui/BitmapButton.cpp 
b/src/apps/haikudepot/ui_generic/BitmapButton.cpp
similarity index 100%
rename from src/apps/haikudepot/ui/BitmapButton.cpp
rename to src/apps/haikudepot/ui_generic/BitmapButton.cpp
diff --git a/src/apps/haikudepot/ui/BitmapButton.h 
b/src/apps/haikudepot/ui_generic/BitmapButton.h
similarity index 100%
rename from src/apps/haikudepot/ui/BitmapButton.h
rename to src/apps/haikudepot/ui_generic/BitmapButton.h
diff --git a/src/apps/haikudepot/ui/BitmapView.cpp 
b/src/apps/haikudepot/ui_generic/BitmapView.cpp
similarity index 100%
rename from src/apps/haikudepot/ui/BitmapView.cpp
rename to src/apps/haikudepot/ui_generic/BitmapView.cpp
diff --git a/src/apps/haikudepot/ui/BitmapView.h 
b/src/apps/haikudepot/ui_generic/BitmapView.h
similarity index 100%
rename from src/apps/haikudepot/ui/BitmapView.h
rename to src/apps/haikudepot/ui_generic/BitmapView.h
diff --git a/src/apps/haikudepot/ui/RatingView.cpp 
b/src/apps/haikudepot/ui_generic/RatingView.cpp
similarity index 100%
rename from src/apps/haikudepot/ui/RatingView.cpp
rename to src/apps/haikudepot/ui_generic/RatingView.cpp
diff --git a/src/apps/haikudepot/ui/RatingView.h 
b/src/apps/haikudepot/ui_generic/RatingView.h
similarity index 100%
rename from src/apps/haikudepot/ui/RatingView.h
rename to src/apps/haikudepot/ui_generic/RatingView.h
diff --git a/src/apps/haikudepot/ui/SharedBitmap.cpp 
b/src/apps/haikudepot/ui_generic/SharedBitmap.cpp
similarity index 100%
rename from src/apps/haikudepot/ui/SharedBitmap.cpp
rename to src/apps/haikudepot/ui_generic/SharedBitmap.cpp
diff --git a/src/apps/haikudepot/ui/SharedBitmap.h 
b/src/apps/haikudepot/ui_generic/SharedBitmap.h
similarity index 100%
rename from src/apps/haikudepot/ui/SharedBitmap.h
rename to src/apps/haikudepot/ui_generic/SharedBitmap.h
diff --git a/src/apps/haikudepot/ui/support.cpp 
b/src/apps/haikudepot/ui_generic/support.cpp
similarity index 100%
rename from src/apps/haikudepot/ui/support.cpp
rename to src/apps/haikudepot/ui_generic/support.cpp
diff --git a/src/apps/haikudepot/ui/support.h 
b/src/apps/haikudepot/ui_generic/support.h
similarity index 100%
rename from src/apps/haikudepot/ui/support.h
rename to src/apps/haikudepot/ui_generic/support.h

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

Commit:      63269a60e45ccdfc9fa4eed64d2654cc2600e8c5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=63269a6
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 20:45:58 2014 UTC

HaikuDepot: Allow RatingView to be wider than MinSize().

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

diff --git a/src/apps/haikudepot/ui_generic/RatingView.cpp 
b/src/apps/haikudepot/ui_generic/RatingView.cpp
index ab97cb1..aab3174 100644
--- a/src/apps/haikudepot/ui_generic/RatingView.cpp
+++ b/src/apps/haikudepot/ui_generic/RatingView.cpp
@@ -8,6 +8,8 @@
 
 #include <stdio.h>
 
+#include <LayoutUtils.h>
+
 
 RatingView::RatingView(const char* name)
        :
@@ -62,6 +64,7 @@ RatingView::Draw(BRect updateRect)
        SetDrawingMode(B_OP_OVER);
 
        BRect rect(Bounds());
+       rect.right = x - 2;
        rect.left = ceilf(rect.left + (fRating / 5.0f) * rect.Width());
 
        rgb_color color = LowColor();
@@ -76,21 +79,22 @@ RatingView::Draw(BRect updateRect)
 BSize
 RatingView::MinSize()
 {
-       return BSize(16 * 5 + 2 * 4, 16 + 2);
+       BSize size(16 * 5 + 2 * 4, 16 + 2);
+       return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
 }
 
 
 BSize
 RatingView::PreferredSize()
 {
-       return MinSize();
+       return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), MinSize());
 }
 
 
 BSize
 RatingView::MaxSize()
 {
-       return MinSize();
+       return BLayoutUtils::ComposeSize(ExplicitMaxSize(), MinSize());
 }
 
 

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

Commit:      c28b83041e3919f35727918d0f81238ad9745f53
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c28b830
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 20:46:33 2014 UTC

HaikuDepot: Add actual rating to RatePackageWindow.

Implemented SetRatingView based on RatingView. It previews the rating
when hovering and makes it permanent when clicked.

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

diff --git a/src/apps/haikudepot/ui/RatePackageWindow.cpp 
b/src/apps/haikudepot/ui/RatePackageWindow.cpp
index 6c922c6..1c544cd 100644
--- a/src/apps/haikudepot/ui/RatePackageWindow.cpp
+++ b/src/apps/haikudepot/ui/RatePackageWindow.cpp
@@ -16,8 +16,10 @@
 #include <MenuItem.h>
 #include <PopUpMenu.h>
 #include <ScrollView.h>
+#include <StringView.h>
 
 #include "MarkupParser.h"
+#include "RatingView.h"
 #include "TextDocumentView.h"
 
 
@@ -27,6 +29,7 @@
 
 enum {
        MSG_SEND                                = 'send',
+       MSG_PACKAGE_RATED               = 'rpkg',
        MSG_STABILITY_SELECTED  = 'stbl'
 };
 
@@ -84,6 +87,51 @@ public:
 };
 
 
+class SetRatingView : public RatingView {
+public:
+       SetRatingView()
+               :
+               RatingView("rate package view"),
+               fPermanentRating(0.0f)
+       {
+               SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
+               SetRating(fPermanentRating);
+       }
+
+       virtual void MouseMoved(BPoint where, uint32 transit,
+               const BMessage* dragMessage)
+       {
+               if (dragMessage != NULL)
+                       return;
+       
+               if ((transit != B_INSIDE_VIEW && transit != B_ENTERED_VIEW)
+                       || where.x > MinSize().width) {
+                       SetRating(fPermanentRating);
+                       return;
+               }
+       
+               float hoverRating = _RatingForMousePos(where);
+               SetRating(hoverRating);
+       }
+
+       virtual void MouseDown(BPoint where)
+       {
+               fPermanentRating = _RatingForMousePos(where);
+               BMessage message(MSG_PACKAGE_RATED);
+               message.AddFloat("rating", fPermanentRating);
+               Window()->PostMessage(&message, Window());
+       }
+
+private:
+       float _RatingForMousePos(BPoint where)
+       {
+               return std::min(5.0f, ceilf(5.0f * where.x / MinSize().width));
+       }
+
+       float           fPermanentRating;
+};
+
+
 static void
 add_stabilities_to_menu(const StabilityRatingList& stabilities, BMenu* menu)
 {
@@ -102,10 +150,15 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, 
BRect frame)
        BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Your rating"),
                B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
                B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
-       fRatingText()
+       fRatingText(),
+       fRating(-1.0f)
 {
        AddToSubset(parent);
-       CenterIn(parent->Frame());
+
+       BStringView* ratingLabel = new BStringView("rating label",
+               B_TRANSLATE("Your rating:"));
+
+       SetRatingView* setRatingView = new SetRatingView();     
 
        TextDocumentView* textView = new TextDocumentView();
        ScrollView* textScrollView = new ScrollView(
@@ -154,8 +207,12 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, 
BRect frame)
 
        // Build layout
        BLayoutBuilder::Group<>(this, B_VERTICAL)
+               .AddGrid()
+                       .Add(ratingLabel, 0, 0)
+                       .Add(setRatingView, 1, 0)
+                       .AddMenuField(stabilityRatingField, 0, 1)
+               .End()
                .Add(textScrollView)
-               .Add(stabilityRatingField)
                .AddGroup(B_HORIZONTAL)
                        .AddGlue()
                        .Add(cancelButton)
@@ -166,6 +223,8 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect 
frame)
 
        // NOTE: Do not make Send the default button. The user might want
        // to type line-breaks instead of sending when hitting RETURN.
+
+       CenterIn(parent->Frame());
 }
 
 
@@ -178,13 +237,18 @@ void
 RatePackageWindow::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case MSG_SEND:
-                       _SendRating();
+               case MSG_PACKAGE_RATED:
+                       message->FindFloat("rating", &fRating);
                        break;
+
                case MSG_STABILITY_SELECTED:
                        message->FindString("name", &fStability);
                        break;
 
+               case MSG_SEND:
+                       _SendRating();
+                       break;
+
                default:
                        BWindow::MessageReceived(message);
                        break;
diff --git a/src/apps/haikudepot/ui/RatePackageWindow.h 
b/src/apps/haikudepot/ui/RatePackageWindow.h
index 5a20e7b..591167f 100644
--- a/src/apps/haikudepot/ui/RatePackageWindow.h
+++ b/src/apps/haikudepot/ui/RatePackageWindow.h
@@ -25,6 +25,7 @@ private:
 
 private:
                        TextDocumentRef         fRatingText;
+                       float                           fRating;
                        BString                         fStability;
                        PackageInfoRef          fPackage;
 };

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

Commit:      6bede507a9228c9b70421769c203db9f40ecbf6f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=6bede50
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 21:07:05 2014 UTC

HaikuDepot: Define StringList type for convenience.

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

diff --git a/src/apps/haikudepot/model/PackageInfo.h 
b/src/apps/haikudepot/model/PackageInfo.h
index 64bc150..aa9ece0 100644
--- a/src/apps/haikudepot/model/PackageInfo.h
+++ b/src/apps/haikudepot/model/PackageInfo.h
@@ -377,4 +377,7 @@ private:
 typedef List<DepotInfo, false> DepotList;
 
 
+typedef List<BString, false> StringList;
+
+
 #endif // PACKAGE_INFO_H

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

Commit:      4ff3d17ae8f8185c3a94fe35035a0fdacc582881
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4ff3d17
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 21:07:39 2014 UTC

HaikuDepot: Put supported languages into a StringList

* Added TODO to retrieve the list from the web-app, there is already an
  API for it. For now, the hard-coded list matches the web-app's and the
  next change in this regard will be to support any known language.
* Make the list accessible.

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

diff --git a/src/apps/haikudepot/model/Model.cpp 
b/src/apps/haikudepot/model/Model.cpp
index ce00590..1166117 100644
--- a/src/apps/haikudepot/model/Model.cpp
+++ b/src/apps/haikudepot/model/Model.cpp
@@ -340,12 +340,22 @@ Model::Model()
                                language.CopyInto(fPreferredLanguage, 0, 2);
                }
        }
-       if (fPreferredLanguage != "en" && fPreferredLanguage != "de"
-               && fPreferredLanguage != "fr" && fPreferredLanguage != "ja"
-               && fPreferredLanguage != "es" && fPreferredLanguage != "zh"
-               && fPreferredLanguage != "pt" && fPreferredLanguage != "ru") {
+
+       // TODO: Fetch this from the web-app.
+       fSupportedLanguages.Add("en");
+       fSupportedLanguages.Add("de");
+       fSupportedLanguages.Add("fr");
+       fSupportedLanguages.Add("ja");
+       fSupportedLanguages.Add("es");
+       fSupportedLanguages.Add("zh");
+       fSupportedLanguages.Add("pt");
+       fSupportedLanguages.Add("ru");
+
+       if (!fSupportedLanguages.Contains(fPreferredLanguage)) {
                // Force the preferred language to one of the currently 
supported
                // ones, until the web application supports all ISO language 
codes.
+               printf("User preferred language '%s' not currently supported, "
+                       "defaulting to 'en'.", fPreferredLanguage.String());
                fPreferredLanguage = "en";
        }
        fWebAppInterface.SetPreferredLanguage(fPreferredLanguage);
diff --git a/src/apps/haikudepot/model/Model.h 
b/src/apps/haikudepot/model/Model.h
index 487049c..d47aa7f 100644
--- a/src/apps/haikudepot/model/Model.h
+++ b/src/apps/haikudepot/model/Model.h
@@ -104,6 +104,9 @@ public:
                        void                            PopulateAllPackages();
                        void                            
StopPopulatingAllPackages();
 
+                       const StringList&       SupportedLanguages() const
+                                                                       { 
return fSupportedLanguages; }
+
                        const BString&          PreferredLanguage() const
                                                                        { 
return fPreferredLanguage; }
 
@@ -175,6 +178,7 @@ private:
                        thread_id                       
fPopulateAllPackagesThread;
        volatile bool                           fStopPopulatingAllPackages;
 
+                       StringList                      fSupportedLanguages;
                        BString                         fPreferredLanguage;
 
                        WebAppInterface         fWebAppInterface;

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

Commit:      da504dbccebd2f1d71cbef2b934e4ba52ef86317
URL:         http://cgit.haiku-os.org/haiku/commit/?id=da504db
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 21:09:45 2014 UTC

HaikuDepot: Allow to set the rating comment's language.

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

diff --git a/src/apps/haikudepot/ui/MainWindow.cpp 
b/src/apps/haikudepot/ui/MainWindow.cpp
index 9192131..ccf09a3 100644
--- a/src/apps/haikudepot/ui/MainWindow.cpp
+++ b/src/apps/haikudepot/ui/MainWindow.cpp
@@ -330,10 +330,11 @@ MainWindow::MessageReceived(BMessage* message)
 
                case MSG_RATE_PACKAGE:
                {
-                       // TODO: Allow only one RatingWindow
+                       // TODO: Allow only one RatePackageWindow
                        // TODO: Mechanism for remembering the window frame
                        RatePackageWindow* window = new RatePackageWindow(this,
-                               BRect(0, 0, 500, 400));
+                               BRect(0, 0, 500, 400), 
fModel.PreferredLanguage(),
+                               fModel.SupportedLanguages());
                        window->Show();
                        break;
                }
diff --git a/src/apps/haikudepot/ui/RatePackageWindow.cpp 
b/src/apps/haikudepot/ui/RatePackageWindow.cpp
index 1c544cd..f2bd396 100644
--- a/src/apps/haikudepot/ui/RatePackageWindow.cpp
+++ b/src/apps/haikudepot/ui/RatePackageWindow.cpp
@@ -30,7 +30,8 @@
 enum {
        MSG_SEND                                = 'send',
        MSG_PACKAGE_RATED               = 'rpkg',
-       MSG_STABILITY_SELECTED  = 'stbl'
+       MSG_STABILITY_SELECTED  = 'stbl',
+       MSG_LANGUAGE_SELECTED   = 'lngs'
 };
 
 //! Layouts the scrollbar so it looks nice with no border and the document
@@ -145,13 +146,28 @@ add_stabilities_to_menu(const StabilityRatingList& 
stabilities, BMenu* menu)
 }
 
 
-RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame)
+static void
+add_languages_to_menu(const StringList& languages, BMenu* menu)
+{
+       for (int i = 0; i < languages.CountItems(); i++) {
+               const BString& language = languages.ItemAtFast(i);
+               BMessage* message = new BMessage(MSG_LANGUAGE_SELECTED);
+               message->AddString("code", language);
+               BMenuItem* item = new BMenuItem(language, message);
+               menu->AddItem(item);
+       }
+}
+
+
+RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame,
+       const BString& preferredLanguage, const StringList& supportedLanguages)
        :
        BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Your rating"),
                B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
                B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
        fRatingText(),
-       fRating(-1.0f)
+       fRating(-1.0f),
+       fCommentLanguage(preferredLanguage)
 {
        AddToSubset(parent);
 
@@ -174,11 +190,10 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, 
BRect frame)
        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"));
@@ -199,6 +214,20 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, 
BRect frame)
        fStability = stabilities.ItemAt(0).Name();
        stabilityMenu->ItemAt(0)->SetMarked(true);
 
+       // Construct languages popup
+       BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language"));
+       BMenuField* languageField = new BMenuField("language",
+               B_TRANSLATE("Comment language:"), languagesMenu);
+
+       add_languages_to_menu(supportedLanguages, languagesMenu);
+       languagesMenu->SetTargetForItems(this);
+
+       BMenuItem* defaultItem = languagesMenu->ItemAt(
+               supportedLanguages.IndexOf(fCommentLanguage));
+       if (defaultItem != NULL)
+               defaultItem->SetMarked(true);
+       
+       // Construct buttons
        BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
                new BMessage(B_QUIT_REQUESTED));
 
@@ -211,6 +240,7 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect 
frame)
                        .Add(ratingLabel, 0, 0)
                        .Add(setRatingView, 1, 0)
                        .AddMenuField(stabilityRatingField, 0, 1)
+                       .AddMenuField(languageField, 0, 2)
                .End()
                .Add(textScrollView)
                .AddGroup(B_HORIZONTAL)
diff --git a/src/apps/haikudepot/ui/RatePackageWindow.h 
b/src/apps/haikudepot/ui/RatePackageWindow.h
index 591167f..1bee5b6 100644
--- a/src/apps/haikudepot/ui/RatePackageWindow.h
+++ b/src/apps/haikudepot/ui/RatePackageWindow.h
@@ -13,7 +13,9 @@
 
 class RatePackageWindow : public BWindow {
 public:
-                                                               
RatePackageWindow(BWindow* parent, BRect frame);
+                                                               
RatePackageWindow(BWindow* parent, BRect frame,
+                                                                       const 
BString& preferredLanguage,
+                                                                       const 
StringList& supportedLanguages);
        virtual                                         ~RatePackageWindow();
 
        virtual void                            MessageReceived(BMessage* 
message);
@@ -27,6 +29,7 @@ private:
                        TextDocumentRef         fRatingText;
                        float                           fRating;
                        BString                         fStability;
+                       BString                         fCommentLanguage;
                        PackageInfoRef          fPackage;
 };
 

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

Revision:    hrev47918
Commit:      83f46c7198f03c981cb985f8901744ef53b8ab6d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=83f46c7
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Sep 27 21:11:41 2014 UTC

HaikuDepot: Handle BMessage for rating comment language

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

diff --git a/src/apps/haikudepot/ui/RatePackageWindow.cpp 
b/src/apps/haikudepot/ui/RatePackageWindow.cpp
index f2bd396..fd72a69 100644
--- a/src/apps/haikudepot/ui/RatePackageWindow.cpp
+++ b/src/apps/haikudepot/ui/RatePackageWindow.cpp
@@ -275,6 +275,10 @@ RatePackageWindow::MessageReceived(BMessage* message)
                        message->FindString("name", &fStability);
                        break;
 
+               case MSG_LANGUAGE_SELECTED:
+                       message->FindString("code", &fCommentLanguage);
+                       break;
+
                case MSG_SEND:
                        _SendRating();
                        break;


Other related posts:

  • » [haiku-commits] haiku: hrev47918 - in src/apps/haikudepot: . ui model ui_generic - superstippi