mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 05:22:06 +08:00
Implemented support for dropping mutiple sections into sections
This commit is contained in:
parent
0edc1b4499
commit
938afb7357
@ -67,23 +67,24 @@ void deleteEmptySplitter(MainContainerWidget* container)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSplitter* findParentSplitter(class QWidget* w)
|
QSplitter* findParentSplitter(QWidget* w)
|
||||||
{
|
{
|
||||||
QSplitter* cw = 0;
|
QSplitter* splitter = 0;
|
||||||
QWidget* next = w;
|
QWidget* parentWidget = w;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ((cw = dynamic_cast<QSplitter*>(next)) != 0)
|
if ((splitter = dynamic_cast<QSplitter*>(parentWidget)) != 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
next = next->parentWidget();
|
parentWidget = parentWidget->parentWidget();
|
||||||
}
|
}
|
||||||
while (next);
|
while (parentWidget);
|
||||||
return cw;
|
return splitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSplitter* findImmediateSplitter(class QWidget* w)
|
|
||||||
|
QSplitter* findImmediateSplitter(QWidget* w)
|
||||||
{
|
{
|
||||||
QLayout* l = w->layout();
|
QLayout* l = w->layout();
|
||||||
if (!l || l->count() <= 0)
|
if (!l || l->count() <= 0)
|
||||||
|
@ -293,6 +293,7 @@ void CContainerWidget::dropIntoSection(FloatingWidget* FloatingWidget,
|
|||||||
std::cout << "target->orientaton " << targetSectionSplitter->orientation()
|
std::cout << "target->orientaton " << targetSectionSplitter->orientation()
|
||||||
<< " orien " << Orientation << std::endl;
|
<< " orien " << Orientation << std::endl;
|
||||||
int index = targetSectionSplitter->indexOf(targetSection);
|
int index = targetSectionSplitter->indexOf(targetSection);
|
||||||
|
std::cout << "targetSectionSplitter->indexOf(targetSection) " << index << std::endl;
|
||||||
if (targetSectionSplitter->orientation() == Orientation)
|
if (targetSectionSplitter->orientation() == Orientation)
|
||||||
{
|
{
|
||||||
std::cout << "targetSectionSplitter->orientation() == Orientation" << std::endl;
|
std::cout << "targetSectionSplitter->orientation() == Orientation" << std::endl;
|
||||||
@ -326,50 +327,18 @@ void CContainerWidget::dropIntoSection(FloatingWidget* FloatingWidget,
|
|||||||
s->addWidget(FloatingMainSplitter);
|
s->addWidget(FloatingMainSplitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->addWidget(targetSection);
|
if (!InsertIndexOffset)
|
||||||
|
{
|
||||||
|
s->addWidget(targetSection);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s->insertWidget(0, targetSection);
|
||||||
|
}
|
||||||
targetSectionSplitter->insertWidget(index, s);
|
targetSectionSplitter->insertWidget(index, s);
|
||||||
}
|
}
|
||||||
FloatingWidget->deleteLater();
|
FloatingWidget->deleteLater();
|
||||||
|
m_Sections.append(SectionWidgets);
|
||||||
/* InternalContentData data;
|
|
||||||
if (!sectionwidget->takeContent(m_Content->uid(), data))
|
|
||||||
{
|
|
||||||
qWarning() << "THIS SHOULD NOT HAPPEN!!" << m_Content->uid();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FloatingWidget* fw = new FloatingWidget(cw, data.content, data.titleWidget, data.contentWidget, cw);
|
|
||||||
fw->resize(sectionwidget->size());
|
|
||||||
fw->setObjectName("FloatingWidget");
|
|
||||||
fw->startFloating(m_DragStartMousePosition);
|
|
||||||
|
|
||||||
// Delete old section, if it is empty now.
|
|
||||||
if (sectionwidget->contents().isEmpty())
|
|
||||||
{
|
|
||||||
delete sectionwidget;
|
|
||||||
sectionwidget = NULL;
|
|
||||||
}
|
|
||||||
deleteEmptySplitter(cw);*/
|
|
||||||
|
|
||||||
|
|
||||||
/*QSplitter* targetSectionSplitter = findParentSplitter(targetSection);
|
|
||||||
SectionWidget* sw = newSectionWidget();
|
|
||||||
sw->addContent(data, true);
|
|
||||||
if (targetSectionSplitter->orientation() == Orientation)
|
|
||||||
{
|
|
||||||
const int index = targetSectionSplitter->indexOf(targetSection);
|
|
||||||
targetSectionSplitter->insertWidget(index + InsertIndexOffset, sw);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const int index = targetSectionSplitter->indexOf(targetSection);
|
|
||||||
QSplitter* s = MainContainerWidget::newSplitter(Orientation);
|
|
||||||
s->addWidget(sw);
|
|
||||||
s->addWidget(targetSection);
|
|
||||||
targetSectionSplitter->insertWidget(index, s);
|
|
||||||
}
|
|
||||||
ret = sw;
|
|
||||||
return ret;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,6 +171,7 @@ void SectionTitleWidget::startFloating(QMouseEvent* ev, MainContainerWidget* cw,
|
|||||||
FloatingWidget* fw;
|
FloatingWidget* fw;
|
||||||
if (sectionwidget->contentCount() > 1)
|
if (sectionwidget->contentCount() > 1)
|
||||||
{
|
{
|
||||||
|
// If section widget has multiple tabs, we take only one tab
|
||||||
InternalContentData data;
|
InternalContentData data;
|
||||||
if (!sectionwidget->takeContent(m_Content->uid(), data))
|
if (!sectionwidget->takeContent(m_Content->uid(), data))
|
||||||
{
|
{
|
||||||
@ -181,7 +182,27 @@ void SectionTitleWidget::startFloating(QMouseEvent* ev, MainContainerWidget* cw,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// If section widget has only one content widget, we can move the complete
|
||||||
|
// section widget into floating widget
|
||||||
|
QSplitter* splitter = findParentSplitter(sectionwidget);
|
||||||
fw = new FloatingWidget(cw, sectionwidget);
|
fw = new FloatingWidget(cw, sectionwidget);
|
||||||
|
if (splitter && splitter->count() == 1)
|
||||||
|
{
|
||||||
|
// if splitter contains only one section widget, then we can
|
||||||
|
// remove the splitter and replace it with the section widget
|
||||||
|
std::cout << "splitter->count() == 1" << std::endl;
|
||||||
|
SectionWidget* sectionwidget = dynamic_cast<SectionWidget*>(splitter->widget(0));
|
||||||
|
QSplitter* parentSplitter = dynamic_cast<QSplitter*>(splitter->parentWidget());
|
||||||
|
if (parentSplitter)
|
||||||
|
{
|
||||||
|
sectionwidget->setParent(0);
|
||||||
|
int index = parentSplitter->indexOf(splitter);
|
||||||
|
splitter->setParent(0);
|
||||||
|
parentSplitter->insertWidget(index, sectionwidget);
|
||||||
|
delete splitter;
|
||||||
|
std::cout << "Index of splitter " << index << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fw->resize(sectionwidget->size());
|
fw->resize(sectionwidget->size());
|
||||||
|
Loading…
Reference in New Issue
Block a user