Moved include files from include to src directory

This commit is contained in:
Uwe Kindler 2017-02-23 21:46:29 +01:00
parent 5dc935f650
commit ca64286117
11 changed files with 1087 additions and 1087 deletions

View File

@ -1,90 +1,90 @@
#ifndef ADS_API_H
#define ADS_API_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QFlags>
class QWidget;
class QSplitter;
// DLL Export API
#ifdef _WIN32
#if defined(ADS_IMPORT)
#define ADS_EXPORT_API
#elif defined(ADS_EXPORT)
#define ADS_EXPORT_API __declspec(dllexport)
#else
#define ADS_EXPORT_API __declspec(dllimport)
#endif
#else
#define ADS_EXPORT_API
#endif
// Use namespace
// Disabled with Qt4, it makes problems with signals and slots.
#ifdef ADS_NAMESPACE_ENABLED
#define ADS_NAMESPACE_BEGIN namespace ads {
#define ADS_NAMESPACE_END }
#define ADS_NS ::ads
#else
#define ADS_NAMESPACE_BEGIN
#define ADS_NAMESPACE_END
#define ADS_NS
#endif
// Always enable "serialization" namespace.
// It is not required for signals and slots.
#define ADS_NAMESPACE_SER_BEGIN namespace ads { namespace serialization {
#define ADS_NAMESPACE_SER_END }}
#define ADS_NS_SER ::ads::serialization
// Width of the native window frame border (based on OS).
#define ADS_WINDOW_FRAME_BORDER_WIDTH 7
// Beautiful C++ stuff.
#define ADS_Expects(cond)
#define ADS_Ensures(cond)
// Indicates whether ADS should include animations.
//#define ADS_ANIMATIONS_ENABLED 1
//#define ADS_ANIMATION_DURATION 150
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionWidget;
enum DropArea
{
InvalidDropArea = 0,
TopDropArea = 1,
RightDropArea = 2,
BottomDropArea = 4,
LeftDropArea = 8,
CenterDropArea = 16,
OuterAreas = TopDropArea | RightDropArea | BottomDropArea | LeftDropArea,
AllAreas = OuterAreas | CenterDropArea
};
Q_DECLARE_FLAGS(DropAreas, DropArea)
void deleteEmptySplitter(CMainContainerWidget* container);
QSplitter* findParentSplitter(QWidget* w);
QSplitter* findImmediateSplitter(QWidget* w);
ADS_NAMESPACE_END
#endif
#ifndef ADS_API_H
#define ADS_API_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QFlags>
class QWidget;
class QSplitter;
// DLL Export API
#ifdef _WIN32
#if defined(ADS_IMPORT)
#define ADS_EXPORT_API
#elif defined(ADS_EXPORT)
#define ADS_EXPORT_API __declspec(dllexport)
#else
#define ADS_EXPORT_API __declspec(dllimport)
#endif
#else
#define ADS_EXPORT_API
#endif
// Use namespace
// Disabled with Qt4, it makes problems with signals and slots.
#ifdef ADS_NAMESPACE_ENABLED
#define ADS_NAMESPACE_BEGIN namespace ads {
#define ADS_NAMESPACE_END }
#define ADS_NS ::ads
#else
#define ADS_NAMESPACE_BEGIN
#define ADS_NAMESPACE_END
#define ADS_NS
#endif
// Always enable "serialization" namespace.
// It is not required for signals and slots.
#define ADS_NAMESPACE_SER_BEGIN namespace ads { namespace serialization {
#define ADS_NAMESPACE_SER_END }}
#define ADS_NS_SER ::ads::serialization
// Width of the native window frame border (based on OS).
#define ADS_WINDOW_FRAME_BORDER_WIDTH 7
// Beautiful C++ stuff.
#define ADS_Expects(cond)
#define ADS_Ensures(cond)
// Indicates whether ADS should include animations.
//#define ADS_ANIMATIONS_ENABLED 1
//#define ADS_ANIMATION_DURATION 150
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionWidget;
enum DropArea
{
InvalidDropArea = 0,
TopDropArea = 1,
RightDropArea = 2,
BottomDropArea = 4,
LeftDropArea = 8,
CenterDropArea = 16,
OuterAreas = TopDropArea | RightDropArea | BottomDropArea | LeftDropArea,
AllAreas = OuterAreas | CenterDropArea
};
Q_DECLARE_FLAGS(DropAreas, DropArea)
void deleteEmptySplitter(CMainContainerWidget* container);
QSplitter* findParentSplitter(QWidget* w);
QSplitter* findImmediateSplitter(QWidget* w);
ADS_NAMESPACE_END
#endif

View File

@ -1,129 +1,129 @@
#ifndef ContainerWidgetH
#define ContainerWidgetH
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
//============================================================================
// 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 CMainContainerWidget;
/**
* @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(CMainContainerWidget* MainContainerWidget, QWidget *parent = nullptr);
virtual ~CContainerWidget();
/**
* Returns the current zOrderIndex
*/
virtual unsigned int zOrderIndex() const;
void dropFloatingWidget(FloatingWidget* FloatingWidget,
const QPoint& TargetPos);
SectionWidget* sectionWidgetAt(const QPoint& GlobalPos) 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);
void dumpLayout();
CMainContainerWidget* mainContainerWidget() const {return m_MainContainerWidget;}
void addSectionWidget(SectionWidget* section);
void takeSection(SectionWidget* Widget);
signals:
/*!
* Emits whenever the "isActiveTab" state of a SectionContent changes.
* Whenever the users sets another tab as active, this signal gets invoked
* for the old tab and the new active tab (the order is unspecified).
*/
void activeTabChanged(const SectionContent::RefPtr& sc, bool active);
protected:
void dropIntoContainer(FloatingWidget* FloatingWidget, DropArea area);
void dropIntoSection(FloatingWidget* FloatingWidget, SectionWidget* targetSection, DropArea area);
virtual bool event(QEvent *e) override;
SectionWidget* newSectionWidget();
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.
CMainContainerWidget* m_MainContainerWidget = 0;
unsigned int m_zOrderIndex = 0;
static unsigned int zOrderCounter;
private:
void dropChildSections(QWidget* Parent);
private slots:
void onActiveTabChanged();
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // ContainerWidgetH
#ifndef ContainerWidgetH
#define ContainerWidgetH
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
//============================================================================
// 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 CMainContainerWidget;
/**
* @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(CMainContainerWidget* MainContainerWidget, QWidget *parent = nullptr);
virtual ~CContainerWidget();
/**
* Returns the current zOrderIndex
*/
virtual unsigned int zOrderIndex() const;
void dropFloatingWidget(FloatingWidget* FloatingWidget,
const QPoint& TargetPos);
SectionWidget* sectionWidgetAt(const QPoint& GlobalPos) 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);
void dumpLayout();
CMainContainerWidget* mainContainerWidget() const {return m_MainContainerWidget;}
void addSectionWidget(SectionWidget* section);
void takeSection(SectionWidget* Widget);
signals:
/*!
* Emits whenever the "isActiveTab" state of a SectionContent changes.
* Whenever the users sets another tab as active, this signal gets invoked
* for the old tab and the new active tab (the order is unspecified).
*/
void activeTabChanged(const SectionContent::RefPtr& sc, bool active);
protected:
void dropIntoContainer(FloatingWidget* FloatingWidget, DropArea area);
void dropIntoSection(FloatingWidget* FloatingWidget, SectionWidget* targetSection, DropArea area);
virtual bool event(QEvent *e) override;
SectionWidget* newSectionWidget();
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.
CMainContainerWidget* m_MainContainerWidget = 0;
unsigned int m_zOrderIndex = 0;
static unsigned int zOrderCounter;
private:
void dropChildSections(QWidget* Parent);
private slots:
void onActiveTabChanged();
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // ContainerWidgetH

View File

@ -1,119 +1,119 @@
#ifndef DROP_OVERLAY_H
#define DROP_OVERLAY_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QPointer>
#include <QHash>
#include <QRect>
#include <QFrame>
class QGridLayout;
#include "ads/API.h"
ADS_NAMESPACE_BEGIN
class DropOverlayCross;
/*!
* DropOverlay paints a translucent rectangle over another widget. The geometry
* of the rectangle is based on the mouse location.
*/
class ADS_EXPORT_API DropOverlay : public QFrame
{
Q_OBJECT
friend class DropOverlayCross;
public:
enum eMode
{
ModeSectionOverlay,
ModeContainerOverlay
};
DropOverlay(QWidget* parent, eMode Mode = ModeSectionOverlay);
virtual ~DropOverlay();
void setAllowedAreas(DropAreas areas);
/**
* Returns flags with all allowed drop areas
*/
DropAreas allowedAreas() const;
/**
* Returns the drop area under the current cursor location
*/
DropArea dropAreaUnderCursor() const;
DropArea showDropOverlay(QWidget* target);
void showDropOverlay(QWidget* target, const QRect& targetAreaRect);
void hideDropOverlay();
/**
* Creates a drop indicator widget for the given drop area
*/
static QWidget* createDropIndicatorWidget(DropArea dropArea);
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void showEvent(QShowEvent* e);
virtual void hideEvent(QHideEvent* e);
virtual void resizeEvent(QResizeEvent* e);
virtual void moveEvent(QMoveEvent* e);
private:
DropAreas _allowedAreas;
DropOverlayCross* _cross;
QPointer<QWidget> _target;
QRect _targetRect;
DropArea _lastLocation;
};
/*!
* DropOverlayCross shows a cross with 5 different drop area possibilities.
* I could have handled everything inside DropOverlay, but because of some
* styling issues it's better to have a separate class for the cross.
*/
class DropOverlayCross : public QWidget
{
Q_OBJECT
friend class DropOverlay;
public:
DropOverlayCross(DropOverlay* overlay);
virtual ~DropOverlayCross();
DropArea cursorLocation() const;
void setupOverlayCross(DropOverlay::eMode Mode);
protected:
virtual void showEvent(QShowEvent* e);
void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
private:
void reset();
QPoint areaGridPosition(const DropArea area);
private:
DropOverlay::eMode m_Mode = DropOverlay::ModeSectionOverlay;
DropOverlay* m_DropOverlay;
QHash<DropArea, QWidget*> m_DropIndicatorWidgets;
QGridLayout* m_GridLayout;
};
ADS_NAMESPACE_END
#endif
#ifndef DROP_OVERLAY_H
#define DROP_OVERLAY_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QPointer>
#include <QHash>
#include <QRect>
#include <QFrame>
class QGridLayout;
#include "ads/API.h"
ADS_NAMESPACE_BEGIN
class DropOverlayCross;
/*!
* DropOverlay paints a translucent rectangle over another widget. The geometry
* of the rectangle is based on the mouse location.
*/
class ADS_EXPORT_API DropOverlay : public QFrame
{
Q_OBJECT
friend class DropOverlayCross;
public:
enum eMode
{
ModeSectionOverlay,
ModeContainerOverlay
};
DropOverlay(QWidget* parent, eMode Mode = ModeSectionOverlay);
virtual ~DropOverlay();
void setAllowedAreas(DropAreas areas);
/**
* Returns flags with all allowed drop areas
*/
DropAreas allowedAreas() const;
/**
* Returns the drop area under the current cursor location
*/
DropArea dropAreaUnderCursor() const;
DropArea showDropOverlay(QWidget* target);
void showDropOverlay(QWidget* target, const QRect& targetAreaRect);
void hideDropOverlay();
/**
* Creates a drop indicator widget for the given drop area
*/
static QWidget* createDropIndicatorWidget(DropArea dropArea);
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void showEvent(QShowEvent* e);
virtual void hideEvent(QHideEvent* e);
virtual void resizeEvent(QResizeEvent* e);
virtual void moveEvent(QMoveEvent* e);
private:
DropAreas _allowedAreas;
DropOverlayCross* _cross;
QPointer<QWidget> _target;
QRect _targetRect;
DropArea _lastLocation;
};
/*!
* DropOverlayCross shows a cross with 5 different drop area possibilities.
* I could have handled everything inside DropOverlay, but because of some
* styling issues it's better to have a separate class for the cross.
*/
class DropOverlayCross : public QWidget
{
Q_OBJECT
friend class DropOverlay;
public:
DropOverlayCross(DropOverlay* overlay);
virtual ~DropOverlayCross();
DropArea cursorLocation() const;
void setupOverlayCross(DropOverlay::eMode Mode);
protected:
virtual void showEvent(QShowEvent* e);
void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
private:
void reset();
QPoint areaGridPosition(const DropArea area);
private:
DropOverlay::eMode m_Mode = DropOverlay::ModeSectionOverlay;
DropOverlay* m_DropOverlay;
QHash<DropArea, QWidget*> m_DropIndicatorWidgets;
QGridLayout* m_GridLayout;
};
ADS_NAMESPACE_END
#endif

View File

@ -1,114 +1,114 @@
#ifndef FLOATINGWIDGET_H
#define FLOATINGWIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QWidget>
#include <QFrame>
class QBoxLayout;
#include "ads/API.h"
#include "ads/SectionContent.h"
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionTitleWidget;
class CSectionContentWidget;
class InternalContentData;
class SectionWidget;
class CContainerWidget;
class FloatingWidget;
class CFloatingTitleWidget : public QFrame
{
Q_OBJECT
private:
QPoint m_DragStartPosition;
QPoint m_DragStartMousePosition;
FloatingWidget* floatingWidget() const;
CMainContainerWidget* mainContainerWidget() const;
void moveFloatingWidget(QMouseEvent* ev);
private slots:
void onMaximizeButtonClicked();
protected:
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
public:
CFloatingTitleWidget(SectionContent::Flags Flags, FloatingWidget* Parent);
signals:
void closeButtonClicked();
};
// FloatingWidget holds and displays SectionContent as a floating window.
// It can be resized, moved and dropped back into a SectionWidget.
class FloatingWidget : public QWidget
{
Q_OBJECT
friend class CMainContainerWidget;
friend class CFloatingTitleWidget;
public:
FloatingWidget(CMainContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, CSectionContentWidget* contentWidget, QWidget* parent = NULL);
FloatingWidget(CMainContainerWidget* container, SectionWidget* sectionWidget);
virtual ~FloatingWidget();
/**
* Returns the current zOrderIndex
*/
unsigned int zOrderIndex() const;
CContainerWidget* containerWidget() const {return m_ContainerWidget;}
CMainContainerWidget* mainContainerWidget() const {return m_MainContainerWidget;}
public://private:
bool takeContent(InternalContentData& data);
void startFloating(const QPoint& Pos);
protected:
virtual void changeEvent(QEvent *event) override;
virtual void moveEvent(QMoveEvent *event) override;
virtual bool event(QEvent *e);
void titleMouseReleaseEvent();
virtual bool eventFilter(QObject *watched, QEvent *event) override;
void updateDropOverlays(const QPoint& GlobalPos);
private slots:
void onCloseButtonClicked();
private:
void setDraggingActive(bool Active);
CMainContainerWidget* m_MainContainerWidget;
CContainerWidget* m_ContainerWidget;
CContainerWidget* m_DropContainer;
bool m_DraggingActive = false;
unsigned int m_zOrderIndex = 0;
QPoint m_DragStartPosition;
QPoint m_DragStartMousePosition;
static unsigned int zOrderCounter;
};
ADS_NAMESPACE_END
#endif
#ifndef FLOATINGWIDGET_H
#define FLOATINGWIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QWidget>
#include <QFrame>
class QBoxLayout;
#include "ads/API.h"
#include "ads/SectionContent.h"
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionTitleWidget;
class CSectionContentWidget;
class InternalContentData;
class SectionWidget;
class CContainerWidget;
class FloatingWidget;
class CFloatingTitleWidget : public QFrame
{
Q_OBJECT
private:
QPoint m_DragStartPosition;
QPoint m_DragStartMousePosition;
FloatingWidget* floatingWidget() const;
CMainContainerWidget* mainContainerWidget() const;
void moveFloatingWidget(QMouseEvent* ev);
private slots:
void onMaximizeButtonClicked();
protected:
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
public:
CFloatingTitleWidget(SectionContent::Flags Flags, FloatingWidget* Parent);
signals:
void closeButtonClicked();
};
// FloatingWidget holds and displays SectionContent as a floating window.
// It can be resized, moved and dropped back into a SectionWidget.
class FloatingWidget : public QWidget
{
Q_OBJECT
friend class CMainContainerWidget;
friend class CFloatingTitleWidget;
public:
FloatingWidget(CMainContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, CSectionContentWidget* contentWidget, QWidget* parent = NULL);
FloatingWidget(CMainContainerWidget* container, SectionWidget* sectionWidget);
virtual ~FloatingWidget();
/**
* Returns the current zOrderIndex
*/
unsigned int zOrderIndex() const;
CContainerWidget* containerWidget() const {return m_ContainerWidget;}
CMainContainerWidget* mainContainerWidget() const {return m_MainContainerWidget;}
public://private:
bool takeContent(InternalContentData& data);
void startFloating(const QPoint& Pos);
protected:
virtual void changeEvent(QEvent *event) override;
virtual void moveEvent(QMoveEvent *event) override;
virtual bool event(QEvent *e);
void titleMouseReleaseEvent();
virtual bool eventFilter(QObject *watched, QEvent *event) override;
void updateDropOverlays(const QPoint& GlobalPos);
private slots:
void onCloseButtonClicked();
private:
void setDraggingActive(bool Active);
CMainContainerWidget* m_MainContainerWidget;
CContainerWidget* m_ContainerWidget;
CContainerWidget* m_DropContainer;
bool m_DraggingActive = false;
unsigned int m_zOrderIndex = 0;
QPoint m_DragStartPosition;
QPoint m_DragStartMousePosition;
static unsigned int zOrderCounter;
};
ADS_NAMESPACE_END
#endif

View File

@ -1,67 +1,67 @@
#ifndef ADS_INTERNAL_HEADER
#define ADS_INTERNAL_HEADER
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QSharedPointer>
#include <QWeakPointer>
#include "ads/API.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#else
#include "ads/SectionContent.h"
#endif
ADS_NAMESPACE_BEGIN
class SectionContent;
class SectionTitleWidget;
class CSectionContentWidget;
class InternalContentData
{
public:
typedef QSharedPointer<InternalContentData> RefPtr;
typedef QWeakPointer<InternalContentData> WeakPtr;
InternalContentData();
~InternalContentData();
QSharedPointer<SectionContent> content;
SectionTitleWidget* titleWidget;
CSectionContentWidget* contentWidget;
};
class HiddenSectionItem
{
public:
HiddenSectionItem() :
preferredSectionId(-1),
preferredSectionIndex(-1)
{}
int preferredSectionId;
int preferredSectionIndex;
InternalContentData data;
};
ADS_NAMESPACE_END
#endif
#ifndef ADS_INTERNAL_HEADER
#define ADS_INTERNAL_HEADER
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QSharedPointer>
#include <QWeakPointer>
#include "ads/API.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#else
#include "ads/SectionContent.h"
#endif
ADS_NAMESPACE_BEGIN
class SectionContent;
class SectionTitleWidget;
class CSectionContentWidget;
class InternalContentData
{
public:
typedef QSharedPointer<InternalContentData> RefPtr;
typedef QWeakPointer<InternalContentData> WeakPtr;
InternalContentData();
~InternalContentData();
QSharedPointer<SectionContent> content;
SectionTitleWidget* titleWidget;
CSectionContentWidget* contentWidget;
};
class HiddenSectionItem
{
public:
HiddenSectionItem() :
preferredSectionId(-1),
preferredSectionIndex(-1)
{}
int preferredSectionId;
int preferredSectionIndex;
InternalContentData data;
};
ADS_NAMESPACE_END
#endif

View File

@ -1,95 +1,95 @@
#ifndef SECTIONCONTENT_H
#define SECTIONCONTENT_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QSharedPointer>
#include <QWeakPointer>
#include <QPointer>
class QWidget;
#include "ads/API.h"
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class ADS_EXPORT_API SectionContent
{
friend class CMainContainerWidget;
private:
SectionContent();
SectionContent(const SectionContent&);
SectionContent& operator=(const SectionContent&);
public:
typedef QSharedPointer<SectionContent> RefPtr;
typedef QWeakPointer<SectionContent> WeakPtr;
enum Flag
{
None = 0,
Closeable = 1,
Maximizable = 2,
AllFlags = Closeable | Maximizable
};
Q_DECLARE_FLAGS(Flags, Flag)
/*!
* Creates new content, associates it to <em>container</em> and takes ownership of
* <em>title</em>- and <em>content</em>- widgets.
* \param uniqueName An unique identifier across the entire process.
* \param container The parent ContainerWidget in which this content will be active.
* \param title The widget to use as title.
* \param content The widget to use as content.
* \return May return a invalid ref-pointer in case of invalid parameters.
*/
static RefPtr newSectionContent(const QString& uniqueName, CMainContainerWidget* container, QWidget* title, QWidget* content);
virtual ~SectionContent();
int uid() const;
QString uniqueName() const;
CMainContainerWidget* containerWidget() const;
QWidget* titleWidgetContent() const;
QWidget* contentWidget() const;
Flags flags() const;
QString visibleTitle() const;
QString title() const;
void setTitle(const QString& title);
void setFlags(const Flags f);
private:
const int _uid;
QString _uniqueName;
QPointer<CMainContainerWidget> m_MainContainerWidget;
QPointer<QWidget> m_TitleWidgetContent;
QPointer<QWidget> m_ContentWidget;
// Optional attributes
QString _title;
Flags _flags;
/* Note: This method could be a problem in static build environment
* since it may begin with 0 for every module which uses ADS.
*/
static int GetNextUid();
};
ADS_NAMESPACE_END
#endif
#ifndef SECTIONCONTENT_H
#define SECTIONCONTENT_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QSharedPointer>
#include <QWeakPointer>
#include <QPointer>
class QWidget;
#include "ads/API.h"
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class ADS_EXPORT_API SectionContent
{
friend class CMainContainerWidget;
private:
SectionContent();
SectionContent(const SectionContent&);
SectionContent& operator=(const SectionContent&);
public:
typedef QSharedPointer<SectionContent> RefPtr;
typedef QWeakPointer<SectionContent> WeakPtr;
enum Flag
{
None = 0,
Closeable = 1,
Maximizable = 2,
AllFlags = Closeable | Maximizable
};
Q_DECLARE_FLAGS(Flags, Flag)
/*!
* Creates new content, associates it to <em>container</em> and takes ownership of
* <em>title</em>- and <em>content</em>- widgets.
* \param uniqueName An unique identifier across the entire process.
* \param container The parent ContainerWidget in which this content will be active.
* \param title The widget to use as title.
* \param content The widget to use as content.
* \return May return a invalid ref-pointer in case of invalid parameters.
*/
static RefPtr newSectionContent(const QString& uniqueName, CMainContainerWidget* container, QWidget* title, QWidget* content);
virtual ~SectionContent();
int uid() const;
QString uniqueName() const;
CMainContainerWidget* containerWidget() const;
QWidget* titleWidgetContent() const;
QWidget* contentWidget() const;
Flags flags() const;
QString visibleTitle() const;
QString title() const;
void setTitle(const QString& title);
void setFlags(const Flags f);
private:
const int _uid;
QString _uniqueName;
QPointer<CMainContainerWidget> m_MainContainerWidget;
QPointer<QWidget> m_TitleWidgetContent;
QPointer<QWidget> m_ContentWidget;
// Optional attributes
QString _title;
Flags _flags;
/* Note: This method could be a problem in static build environment
* since it may begin with 0 for every module which uses ADS.
*/
static int GetNextUid();
};
ADS_NAMESPACE_END
#endif

View File

@ -1,85 +1,85 @@
#ifndef SECTION_CONTENT_WIDGET_H
#define SECTION_CONTENT_WIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QFrame>
#include "ads/API.h"
#include "ads/SectionContent.h"
namespace ads
{
class CMainContainerWidget;
class SectionWidget;
class SectionTitleWidget;
struct SectionContentWidgetPrivate;
class CSectionContentWidget : public QFrame
{
Q_OBJECT
private:
SectionContentWidgetPrivate* d;
friend class SectionContentWidgetPrivate;
friend class CMainContainerWidget;
public:
enum Flag
{
None = 0,
Closeable = 1,
Maximizable = 2,
AllFlags = Closeable | Maximizable
};
Q_DECLARE_FLAGS(Flags, Flag)
CSectionContentWidget(SectionContent::RefPtr c = SectionContent::RefPtr(), QWidget* parent = 0);
virtual ~CSectionContentWidget();
/*!
* Creates new content, associates it to <em>container</em> and takes ownership of
* <em>title</em>- and <em>content</em>- widgets.
* \param uniqueName An unique identifier across the entire process.
* \param container The parent ContainerWidget in which this content will be active.
* \param title The widget to use as title.
* \param content The widget to use as content.
* \return May return a invalid ref-pointer in case of invalid parameters.
*/
static CSectionContentWidget* newSectionContent(const QString& uniqueName,
CMainContainerWidget* container, QWidget* title, QWidget* content);
int uid() const;
QString uniqueName() const;
CMainContainerWidget* containerWidget() const;
QWidget* titleWidgetContent() const;
QWidget* contentWidget() const;
Flags flags() const;
QString visibleTitle() const;
QString title() const;
void setTitle(const QString& title);
void setFlags(const Flags f);
private:
SectionContent::RefPtr _content;
};
} // namespace ads
#endif
#ifndef SECTION_CONTENT_WIDGET_H
#define SECTION_CONTENT_WIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QFrame>
#include "ads/API.h"
#include "ads/SectionContent.h"
namespace ads
{
class CMainContainerWidget;
class SectionWidget;
class SectionTitleWidget;
struct SectionContentWidgetPrivate;
class CSectionContentWidget : public QFrame
{
Q_OBJECT
private:
SectionContentWidgetPrivate* d;
friend class SectionContentWidgetPrivate;
friend class CMainContainerWidget;
public:
enum Flag
{
None = 0,
Closeable = 1,
Maximizable = 2,
AllFlags = Closeable | Maximizable
};
Q_DECLARE_FLAGS(Flags, Flag)
CSectionContentWidget(SectionContent::RefPtr c = SectionContent::RefPtr(), QWidget* parent = 0);
virtual ~CSectionContentWidget();
/*!
* Creates new content, associates it to <em>container</em> and takes ownership of
* <em>title</em>- and <em>content</em>- widgets.
* \param uniqueName An unique identifier across the entire process.
* \param container The parent ContainerWidget in which this content will be active.
* \param title The widget to use as title.
* \param content The widget to use as content.
* \return May return a invalid ref-pointer in case of invalid parameters.
*/
static CSectionContentWidget* newSectionContent(const QString& uniqueName,
CMainContainerWidget* container, QWidget* title, QWidget* content);
int uid() const;
QString uniqueName() const;
CMainContainerWidget* containerWidget() const;
QWidget* titleWidgetContent() const;
QWidget* contentWidget() const;
Flags flags() const;
QString visibleTitle() const;
QString title() const;
void setTitle(const QString& title);
void setFlags(const Flags f);
private:
SectionContent::RefPtr _content;
};
} // namespace ads
#endif

View File

@ -1,78 +1,78 @@
#ifndef SECTION_TITLE_WIDGET_H
#define SECTION_TITLE_WIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QPointer>
#include <QPoint>
#include <QFrame>
#include "ads/API.h"
#include "ads/SectionContent.h"
class QPushButton;
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionWidget;
class FloatingWidget;
class SectionTitleWidget : public QFrame
{
Q_OBJECT
Q_PROPERTY(bool activeTab READ isActiveTab WRITE setActiveTab NOTIFY activeTabChanged)
friend class CMainContainerWidget;
friend class SectionWidget;
friend class CContainerWidget;
SectionContent::RefPtr m_Content;
// Drag & Drop (Floating)
QPoint m_DragStartMousePosition;
QPoint m_DragStartGlobalMousePosition;
QPoint m_DragStartPosition;
// Drag & Drop (Title/Tabs)
bool m_TabMoving;
// Property values
bool m_IsActiveTab;
public:
SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent);
virtual ~SectionTitleWidget();
bool isActiveTab() const;
void setActiveTab(bool active);
protected:
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
private:
void startFloating(QMouseEvent* ev, CMainContainerWidget* cw, SectionWidget* sectionwidget);
void moveTab(QMouseEvent* ev);
signals:
void activeTabChanged();
void clicked();
};
ADS_NAMESPACE_END
#endif
#ifndef SECTION_TITLE_WIDGET_H
#define SECTION_TITLE_WIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QPointer>
#include <QPoint>
#include <QFrame>
#include "ads/API.h"
#include "ads/SectionContent.h"
class QPushButton;
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionWidget;
class FloatingWidget;
class SectionTitleWidget : public QFrame
{
Q_OBJECT
Q_PROPERTY(bool activeTab READ isActiveTab WRITE setActiveTab NOTIFY activeTabChanged)
friend class CMainContainerWidget;
friend class SectionWidget;
friend class CContainerWidget;
SectionContent::RefPtr m_Content;
// Drag & Drop (Floating)
QPoint m_DragStartMousePosition;
QPoint m_DragStartGlobalMousePosition;
QPoint m_DragStartPosition;
// Drag & Drop (Title/Tabs)
bool m_TabMoving;
// Property values
bool m_IsActiveTab;
public:
SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent);
virtual ~SectionTitleWidget();
bool isActiveTab() const;
void setActiveTab(bool active);
protected:
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
private:
void startFloating(QMouseEvent* ev, CMainContainerWidget* cw, SectionWidget* sectionwidget);
void moveTab(QMouseEvent* ev);
signals:
void activeTabChanged();
void clicked();
};
ADS_NAMESPACE_END
#endif

View File

@ -1,129 +1,129 @@
#ifndef SECTION_WIDGET_H
#define SECTION_WIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QDebug>
#include <QPointer>
#include <QList>
#include <QFrame>
#include <QScrollArea>
class QBoxLayout;
class QStackedLayout;
class QPushButton;
class QMenu;
#include "ads/API.h"
#include "ads/Internal.h"
#include "ads/SectionContent.h"
#include "ads/FloatingWidget.h"
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionTitleWidget;
class CSectionContentWidget;
// SectionWidget manages multiple instances of SectionContent.
// It displays a title TAB, which is clickable and will switch to
// the contents associated to the title when clicked.
class ADS_EXPORT_API SectionWidget : public QFrame
{
Q_OBJECT
friend class CMainContainerWidget;
friend class CContainerWidget;
explicit SectionWidget(CMainContainerWidget* MainContainer, CContainerWidget* parent);
public:
virtual ~SectionWidget();
int uid() const;
CContainerWidget* containerWidget() const;
QRect titleAreaGeometry() const;
QRect contentAreaGeometry() const;
const QList<SectionContent::RefPtr>& contents() const { return m_Contents; }
void addContent(const SectionContent::RefPtr& c);
void addContent(const InternalContentData& data, bool autoActivate);
bool takeContent(int uid, InternalContentData& data);
bool takeContentAt(int Index, InternalContentData& data);
int indexOfContent(const SectionContent::RefPtr& c) const;
int indexOfContentByUid(int uid) const;
int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = NULL) const;
int currentIndex() const;
void moveContent(int from, int to);
virtual bool eventFilter(QObject *watched, QEvent *event);
inline int contentCount() const {return m_ContentWidgets.size();}
protected:
virtual void showEvent(QShowEvent*);
public slots:
void setCurrentIndex(int index);
private slots:
void onSectionTitleClicked();
void onCloseButtonClicked();
void onTabsMenuActionTriggered(bool);
void updateTabsMenu();
private:
const int _uid;
QPointer<CMainContainerWidget> m_MainContainerWidget;
QList<SectionContent::RefPtr> m_Contents;
QList<SectionTitleWidget*> m_TitleWidgets;
QList<CSectionContentWidget*> m_ContentWidgets;
QBoxLayout* _topLayout;
QScrollArea* _tabsScrollArea;
QWidget* _tabsContainerWidget;
QBoxLayout* _tabsLayout;
QPushButton* _tabsMenuButton;
QPushButton* _closeButton;
int _tabsLayoutInitCount; // used for calculations on _tabsLayout modification calls.
QStackedLayout *_contentsLayout;
QPoint _mousePressPoint;
SectionContent::RefPtr _mousePressContent;
SectionTitleWidget* _mousePressTitleWidget;
static int GetNextUid();
};
/* Custom scrollable implementation for tabs */
class SectionWidgetTabsScrollArea : public QScrollArea
{
public:
SectionWidgetTabsScrollArea(SectionWidget* sectionWidget, QWidget* parent = NULL);
virtual ~SectionWidgetTabsScrollArea();
protected:
QPoint _dragStartPos;
QPointer<FloatingWidget> _fw;
virtual void wheelEvent(QWheelEvent*);
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
};
ADS_NAMESPACE_END
#endif
#ifndef SECTION_WIDGET_H
#define SECTION_WIDGET_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QDebug>
#include <QPointer>
#include <QList>
#include <QFrame>
#include <QScrollArea>
class QBoxLayout;
class QStackedLayout;
class QPushButton;
class QMenu;
#include "ads/API.h"
#include "ads/Internal.h"
#include "ads/SectionContent.h"
#include "ads/FloatingWidget.h"
ADS_NAMESPACE_BEGIN
class CMainContainerWidget;
class SectionTitleWidget;
class CSectionContentWidget;
// SectionWidget manages multiple instances of SectionContent.
// It displays a title TAB, which is clickable and will switch to
// the contents associated to the title when clicked.
class ADS_EXPORT_API SectionWidget : public QFrame
{
Q_OBJECT
friend class CMainContainerWidget;
friend class CContainerWidget;
explicit SectionWidget(CMainContainerWidget* MainContainer, CContainerWidget* parent);
public:
virtual ~SectionWidget();
int uid() const;
CContainerWidget* containerWidget() const;
QRect titleAreaGeometry() const;
QRect contentAreaGeometry() const;
const QList<SectionContent::RefPtr>& contents() const { return m_Contents; }
void addContent(const SectionContent::RefPtr& c);
void addContent(const InternalContentData& data, bool autoActivate);
bool takeContent(int uid, InternalContentData& data);
bool takeContentAt(int Index, InternalContentData& data);
int indexOfContent(const SectionContent::RefPtr& c) const;
int indexOfContentByUid(int uid) const;
int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = NULL) const;
int currentIndex() const;
void moveContent(int from, int to);
virtual bool eventFilter(QObject *watched, QEvent *event);
inline int contentCount() const {return m_ContentWidgets.size();}
protected:
virtual void showEvent(QShowEvent*);
public slots:
void setCurrentIndex(int index);
private slots:
void onSectionTitleClicked();
void onCloseButtonClicked();
void onTabsMenuActionTriggered(bool);
void updateTabsMenu();
private:
const int _uid;
QPointer<CMainContainerWidget> m_MainContainerWidget;
QList<SectionContent::RefPtr> m_Contents;
QList<SectionTitleWidget*> m_TitleWidgets;
QList<CSectionContentWidget*> m_ContentWidgets;
QBoxLayout* _topLayout;
QScrollArea* _tabsScrollArea;
QWidget* _tabsContainerWidget;
QBoxLayout* _tabsLayout;
QPushButton* _tabsMenuButton;
QPushButton* _closeButton;
int _tabsLayoutInitCount; // used for calculations on _tabsLayout modification calls.
QStackedLayout *_contentsLayout;
QPoint _mousePressPoint;
SectionContent::RefPtr _mousePressContent;
SectionTitleWidget* _mousePressTitleWidget;
static int GetNextUid();
};
/* Custom scrollable implementation for tabs */
class SectionWidgetTabsScrollArea : public QScrollArea
{
public:
SectionWidgetTabsScrollArea(SectionWidget* sectionWidget, QWidget* parent = NULL);
virtual ~SectionWidgetTabsScrollArea();
protected:
QPoint _dragStartPos;
QPointer<FloatingWidget> _fw;
virtual void wheelEvent(QWheelEvent*);
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
};
ADS_NAMESPACE_END
#endif

View File

@ -1,181 +1,181 @@
#ifndef ADS_SERIALIZATION_H
#define ADS_SERIALIZATION_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QtGlobal>
#include <QList>
#include <QString>
#include <QDataStream>
#include <QBuffer>
#include "ads/API.h"
ADS_NAMESPACE_SER_BEGIN
enum EntryType
{
ET_Unknown = 0x00000000,
ET_Hierarchy = 0x00000001,
ET_SectionIndex = 0x00000002,
// Begin of custom entry types (e.g. CustomType + 42)
ET_Custom = 0x0000ffff
};
class ADS_EXPORT_API HeaderEntity
{
public:
static qint32 MAGIC;
static qint32 MAJOR_VERSION;
static qint32 MINOR_VERSION;
HeaderEntity();
qint32 magic;
qint32 majorVersion;
qint32 minorVersion;
};
QDataStream& operator<<(QDataStream& out, const HeaderEntity& data);
QDataStream& operator>>(QDataStream& in, HeaderEntity& data);
class ADS_EXPORT_API OffsetsHeaderEntity
{
public:
OffsetsHeaderEntity();
qint64 entriesCount;
QList<class OffsetsHeaderEntryEntity> entries;
};
QDataStream& operator<<(QDataStream& out, const OffsetsHeaderEntity& data);
QDataStream& operator>>(QDataStream& in, OffsetsHeaderEntity& data);
class ADS_EXPORT_API OffsetsHeaderEntryEntity
{
public:
OffsetsHeaderEntryEntity();
qint32 type;
qint64 offset;
qint64 contentSize;
};
QDataStream& operator<<(QDataStream& out, const OffsetsHeaderEntryEntity& data);
QDataStream& operator>>(QDataStream& in, OffsetsHeaderEntryEntity& data);
class ADS_EXPORT_API SectionEntity
{
public:
SectionEntity();
qint32 x;
qint32 y;
qint32 width;
qint32 height;
qint32 currentIndex;
qint32 sectionContentsCount;
QList<class SectionContentEntity> sectionContents;
};
QDataStream& operator<<(QDataStream& out, const SectionEntity& data);
QDataStream& operator>>(QDataStream& in, SectionEntity& data);
class ADS_EXPORT_API SectionContentEntity
{
public:
SectionContentEntity();
QString uniqueName;
bool visible;
qint32 preferredIndex;
};
QDataStream& operator<<(QDataStream& out, const SectionContentEntity& data);
QDataStream& operator>>(QDataStream& in, SectionContentEntity& data);
class ADS_EXPORT_API FloatingContentEntity
{
public:
FloatingContentEntity();
QString uniqueName;
qint32 xpos;
qint32 ypos;
qint32 width;
qint32 height;
bool visible;
};
QDataStream& operator<<(QDataStream& out, const FloatingContentEntity& data);
QDataStream& operator>>(QDataStream& in, FloatingContentEntity& data);
// Type: OffsetHeaderEntry::Hierarchy
class ADS_EXPORT_API HierarchyData
{
public:
HierarchyData();
QByteArray data;
};
QDataStream& operator<<(QDataStream& out, const HierarchyData& data);
QDataStream& operator>>(QDataStream& in, HierarchyData& data);
// Type: OffsetHeaderEntry::SectionIndex
class ADS_EXPORT_API SectionIndexData
{
public:
SectionIndexData();
qint32 sectionsCount;
QList<SectionEntity> sections;
};
QDataStream& operator<<(QDataStream& out, const SectionIndexData& data);
QDataStream& operator>>(QDataStream& in, SectionIndexData& data);
/*!
* \brief The InMemoryWriter class writes into a QByteArray.
*/
class ADS_EXPORT_API InMemoryWriter
{
public:
InMemoryWriter();
bool write(qint32 entryType, const QByteArray& data);
bool write(const SectionIndexData& data);
QByteArray toByteArray() const;
qint32 offsetsCount() const { return _offsetsHeader.entriesCount; }
private:
QBuffer _contentBuffer;
OffsetsHeaderEntity _offsetsHeader;
};
/*!
* \brief The InMemoryReader class
*/
class ADS_EXPORT_API InMemoryReader
{
public:
InMemoryReader(const QByteArray& data);
bool initReadHeader();
bool read(qint32 entryType, QByteArray &data);
bool read(SectionIndexData& sid);
qint32 offsetsCount() const { return _offsetsHeader.entriesCount; }
private:
QByteArray _data;
OffsetsHeaderEntity _offsetsHeader;
};
ADS_NAMESPACE_SER_END
#endif
#ifndef ADS_SERIALIZATION_H
#define ADS_SERIALIZATION_H
/*******************************************************************************
** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <QtGlobal>
#include <QList>
#include <QString>
#include <QDataStream>
#include <QBuffer>
#include "ads/API.h"
ADS_NAMESPACE_SER_BEGIN
enum EntryType
{
ET_Unknown = 0x00000000,
ET_Hierarchy = 0x00000001,
ET_SectionIndex = 0x00000002,
// Begin of custom entry types (e.g. CustomType + 42)
ET_Custom = 0x0000ffff
};
class ADS_EXPORT_API HeaderEntity
{
public:
static qint32 MAGIC;
static qint32 MAJOR_VERSION;
static qint32 MINOR_VERSION;
HeaderEntity();
qint32 magic;
qint32 majorVersion;
qint32 minorVersion;
};
QDataStream& operator<<(QDataStream& out, const HeaderEntity& data);
QDataStream& operator>>(QDataStream& in, HeaderEntity& data);
class ADS_EXPORT_API OffsetsHeaderEntity
{
public:
OffsetsHeaderEntity();
qint64 entriesCount;
QList<class OffsetsHeaderEntryEntity> entries;
};
QDataStream& operator<<(QDataStream& out, const OffsetsHeaderEntity& data);
QDataStream& operator>>(QDataStream& in, OffsetsHeaderEntity& data);
class ADS_EXPORT_API OffsetsHeaderEntryEntity
{
public:
OffsetsHeaderEntryEntity();
qint32 type;
qint64 offset;
qint64 contentSize;
};
QDataStream& operator<<(QDataStream& out, const OffsetsHeaderEntryEntity& data);
QDataStream& operator>>(QDataStream& in, OffsetsHeaderEntryEntity& data);
class ADS_EXPORT_API SectionEntity
{
public:
SectionEntity();
qint32 x;
qint32 y;
qint32 width;
qint32 height;
qint32 currentIndex;
qint32 sectionContentsCount;
QList<class SectionContentEntity> sectionContents;
};
QDataStream& operator<<(QDataStream& out, const SectionEntity& data);
QDataStream& operator>>(QDataStream& in, SectionEntity& data);
class ADS_EXPORT_API SectionContentEntity
{
public:
SectionContentEntity();
QString uniqueName;
bool visible;
qint32 preferredIndex;
};
QDataStream& operator<<(QDataStream& out, const SectionContentEntity& data);
QDataStream& operator>>(QDataStream& in, SectionContentEntity& data);
class ADS_EXPORT_API FloatingContentEntity
{
public:
FloatingContentEntity();
QString uniqueName;
qint32 xpos;
qint32 ypos;
qint32 width;
qint32 height;
bool visible;
};
QDataStream& operator<<(QDataStream& out, const FloatingContentEntity& data);
QDataStream& operator>>(QDataStream& in, FloatingContentEntity& data);
// Type: OffsetHeaderEntry::Hierarchy
class ADS_EXPORT_API HierarchyData
{
public:
HierarchyData();
QByteArray data;
};
QDataStream& operator<<(QDataStream& out, const HierarchyData& data);
QDataStream& operator>>(QDataStream& in, HierarchyData& data);
// Type: OffsetHeaderEntry::SectionIndex
class ADS_EXPORT_API SectionIndexData
{
public:
SectionIndexData();
qint32 sectionsCount;
QList<SectionEntity> sections;
};
QDataStream& operator<<(QDataStream& out, const SectionIndexData& data);
QDataStream& operator>>(QDataStream& in, SectionIndexData& data);
/*!
* \brief The InMemoryWriter class writes into a QByteArray.
*/
class ADS_EXPORT_API InMemoryWriter
{
public:
InMemoryWriter();
bool write(qint32 entryType, const QByteArray& data);
bool write(const SectionIndexData& data);
QByteArray toByteArray() const;
qint32 offsetsCount() const { return _offsetsHeader.entriesCount; }
private:
QBuffer _contentBuffer;
OffsetsHeaderEntity _offsetsHeader;
};
/*!
* \brief The InMemoryReader class
*/
class ADS_EXPORT_API InMemoryReader
{
public:
InMemoryReader(const QByteArray& data);
bool initReadHeader();
bool read(qint32 entryType, QByteArray &data);
bool read(SectionIndexData& sid);
qint32 offsetsCount() const { return _offsetsHeader.entriesCount; }
private:
QByteArray _data;
OffsetsHeaderEntity _offsetsHeader;
};
ADS_NAMESPACE_SER_END
#endif