[hyena/gtk3] ListView: convert an if-else-if block into a nested-if



commit a266cc2bbc0fb0122c73e83cba316482ea4e6103
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Fri Sep 6 13:14:17 2013 +0200

    ListView: convert an if-else-if block into a nested-if
    
    The fact that we had a comment "// model is null" in the else-if
    part of this if-block was a strong evidence that the code was
    not very readable to begin with, so we morph this to convert it
    into a nested if block in the UpdateAdjustments() method, and
    we remove the comment (even though this provides a higher level
    of indentation, it will help to make the next commit after this,
    much more understandable).
    
    No change of behaviour in this commit.

 .../ListView/ListView_Interaction.cs               |   46 ++++++++++---------
 1 files changed, 24 insertions(+), 22 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs 
b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
index 4c533a5..8368175 100644
--- a/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
+++ b/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
@@ -1023,30 +1023,32 @@ namespace Hyena.Data.Gui
                 }
             }
 
-            if (vadjustment != null && model != null) {
-                // FIXME: hard-coded grid logic
-                if (ViewLayout != null) {
-                    vadjustment.Upper = ViewLayout.VirtualSize.Height;
-                    vadjustment.StepIncrement = ViewLayout.ChildSize.Height;
-                } else {
-                    vadjustment.Upper = ChildSize.Height * model.Count;
-                    vadjustment.StepIncrement = ChildSize.Height;
-                }
+            if (vadjustment != null) {
 
-                if (vadjustment.Value + vadjustment.PageSize > vadjustment.Upper) {
-                    vadjustment.Value = Math.Max (0, vadjustment.Upper - vadjustment.PageSize);
-                }
-                if (vadjustment.Upper > 0 && vadjustment.Upper < vadjustment.PageSize) {
-                    vadjustment.Upper = vadjustment.PageSize;
+                if (model != null) {
+                    // FIXME: hard-coded grid logic
+                    if (ViewLayout != null) {
+                        vadjustment.Upper = ViewLayout.VirtualSize.Height;
+                        vadjustment.StepIncrement = ViewLayout.ChildSize.Height;
+                    } else {
+                        vadjustment.Upper = ChildSize.Height * model.Count;
+                        vadjustment.StepIncrement = ChildSize.Height;
+                    }
+
+                    if (vadjustment.Value + vadjustment.PageSize > vadjustment.Upper) {
+                        vadjustment.Value = Math.Max (0, vadjustment.Upper - vadjustment.PageSize);
+                    }
+                    if (vadjustment.Upper > 0 && vadjustment.Upper < vadjustment.PageSize) {
+                        vadjustment.Upper = vadjustment.PageSize;
+                    }
+                } else {
+                    vadjustment.Upper = 0;
+                    vadjustment.Lower = 0;
+                    vadjustment.PageSize = 0;
+                    vadjustment.PageIncrement = 0;
+                    vadjustment.StepIncrement = 0;
+                    vadjustment.Value = 0;
                 }
-            } else if (vadjustment != null) {
-                // model is null
-                vadjustment.Upper = 0;
-                vadjustment.Lower = 0;
-                vadjustment.PageSize = 0;
-                vadjustment.PageIncrement = 0;
-                vadjustment.StepIncrement = 0;
-                vadjustment.Value = 0;
             }
 
             if (hadjustment != null) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]