2016-02-02 22:01:48 +08:00
|
|
|
#include "ads/ContainerWidget.h"
|
2016-02-12 15:00:31 +08:00
|
|
|
#include "ads/Internal.h"
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QSplitter>
|
2016-02-11 21:33:02 +08:00
|
|
|
#include <QDataStream>
|
|
|
|
#include <QtGlobal>
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
ADS_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
// Static Helper //////////////////////////////////////////////////////
|
|
|
|
|
2016-02-03 15:01:26 +08:00
|
|
|
static QSplitter* newSplitter(Qt::Orientation orientation = Qt::Horizontal, QWidget* parent = 0)
|
2015-12-09 19:21:38 +08:00
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
QSplitter* s = new QSplitter(orientation, parent);
|
2015-12-09 19:21:38 +08:00
|
|
|
s->setChildrenCollapsible(false);
|
|
|
|
s->setOpaqueResize(false);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:55:45 +08:00
|
|
|
static void dropContentOuterHelper(ContainerWidget* cw, QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append)
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
SectionWidget* sw = new SectionWidget(cw);
|
2016-02-01 17:55:45 +08:00
|
|
|
sw->addContent(data, true);
|
|
|
|
|
|
|
|
QSplitter* oldsp = findImmediateSplitter(cw);
|
|
|
|
if (oldsp->orientation() == orientation
|
2016-02-11 21:33:02 +08:00
|
|
|
|| oldsp->count() == 1)
|
2016-02-01 17:55:45 +08:00
|
|
|
{
|
|
|
|
oldsp->setOrientation(orientation);
|
|
|
|
if (append)
|
|
|
|
oldsp->addWidget(sw);
|
|
|
|
else
|
|
|
|
oldsp->insertWidget(0, sw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
QSplitter* sp = newSplitter(orientation);
|
2016-02-01 17:55:45 +08:00
|
|
|
if (append)
|
|
|
|
{
|
2016-02-12 15:00:31 +08:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-02-11 22:02:42 +08:00
|
|
|
QLayoutItem* li = l->replaceWidget(oldsp, sp);
|
2016-02-01 17:55:45 +08:00
|
|
|
sp->addWidget(oldsp);
|
|
|
|
sp->addWidget(sw);
|
|
|
|
delete li;
|
2016-02-12 15:00:31 +08:00
|
|
|
#else
|
|
|
|
int index = l->indexOf(oldsp);
|
|
|
|
QLayoutItem* li = l->takeAt(index);
|
|
|
|
sp->addWidget(oldsp);
|
|
|
|
sp->addWidget(sw);
|
|
|
|
delete li;
|
|
|
|
#endif
|
2016-02-01 17:55:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-12 15:00:31 +08:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-02-01 17:55:45 +08:00
|
|
|
sp->addWidget(sw);
|
2016-02-11 22:02:42 +08:00
|
|
|
QLayoutItem* li = l->replaceWidget(oldsp, sp);
|
2016-02-01 17:55:45 +08:00
|
|
|
sp->addWidget(oldsp);
|
|
|
|
delete li;
|
2016-02-12 15:00:31 +08:00
|
|
|
#else
|
|
|
|
sp->addWidget(sw);
|
|
|
|
int index = l->indexOf(oldsp);
|
|
|
|
QLayoutItem* li = l->takeAt(index);
|
|
|
|
sp->addWidget(oldsp);
|
|
|
|
delete li;
|
|
|
|
#endif
|
2016-02-01 17:55:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ContainerWidget::ContainerWidget(QWidget *parent) :
|
|
|
|
QFrame(parent),
|
|
|
|
_mainLayout(NULL),
|
|
|
|
_orientation(Qt::Horizontal),
|
|
|
|
_splitter(NULL)
|
|
|
|
{
|
|
|
|
_mainLayout = new QGridLayout();
|
|
|
|
_mainLayout->setContentsMargins(9, 9, 9, 9);
|
2016-02-02 17:13:11 +08:00
|
|
|
_mainLayout->setSpacing(0);
|
2015-12-09 19:21:38 +08:00
|
|
|
setLayout(_mainLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::Orientation ContainerWidget::orientation() const
|
|
|
|
{
|
|
|
|
return _orientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContainerWidget::setOrientation(Qt::Orientation orientation)
|
|
|
|
{
|
|
|
|
if (_orientation != orientation)
|
|
|
|
{
|
|
|
|
_orientation = orientation;
|
|
|
|
emit orientationChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContainerWidget::dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area)
|
|
|
|
{
|
2016-02-01 17:55:45 +08:00
|
|
|
// Drop on outer area
|
2015-12-09 19:21:38 +08:00
|
|
|
if (!targetSection)
|
|
|
|
{
|
2016-02-01 17:55:45 +08:00
|
|
|
switch (area)
|
|
|
|
{
|
|
|
|
case TopDropArea:
|
|
|
|
dropContentOuterHelper(this, _mainLayout, data, Qt::Vertical, false);
|
|
|
|
break;
|
|
|
|
case RightDropArea:
|
|
|
|
dropContentOuterHelper(this, _mainLayout, data, Qt::Horizontal, true);
|
|
|
|
break;
|
|
|
|
case BottomDropArea:
|
|
|
|
dropContentOuterHelper(this, _mainLayout, data, Qt::Vertical, true);
|
|
|
|
break;
|
|
|
|
case LeftDropArea:
|
|
|
|
dropContentOuterHelper(this, _mainLayout, data, Qt::Horizontal, false);
|
|
|
|
break;
|
2016-02-03 17:50:34 +08:00
|
|
|
default:
|
|
|
|
return;
|
2016-02-01 17:55:45 +08:00
|
|
|
}
|
2015-12-09 19:21:38 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-03 15:01:26 +08:00
|
|
|
QSplitter* targetSectionSplitter = findParentSplitter(targetSection);
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
// Drop logic based on area.
|
|
|
|
switch (area)
|
|
|
|
{
|
|
|
|
case TopDropArea:
|
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
SectionWidget* sw = new SectionWidget(this);
|
2015-12-09 19:21:38 +08:00
|
|
|
sw->addContent(data, true);
|
|
|
|
if (targetSectionSplitter->orientation() == Qt::Vertical)
|
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
const int index = targetSectionSplitter->indexOf(targetSection);
|
2015-12-09 19:21:38 +08:00
|
|
|
targetSectionSplitter->insertWidget(index, sw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
const int index = targetSectionSplitter->indexOf(targetSection);
|
|
|
|
QSplitter* s = newSplitter(Qt::Vertical);
|
2015-12-09 19:21:38 +08:00
|
|
|
s->addWidget(sw);
|
|
|
|
s->addWidget(targetSection);
|
|
|
|
targetSectionSplitter->insertWidget(index, s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RightDropArea:
|
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
SectionWidget* sw = new SectionWidget(this);
|
2015-12-09 19:21:38 +08:00
|
|
|
sw->addContent(data, true);
|
|
|
|
if (targetSectionSplitter->orientation() == Qt::Horizontal)
|
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
const int index = targetSectionSplitter->indexOf(targetSection);
|
2015-12-09 19:21:38 +08:00
|
|
|
targetSectionSplitter->insertWidget(index + 1, sw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
const int index = targetSectionSplitter->indexOf(targetSection);
|
|
|
|
QSplitter* s = newSplitter(Qt::Horizontal);
|
2015-12-09 19:21:38 +08:00
|
|
|
s->addWidget(targetSection);
|
|
|
|
s->addWidget(sw);
|
|
|
|
targetSectionSplitter->insertWidget(index, s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BottomDropArea:
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
SectionWidget* sw = new SectionWidget(this);
|
2015-12-09 19:21:38 +08:00
|
|
|
sw->addContent(data, true);
|
|
|
|
if (targetSectionSplitter->orientation() == Qt::Vertical)
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
int index = targetSectionSplitter->indexOf(targetSection);
|
2015-12-09 19:21:38 +08:00
|
|
|
targetSectionSplitter->insertWidget(index + 1, sw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
int index = targetSectionSplitter->indexOf(targetSection);
|
|
|
|
QSplitter* s = newSplitter(Qt::Vertical);
|
2015-12-09 19:21:38 +08:00
|
|
|
s->addWidget(targetSection);
|
|
|
|
s->addWidget(sw);
|
|
|
|
targetSectionSplitter->insertWidget(index, s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LeftDropArea:
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
SectionWidget* sw = new SectionWidget(this);
|
2015-12-09 19:21:38 +08:00
|
|
|
sw->addContent(data, true);
|
|
|
|
if (targetSectionSplitter->orientation() == Qt::Horizontal)
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
int index = targetSectionSplitter->indexOf(targetSection);
|
2015-12-09 19:21:38 +08:00
|
|
|
targetSectionSplitter->insertWidget(index, sw);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
QSplitter* s = newSplitter(Qt::Horizontal);
|
2015-12-09 19:21:38 +08:00
|
|
|
s->addWidget(sw);
|
2016-02-11 22:02:42 +08:00
|
|
|
int index = targetSectionSplitter->indexOf(targetSection);
|
2015-12-09 19:21:38 +08:00
|
|
|
targetSectionSplitter->insertWidget(index, s);
|
|
|
|
s->addWidget(targetSection);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CenterDropArea:
|
|
|
|
{
|
|
|
|
targetSection->addContent(data, true);
|
|
|
|
break;
|
|
|
|
}
|
2016-02-03 17:50:34 +08:00
|
|
|
default:
|
|
|
|
break;
|
2015-12-09 19:21:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContainerWidget::addSection(SectionWidget* section)
|
|
|
|
{
|
|
|
|
// Create default splitter.
|
|
|
|
if (!_splitter)
|
|
|
|
{
|
2016-02-03 15:01:26 +08:00
|
|
|
_splitter = newSplitter(_orientation);
|
2015-12-09 19:21:38 +08:00
|
|
|
_mainLayout->addWidget(_splitter, 0, 0);
|
|
|
|
}
|
|
|
|
if (_splitter->indexOf(section) != -1)
|
|
|
|
{
|
|
|
|
qWarning() << Q_FUNC_INFO << QString("Section has already been added");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_splitter->addWidget(section);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContainerWidget::splitSections(SectionWidget* s1, SectionWidget* s2, Qt::Orientation orientation)
|
|
|
|
{
|
|
|
|
addSection(s1);
|
|
|
|
addSection(s2);
|
|
|
|
|
2016-02-02 20:49:10 +08:00
|
|
|
QSplitter* currentSplitter = findParentSplitter(s1);
|
2015-12-09 19:21:38 +08:00
|
|
|
if (currentSplitter)
|
|
|
|
{
|
|
|
|
const int index = currentSplitter->indexOf(s1);
|
2016-02-03 15:01:26 +08:00
|
|
|
QSplitter* splitter = newSplitter(orientation, this);
|
2015-12-09 19:21:38 +08:00
|
|
|
splitter->addWidget(s1);
|
|
|
|
splitter->addWidget(s2);
|
|
|
|
currentSplitter->insertWidget(index, splitter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionWidget* ContainerWidget::sectionAt(const QPoint& pos) const
|
|
|
|
{
|
2016-02-02 20:49:10 +08:00
|
|
|
const QPoint gpos = mapToGlobal(pos);
|
2015-12-09 19:21:38 +08:00
|
|
|
for (int i = 0; i < _sections.size(); ++i)
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
SectionWidget* sw = _sections[i];
|
2015-12-09 19:21:38 +08:00
|
|
|
if (sw->rect().contains(sw->mapFromGlobal(gpos)))
|
|
|
|
{
|
|
|
|
return sw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect ContainerWidget::outerTopDropRect() const
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
QRect r = rect();
|
|
|
|
int h = r.height() / 100 * 5;
|
2015-12-09 19:21:38 +08:00
|
|
|
return QRect(r.left(), r.top(), r.width(), h);
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect ContainerWidget::outerRightDropRect() const
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
QRect r = rect();
|
|
|
|
int w = r.width() / 100 * 5;
|
2015-12-09 19:21:38 +08:00
|
|
|
return QRect(r.right() - w, r.top(), w, r.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect ContainerWidget::outerBottomDropRect() const
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
QRect r = rect();
|
|
|
|
int h = r.height() / 100 * 5;
|
2015-12-09 19:21:38 +08:00
|
|
|
return QRect(r.left(), r.bottom() - h, r.width(), h);
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect ContainerWidget::outerLeftDropRect() const
|
|
|
|
{
|
2016-02-11 22:02:42 +08:00
|
|
|
QRect r = rect();
|
|
|
|
int w = r.width() / 100 * 5;
|
2015-12-09 19:21:38 +08:00
|
|
|
return QRect(r.left(), r.top(), w, r.height());
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:43:34 +08:00
|
|
|
QByteArray ContainerWidget::saveState() const
|
2016-02-01 17:55:45 +08:00
|
|
|
{
|
|
|
|
QByteArray ba;
|
|
|
|
QDataStream out(&ba, QIODevice::WriteOnly);
|
|
|
|
out.setVersion(QDataStream::Qt_4_5);
|
2016-02-11 21:33:02 +08:00
|
|
|
out << (quint32) 0x00001337; // Magic
|
|
|
|
out << (quint32) 1; // Version
|
|
|
|
|
|
|
|
// Walk through layout for splitters
|
|
|
|
// Well.. there actually shouldn't be more than one
|
|
|
|
for (int i = 0; i < _mainLayout->count(); ++i)
|
|
|
|
{
|
|
|
|
QLayoutItem* li = _mainLayout->itemAt(i);
|
|
|
|
if (!li->widget())
|
|
|
|
continue;
|
|
|
|
saveGeometryWalk(out, li->widget());
|
|
|
|
}
|
2016-02-01 17:55:45 +08:00
|
|
|
return ba;
|
|
|
|
}
|
|
|
|
|
2016-02-12 18:43:34 +08:00
|
|
|
bool ContainerWidget::restoreState(const QByteArray& data)
|
2016-02-01 17:55:45 +08:00
|
|
|
{
|
|
|
|
QDataStream in(data);
|
|
|
|
in.setVersion(QDataStream::Qt_4_5);
|
|
|
|
|
2016-02-11 21:33:02 +08:00
|
|
|
quint32 magic = 0;
|
2016-02-01 17:55:45 +08:00
|
|
|
in >> magic;
|
2016-02-11 21:33:02 +08:00
|
|
|
if (magic != 0x00001337)
|
|
|
|
return false;
|
2016-02-01 17:55:45 +08:00
|
|
|
|
2016-02-11 21:33:02 +08:00
|
|
|
quint32 version = 0;
|
|
|
|
in >> version;
|
|
|
|
if (version != 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QList<SectionWidget*> currentSections = _sections;
|
|
|
|
_sections.clear();
|
|
|
|
|
|
|
|
const bool success = restoreGeometryWalk(in, NULL);
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
QLayoutItem* old = _mainLayout->takeAt(0);
|
|
|
|
_mainLayout->addWidget(_splitter);
|
|
|
|
delete old;
|
|
|
|
qDeleteAll(currentSections);
|
|
|
|
}
|
|
|
|
return success;
|
2016-02-01 17:55:45 +08:00
|
|
|
}
|
|
|
|
|
2016-02-02 20:49:10 +08:00
|
|
|
QMenu* ContainerWidget::createContextMenu() const
|
2015-12-09 19:21:38 +08:00
|
|
|
{
|
2016-02-02 20:49:10 +08:00
|
|
|
QMenu* m = new QMenu(const_cast<ContainerWidget*>(this));
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-02 20:49:10 +08:00
|
|
|
// Contents of SectionWidgets
|
|
|
|
for (int i = 0; i < _sections.size(); ++i)
|
|
|
|
{
|
|
|
|
SectionWidget* sw = _sections.at(i);
|
|
|
|
QList<SectionContent::RefPtr> contents = sw->contents();
|
|
|
|
foreach (const SectionContent::RefPtr& c, contents)
|
|
|
|
{
|
|
|
|
m->addAction(QIcon(), QString("Content %1").arg(c->uid()));
|
|
|
|
}
|
|
|
|
}
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-02 20:49:10 +08:00
|
|
|
// Contents of FloatingWidgets
|
|
|
|
if (_floatingWidgets.size())
|
|
|
|
{
|
|
|
|
if (m->actions().size())
|
|
|
|
m->addSeparator();
|
|
|
|
for (int i = 0; i < _floatingWidgets.size(); ++i)
|
|
|
|
{
|
|
|
|
FloatingWidget* fw = _floatingWidgets.at(i);
|
|
|
|
SectionContent::RefPtr c = fw->content();
|
2016-02-03 15:01:26 +08:00
|
|
|
QAction* a = m->addAction(QIcon(), QString("Floating %1").arg(c->uid()));
|
|
|
|
a->setCheckable(true);
|
|
|
|
a->setChecked(fw->isVisible());
|
2016-02-12 15:00:31 +08:00
|
|
|
#if QT_VERSION >= 0x050000
|
2016-02-03 16:15:07 +08:00
|
|
|
QObject::connect(a, &QAction::toggled, fw, &FloatingWidget::setVisible);
|
2016-02-12 15:00:31 +08:00
|
|
|
#else
|
|
|
|
QObject::connect(a, SIGNAL(toggled(bool)), fw, SLOT(setVisible(bool)));
|
|
|
|
#endif
|
2016-02-02 20:49:10 +08:00
|
|
|
}
|
|
|
|
}
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-02 20:49:10 +08:00
|
|
|
return m;
|
2015-12-09 19:21:38 +08:00
|
|
|
}
|
|
|
|
|
2016-02-11 21:33:02 +08:00
|
|
|
void ContainerWidget::saveGeometryWalk(QDataStream& out, QWidget* widget) const
|
|
|
|
{
|
|
|
|
QSplitter* sp = NULL;
|
|
|
|
SectionWidget* sw = NULL;
|
|
|
|
|
|
|
|
if (!widget)
|
|
|
|
{
|
|
|
|
out << 0;
|
|
|
|
}
|
|
|
|
else if ((sp = dynamic_cast<QSplitter*>(widget)) != NULL)
|
|
|
|
{
|
|
|
|
out << 1; // Type = QSplitter
|
|
|
|
out << ((sp->orientation() == Qt::Horizontal) ? (int) 1 : (int) 2);
|
|
|
|
out << sp->count();
|
2016-02-11 21:42:55 +08:00
|
|
|
out << sp->sizes();
|
2016-02-11 21:33:02 +08:00
|
|
|
for (int i = 0; i < sp->count(); ++i)
|
|
|
|
{
|
|
|
|
saveGeometryWalk(out, sp->widget(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((sw = dynamic_cast<SectionWidget*>(widget)) != NULL)
|
|
|
|
{
|
|
|
|
out << 2; // Type = SectionWidget
|
2016-02-11 21:51:38 +08:00
|
|
|
out << sw->currentIndex();
|
2016-02-11 21:33:02 +08:00
|
|
|
out << sw->contents().count();
|
|
|
|
const QList<SectionContent::RefPtr>& contents = sw->contents();
|
|
|
|
for (int i = 0; i < contents.count(); ++i)
|
|
|
|
{
|
|
|
|
out << contents[i]->uniqueName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ContainerWidget::restoreGeometryWalk(QDataStream& in, QSplitter* currentSplitter)
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
in >> type;
|
|
|
|
|
|
|
|
// Splitter
|
|
|
|
if (type == 1)
|
|
|
|
{
|
|
|
|
int orientation, count;
|
2016-02-11 21:42:55 +08:00
|
|
|
QList<int> sizes;
|
|
|
|
in >> orientation >> count >> sizes;
|
2016-02-11 21:33:02 +08:00
|
|
|
|
|
|
|
QSplitter* sp = newSplitter((Qt::Orientation) orientation);
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
if (!restoreGeometryWalk(in, sp))
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-11 21:42:55 +08:00
|
|
|
sp->setSizes(sizes);
|
|
|
|
|
2016-02-11 21:33:02 +08:00
|
|
|
if (!currentSplitter)
|
|
|
|
_splitter = sp;
|
|
|
|
else
|
|
|
|
currentSplitter->addWidget(sp);
|
|
|
|
}
|
|
|
|
// Section
|
|
|
|
else if (type == 2)
|
|
|
|
{
|
|
|
|
if (!currentSplitter)
|
|
|
|
{
|
|
|
|
qWarning() << "Missing splitter object for section";
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-11 21:51:38 +08:00
|
|
|
|
|
|
|
int currentIndex, count;
|
|
|
|
in >> currentIndex >> count;
|
2016-02-11 21:33:02 +08:00
|
|
|
|
|
|
|
SectionWidget* sw = new SectionWidget(this);
|
2016-02-11 21:42:55 +08:00
|
|
|
// sw->setGeometry(geom);
|
2016-02-11 21:33:02 +08:00
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
QString name;
|
|
|
|
in >> name;
|
|
|
|
SectionContent::RefPtr sc = SectionContent::LookupMapByName.value(name).toStrongRef();
|
|
|
|
if (sc)
|
|
|
|
sw->addContent(sc);
|
|
|
|
}
|
2016-02-11 21:51:38 +08:00
|
|
|
sw->setCurrentIndex(currentIndex);
|
2016-02-11 21:33:02 +08:00
|
|
|
currentSplitter->addWidget(sw);
|
|
|
|
}
|
|
|
|
// Unknown
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << QString("");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:50:34 +08:00
|
|
|
ADS_NAMESPACE_END
|