mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Continued refactoring, created private ContainerWidget class
This commit is contained in:
parent
889d9bff5b
commit
3fd20fad16
@ -15,36 +15,13 @@ class QGridLayout;
|
||||
#include "ads/SectionContent.h"
|
||||
#include "ads/FloatingWidget.h"
|
||||
#include "ads/Serialization.h"
|
||||
#include "ContainerWidget_p.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
class SectionWidget;
|
||||
class DropOverlay;
|
||||
class InternalContentData;
|
||||
|
||||
struct ContainerWidgetPrivate
|
||||
{
|
||||
// Elements inside container.
|
||||
QList<SectionWidget*> sections;
|
||||
QList<FloatingWidget*> floatings;
|
||||
QHash<int, HiddenSectionItem> hiddenSectionContents;
|
||||
|
||||
|
||||
// Helper lookup maps, restricted to this container.
|
||||
QHash<int, SectionContent::WeakPtr> scLookupMapById;
|
||||
QHash<QString, SectionContent::WeakPtr> scLookupMapByName;
|
||||
QHash<int, SectionWidget*> swLookupMapById;
|
||||
|
||||
|
||||
// Layout stuff
|
||||
QGridLayout* mainLayout = nullptr;;
|
||||
Qt::Orientation orientation = Qt::Horizontal;
|
||||
QPointer<QSplitter> splitter; // $mfreiholz: I'd like to remove this variable entirely,
|
||||
// because it changes during user interaction anyway.
|
||||
|
||||
// Drop overlay stuff.
|
||||
QPointer<DropOverlay> dropOverlay;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* ContainerWidget is the main container to provide the docking
|
||||
@ -130,13 +107,6 @@ public:
|
||||
// Advanced Public API
|
||||
// You usually should not need access to this methods
|
||||
//
|
||||
|
||||
// Outer DropAreas
|
||||
QRect outerTopDropRect() const;
|
||||
QRect outerRightDropRect() const;
|
||||
QRect outerBottomDropRect() const;
|
||||
QRect outerLeftDropRect() const;
|
||||
|
||||
/*!
|
||||
* \brief contents
|
||||
* \return List of known SectionContent for this ContainerWidget.
|
||||
|
57
AdvancedDockingSystem/include/ads/ContainerWidget_p.h
Normal file
57
AdvancedDockingSystem/include/ads/ContainerWidget_p.h
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef ContainerWidget_pH
|
||||
#define ContainerWidget_pH
|
||||
//============================================================================
|
||||
/// \file ContainerWidget_p.h
|
||||
/// \author Uwe Kindler
|
||||
/// \date 21.01.2017
|
||||
/// \brief Declaration of
|
||||
//============================================================================
|
||||
|
||||
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QPointer>
|
||||
#include <QGridLayout>
|
||||
#include <QSplitter>
|
||||
|
||||
#include "ads/DropOverlay.h"
|
||||
|
||||
namespace ads
|
||||
{
|
||||
|
||||
class SectionWidget;
|
||||
class FloatingWidget;
|
||||
class HiddenSectionItem;
|
||||
|
||||
|
||||
struct ContainerWidgetPrivate
|
||||
{
|
||||
// Elements inside container.
|
||||
QList<SectionWidget*> sections;
|
||||
QList<FloatingWidget*> floatings;
|
||||
QHash<int, HiddenSectionItem> hiddenSectionContents;
|
||||
|
||||
|
||||
// Helper lookup maps, restricted to this container.
|
||||
QHash<int, SectionContent::WeakPtr> SectionContentIdMap;
|
||||
QHash<QString, SectionContent::WeakPtr> SectionContentNameMap;
|
||||
QHash<int, SectionWidget*> SectionWidgetIdMap;
|
||||
|
||||
|
||||
// Layout stuff
|
||||
QGridLayout* mainLayout = nullptr;
|
||||
Qt::Orientation orientation = Qt::Horizontal;
|
||||
QPointer<QSplitter> splitter; // $mfreiholz: I'd like to remove this variable entirely,
|
||||
// because it changes during user interaction anyway.
|
||||
|
||||
// Drop overlay stuff.
|
||||
QPointer<DropOverlay> dropOverlay;
|
||||
QWidget* LeftBorderDropArea;
|
||||
};
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif // ContainerWidget_pH
|
@ -27,9 +27,6 @@ public:
|
||||
|
||||
void setAllowedAreas(DropAreas areas);
|
||||
DropAreas allowedAreas() const;
|
||||
|
||||
void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
|
||||
|
||||
DropArea cursorLocation() const;
|
||||
|
||||
DropArea showDropOverlay(QWidget* target);
|
||||
@ -51,12 +48,9 @@ protected:
|
||||
private:
|
||||
DropAreas _allowedAreas;
|
||||
DropOverlayCross* _cross;
|
||||
|
||||
bool _fullAreaDrop;
|
||||
QPointer<QWidget> _target;
|
||||
QRect _targetRect;
|
||||
DropArea _lastLocation;
|
||||
QWidget* m_LeftBorderDropArea;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -41,6 +41,10 @@ ContainerWidget::ContainerWidget(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
d(new ContainerWidgetPrivate())
|
||||
{
|
||||
d->LeftBorderDropArea = DropOverlay::createDropIndicatorWidget(LeftBorderDropArea);
|
||||
d->LeftBorderDropArea->setVisible(false);
|
||||
d->LeftBorderDropArea->setWindowTitle("LeftBorderDropArea");
|
||||
|
||||
d->dropOverlay = new DropOverlay(this);
|
||||
d->mainLayout = new QGridLayout();
|
||||
d->mainLayout->setContentsMargins(4, 4, 4, 4);
|
||||
@ -64,9 +68,9 @@ ContainerWidget::~ContainerWidget()
|
||||
FloatingWidget* fw = d->floatings.takeLast();
|
||||
delete fw;
|
||||
}
|
||||
d->scLookupMapById.clear();
|
||||
d->scLookupMapByName.clear();
|
||||
d->swLookupMapById.clear();
|
||||
d->SectionContentIdMap.clear();
|
||||
d->SectionContentNameMap.clear();
|
||||
d->SectionWidgetIdMap.clear();
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -157,7 +161,7 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
||||
hsi.data.titleWidget->setVisible(true);
|
||||
hsi.data.contentWidget->setVisible(true);
|
||||
SectionWidget* sw = nullptr;
|
||||
if (hsi.preferredSectionId > 0 && (sw = d->swLookupMapById.value(hsi.preferredSectionId)) != nullptr)
|
||||
if (hsi.preferredSectionId > 0 && (sw = d->SectionWidgetIdMap.value(hsi.preferredSectionId)) != nullptr)
|
||||
{
|
||||
sw->addContent(hsi.data, true);
|
||||
emit sectionContentVisibilityChanged(sc, true);
|
||||
@ -410,37 +414,10 @@ bool ContainerWidget::restoreState(const QByteArray& data)
|
||||
return true;
|
||||
}
|
||||
|
||||
QRect ContainerWidget::outerTopDropRect() const
|
||||
{
|
||||
QRect r = rect();
|
||||
int h = r.height() / 100 * 5;
|
||||
return QRect(r.left(), r.top(), r.width(), h);
|
||||
}
|
||||
|
||||
QRect ContainerWidget::outerRightDropRect() const
|
||||
{
|
||||
QRect r = rect();
|
||||
int w = r.width() / 100 * 5;
|
||||
return QRect(r.right() - w, r.top(), w, r.height());
|
||||
}
|
||||
|
||||
QRect ContainerWidget::outerBottomDropRect() const
|
||||
{
|
||||
QRect r = rect();
|
||||
int h = r.height() / 100 * 5;
|
||||
return QRect(r.left(), r.bottom() - h, r.width(), h);
|
||||
}
|
||||
|
||||
QRect ContainerWidget::outerLeftDropRect() const
|
||||
{
|
||||
QRect r = rect();
|
||||
int w = r.width() / 100 * 5;
|
||||
return QRect(r.left(), r.top(), w, r.height());
|
||||
}
|
||||
|
||||
QList<SectionContent::RefPtr> ContainerWidget::contents() const
|
||||
{
|
||||
QList<SectionContent::WeakPtr> wl = d->scLookupMapById.values();
|
||||
QList<SectionContent::WeakPtr> wl = d->SectionContentIdMap.values();
|
||||
QList<SectionContent::RefPtr> sl;
|
||||
for (int i = 0; i < wl.count(); ++i)
|
||||
{
|
||||
@ -768,7 +745,7 @@ QByteArray ContainerWidget::saveHierarchy() const
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
if (iter.value().preferredSectionId <= 0 || !d->swLookupMapById.contains(iter.value().preferredSectionId))
|
||||
if (iter.value().preferredSectionId <= 0 || !d->SectionWidgetIdMap.contains(iter.value().preferredSectionId))
|
||||
cnt++;
|
||||
}
|
||||
out << cnt;
|
||||
@ -776,7 +753,7 @@ QByteArray ContainerWidget::saveHierarchy() const
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
if (iter.value().preferredSectionId <= 0 || !d->swLookupMapById.contains(iter.value().preferredSectionId))
|
||||
if (iter.value().preferredSectionId <= 0 || !d->SectionWidgetIdMap.contains(iter.value().preferredSectionId))
|
||||
out << iter.value().data.content->uniqueName();
|
||||
}
|
||||
}
|
||||
@ -941,7 +918,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||
QString uname;
|
||||
in >> uname;
|
||||
|
||||
const SectionContent::RefPtr sc = d->scLookupMapByName.value(uname);
|
||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname);
|
||||
if (!sc)
|
||||
continue;
|
||||
|
||||
@ -967,7 +944,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||
{
|
||||
QString uname;
|
||||
in >> uname;
|
||||
const SectionContent::RefPtr sc = d->scLookupMapByName.value(uname);
|
||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname);
|
||||
if (!sc)
|
||||
continue;
|
||||
|
||||
@ -1006,7 +983,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||
contents.append(contentsToHide.at(i));
|
||||
|
||||
// Compare restored contents with available contents
|
||||
const QList<SectionContent::WeakPtr> allContents = d->scLookupMapById.values();
|
||||
const QList<SectionContent::WeakPtr> allContents = d->SectionContentIdMap.values();
|
||||
for (int i = 0; i < allContents.count(); ++i)
|
||||
{
|
||||
const SectionContent::RefPtr sc = allContents.at(i).toStrongRef();
|
||||
@ -1078,7 +1055,7 @@ bool ContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList
|
||||
bool visible = false;
|
||||
in >> visible;
|
||||
|
||||
const SectionContent::RefPtr sc = d->scLookupMapByName.value(uname).toStrongRef();
|
||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname).toStrongRef();
|
||||
if (!sc)
|
||||
{
|
||||
qWarning() << "Can not find SectionContent:" << uname;
|
||||
@ -1161,7 +1138,7 @@ bool ContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplit
|
||||
int preferredIndex = -1;
|
||||
in >> preferredIndex;
|
||||
|
||||
const SectionContent::RefPtr sc = d->scLookupMapByName.value(uname).toStrongRef();
|
||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname).toStrongRef();
|
||||
if (!sc)
|
||||
{
|
||||
qWarning() << "Can not find SectionContent:" << uname;
|
||||
@ -1246,7 +1223,7 @@ void ContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
||||
if (!a)
|
||||
return;
|
||||
const int uid = a->property("uid").toInt();
|
||||
const SectionContent::RefPtr sc = d->scLookupMapById.value(uid).toStrongRef();
|
||||
const SectionContent::RefPtr sc = d->SectionContentIdMap.value(uid).toStrongRef();
|
||||
if (sc.isNull())
|
||||
{
|
||||
qCritical() << "Can not find content by ID" << uid;
|
||||
@ -1261,14 +1238,21 @@ void ContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
||||
|
||||
void ContainerWidget::moveFloatingWidget(const QPoint& TargetPos)
|
||||
{
|
||||
// Mouse is over a SectionWidget
|
||||
SectionWidget* sectionwidget = sectionAt(mapFromGlobal(QCursor::pos()));
|
||||
// Mouse is over the container widget
|
||||
if (rect().contains(mapFromGlobal(QCursor::pos())))
|
||||
{
|
||||
std::cout << "over Container" << std::endl;
|
||||
d->LeftBorderDropArea->show();
|
||||
d->LeftBorderDropArea->raise();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "-----------------" << std::endl;
|
||||
d->LeftBorderDropArea->hide();
|
||||
}
|
||||
|
||||
|
||||
// Mouse is over a SectionWidget
|
||||
SectionWidget* sectionwidget = sectionAt(mapFromGlobal(QCursor::pos()));
|
||||
if (sectionwidget)
|
||||
{
|
||||
qInfo() << "over sectionWidget";
|
||||
@ -1305,6 +1289,10 @@ FloatingWidget* ContainerWidget::startFloating(SectionWidget* sectionwidget, int
|
||||
sectionwidget = NULL;
|
||||
}
|
||||
deleteEmptySplitter(this);
|
||||
|
||||
QRect Rect = rect();
|
||||
QPoint Pos(Rect.left(), Rect.center().y());
|
||||
d->LeftBorderDropArea->move(mapToGlobal(Pos));
|
||||
return fw;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,6 @@ DropOverlay::DropOverlay(QWidget* parent) :
|
||||
QFrame(parent),
|
||||
_allowedAreas(InvalidDropArea),
|
||||
_cross(new DropOverlayCross(this)),
|
||||
_fullAreaDrop(false),
|
||||
_lastLocation(InvalidDropArea)
|
||||
{
|
||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||
@ -144,10 +143,6 @@ DropOverlay::DropOverlay(QWidget* parent) :
|
||||
areaWidgets.insert(ADS_NS::LeftDropArea, createDropIndicatorWidget(LeftDropArea));//createDropWidget(":/img/split-left.png"));
|
||||
areaWidgets.insert(ADS_NS::CenterDropArea, createDropIndicatorWidget(CenterDropArea));//createDropWidget(":/img/dock-center.png"));
|
||||
|
||||
m_LeftBorderDropArea = createDropIndicatorWidget(LeftDropArea);
|
||||
m_LeftBorderDropArea->setVisible(false);
|
||||
m_LeftBorderDropArea->setWindowTitle("DropOverlayCross");
|
||||
|
||||
_cross->setAreaWidgets(areaWidgets);
|
||||
_cross->setVisible(false);
|
||||
setVisible(false);
|
||||
@ -171,10 +166,6 @@ DropAreas DropOverlay::allowedAreas() const
|
||||
return _allowedAreas;
|
||||
}
|
||||
|
||||
void DropOverlay::setAreaWidgets(const QHash<DropArea, QWidget*>& widgets)
|
||||
{
|
||||
_cross->setAreaWidgets(widgets);
|
||||
}
|
||||
|
||||
DropArea DropOverlay::cursorLocation() const
|
||||
{
|
||||
@ -183,8 +174,7 @@ DropArea DropOverlay::cursorLocation() const
|
||||
|
||||
DropArea DropOverlay::showDropOverlay(QWidget* target)
|
||||
{
|
||||
qInfo() << "DropOverlay::showDropOverlay(QWidget* target)";
|
||||
_fullAreaDrop = true;
|
||||
std::cout << "DropOverlay::showDropOverlay(QWidget* target)" << std::endl;
|
||||
if (_target == target)
|
||||
{
|
||||
qInfo() << "_target == target";
|
||||
@ -199,9 +189,8 @@ DropArea DropOverlay::showDropOverlay(QWidget* target)
|
||||
return da;
|
||||
}
|
||||
|
||||
hideDropOverlay();
|
||||
qInfo() << "_target != target, hideDropOverlay(), _fullAreaDrop = false";
|
||||
_fullAreaDrop = false;
|
||||
//hideDropOverlay();
|
||||
std::cout << "_target != target, hideDropOverlay(), _fullAreaDrop = false" << std::endl;
|
||||
_target = target;
|
||||
_targetRect = QRect();
|
||||
_lastLocation = InvalidDropArea;
|
||||
@ -209,9 +198,7 @@ DropArea DropOverlay::showDropOverlay(QWidget* target)
|
||||
// Move it over the target.
|
||||
resize(target->size());
|
||||
move(target->mapToGlobal(target->rect().topLeft()));
|
||||
|
||||
show();
|
||||
|
||||
return cursorLocation();
|
||||
}
|
||||
|
||||
@ -222,8 +209,7 @@ void DropOverlay::showDropOverlay(QWidget* target, const QRect& targetAreaRect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hideDropOverlay();
|
||||
_fullAreaDrop = true;
|
||||
//hideDropOverlay();
|
||||
_target = target;
|
||||
_targetRect = targetAreaRect;
|
||||
_lastLocation = InvalidDropArea;
|
||||
@ -231,9 +217,7 @@ void DropOverlay::showDropOverlay(QWidget* target, const QRect& targetAreaRect)
|
||||
// Move it over the target's area.
|
||||
resize(targetAreaRect.size());
|
||||
move(target->mapToGlobal(QPoint(targetAreaRect.x(), targetAreaRect.y())));
|
||||
|
||||
show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -241,7 +225,6 @@ void DropOverlay::hideDropOverlay()
|
||||
{
|
||||
qInfo() << "hideDropOverlay() _fullAreaDrop = false";
|
||||
hide();
|
||||
_fullAreaDrop = false;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
_target.clear();
|
||||
#else
|
||||
@ -253,9 +236,6 @@ void DropOverlay::hideDropOverlay()
|
||||
|
||||
void DropOverlay::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter p(this);
|
||||
const QColor areaColor = palette().color(QPalette::Active, QPalette::Highlight);
|
||||
|
||||
// Draw rect based on location
|
||||
QRect r = rect();
|
||||
const DropArea da = cursorLocation();
|
||||
@ -278,23 +258,13 @@ void DropOverlay::paintEvent(QPaintEvent*)
|
||||
r = rect();
|
||||
break;
|
||||
default:
|
||||
r = QRect();
|
||||
return;
|
||||
}
|
||||
if (!r.isNull())
|
||||
{
|
||||
p.fillRect(r, QBrush(areaColor, Qt::Dense4Pattern));
|
||||
p.setBrush(QBrush(areaColor));
|
||||
p.drawRect(r);
|
||||
}
|
||||
|
||||
// Draw rect over the entire size + border.
|
||||
// auto r = rect();
|
||||
// r.setWidth(r.width() - 1);
|
||||
// r.setHeight(r.height() - 1);
|
||||
|
||||
// p.fillRect(r, QBrush(QColor(0, 100, 255), Qt::Dense4Pattern));
|
||||
// p.setBrush(QBrush(QColor(0, 100, 255)));
|
||||
// p.drawRect(r);
|
||||
QPainter painter(this);
|
||||
QColor Color = palette().color(QPalette::Active, QPalette::Highlight);
|
||||
painter.fillRect(r, QBrush(Color, Qt::Dense4Pattern));
|
||||
painter.setBrush(QBrush(Color));
|
||||
painter.drawRect(r);
|
||||
}
|
||||
|
||||
void DropOverlay::showEvent(QShowEvent*)
|
||||
@ -302,15 +272,11 @@ void DropOverlay::showEvent(QShowEvent*)
|
||||
_cross->show();
|
||||
QRect ContainerWidgetRect = parentWidget()->rect();
|
||||
QPoint Pos(ContainerWidgetRect.left(), ContainerWidgetRect.center().y());
|
||||
m_LeftBorderDropArea->move(parentWidget()->mapToGlobal(Pos));
|
||||
m_LeftBorderDropArea->show();
|
||||
|
||||
}
|
||||
|
||||
void DropOverlay::hideEvent(QHideEvent*)
|
||||
{
|
||||
_cross->hide();
|
||||
m_LeftBorderDropArea->hide();
|
||||
}
|
||||
|
||||
void DropOverlay::resizeEvent(QResizeEvent* e)
|
||||
|
@ -16,8 +16,8 @@ SectionContent::SectionContent() :
|
||||
|
||||
SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueName, ContainerWidget* container, QWidget* title, QWidget* content)
|
||||
{
|
||||
auto SectionContentNameMap = container->d->scLookupMapByName;
|
||||
auto SectionContentIdMap = container->d->scLookupMapById;
|
||||
auto SectionContentNameMap = container->d->SectionContentNameMap;
|
||||
auto SectionContentIdMap = container->d->SectionContentIdMap;
|
||||
|
||||
if (uniqueName.isEmpty())
|
||||
{
|
||||
@ -48,8 +48,8 @@ SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueNa
|
||||
|
||||
SectionContent::~SectionContent()
|
||||
{
|
||||
auto SectionContentNameMap = _containerWidget->d->scLookupMapByName;
|
||||
auto SectionContentIdMap = _containerWidget->d->scLookupMapById;
|
||||
auto SectionContentNameMap = _containerWidget->d->SectionContentNameMap;
|
||||
auto SectionContentIdMap = _containerWidget->d->SectionContentIdMap;
|
||||
|
||||
if (_containerWidget)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||
// Mouse is over a outer-edge drop area
|
||||
else
|
||||
{
|
||||
DropArea dropArea = ADS_NS::InvalidDropArea;
|
||||
/*DropArea dropArea = ADS_NS::InvalidDropArea;
|
||||
if (cw->outerTopDropRect().contains(cw->mapFromGlobal(ev->globalPos())))
|
||||
dropArea = ADS_NS::TopDropArea;
|
||||
if (cw->outerRightDropRect().contains(cw->mapFromGlobal(ev->globalPos())))
|
||||
@ -114,7 +114,7 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||
m_FloatingWidget->deleteLater();
|
||||
m_FloatingWidget.clear();
|
||||
cw->dropContent(data, NULL, dropArea, true);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
// End of tab moving, change order now
|
||||
|
@ -93,14 +93,14 @@ SectionWidget::SectionWidget(ContainerWidget* parent) :
|
||||
_contentsLayout->setSpacing(0);
|
||||
l->addLayout(_contentsLayout, 1);
|
||||
|
||||
_container->d->swLookupMapById.insert(_uid, this);
|
||||
_container->d->SectionWidgetIdMap.insert(_uid, this);
|
||||
}
|
||||
|
||||
SectionWidget::~SectionWidget()
|
||||
{
|
||||
if (_container)
|
||||
{
|
||||
_container->d->swLookupMapById.remove(_uid);
|
||||
_container->d->SectionWidgetIdMap.remove(_uid);
|
||||
_container->d->sections.removeAll(this); // Note: I don't like this here, but we have to remove it from list...
|
||||
}
|
||||
|
||||
|
@ -90,34 +90,31 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
// Setup actions.
|
||||
QObject::connect(ui->actionContentList, SIGNAL(triggered()), this, SLOT(showSectionContentListDialog()));
|
||||
connect(ui->actionContentList, SIGNAL(triggered()), this, SLOT(showSectionContentListDialog()));
|
||||
|
||||
// ADS - Create main container (ContainerWidget).
|
||||
_container = new ADS_NS::ContainerWidget();
|
||||
#if QT_VERSION >= 0x050000
|
||||
QObject::connect(_container, &ADS_NS::ContainerWidget::activeTabChanged, this, &MainWindow::onActiveTabChanged);
|
||||
QObject::connect(_container, &ADS_NS::ContainerWidget::sectionContentVisibilityChanged, this, &MainWindow::onSectionContentVisibilityChanged);
|
||||
#else
|
||||
QObject::connect(_container, SIGNAL(activeTabChanged(const SectionContent::RefPtr&, bool)), this, SLOT(onActiveTabChanged(const SectionContent::RefPtr&, bool)));
|
||||
QObject::connect(_container, SIGNAL(sectionContentVisibilityChanged(SectionContent::RefPtr,bool)), this, SLOT(onSectionContentVisibilityChanged(SectionContent::RefPtr,bool)));
|
||||
#endif
|
||||
connect(_container, SIGNAL(activeTabChanged(const SectionContent::RefPtr&, bool)), this, SLOT(onActiveTabChanged(const SectionContent::RefPtr&, bool)));
|
||||
connect(_container, SIGNAL(sectionContentVisibilityChanged(SectionContent::RefPtr,bool)), this, SLOT(onSectionContentVisibilityChanged(SectionContent::RefPtr,bool)));
|
||||
setCentralWidget(_container);
|
||||
createContent();
|
||||
// Default window geometry
|
||||
resize(800, 600);
|
||||
restoreGeometry(loadDataHelper("MainWindow"));
|
||||
|
||||
// Optional: Use custom drop area widgets.
|
||||
if (false)
|
||||
{
|
||||
QHash<ADS_NS::DropArea, QWidget*> areaWidgets;
|
||||
areaWidgets.insert(ADS_NS::TopDropArea, new QPushButton("TOP"));
|
||||
areaWidgets.insert(ADS_NS::RightDropArea, new QPushButton("RIGHT"));
|
||||
areaWidgets.insert(ADS_NS::BottomDropArea, new QPushButton("BOTTOM"));
|
||||
areaWidgets.insert(ADS_NS::LeftDropArea, new QPushButton("LEFT"));
|
||||
areaWidgets.insert(ADS_NS::CenterDropArea, new QPushButton("CENTER"));
|
||||
_container->dropOverlay()->setAreaWidgets(areaWidgets);
|
||||
// ADS - Restore geometries and states of contents.
|
||||
//_container->restoreState(loadDataHelper("ContainerWidget"));
|
||||
}
|
||||
|
||||
// ADS - Adding some contents.
|
||||
if (true)
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createContent()
|
||||
{
|
||||
// ADS - Adding some contents.
|
||||
// Test #1: Use high-level public API
|
||||
ADS_NS::ContainerWidget* cw = _container;
|
||||
ADS_NS::SectionWidget* sw = NULL;
|
||||
@ -134,9 +131,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ADS_NS::SectionContent::RefPtr sc = createLongTextLabelSC(cw);
|
||||
sc->setFlags(ADS_NS::SectionContent::AllFlags ^ ADS_NS::SectionContent::Closeable);
|
||||
_container->addSectionContent(sc);*/
|
||||
}
|
||||
else if (false)
|
||||
{
|
||||
|
||||
#if 0
|
||||
// Issue #2: If the first drop is not into CenterDropArea, the application crashes.
|
||||
ADS_NS::ContainerWidget* cw = _container;
|
||||
ADS_NS::SectionWidget* sw = NULL;
|
||||
@ -148,19 +144,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea);
|
||||
sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::RightDropArea);
|
||||
sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::BottomDropArea);
|
||||
}
|
||||
|
||||
// Default window geometry
|
||||
resize(800, 600);
|
||||
restoreGeometry(loadDataHelper("MainWindow"));
|
||||
|
||||
// ADS - Restore geometries and states of contents.
|
||||
//_container->restoreState(loadDataHelper("ContainerWidget"));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::showSectionContentListDialog()
|
||||
|
@ -38,6 +38,7 @@ protected:
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
ADS_NS::ContainerWidget* _container;
|
||||
void createContent();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user