61 #include "QtMultiViewLayout.hh" 68 QtMultiViewLayout::QtMultiViewLayout (QGraphicsLayoutItem * _parent) :
69 QGraphicsLayout (_parent),
101 if ((
int) _i > count ())
121 for (
int i = 0; i < 4; i++)
130 QGraphicsLayoutItem * QtMultiViewLayout::itemAt(
int _i)
const 132 if (_i < 0 || _i > 3)
139 void QtMultiViewLayout::removeAt (
int _index)
141 if (_index < 0 || _index > 3)
148 QSizeF QtMultiViewLayout::sizeHint(Qt::SizeHint ,
const QSizeF & _constraint)
const 157 QGraphicsLayoutItem::setGeometry (rect);
166 QRectF r = contentsRect ();
168 if (!items_[primary_])
173 if (mode == SingleView)
175 for (
int i = 0; i < 4; i++)
177 items_[primary_]->show ();
178 }
else if ( mode == DoubleView) {
179 for (
int i = 0; i < 2; i++)
182 for (
int i = 2; i < 4; i++)
186 for (
int i = 0; i < 4; i++)
194 items_[primary_]->setGeometry (r);
198 int width = (r.width() - spacing_) / 2;
199 int height = r.height();
200 items_[0]->resize (width, height);
201 items_[1]->resize (width, height);
203 items_[0]->setPos(r.topLeft());
204 items_[1]->setPos(r.x() + width + spacing_, r.y());
209 int width = (r.width() - spacing_) / 2;
210 int height = (r.height() - spacing_) / 2;
211 items_[0]->resize (width, height);
212 items_[1]->resize (r.width() - width - spacing_, height);
213 items_[2]->resize (width, r.height() - height - spacing_);
214 items_[3]->resize (r.width() - width - spacing_,r.height() - height - spacing_);
215 items_[0]->setPos (r.topLeft());
216 items_[1]->setPos (r.x() + width + spacing_, r.y());
217 items_[2]->setPos (r.x(), r.y() + height + spacing_);
218 items_[3]->setPos (r.x() + width + spacing_, r.y() + height + spacing_);
225 for (
unsigned int i = 0, j = 1; i < 4; i++)
228 int width = (r.width() - spacing_) * 3 / 4;
229 int ewidth = r.width() - spacing_ - width;
230 int eheight = (r.height() - (spacing_ * 2)) / 3;
231 items_[order[0]]->resize (width, r.height());
232 items_[order[1]]->resize (ewidth, eheight);
233 items_[order[2]]->resize (ewidth, eheight);
234 items_[order[3]]->resize (ewidth, r.height() - ((eheight + spacing_) * 2));
235 items_[order[0]]->setPos (r.topLeft());
236 items_[order[1]]->setPos (r.x() + width + spacing_, r.y());
237 items_[order[2]]->setPos (r.x() + width + spacing_, r.y() + eheight + spacing_);
238 items_[order[3]]->setPos (r.x() + width + spacing_,
239 r.y() + ((eheight + spacing_) * 2));
void addItem(QGraphicsWidget *_item, unsigned int _pos)
Adds Widget to Layout.
virtual int count() const
Pure virtual functions that have to be implemented.
void setPrimary(unsigned int _i)
Sets primary element for SingleView and HSplit.
void setMode(MultiViewMode _mode)
Sets layout mode.
MultiViewMode
MultiView display modes.
void setSpacing(unsigned int _s)
Sets space between items.
void reLayout()
Recalculate layout.
virtual void setGeometry(const QRectF &rect)
Tracks geometry changes.