[haiku-commits] Change in haiku[master]: HaikuDepot: Changelog & Contents Tabs

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 20 May 2020 11:02:28 +0000

From Andrew Lindesay <apl@xxxxxxxxxxxxxx>:

Andrew Lindesay has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2749 ;)


Change subject: HaikuDepot: Changelog & Contents Tabs
......................................................................

HaikuDepot: Changelog & Contents Tabs

Disable the changelog tab in the case that a package
has no changelog.  Also disable the contents tab and
do not attempt to load the package contents in the
case where a package is not installed on the host.

Resolves #15299
---
M src/apps/haikudepot/model/PackageInfo.cpp
M src/apps/haikudepot/model/PackageInfo.h
M src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp
M src/apps/haikudepot/server/schema/dumpexportpkg.json
M src/apps/haikudepot/server/schema/dumpexportreference.json
M src/apps/haikudepot/ui/PackageContentsView.cpp
M src/apps/haikudepot/ui/PackageContentsView.h
M src/apps/haikudepot/ui/PackageInfoView.cpp
8 files changed, 127 insertions(+), 83 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/49/2749/1

diff --git a/src/apps/haikudepot/model/PackageInfo.cpp 
b/src/apps/haikudepot/model/PackageInfo.cpp
index 855d193..fe5b850 100644
--- a/src/apps/haikudepot/model/PackageInfo.cpp
+++ b/src/apps/haikudepot/model/PackageInfo.cpp
@@ -1,7 +1,7 @@
 /*
  * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
  * Copyright 2013, Rene Gollent <rene@xxxxxxxxxxx>.
- * Copyright 2016-2019, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * Copyright 2016-2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */

@@ -547,6 +547,7 @@
        fPublisher(publisher),
        fShortDescription(shortDescription),
        fFullDescription(fullDescription),
+       fHasChangelog(false),
        fChangelog(),
        fCategories(),
        fUserRatings(),
@@ -578,6 +579,7 @@
        fPublisher(other.fPublisher),
        fShortDescription(other.fShortDescription),
        fFullDescription(other.fFullDescription),
+       fHasChangelog(other.fHasChangelog),
        fChangelog(other.fChangelog),
        fCategories(other.fCategories),
        fUserRatings(other.fUserRatings),
@@ -611,6 +613,7 @@
        fPublisher = other.fPublisher;
        fShortDescription = other.fShortDescription;
        fFullDescription = other.fFullDescription;
+       fHasChangelog = other.fHasChangelog;
        fChangelog = other.fChangelog;
        fCategories = other.fCategories;
        fUserRatings = other.fUserRatings;
@@ -642,6 +645,7 @@
                && fPublisher == other.fPublisher
                && fShortDescription == other.fShortDescription
                && fFullDescription == other.fFullDescription
+               && fHasChangelog == other.fHasChangelog
                && fChangelog == other.fChangelog
                && fCategories == other.fCategories
                && fUserRatings == other.fUserRatings
@@ -715,6 +719,13 @@


 void
+PackageInfo::SetHasChangelog(bool value)
+{
+       fHasChangelog = value;
+}
+
+
+void
 PackageInfo::SetChangelog(const BString& changelog)
 {
        if (fChangelog != changelog) {
diff --git a/src/apps/haikudepot/model/PackageInfo.h 
b/src/apps/haikudepot/model/PackageInfo.h
index 512b6a4..89d1fb6 100644
--- a/src/apps/haikudepot/model/PackageInfo.h
+++ b/src/apps/haikudepot/model/PackageInfo.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
- * Copyright 2016-2019, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * Copyright 2016-2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 #ifndef PACKAGE_INFO_H
@@ -286,6 +286,10 @@
                        void                            SetIcon(const 
BitmapRef& icon);
                        const BitmapRef&        Icon() const
                                                                        { 
return fIcon; }
+
+                       void                            SetHasChangelog(bool 
value);
+                       bool                            HasChangelog() const
+                                                                       { 
return fHasChangelog; }
                        void                            SetChangelog(const 
BString& changelog);
                        const BString&          Changelog() const
                                                                        { 
return fChangelog; }
@@ -380,6 +384,7 @@
                        PublisherInfo           fPublisher;
                        BString                         fShortDescription;
                        BString                         fFullDescription;
+                       bool                            fHasChangelog;
                        BString                         fChangelog;
                        CategoryList            fCategories;
                        UserRatingList          fUserRatings;
diff --git a/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp 
b/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp
index 6e4695a..5e219fb 100644
--- a/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp
+++ b/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2019, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * Copyright 2017-2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */

@@ -159,6 +159,8 @@

        package->SetRatingSummary(summary);

+       package->SetHasChangelog(pkg->HasChangelog());
+
        if (!pkg->ProminenceOrderingIsNull())
                package->SetProminence(pkg->ProminenceOrdering());

diff --git a/src/apps/haikudepot/server/schema/dumpexportpkg.json 
b/src/apps/haikudepot/server/schema/dumpexportpkg.json
index 7130418..653d76f 100644
--- a/src/apps/haikudepot/server/schema/dumpexportpkg.json
+++ b/src/apps/haikudepot/server/schema/dumpexportpkg.json
@@ -17,6 +17,9 @@
     "derivedRating": {
       "type": "number"
     },
+    "hasChangelog": {
+      "type": "boolean"
+    },
     "pkgScreenshots": {
       "type": "array",
       "items": {
diff --git a/src/apps/haikudepot/server/schema/dumpexportreference.json 
b/src/apps/haikudepot/server/schema/dumpexportreference.json
index 08eb684..cd171f3 100644
--- a/src/apps/haikudepot/server/schema/dumpexportreference.json
+++ b/src/apps/haikudepot/server/schema/dumpexportreference.json
@@ -5,68 +5,71 @@
   "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReference",
   "type": "object",
   "properties": {
-       "naturalLanguages": {
-         "type": "array",
-         "items": {
-               "type": "object",
-               "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceNaturalLanguage",
-               "properties": {
-                 "code": {
-                       "type": "string"
-                 },
-                 "name": {
-                       "type": "string"
-                 },
-                 "isPopular": {
-                       "type": "boolean"
-                 }
-               }
-         }
-       },
-       "pkgCategories": {
-         "type": "array",
-         "items": {
-               "type": "object",
-               "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferencePkgCategory",
-               "properties": {
-                 "code": {
-                       "type": "string"
-                 },
-                 "name": {
-                       "type": "string"
-                 }
-               }
-         }
-       },
-       "userRatingStabilities": {
-         "type": "array",
-         "items": {
-               "type": "object",
-               "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceUserRatingStability",
-               "properties": {
-                 "code": {
-                       "type": "string"
-                 },
-                 "name": {
-                       "type": "string"
-                 }
-               }
-         }
-       },
-       "countries": {
-         "type": "array",
-         "items": {
-               "type": "object",
-               "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceCountry",
-               "properties": {
-                 "code": {
-                       "type": "string"
-                 },
-                 "name": {
-                       "type": "string"
-                 }
-               }
-         }
-       }
+    "naturalLanguages": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceNaturalLanguage",
+        "properties": {
+          "code": {
+            "type": "string"
+          },
+          "name": {
+            "type": "string"
+          },
+          "isPopular": {
+            "type": "boolean"
+          }
+        }
+      }
+    },
+    "pkgCategories": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferencePkgCategory",
+        "properties": {
+          "code": {
+            "type": "string"
+          },
+          "name": {
+            "type": "string"
+          }
+        }
+      }
+    },
+    "userRatingStabilities": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceUserRatingStability",
+        "properties": {
+          "code": {
+            "type": "string"
+          },
+          "name": {
+            "type": "string"
+          },
+          "ordering": {
+            "type": "integer"
+          }
+        }
+      }
+    },
+    "countries": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "javaType": 
"org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceCountry",
+        "properties": {
+          "code": {
+            "type": "string"
+          },
+          "name": {
+            "type": "string"
+          }
+        }
+      }
+    }
   }
 }
\ No newline at end of file
diff --git a/src/apps/haikudepot/ui/PackageContentsView.cpp 
b/src/apps/haikudepot/ui/PackageContentsView.cpp
index 5d2e0c8..0a29ce0 100644
--- a/src/apps/haikudepot/ui/PackageContentsView.cpp
+++ b/src/apps/haikudepot/ui/PackageContentsView.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright 2015, TigerKid001.
+ * Copyright 2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>
  * All rights reserved. Distributed under the terms of the MIT License.
  */

@@ -293,9 +294,6 @@
                return;
        }

-//     printf("PackageContentsView::SetPackage(%s)\n",
-//             package.Get() != NULL ? package->Name().String() : "NULL");
-
        Clear();

        {
@@ -303,7 +301,12 @@
                fPackage = package;
                fLastPackageState = package.Get() != NULL ? package->State() : 
NONE;
        }
-       release_sem_etc(fContentPopulatorSem, 1, 0);
+
+       // if the package is not installed then there is no point in attempting 
to
+       // populate data for it.
+
+       if (package.Get() != NULL && package->State() == ACTIVATED)
+               release_sem_etc(fContentPopulatorSem, 1, 0);
 }


@@ -349,7 +352,7 @@
                }

                if (package.Get() != NULL) {
-                       if (!view->_PopuplatePackageContens(*package.Get())) {
+                       if (!view->_PopulatePackageContents(*package.Get())) {
                                if (view->LockLooperWithTimeout(1000000) == 
B_OK) {
                                        view->fContentListView->AddItem(
                                                new 
BStringItem(B_TRANSLATE("<Package contents not "
@@ -365,7 +368,7 @@


 bool
-PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
+PackageContentsView::_PopulatePackageContents(const PackageInfo& package)
 {
        BPath packagePath;

@@ -386,7 +389,7 @@
                                return false;
                        }
                } else {
-                       
printf("PackageContentsView::_PopuplatePackageContens(): "
+                       
printf("PackageContentsView::_PopulatePackageContents(): "
                                "unknown install location");
                        return false;
                }
@@ -400,7 +403,7 @@

        status_t status = reader.Init(packagePath.Path());
        if (status != B_OK) {
-               printf("PackageContentsView::_PopuplatePackageContens(): "
+               printf("PackageContentsView::_PopulatePackageContents(): "
                        "failed to init BPackageReader(%s): %s\n",
                        packagePath.Path(), strerror(status));
                return false;
@@ -411,7 +414,7 @@
                fPackageLock, fPackage);
        status = reader.ParseContent(&contentHandler);
        if (status != B_OK) {
-               printf("PackageContentsView::_PopuplatePackageContens(): "
+               printf("PackageContentsView::_PopulatePackageContents(): "
                        "failed parse package contents: %s\n", 
strerror(status));
                // NOTE: Do not return false, since it taken to mean this
                // is a remote package, but is it not, we simply want to stop
diff --git a/src/apps/haikudepot/ui/PackageContentsView.h 
b/src/apps/haikudepot/ui/PackageContentsView.h
index 136a53c..a5d44c6 100644
--- a/src/apps/haikudepot/ui/PackageContentsView.h
+++ b/src/apps/haikudepot/ui/PackageContentsView.h
@@ -1,5 +1,6 @@
 /*
  * Copyright 2015, TigerKid001.
+ * Copyright 2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 #ifndef PACKAGE_CONTENTS_VIEW_H
@@ -27,7 +28,7 @@
 private:
                        void                            _InitContentPopulator();
        static  int32                           _ContentPopulatorThread(void* 
arg);
-                       bool                            
_PopuplatePackageContens(
+                       bool                            
_PopulatePackageContents(
                                                                        const 
PackageInfo& package);
                        int32                           _InstallLocation(
                                                                        const 
PackageInfo& package) const;
diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp 
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 1d8f604..1358197 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
- * Copyright 2018-2019, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * Copyright 2018-2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */

@@ -54,6 +54,14 @@
 #define B_TRANSLATION_CONTEXT "PackageInfoView"


+enum {
+       TAB_ABOUT               = 0,
+       TAB_RATINGS             = 1,
+       TAB_CHANGELOG   = 2,
+       TAB_CONTENTS    = 3
+};
+
+
 static const float kContentTint = (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0f;


@@ -1223,12 +1231,12 @@
                AddTab(fChangelogView);
                AddTab(fContentsView);

-               TabAt(0)->SetLabel(B_TRANSLATE("About"));
-               TabAt(1)->SetLabel(B_TRANSLATE("Ratings"));
-               TabAt(2)->SetLabel(B_TRANSLATE("Changelog"));
-               TabAt(3)->SetLabel(B_TRANSLATE("Contents"));
+               TabAt(TAB_ABOUT)->SetLabel(B_TRANSLATE("About"));
+               TabAt(TAB_RATINGS)->SetLabel(B_TRANSLATE("Ratings"));
+               TabAt(TAB_CHANGELOG)->SetLabel(B_TRANSLATE("Changelog"));
+               TabAt(TAB_CONTENTS)->SetLabel(B_TRANSLATE("Contents"));

-               Select(0);
+               Select(TAB_ABOUT);
        }

        virtual ~PagesView()
@@ -1239,7 +1247,15 @@
        void SetPackage(const PackageInfoRef& package, bool switchToDefaultTab)
        {
                if (switchToDefaultTab)
-                       Select(0);
+                       Select(TAB_ABOUT);
+
+               TabAt(TAB_CHANGELOG)->SetEnabled(
+                       package.Get() != NULL && package->HasChangelog());
+               TabAt(TAB_CONTENTS)->SetEnabled(
+                       package.Get() != NULL && package->State() == ACTIVATED);
+               Invalidate(TabFrame(TAB_CHANGELOG));
+               Invalidate(TabFrame(TAB_CONTENTS));
+
                fAboutView->SetPackage(*package.Get());
                fUserRatingsView->SetPackage(*package.Get());
                fChangelogView->SetPackage(*package.Get());

--
To view, visit https://review.haiku-os.org/c/haiku/+/2749
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Id17daf46aba6709f35438db2ee30f3485fc251ea
Gerrit-Change-Number: 2749
Gerrit-PatchSet: 1
Gerrit-Owner: Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: HaikuDepot: Changelog & Contents Tabs - Gerrit