53 #include "QtMultiViewLayout.hh" 60 QtMultiViewLayout::QtMultiViewLayout (QGraphicsLayoutItem * _parent) :
61 QGraphicsLayout (_parent),
93 if ((
int) _i > count ())
113 for (
int i = 0; i < 4; i++)
122 QGraphicsLayoutItem * QtMultiViewLayout::itemAt(
int _i)
const 124 if (_i < 0 || _i > 3)
131 void QtMultiViewLayout::removeAt (
int _index)
133 if (_index < 0 || _index > 3)
140 QSizeF QtMultiViewLayout::sizeHint(Qt::SizeHint ,
const QSizeF & _constraint)
const 149 QGraphicsLayoutItem::setGeometry (rect);
158 QRectF r = contentsRect ();
160 if (!items_[primary_])
165 if (mode == SingleView)
167 for (
int i = 0; i < 4; i++)
169 items_[primary_]->show ();
170 }
else if ( mode == DoubleView) {
171 for (
int i = 0; i < 2; i++)
174 for (
int i = 2; i < 4; i++)
178 for (
int i = 0; i < 4; i++)
186 items_[primary_]->setGeometry (r);
190 int width = (r.width() - spacing_) / 2;
191 int height = r.height();
192 items_[0]->resize (width, height);
193 items_[1]->resize (width, height);
195 items_[0]->setPos(r.topLeft());
196 items_[1]->setPos(r.x() + width + spacing_, r.y());
201 int width = (r.width() - spacing_) / 2;
202 int height = (r.height() - spacing_) / 2;
203 items_[0]->resize (width, height);
204 items_[1]->resize (r.width() - width - spacing_, height);
205 items_[2]->resize (width, r.height() - height - spacing_);
206 items_[3]->resize (r.width() - width - spacing_,r.height() - height - spacing_);
207 items_[0]->setPos (r.topLeft());
208 items_[1]->setPos (r.x() + width + spacing_, r.y());
209 items_[2]->setPos (r.x(), r.y() + height + spacing_);
210 items_[3]->setPos (r.x() + width + spacing_, r.y() + height + spacing_);
217 for (
unsigned int i = 0, j = 1; i < 4; i++)
220 int width = (r.width() - spacing_) * 3 / 4;
221 int ewidth = r.width() - spacing_ - width;
222 int eheight = (r.height() - (spacing_ * 2)) / 3;
223 items_[order[0]]->resize (width, r.height());
224 items_[order[1]]->resize (ewidth, eheight);
225 items_[order[2]]->resize (ewidth, eheight);
226 items_[order[3]]->resize (ewidth, r.height() - ((eheight + spacing_) * 2));
227 items_[order[0]]->setPos (r.topLeft());
228 items_[order[1]]->setPos (r.x() + width + spacing_, r.y());
229 items_[order[2]]->setPos (r.x() + width + spacing_, r.y() + eheight + spacing_);
230 items_[order[3]]->setPos (r.x() + width + spacing_,
231 r.y() + ((eheight + spacing_) * 2));
void reLayout()
Recalculate layout.
virtual void setGeometry(const QRectF &rect)
Tracks geometry changes.
void setPrimary(unsigned int _i)
Sets primary element for SingleView and HSplit.
virtual int count() const
Pure virtual functions that have to be implemented.
void setSpacing(unsigned int _s)
Sets space between items.
void setMode(MultiViewMode _mode)
Sets layout mode.
void addItem(QGraphicsWidget *_item, unsigned int _pos)
Adds Widget to Layout.
MultiViewMode
MultiView display modes.