[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sdk/kdevplatform/sublime
From:       Alexander Dymo <adymo () kdevelop ! org>
Date:       2009-12-15 23:52:47
Message-ID: 1260921167.730740.25852.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1062785 by dymo:

Do not allow to resize toolviews above certain size. That size is computed as:
- the maximum size at which splitters aren't covered by toolbars and other toolviews
- the maximum size at which other toolviews  maintain their minimum size

The calculation is not optimal in case of unlocked (unanchored) toolviews. Also it \
doesn't let the toolview to cover the whole central space. But in any case, now it \
should not be possible to get "unfixable" toolview sizes by dragging splitters.

BUG:217553


 M  +103 -0    ideallayout.cpp  
 M  +2 -0      ideallayout.h  


--- trunk/extragear/sdk/kdevplatform/sublime/ideallayout.cpp #1062784:1062785
@@ -390,6 +390,105 @@
     }
 }
 
+QSize IdealMainLayout::maximumSize() const
+{
+    return QLayout::maximumSize();
+}
+
+void IdealMainLayout::maximumSize(IdealMainLayout::Role role, int& maxWidth, int& \
maxHeight) const +{
+    IdealMainLayout::Role oppositeRole;
+    QList<IdealMainLayout::Role> rolesInBetween;
+    
+    switch (role) {
+        case Left:
+            oppositeRole = Right;
+            if (!m_bottomOwnsBottomLeft) rolesInBetween << Bottom;
+            if (!m_topOwnsTopLeft) rolesInBetween << Top;
+            break;
+        case Right:
+            oppositeRole = Left; 
+            if (!m_bottomOwnsBottomRight) rolesInBetween << Bottom;
+            if (!m_topOwnsTopRight) rolesInBetween << Top;
+            break;
+        case Top:
+            oppositeRole = Bottom;
+            if (m_topOwnsTopLeft) rolesInBetween << Left;
+            if (m_topOwnsTopRight) rolesInBetween << Right;
+            break;
+        case Bottom:
+            oppositeRole = Top; 
+            if (m_bottomOwnsBottomLeft) rolesInBetween << Left;
+            if (m_bottomOwnsBottomRight) rolesInBetween << Right;
+            break;
+        default:
+            break;
+    }
+    
+    maxWidth = geometry().width();
+    maxHeight = geometry().height();
+    
+    foreach (QLayoutItem* item, m_items[oppositeRole]->items()) {
+        const QSize itemSizeHint = item->sizeHint();
+        switch (role) {
+            case Left:
+            case Right:
+                if (m_items[oppositeRole]->anchored)
+                    maxWidth -= itemSizeHint.width() + splitterWidth();
+                break;
+
+            case Top:
+            case Bottom:
+                if (m_items[oppositeRole]->anchored)
+                    maxHeight -= itemSizeHint.height() + splitterWidth();
+                break;
+                
+            default:
+                break;
+        }
+    }
+
+    int betweenWidth = 0;
+    int betweenHeight = 0;
+    foreach (IdealMainLayout::Role betweenRole, rolesInBetween) {
+        int betweenWidthForRole = 0;
+        int betweenHeightForRole = 0;
+        foreach (QLayoutItem* item, m_items[betweenRole]->items()) {
+            const QSize itemSizeHint = item->sizeHint();
+            switch (role) {
+                case Left:
+                case Right:
+                    if (m_items[betweenRole]->anchored)
+                        betweenWidthForRole += itemSizeHint.width();
+                    break;
+
+                case Top:
+                case Bottom:
+                    if (m_items[betweenRole]->anchored)
+                        betweenHeightForRole += itemSizeHint.height();
+                    break;
+                    
+                default:
+                    break;
+            }
+        }
+        betweenWidth = qMax(betweenWidth, betweenWidthForRole);
+        betweenHeight = qMax(betweenHeight, betweenHeightForRole);
+    }
+    maxWidth -= betweenWidth;
+    maxHeight -= betweenHeight;
+
+    int centralWidth = 50;
+    int centralHeight = 50;
+    foreach (QLayoutItem* item, m_items[Central]->items()) {
+        const QSize itemSizeHint = item->sizeHint();
+        centralWidth = qMax(itemSizeHint.width(), centralWidth);
+        centralHeight = qMax(itemSizeHint.height(), centralHeight);
+    }
+    maxWidth -= centralWidth;
+    maxHeight -= centralHeight;
+}
+
 QLayoutItem * IdealMainLayout::itemAt(int index) const
 {
     int at = 0;
@@ -786,8 +885,12 @@
     int newWidth = thickness - offset;
     int minWidth = 0, softMinWidth = 0, minHeight = 0, softMinHeight = 0;
     minimumSize(role, minWidth, softMinWidth, minHeight, softMinHeight);
+    int maxWidth = 0, maxHeight = 0;
+    maximumSize(role, maxWidth, maxHeight);
     if (newWidth < ((role == Left || role == Right) ? minWidth : minHeight))
         return; //do not resize widget below its minimum size
+    if (newWidth > ((role == Left || role == Right) ? maxWidth : maxHeight))
+        return; //do not resize widget above its maximum size
 
     m_items[role]->width = newWidth;
 
--- trunk/extragear/sdk/kdevplatform/sublime/ideallayout.h #1062784:1062785
@@ -121,6 +121,7 @@
     void maximizeWidget(QWidget* widget);
 
     virtual QSize minimumSize() const;
+    virtual QSize maximumSize() const;
 
     virtual QSize sizeHint() const;
 
@@ -162,6 +163,7 @@
     void layout(Role role1, Role role2, Role role3, Role role4, QRect& rect) const;
     void layoutItem(Role role, QRect& rect) const;
     void minimumSize(Role role, int& minWidth, int& softMinWidth, int& minHeight, \
int& softMinHeight) const; +    void maximumSize(Role role, int& maxWidth, int& \
maxHeight) const;  
 private:
     void createArea(Role role);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic