Class: Qt::AdaptiveGridLayout

Inherits:
GridLayout show all
Defined in:
lib/cosmos/gui/qt.rb

Instance Method Summary collapse

Methods inherited from GridLayout

#initialize

Constructor Details

This class inherits a constructor from Qt::GridLayout

Instance Method Details

#addWidget(widget) ⇒ Object



741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/cosmos/gui/qt.rb', line 741

def addWidget(widget)
  case (count() + 1)
  when 3 # reorder things to add a second column
    old = takeAt(1)
    addItem(old, 0, 1)
    super(widget)
  when 7 # reorder everything to add a third column
    items = []
    # Take the items in reverse order because taking an item changes the indexes
    5.downto(2).each {|index| items << takeAt(index)}
    # Reverse the items to get them back into insertion order
    items.reverse!
    addItem(items[0], 0, 2)
    addItem(items[1], 1, 0)
    addItem(items[2], 1, 1)
    addItem(items[3], 1, 2)
    super(widget)
  # When we have established the desired number of rows we can add things and GridLayout does the right thing
  else
    super(widget)
  end
end