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;
|
|
|
|
|
2016-02-15 18:32:35 +08:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* ContainerWidget is the main container to provide the docking
|
|
|
|
* functionality. It manages mulitple Sections and all possible areas.
|
|
|
|
*/
|
2015-12-09 19:21:38 +08:00
|
|
|
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;
|
2016-02-15 18:32:35 +08:00
|
|
|
friend class SectionTitleWidget;
|
|
|
|
friend class SectionContentWidget;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ContainerWidget(QWidget *parent = NULL);
|
|
|
|
|
2016-02-15 17:28:42 +08:00
|
|
|
//
|
|
|
|
// Public API
|
|
|
|
//
|
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
Qt::Orientation orientation() const;
|
|
|
|
void setOrientation(Qt::Orientation orientation);
|
|
|
|
|
2016-02-15 17:28:42 +08:00
|
|
|
/*!
|
|
|
|
* Adds the section-content <em>sc</em> to this container-widget into the section-widget <em>sw</em>.
|
|
|
|
* If <em>sw</em> is not NULL, the <em>area</em> is used to indicate how the content should be arranged.
|
|
|
|
* Returns a pointer to the SectionWidget of the added SectionContent. Do not use it for anything else than adding more
|
|
|
|
* SectionContent elements with this method.
|
|
|
|
*/
|
|
|
|
SectionWidget* addSectionContent(const SectionContent::RefPtr& sc, SectionWidget* sw = NULL, DropArea area = CenterDropArea);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Creates a QMenu based on available SectionContents.
|
2016-02-15 18:32:35 +08:00
|
|
|
* The caller is responsible to delete the menu.
|
2016-02-15 17:28:42 +08:00
|
|
|
*/
|
|
|
|
QMenu* createContextMenu() const;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-15 18:13:58 +08:00
|
|
|
/*!
|
|
|
|
* Serializes the current state of contents and returns it as a plain byte array.
|
|
|
|
* \see restoreState(const QByteArray&)
|
|
|
|
*/
|
|
|
|
QByteArray saveState() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Deserilizes the state of contents from <em>data</em>, which was written with <em>saveState()</em>.
|
|
|
|
* \see saveState()
|
|
|
|
*/
|
|
|
|
bool restoreState(const QByteArray& data);
|
|
|
|
|
2016-02-15 17:28:42 +08:00
|
|
|
//
|
2016-02-15 18:32:35 +08:00
|
|
|
// Advanced Public API
|
|
|
|
// You usually should not need access to this methods
|
2016-02-15 17:28:42 +08:00
|
|
|
//
|
|
|
|
|
2016-02-15 18:32:35 +08:00
|
|
|
// Outer DropAreas
|
2015-12-09 19:21:38 +08:00
|
|
|
QRect outerTopDropRect() const;
|
|
|
|
QRect outerRightDropRect() const;
|
|
|
|
QRect outerBottomDropRect() const;
|
|
|
|
QRect outerLeftDropRect() const;
|
|
|
|
|
2016-02-11 21:33:02 +08:00
|
|
|
private:
|
2016-02-15 18:32:35 +08:00
|
|
|
//
|
|
|
|
// Internal Stuff Begins Here
|
|
|
|
//
|
|
|
|
|
2016-02-17 16:59:11 +08:00
|
|
|
SectionWidget* newSectionWidget();
|
2016-02-15 18:32:35 +08:00
|
|
|
SectionWidget* dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area, bool autoActive = true);
|
|
|
|
void addSection(SectionWidget* section);
|
|
|
|
SectionWidget* sectionAt(const QPoint& pos) const;
|
2016-02-15 18:13:58 +08:00
|
|
|
SectionWidget* dropContentOuterHelper(QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append);
|
2016-02-11 21:33:02 +08:00
|
|
|
void saveGeometryWalk(QDataStream& out, QWidget* widget) const;
|
2016-02-17 16:59:11 +08:00
|
|
|
bool restoreFloatingWidgets(QDataStream& in, QList<FloatingWidget*>& floatings);
|
|
|
|
bool restoreSectionWidgets(QDataStream& in, QSplitter* currentSplitter, QList<SectionWidget*>& sections);
|
2016-02-15 17:28:42 +08:00
|
|
|
bool takeContent(const SectionContent::RefPtr& sc, InternalContentData& data);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onActionToggleSectionContentVisibility(bool visible);
|
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
signals:
|
|
|
|
void orientationChanged();
|
|
|
|
|
2016-02-15 18:32:35 +08:00
|
|
|
private:
|
2016-02-17 16:59:11 +08:00
|
|
|
// Sections of this container
|
2015-12-09 19:21:38 +08:00
|
|
|
QList<SectionWidget*> _sections;
|
|
|
|
|
2016-02-17 16:59:11 +08:00
|
|
|
//Floatings of this container
|
|
|
|
QList<FloatingWidget*> _floatings;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
// Layout stuff
|
|
|
|
QGridLayout* _mainLayout;
|
2016-02-11 21:33:02 +08:00
|
|
|
Qt::Orientation _orientation;
|
2016-02-17 16:59:11 +08:00
|
|
|
QPointer<QSplitter> _splitter; // $mfreiholz: I'd like to remove this variable entirely.
|
2015-12-09 19:21:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ADS_NAMESPACE_END
|
2016-02-12 14:15:10 +08:00
|
|
|
#endif
|