Qt-Advanced-Docking-System/AdvancedDockingSystem/include/ads/ContainerWidget.h
2017-02-07 23:51:29 +01:00

97 lines
3.3 KiB
C++

#ifndef ContainerWidgetH
#define ContainerWidgetH
//============================================================================
/// \file ContainerWidget.h
/// \author Uwe Kindler
/// \date 03.02.2017
/// \brief Declaration of CContainerWidget
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QFrame>
#include "ads/API.h"
#include "ads/Internal.h"
#include "ads/SectionContent.h"
#include "ads/FloatingWidget.h"
#include "ads/Serialization.h"
#include "ads/DropOverlay.h"
namespace ads
{
class SectionWidget;
class DropOverlay;
class InternalContentData;
class MainContainerWidget;
/**
* @brief
*/
class CContainerWidget : public QFrame
{
Q_OBJECT
friend class SectionContent;
friend class SectionWidget;
friend class FloatingWidget;
friend class SectionTitleWidget;
friend class ContainerWidgetPrivate;
public:
explicit CContainerWidget(MainContainerWidget* MainContainerWidget, QWidget *parent = nullptr);
virtual ~CContainerWidget();
void moveFloatingWidget(const QPoint& TargetPos);
/**
* Returns the current zOrderIndex
*/
unsigned int zOrderIndex() const;
void dropFloatingWidget(FloatingWidget* FloatingWidget,
const QPoint& TargetPos);
SectionWidget* sectionWidgetAt(const QPoint& pos) const;
/**
* This function returns true if this container widgets z order index is
* higher than the index of the container widget given in Other parameter
*/
bool isInFrontOf(CContainerWidget* Other) const;
SectionWidget* dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area, bool autoActive = true);
/*!
* 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);
protected:
virtual bool event(QEvent *e) override;
SectionWidget* newSectionWidget();
void addSectionWidget(SectionWidget* section);
SectionWidget* dropContentOuterHelper(QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append);
SectionWidget* insertNewSectionWidget(const InternalContentData& data,
SectionWidget* targetSection, SectionWidget* ret, Qt::Orientation Orientation, int InsertIndexOffset);
QList<SectionWidget*> m_Sections;
// Layout stuff
QGridLayout* m_MainLayout = nullptr;
Qt::Orientation m_Orientation = Qt::Horizontal;
QPointer<QSplitter> m_Splitter; // $mfreiholz: I'd like to remove this variable entirely,
// because it changes during user interaction anyway.
MainContainerWidget* m_MainContainerWidget = 0;
unsigned int m_zOrderIndex = 0;
static unsigned int zOrderCounter;
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // ContainerWidgetH