[Silica] GridItem lacks "hidden" property

REPRODUCIBILITY: 100%
OS VERSION: 4.4.0.72 (but likely all)
HARDWARE: n/a
UI LANGUAGE: n/a
REGRESSION: no

DESCRIPTION:

Sailfish Silica provides ListItem and GridItem QML types, intended to be use as delegates in SilicaListView and SilicaGridView types, respectively.

ListItem exposes a hidden property, which allows delegates to not be displayed in a View, while their data remains in the model. This is very useful.

GridItem is very similar in purpose, but does not have a hidden property.

PRECONDITIONS:

none

STEPS TO REPRODUCE:

  1. Write some kind of Silica-based application
  2. Use SilicaListView and ListItem to show some elements in the UI
  3. Use ListItem::hidden to hide some of those elements
  4. Make a UI design decision to switch from a ListView to a GridView
  5. Find that it’s not as simple as changing the delegate type, as hidden is not available any more.

EXPECTED RESULT:

Similar/equivalent/compatible features of
SilicaListView + ListItem, and SilicaGridView + GridItem QML types.

ACTUAL RESULT:

n/a

MODIFICATIONS:

n/a

ADDITIONAL INFORMATION:

I realize that this may be considered a Feature Request rather than a bug, but I think my expectation of these type pairs to be compatible/exchangeable is reasonable in the light of the use case described under “Steps”.

1 Like

Implementing the hidden property appears to be quite simple, by copying how ListItem does it, but I have not done any noteworthy testing with this:

--- a/a/GridItem.qml
+++ b/b/GridItem.qml
@@ -39,6 +39,8 @@ import "private"
 ViewItem {
     id: gridItem

+    property bool hidden
+
     property bool openRemorseBelow: width < Theme.itemSizeHuge
     property Item _gridView
     property Item __silica_remorse_content
@@ -95,6 +97,16 @@ ViewItem {
                     target: gridItem
                     z: 1000
                 }
+            },
+            State {
+                when: gridItem.hidden
+                name: "hidden"
+                PropertyChanges {
+                    target: gridItem
+                    contentHeight: 0
+                    enabled: false
+                    opacity: 0.0
+                }
             }
         ]
         transitions: Transition {

… or, as a user of GridItem, without hacking upstream Silica components:

GridView {
    // [...]
    delegate: GridItem { id: gitem
            // [...]
            // replicate the 'hidden' property from Sailfish.Silica.ListItem
            property bool hidden
            Item {
                states: State {
                    when: gitem.hidden
                    name: "hidden"
                    PropertyChanges {
                        target: gitem
                        contentHeight: 0
                        enabled: false
                        opacity: 0.0
                    }
                }
            }
        }
    }
3 Likes

Thanks for the report and your proposed solution @nephros. As you point out, it’s debatable that maybe this should be a feature request, but I’ve recorded it as a bug and set it here as tracked.

If there are any updates, I’ll do my best to post them back here.

2 Likes