2015-12-09 19:21:38 +08:00
|
|
|
#ifndef ADS_CONTAINERWIDGET_H
|
|
|
|
#define ADS_CONTAINERWIDGET_H
|
|
|
|
|
2016-02-03 15:01:26 +08:00
|
|
|
#include <QPointer>
|
2015-12-09 19:21:38 +08:00
|
|
|
#include <QFrame>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QList>
|
|
|
|
class QSplitter;
|
2016-02-02 20:49:10 +08:00
|
|
|
class QMenu;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-02 22:01:48 +08:00
|
|
|
#include "ads/API.h"
|
|
|
|
#include "ads/SectionContent.h"
|
|
|
|
#include "ads/SectionWidget.h"
|
|
|
|
#include "ads/FloatingWidget.h"
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
ADS_NAMESPACE_BEGIN
|
|
|
|
|
2016-02-12 15:00:31 +08:00
|
|
|
class InternalContentData;
|
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
// ContainerWidget is the main container to provide the docking
|
|
|
|
// functionality. It manages mulitple Sections and all possible areas.
|
|
|
|
class ContainerWidget : public QFrame
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
|
|
|
|
|
|
|
|
friend class SectionWidget;
|
2016-02-02 20:49:10 +08:00
|
|
|
friend class FloatingWidget;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ContainerWidget(QWidget *parent = NULL);
|
|
|
|
|
|
|
|
Qt::Orientation orientation() const;
|
|
|
|
void setOrientation(Qt::Orientation orientation);
|
|
|
|
|
|
|
|
void dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area);
|
|
|
|
|
|
|
|
void addSection(SectionWidget* section);
|
|
|
|
void splitSections(SectionWidget* section1, SectionWidget* section2, Qt::Orientation orientation = Qt::Horizontal);
|
|
|
|
SectionWidget* sectionAt(const QPoint& pos) const;
|
|
|
|
|
|
|
|
// Drop areas for the ContainerWidget
|
|
|
|
QRect outerTopDropRect() const;
|
|
|
|
QRect outerRightDropRect() const;
|
|
|
|
QRect outerBottomDropRect() const;
|
|
|
|
QRect outerLeftDropRect() const;
|
|
|
|
|
2016-02-01 17:55:45 +08:00
|
|
|
// Geometry and state serialization
|
|
|
|
QByteArray saveGeometry() const;
|
|
|
|
bool restoreGeometry(const QByteArray& data);
|
|
|
|
|
2016-02-02 20:49:10 +08:00
|
|
|
QMenu* createContextMenu() const;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-11 21:33:02 +08:00
|
|
|
private:
|
|
|
|
void saveGeometryWalk(QDataStream& out, QWidget* widget) const;
|
|
|
|
bool restoreGeometryWalk(QDataStream& in, QSplitter* currentSplitter = NULL);
|
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
signals:
|
|
|
|
void orientationChanged();
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Existing sections.
|
|
|
|
// SectionWidgets are always visible.
|
|
|
|
QList<SectionWidget*> _sections;
|
|
|
|
|
|
|
|
// All currently active Floatingwidgets.
|
|
|
|
QList<FloatingWidget*> _floatingWidgets;
|
|
|
|
|
|
|
|
// Layout stuff
|
|
|
|
QGridLayout* _mainLayout;
|
2016-02-11 21:33:02 +08:00
|
|
|
Qt::Orientation _orientation;
|
|
|
|
QPointer<QSplitter> _splitter;
|
2015-12-09 19:21:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ADS_NAMESPACE_END
|
2016-02-12 14:15:10 +08:00
|
|
|
#endif
|