mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 10:24:45 +08:00
Continued refactoring to prepare split of functionality of ContainerWidget
This commit is contained in:
parent
411e4002f1
commit
f4c0d38ba4
@ -48,7 +48,7 @@ class QSplitter;
|
|||||||
//#define ADS_ANIMATION_DURATION 150
|
//#define ADS_ANIMATION_DURATION 150
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class ContainerWidget;
|
class MainContainerWidget;
|
||||||
class SectionWidget;
|
class SectionWidget;
|
||||||
|
|
||||||
enum DropArea
|
enum DropArea
|
||||||
@ -65,8 +65,8 @@ enum DropArea
|
|||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(DropAreas, DropArea)
|
Q_DECLARE_FLAGS(DropAreas, DropArea)
|
||||||
|
|
||||||
void deleteEmptySplitter(ContainerWidget* container);
|
void deleteEmptySplitter(MainContainerWidget* container);
|
||||||
ContainerWidget* findParentContainerWidget(QWidget* w);
|
MainContainerWidget* findParentContainerWidget(QWidget* w);
|
||||||
SectionWidget* findParentSectionWidget(QWidget* w);
|
SectionWidget* findParentSectionWidget(QWidget* w);
|
||||||
QSplitter* findParentSplitter(QWidget* w);
|
QSplitter* findParentSplitter(QWidget* w);
|
||||||
QSplitter* findImmediateSplitter(QWidget* w);
|
QSplitter* findImmediateSplitter(QWidget* w);
|
||||||
|
@ -5,17 +5,18 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QSplitter>
|
||||||
|
|
||||||
class QPoint;
|
class QPoint;
|
||||||
class QSplitter;
|
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QGridLayout;
|
|
||||||
|
|
||||||
#include "ads/API.h"
|
#include "ads/API.h"
|
||||||
#include "ads/Internal.h"
|
#include "ads/Internal.h"
|
||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
#include "ads/FloatingWidget.h"
|
#include "ads/FloatingWidget.h"
|
||||||
#include "ads/Serialization.h"
|
#include "ads/Serialization.h"
|
||||||
#include "ContainerWidget_p.h"
|
#include "ads/DropOverlay.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class SectionWidget;
|
class SectionWidget;
|
||||||
@ -23,11 +24,12 @@ class DropOverlay;
|
|||||||
class InternalContentData;
|
class InternalContentData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* ContainerWidget is the main container to provide the docking
|
* ContainerWidget is the main container to provide the docking
|
||||||
* functionality. It manages multiple sections with all possible areas.
|
* functionality. It manages multiple sections with all possible areas.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT_API ContainerWidget : public QFrame
|
class ADS_EXPORT_API MainContainerWidget : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -35,13 +37,11 @@ class ADS_EXPORT_API ContainerWidget : public QFrame
|
|||||||
friend class SectionWidget;
|
friend class SectionWidget;
|
||||||
friend class FloatingWidget;
|
friend class FloatingWidget;
|
||||||
friend class SectionTitleWidget;
|
friend class SectionTitleWidget;
|
||||||
friend class SectionContentWidget;
|
|
||||||
friend class SectionWidgetTabsScrollArea;
|
|
||||||
friend class ContainerWidgetPrivate;
|
friend class ContainerWidgetPrivate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ContainerWidget(QWidget *parent = NULL);
|
explicit MainContainerWidget(QWidget *parent = NULL);
|
||||||
virtual ~ContainerWidget();
|
virtual ~MainContainerWidget();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Public API
|
// Public API
|
||||||
@ -113,7 +113,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
QList<SectionContent::RefPtr> contents() const;
|
QList<SectionContent::RefPtr> contents() const;
|
||||||
|
|
||||||
QPointer<DropOverlay> dropOverlay() const;
|
/**
|
||||||
|
* Access function for the section drop overlay
|
||||||
|
*/
|
||||||
|
QPointer<DropOverlay> sectionDropOverlay() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the events of the floating widgets
|
||||||
|
*/
|
||||||
|
virtual bool event(QEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//
|
//
|
||||||
@ -122,8 +130,8 @@ private:
|
|||||||
|
|
||||||
SectionWidget* newSectionWidget();
|
SectionWidget* newSectionWidget();
|
||||||
SectionWidget* dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area, bool autoActive = true);
|
SectionWidget* dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area, bool autoActive = true);
|
||||||
void addSection(SectionWidget* section);
|
void addSectionWidget(SectionWidget* section);
|
||||||
SectionWidget* sectionAt(const QPoint& pos) const;
|
SectionWidget* sectionWidgetAt(const QPoint& pos) const;
|
||||||
SectionWidget* dropContentOuterHelper(QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append);
|
SectionWidget* dropContentOuterHelper(QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append);
|
||||||
|
|
||||||
// Serialization
|
// Serialization
|
||||||
@ -138,18 +146,17 @@ private:
|
|||||||
bool restoreSectionWidgets(QDataStream& in, int version, QSplitter* currentSplitter, QList<SectionWidget*>& sections, QList<SectionContent::RefPtr>& contentsToHide);
|
bool restoreSectionWidgets(QDataStream& in, int version, QSplitter* currentSplitter, QList<SectionWidget*>& sections, QList<SectionContent::RefPtr>& contentsToHide);
|
||||||
|
|
||||||
bool takeContent(const SectionContent::RefPtr& sc, InternalContentData& data);
|
bool takeContent(const SectionContent::RefPtr& sc, InternalContentData& data);
|
||||||
|
|
||||||
void moveFloatingWidget(const QPoint& TargetPos);
|
|
||||||
FloatingWidget* startFloating(SectionWidget* sectionwidget, int ContentUid, const QPoint& TargetPos);
|
FloatingWidget* startFloating(SectionWidget* sectionwidget, int ContentUid, const QPoint& TargetPos);
|
||||||
void hideContainerOverlay();
|
void hideContainerOverlay();
|
||||||
SectionWidget* insertNewSectionWidget(const InternalContentData& data,
|
SectionWidget* insertNewSectionWidget(const InternalContentData& data,
|
||||||
SectionWidget* targetSection, SectionWidget* ret, Qt::Orientation Orientation, int InsertIndexOffset);
|
SectionWidget* targetSection, SectionWidget* ret, Qt::Orientation Orientation, int InsertIndexOffset);
|
||||||
|
void moveFloatingWidget(const QPoint& TargetPos);
|
||||||
|
void dropFloatingWidget(FloatingWidget* FloatingWidget, const QPoint& TargetPos);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onActiveTabChanged();
|
void onActiveTabChanged();
|
||||||
void onActionToggleSectionContentVisibility(bool visible);
|
void onActionToggleSectionContentVisibility(bool visible);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void orientationChanged();
|
void orientationChanged();
|
||||||
|
|
||||||
@ -168,7 +175,26 @@ signals:
|
|||||||
void sectionContentVisibilityChanged(const SectionContent::RefPtr& sc, bool visible);
|
void sectionContentVisibilityChanged(const SectionContent::RefPtr& sc, bool visible);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContainerWidgetPrivate* d;///< private data
|
QList<SectionWidget*> m_Sections;
|
||||||
|
QList<FloatingWidget*> m_Floatings;
|
||||||
|
QHash<int, HiddenSectionItem> m_HiddenSectionContents;
|
||||||
|
|
||||||
|
|
||||||
|
// Helper lookup maps, restricted to this container.
|
||||||
|
QHash<int, SectionContent::WeakPtr> m_SectionContentIdMap;
|
||||||
|
QHash<QString, SectionContent::WeakPtr> m_SectionContentNameMap;
|
||||||
|
QHash<int, SectionWidget*> m_SectionWidgetIdMap;
|
||||||
|
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// Drop overlay stuff.
|
||||||
|
QPointer<DropOverlay> m_SectionDropOverlay;
|
||||||
|
QPointer<DropOverlay> m_ContainerDropOverlay;
|
||||||
};
|
};
|
||||||
|
|
||||||
ADS_NAMESPACE_END
|
ADS_NAMESPACE_END
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
#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;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Container widget private data
|
|
||||||
*/
|
|
||||||
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> SectionDropOverlay;
|
|
||||||
QPointer<DropOverlay> ContainerDropOverlay;
|
|
||||||
//QWidget* LeftBorderDropArea;
|
|
||||||
}; // struct ContainerWidgetPrivate
|
|
||||||
} // namespace ads
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
#endif // ContainerWidget_pH
|
|
@ -32,8 +32,16 @@ public:
|
|||||||
virtual ~DropOverlay();
|
virtual ~DropOverlay();
|
||||||
|
|
||||||
void setAllowedAreas(DropAreas areas);
|
void setAllowedAreas(DropAreas areas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns flags with all allowed drop areas
|
||||||
|
*/
|
||||||
DropAreas allowedAreas() const;
|
DropAreas allowedAreas() const;
|
||||||
DropArea cursorLocation() const;
|
|
||||||
|
/**
|
||||||
|
* Returns the drop area under the current cursor location
|
||||||
|
*/
|
||||||
|
DropArea dropAreaUnderCursor() const;
|
||||||
|
|
||||||
DropArea showDropOverlay(QWidget* target);
|
DropArea showDropOverlay(QWidget* target);
|
||||||
void showDropOverlay(QWidget* target, const QRect& targetAreaRect);
|
void showDropOverlay(QWidget* target, const QRect& targetAreaRect);
|
||||||
|
@ -8,7 +8,7 @@ class QBoxLayout;
|
|||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class ContainerWidget;
|
class MainContainerWidget;
|
||||||
class SectionTitleWidget;
|
class SectionTitleWidget;
|
||||||
class SectionContentWidget;
|
class SectionContentWidget;
|
||||||
class InternalContentData;
|
class InternalContentData;
|
||||||
@ -20,28 +20,44 @@ class FloatingWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class ContainerWidget;
|
friend class MainContainerWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FloatingWidget(ContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent = NULL);
|
FloatingWidget(MainContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent = NULL);
|
||||||
FloatingWidget(SectionWidget* sectionWidget);
|
FloatingWidget(SectionWidget* sectionWidget);
|
||||||
virtual ~FloatingWidget();
|
virtual ~FloatingWidget();
|
||||||
|
|
||||||
SectionContent::RefPtr content() const { return _content; }
|
SectionContent::RefPtr content() const { return _content; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if this floating widget is dragged right now.
|
||||||
|
* That means, left mouse button is down in the title widget
|
||||||
|
*/
|
||||||
|
bool isDraggingActive() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current zOrderIndex
|
||||||
|
*/
|
||||||
|
unsigned int zOrderIndex() const;
|
||||||
|
|
||||||
public://private:
|
public://private:
|
||||||
bool takeContent(InternalContentData& data);
|
bool takeContent(InternalContentData& data);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void changeEvent(QEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCloseButtonClicked();
|
void onCloseButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContainerWidget* _container;
|
MainContainerWidget* _container;
|
||||||
SectionContent::RefPtr _content;
|
SectionContent::RefPtr _content;
|
||||||
SectionTitleWidget* _titleWidget;
|
SectionTitleWidget* _titleWidget;
|
||||||
SectionContentWidget* _contentWidget;
|
SectionContentWidget* _contentWidget;
|
||||||
|
|
||||||
QBoxLayout* _titleLayout;
|
QBoxLayout* _titleLayout;
|
||||||
|
unsigned int m_zOrderIndex = 0;
|
||||||
|
static unsigned int zOrderCounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
ADS_NAMESPACE_END
|
ADS_NAMESPACE_END
|
||||||
|
@ -9,11 +9,11 @@ class QWidget;
|
|||||||
#include "ads/API.h"
|
#include "ads/API.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class ContainerWidget;
|
class MainContainerWidget;
|
||||||
|
|
||||||
class ADS_EXPORT_API SectionContent
|
class ADS_EXPORT_API SectionContent
|
||||||
{
|
{
|
||||||
friend class ContainerWidget;
|
friend class MainContainerWidget;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SectionContent();
|
SectionContent();
|
||||||
@ -41,12 +41,12 @@ public:
|
|||||||
* \param content The widget to use as content.
|
* \param content The widget to use as content.
|
||||||
* \return May return a invalid ref-pointer in case of invalid parameters.
|
* \return May return a invalid ref-pointer in case of invalid parameters.
|
||||||
*/
|
*/
|
||||||
static RefPtr newSectionContent(const QString& uniqueName, ContainerWidget* container, QWidget* title, QWidget* content);
|
static RefPtr newSectionContent(const QString& uniqueName, MainContainerWidget* container, QWidget* title, QWidget* content);
|
||||||
|
|
||||||
virtual ~SectionContent();
|
virtual ~SectionContent();
|
||||||
int uid() const;
|
int uid() const;
|
||||||
QString uniqueName() const;
|
QString uniqueName() const;
|
||||||
ContainerWidget* containerWidget() const;
|
MainContainerWidget* containerWidget() const;
|
||||||
QWidget* titleWidget() const;
|
QWidget* titleWidget() const;
|
||||||
QWidget* contentWidget() const;
|
QWidget* contentWidget() const;
|
||||||
Flags flags() const;
|
Flags flags() const;
|
||||||
@ -60,7 +60,7 @@ private:
|
|||||||
const int _uid;
|
const int _uid;
|
||||||
QString _uniqueName;
|
QString _uniqueName;
|
||||||
|
|
||||||
QPointer<ContainerWidget> _containerWidget;
|
QPointer<MainContainerWidget> _containerWidget;
|
||||||
QPointer<QWidget> _titleWidget;
|
QPointer<QWidget> _titleWidget;
|
||||||
QPointer<QWidget> _contentWidget;
|
QPointer<QWidget> _contentWidget;
|
||||||
|
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class ContainerWidget;
|
class MainContainerWidget;
|
||||||
class SectionWidget;
|
class SectionWidget;
|
||||||
|
|
||||||
class SectionContentWidget : public QFrame
|
class SectionContentWidget : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class ContainerWidget;
|
friend class MainContainerWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SectionContentWidget(SectionContent::RefPtr c, QWidget* parent = 0);
|
SectionContentWidget(SectionContent::RefPtr c, QWidget* parent = 0);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class ContainerWidget;
|
class MainContainerWidget;
|
||||||
class SectionWidget;
|
class SectionWidget;
|
||||||
class FloatingWidget;
|
class FloatingWidget;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ class SectionTitleWidget : public QFrame
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool activeTab READ isActiveTab WRITE setActiveTab NOTIFY activeTabChanged)
|
Q_PROPERTY(bool activeTab READ isActiveTab WRITE setActiveTab NOTIFY activeTabChanged)
|
||||||
|
|
||||||
friend class ContainerWidget;
|
friend class MainContainerWidget;
|
||||||
friend class SectionWidget;
|
friend class SectionWidget;
|
||||||
|
|
||||||
SectionContent::RefPtr m_Content;
|
SectionContent::RefPtr m_Content;
|
||||||
@ -40,14 +40,20 @@ public:
|
|||||||
bool isActiveTab() const;
|
bool isActiveTab() const;
|
||||||
void setActiveTab(bool active);
|
void setActiveTab(bool active);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if this sections title widget is currently dragging
|
||||||
|
* a floating widget
|
||||||
|
*/
|
||||||
|
bool isDraggingFloatingWidget() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QMouseEvent* ev);
|
virtual void mousePressEvent(QMouseEvent* ev);
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* ev);
|
virtual void mouseReleaseEvent(QMouseEvent* ev);
|
||||||
virtual void mouseMoveEvent(QMouseEvent* ev);
|
virtual void mouseMoveEvent(QMouseEvent* ev);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void moveFloatingWidget(QMouseEvent* ev, ContainerWidget* cw);
|
void moveFloatingWidget(QMouseEvent* ev, MainContainerWidget* cw);
|
||||||
void startFloating(QMouseEvent* ev, ContainerWidget* cw, SectionWidget* sectionwidget);
|
void startFloating(QMouseEvent* ev, MainContainerWidget* cw, SectionWidget* sectionwidget);
|
||||||
void moveTab(QMouseEvent* ev);
|
void moveTab(QMouseEvent* ev);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -17,7 +17,7 @@ class QMenu;
|
|||||||
#include "ads/FloatingWidget.h"
|
#include "ads/FloatingWidget.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class ContainerWidget;
|
class MainContainerWidget;
|
||||||
class SectionTitleWidget;
|
class SectionTitleWidget;
|
||||||
class SectionContentWidget;
|
class SectionContentWidget;
|
||||||
|
|
||||||
@ -27,15 +27,15 @@ class SectionContentWidget;
|
|||||||
class ADS_EXPORT_API SectionWidget : public QFrame
|
class ADS_EXPORT_API SectionWidget : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class ContainerWidget;
|
friend class MainContainerWidget;
|
||||||
|
|
||||||
explicit SectionWidget(ContainerWidget* parent);
|
explicit SectionWidget(MainContainerWidget* parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~SectionWidget();
|
virtual ~SectionWidget();
|
||||||
|
|
||||||
int uid() const;
|
int uid() const;
|
||||||
ContainerWidget* containerWidget() const;
|
MainContainerWidget* containerWidget() const;
|
||||||
|
|
||||||
QRect titleAreaGeometry() const;
|
QRect titleAreaGeometry() const;
|
||||||
QRect contentAreaGeometry() const;
|
QRect contentAreaGeometry() const;
|
||||||
@ -69,7 +69,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
const int _uid;
|
const int _uid;
|
||||||
|
|
||||||
QPointer<ContainerWidget> _container;
|
QPointer<MainContainerWidget> _container;
|
||||||
QList<SectionContent::RefPtr> _contents;
|
QList<SectionContent::RefPtr> _contents;
|
||||||
QList<SectionTitleWidget*> _sectionTitles;
|
QList<SectionTitleWidget*> _sectionTitles;
|
||||||
QList<SectionContentWidget*> _sectionContents;
|
QList<SectionContentWidget*> _sectionContents;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <ads/ContainerWidget.h>
|
||||||
#include "ads/API.h"
|
#include "ads/API.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@ -5,7 +6,6 @@
|
|||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "ads/ContainerWidget.h"
|
|
||||||
#include "ads/SectionWidget.h"
|
#include "ads/SectionWidget.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
@ -25,7 +25,7 @@ static bool splitterContainsSectionWidget(QSplitter* splitter)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteEmptySplitter(ContainerWidget* container)
|
void deleteEmptySplitter(MainContainerWidget* container)
|
||||||
{
|
{
|
||||||
bool doAgain = false;
|
bool doAgain = false;
|
||||||
do
|
do
|
||||||
@ -47,13 +47,13 @@ void deleteEmptySplitter(ContainerWidget* container)
|
|||||||
while (doAgain);
|
while (doAgain);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerWidget* findParentContainerWidget(QWidget* w)
|
MainContainerWidget* findParentContainerWidget(QWidget* w)
|
||||||
{
|
{
|
||||||
ContainerWidget* cw = 0;
|
MainContainerWidget* cw = 0;
|
||||||
QWidget* next = w;
|
QWidget* next = w;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ((cw = dynamic_cast<ContainerWidget*>(next)) != 0)
|
if ((cw = dynamic_cast<MainContainerWidget*>(next)) != 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include "ads/ContainerWidget.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -10,6 +8,7 @@
|
|||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include "ads/Internal.h"
|
#include "ads/Internal.h"
|
||||||
#include "ads/SectionWidget.h"
|
#include "ads/SectionWidget.h"
|
||||||
@ -19,13 +18,11 @@
|
|||||||
#include "ads/Serialization.h"
|
#include "ads/Serialization.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "../include/ads/ContainerWidget.h"
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Static Helper //////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static QSplitter* newSplitter(Qt::Orientation orientation = Qt::Horizontal, QWidget* parent = 0)
|
static QSplitter* newSplitter(Qt::Orientation orientation = Qt::Horizontal, QWidget* parent = 0)
|
||||||
{
|
{
|
||||||
QSplitter* s = new QSplitter(orientation, parent);
|
QSplitter* s = new QSplitter(orientation, parent);
|
||||||
@ -35,47 +32,46 @@ static QSplitter* newSplitter(Qt::Orientation orientation = Qt::Horizontal, QWid
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
ContainerWidget::ContainerWidget(QWidget *parent) :
|
|
||||||
QFrame(parent),
|
MainContainerWidget::MainContainerWidget(QWidget *parent) :
|
||||||
d(new ContainerWidgetPrivate())
|
QFrame(parent)
|
||||||
{
|
{
|
||||||
d->SectionDropOverlay = new DropOverlay(this, DropOverlay::ModeSectionOverlay);
|
m_SectionDropOverlay = new DropOverlay(this, DropOverlay::ModeSectionOverlay);
|
||||||
d->ContainerDropOverlay = new DropOverlay(this, DropOverlay::ModeContainerOverlay);
|
m_ContainerDropOverlay = new DropOverlay(this, DropOverlay::ModeContainerOverlay);
|
||||||
d->ContainerDropOverlay->setAttribute(Qt::WA_TransparentForMouseEvents);
|
m_ContainerDropOverlay->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
d->ContainerDropOverlay->setWindowFlags(d->ContainerDropOverlay->windowFlags() | Qt::WindowTransparentForInput);
|
m_ContainerDropOverlay->setWindowFlags(m_ContainerDropOverlay->windowFlags() | Qt::WindowTransparentForInput);
|
||||||
|
|
||||||
d->MainLayout = new QGridLayout();
|
m_MainLayout = new QGridLayout();
|
||||||
d->MainLayout->setContentsMargins(0, 1, 0, 0);
|
m_MainLayout->setContentsMargins(0, 1, 0, 0);
|
||||||
d->MainLayout->setSpacing(0);
|
m_MainLayout->setSpacing(0);
|
||||||
setLayout(d->MainLayout);
|
setLayout(m_MainLayout);
|
||||||
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerWidget::~ContainerWidget()
|
MainContainerWidget::~MainContainerWidget()
|
||||||
{
|
{
|
||||||
// Note: It's required to delete in 2 steps
|
// Note: It's required to delete in 2 steps
|
||||||
// Remove from list, and then delete.
|
// Remove from list, and then delete.
|
||||||
// Because the destrcutor of objects wants to modify the current
|
// Because the destrcutor of objects wants to modify the current
|
||||||
// iterating list as well... :-/
|
// iterating list as well... :-/
|
||||||
while (!d->sections.isEmpty())
|
while (!m_Sections.isEmpty())
|
||||||
{
|
{
|
||||||
SectionWidget* sw = d->sections.takeLast();
|
SectionWidget* sw = m_Sections.takeLast();
|
||||||
delete sw;
|
delete sw;
|
||||||
}
|
}
|
||||||
while (!d->floatings.isEmpty())
|
while (!m_Floatings.isEmpty())
|
||||||
{
|
{
|
||||||
FloatingWidget* fw = d->floatings.takeLast();
|
FloatingWidget* fw = m_Floatings.takeLast();
|
||||||
delete fw;
|
delete fw;
|
||||||
}
|
}
|
||||||
d->SectionContentIdMap.clear();
|
m_SectionContentIdMap.clear();
|
||||||
d->SectionContentNameMap.clear();
|
m_SectionContentNameMap.clear();
|
||||||
d->SectionWidgetIdMap.clear();
|
m_SectionWidgetIdMap.clear();
|
||||||
delete d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SectionWidget* ContainerWidget::addSectionContent(const SectionContent::RefPtr& sc, SectionWidget* sw, DropArea area)
|
SectionWidget* MainContainerWidget::addSectionContent(const SectionContent::RefPtr& sc, SectionWidget* sw, DropArea area)
|
||||||
{
|
{
|
||||||
ADS_Expects(!sc.isNull());
|
ADS_Expects(!sc.isNull());
|
||||||
|
|
||||||
@ -89,7 +85,7 @@ SectionWidget* ContainerWidget::addSectionContent(const SectionContent::RefPtr&
|
|||||||
return dropContent(data, sw, area, false);
|
return dropContent(data, sw, area, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
bool MainContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
||||||
{
|
{
|
||||||
ADS_Expects(!sc.isNull());
|
ADS_Expects(!sc.isNull());
|
||||||
|
|
||||||
@ -103,13 +99,13 @@ bool ContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
// but only cares about SectionWidgets right now. So we need to check whether it was a FloatingWidget
|
// but only cares about SectionWidgets right now. So we need to check whether it was a FloatingWidget
|
||||||
// and delete it.
|
// and delete it.
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < d->floatings.count(); ++i)
|
for (int i = 0; i < m_Floatings.count(); ++i)
|
||||||
{
|
{
|
||||||
FloatingWidget* fw = d->floatings.at(i);
|
FloatingWidget* fw = m_Floatings.at(i);
|
||||||
InternalContentData data;
|
InternalContentData data;
|
||||||
if (!(found = fw->takeContent(data)))
|
if (!(found = fw->takeContent(data)))
|
||||||
continue;
|
continue;
|
||||||
d->floatings.removeAll(fw);
|
m_Floatings.removeAll(fw);
|
||||||
delete fw;
|
delete fw;
|
||||||
delete data.titleWidget;
|
delete data.titleWidget;
|
||||||
delete data.contentWidget;
|
delete data.contentWidget;
|
||||||
@ -117,14 +113,14 @@ bool ContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
} // End of ugly work arround.
|
} // End of ugly work arround.
|
||||||
|
|
||||||
// Get from hidden contents and delete associated internal stuff.
|
// Get from hidden contents and delete associated internal stuff.
|
||||||
if (!d->hiddenSectionContents.contains(sc->uid()))
|
if (!m_HiddenSectionContents.contains(sc->uid()))
|
||||||
{
|
{
|
||||||
qFatal("Something went wrong... The content should have been there :-/");
|
qFatal("Something went wrong... The content should have been there :-/");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete internal objects.
|
// Delete internal objects.
|
||||||
HiddenSectionItem hsi = d->hiddenSectionContents.take(sc->uid());
|
HiddenSectionItem hsi = m_HiddenSectionContents.take(sc->uid());
|
||||||
delete hsi.data.titleWidget;
|
delete hsi.data.titleWidget;
|
||||||
delete hsi.data.contentWidget;
|
delete hsi.data.contentWidget;
|
||||||
|
|
||||||
@ -134,14 +130,14 @@ bool ContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
bool MainContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
||||||
{
|
{
|
||||||
ADS_Expects(!sc.isNull());
|
ADS_Expects(!sc.isNull());
|
||||||
|
|
||||||
// Search SC in floatings
|
// Search SC in floatings
|
||||||
for (int i = 0; i < d->floatings.count(); ++i)
|
for (int i = 0; i < m_Floatings.count(); ++i)
|
||||||
{
|
{
|
||||||
FloatingWidget* fw = d->floatings.at(i);
|
FloatingWidget* fw = m_Floatings.at(i);
|
||||||
const bool found = fw->content()->uid() == sc->uid();
|
const bool found = fw->content()->uid() == sc->uid();
|
||||||
if (!found)
|
if (!found)
|
||||||
continue;
|
continue;
|
||||||
@ -155,19 +151,19 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
// Search SC in hidden sections
|
// Search SC in hidden sections
|
||||||
// Try to show them in the last position, otherwise simply append
|
// Try to show them in the last position, otherwise simply append
|
||||||
// it to the first section (or create a new section?)
|
// it to the first section (or create a new section?)
|
||||||
if (d->hiddenSectionContents.contains(sc->uid()))
|
if (m_HiddenSectionContents.contains(sc->uid()))
|
||||||
{
|
{
|
||||||
const HiddenSectionItem hsi = d->hiddenSectionContents.take(sc->uid());
|
const HiddenSectionItem hsi = m_HiddenSectionContents.take(sc->uid());
|
||||||
hsi.data.titleWidget->setVisible(true);
|
hsi.data.titleWidget->setVisible(true);
|
||||||
hsi.data.contentWidget->setVisible(true);
|
hsi.data.contentWidget->setVisible(true);
|
||||||
SectionWidget* sw = nullptr;
|
SectionWidget* sw = nullptr;
|
||||||
if (hsi.preferredSectionId > 0 && (sw = d->SectionWidgetIdMap.value(hsi.preferredSectionId)) != nullptr)
|
if (hsi.preferredSectionId > 0 && (sw = m_SectionWidgetIdMap.value(hsi.preferredSectionId)) != nullptr)
|
||||||
{
|
{
|
||||||
sw->addContent(hsi.data, true);
|
sw->addContent(hsi.data, true);
|
||||||
emit sectionContentVisibilityChanged(sc, true);
|
emit sectionContentVisibilityChanged(sc, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (d->sections.size() > 0 && (sw = d->sections.first()) != NULL)
|
else if (m_Sections.size() > 0 && (sw = m_Sections.first()) != NULL)
|
||||||
{
|
{
|
||||||
sw->addContent(hsi.data, true);
|
sw->addContent(hsi.data, true);
|
||||||
emit sectionContentVisibilityChanged(sc, true);
|
emit sectionContentVisibilityChanged(sc, true);
|
||||||
@ -176,7 +172,7 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sw = newSectionWidget();
|
sw = newSectionWidget();
|
||||||
addSection(sw);
|
addSectionWidget(sw);
|
||||||
sw->addContent(hsi.data, true);
|
sw->addContent(hsi.data, true);
|
||||||
emit sectionContentVisibilityChanged(sc, true);
|
emit sectionContentVisibilityChanged(sc, true);
|
||||||
return true;
|
return true;
|
||||||
@ -189,18 +185,18 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
bool MainContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
||||||
{
|
{
|
||||||
ADS_Expects(!sc.isNull());
|
ADS_Expects(!sc.isNull());
|
||||||
|
|
||||||
// Search SC in floatings
|
// Search SC in floatings
|
||||||
// We can simply hide floatings, nothing else required.
|
// We can simply hide floatings, nothing else required.
|
||||||
for (int i = 0; i < d->floatings.count(); ++i)
|
for (int i = 0; i < m_Floatings.count(); ++i)
|
||||||
{
|
{
|
||||||
const bool found = d->floatings.at(i)->content()->uid() == sc->uid();
|
const bool found = m_Floatings.at(i)->content()->uid() == sc->uid();
|
||||||
if (!found)
|
if (!found)
|
||||||
continue;
|
continue;
|
||||||
d->floatings.at(i)->setVisible(false);
|
m_Floatings.at(i)->setVisible(false);
|
||||||
emit sectionContentVisibilityChanged(sc, false);
|
emit sectionContentVisibilityChanged(sc, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -209,9 +205,9 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
// It's required to remove the SC from SW completely and hold it in a
|
// It's required to remove the SC from SW completely and hold it in a
|
||||||
// separate list as long as a "showSectionContent" gets called for the SC again.
|
// separate list as long as a "showSectionContent" gets called for the SC again.
|
||||||
// In case that the SW does not have any other SCs, we need to delete it.
|
// In case that the SW does not have any other SCs, we need to delete it.
|
||||||
for (int i = 0; i < d->sections.count(); ++i)
|
for (int i = 0; i < m_Sections.count(); ++i)
|
||||||
{
|
{
|
||||||
SectionWidget* sw = d->sections.at(i);
|
SectionWidget* sw = m_Sections.at(i);
|
||||||
const bool found = sw->indexOfContent(sc) >= 0;
|
const bool found = sw->indexOfContent(sc) >= 0;
|
||||||
if (!found)
|
if (!found)
|
||||||
continue;
|
continue;
|
||||||
@ -224,7 +220,7 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
|
|
||||||
hsi.data.titleWidget->setVisible(false);
|
hsi.data.titleWidget->setVisible(false);
|
||||||
hsi.data.contentWidget->setVisible(false);
|
hsi.data.contentWidget->setVisible(false);
|
||||||
d->hiddenSectionContents.insert(sc->uid(), hsi);
|
m_HiddenSectionContents.insert(sc->uid(), hsi);
|
||||||
|
|
||||||
if (sw->contents().isEmpty())
|
if (sw->contents().isEmpty())
|
||||||
{
|
{
|
||||||
@ -238,21 +234,21 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
|
|
||||||
// Search SC in hidden elements
|
// Search SC in hidden elements
|
||||||
// The content may already be hidden
|
// The content may already be hidden
|
||||||
if (d->hiddenSectionContents.contains(sc->uid()))
|
if (m_HiddenSectionContents.contains(sc->uid()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
qFatal("Unable to hide SectionContent, don't know this one 8-/");
|
qFatal("Unable to hide SectionContent, don't know this one 8-/");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
|
bool MainContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
|
||||||
{
|
{
|
||||||
ADS_Expects(!sc.isNull());
|
ADS_Expects(!sc.isNull());
|
||||||
|
|
||||||
// Search SC in sections
|
// Search SC in sections
|
||||||
for (int i = 0; i < d->sections.count(); ++i)
|
for (int i = 0; i < m_Sections.count(); ++i)
|
||||||
{
|
{
|
||||||
SectionWidget* sw = d->sections.at(i);
|
SectionWidget* sw = m_Sections.at(i);
|
||||||
int index = sw->indexOfContent(sc);
|
int index = sw->indexOfContent(sc);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
continue;
|
continue;
|
||||||
@ -261,9 +257,9 @@ bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search SC in floatings
|
// Search SC in floatings
|
||||||
for (int i = 0; i < d->floatings.size(); ++i)
|
for (int i = 0; i < m_Floatings.size(); ++i)
|
||||||
{
|
{
|
||||||
FloatingWidget* fw = d->floatings.at(i);
|
FloatingWidget* fw = m_Floatings.at(i);
|
||||||
if (fw->content()->uid() != sc->uid())
|
if (fw->content()->uid() != sc->uid())
|
||||||
continue;
|
continue;
|
||||||
fw->setVisible(true);
|
fw->setVisible(true);
|
||||||
@ -272,30 +268,30 @@ bool ContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search SC in hidden
|
// Search SC in hidden
|
||||||
if (d->hiddenSectionContents.contains(sc->uid()))
|
if (m_HiddenSectionContents.contains(sc->uid()))
|
||||||
return showSectionContent(sc);
|
return showSectionContent(sc);
|
||||||
|
|
||||||
qFatal("Unable to hide SectionContent, don't know this one 8-/");
|
qFatal("Unable to hide SectionContent, don't know this one 8-/");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::isSectionContentVisible(const SectionContent::RefPtr& sc)
|
bool MainContainerWidget::isSectionContentVisible(const SectionContent::RefPtr& sc)
|
||||||
{
|
{
|
||||||
ADS_Expects(!sc.isNull());
|
ADS_Expects(!sc.isNull());
|
||||||
|
|
||||||
// Search SC in floatings
|
// Search SC in floatings
|
||||||
for (int i = 0; i < d->floatings.count(); ++i)
|
for (int i = 0; i < m_Floatings.count(); ++i)
|
||||||
{
|
{
|
||||||
const bool found = d->floatings.at(i)->content()->uid() == sc->uid();
|
const bool found = m_Floatings.at(i)->content()->uid() == sc->uid();
|
||||||
if (!found)
|
if (!found)
|
||||||
continue;
|
continue;
|
||||||
return d->floatings.at(i)->isVisible();
|
return m_Floatings.at(i)->isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search SC in sections
|
// Search SC in sections
|
||||||
for (int i = 0; i < d->sections.count(); ++i)
|
for (int i = 0; i < m_Sections.count(); ++i)
|
||||||
{
|
{
|
||||||
SectionWidget* sw = d->sections.at(i);
|
SectionWidget* sw = m_Sections.at(i);
|
||||||
const int index = sw->indexOfContent(sc);
|
const int index = sw->indexOfContent(sc);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
continue;
|
continue;
|
||||||
@ -303,22 +299,22 @@ bool ContainerWidget::isSectionContentVisible(const SectionContent::RefPtr& sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search SC in hidden
|
// Search SC in hidden
|
||||||
if (d->hiddenSectionContents.contains(sc->uid()))
|
if (m_HiddenSectionContents.contains(sc->uid()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qWarning() << "SectionContent is not a part of this ContainerWidget:" << sc->uniqueName();
|
qWarning() << "SectionContent is not a part of this ContainerWidget:" << sc->uniqueName();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu* ContainerWidget::createContextMenu() const
|
QMenu* MainContainerWidget::createContextMenu() const
|
||||||
{
|
{
|
||||||
// Fill map with actions (sorted by key!)
|
// Fill map with actions (sorted by key!)
|
||||||
QMap<QString, QAction*> actions;
|
QMap<QString, QAction*> actions;
|
||||||
|
|
||||||
// Visible contents of sections
|
// Visible contents of sections
|
||||||
for (int i = 0; i < d->sections.size(); ++i)
|
for (int i = 0; i < m_Sections.size(); ++i)
|
||||||
{
|
{
|
||||||
const SectionWidget* sw = d->sections.at(i);
|
const SectionWidget* sw = m_Sections.at(i);
|
||||||
const QList<SectionContent::RefPtr>& contents = sw->contents();
|
const QList<SectionContent::RefPtr>& contents = sw->contents();
|
||||||
foreach (const SectionContent::RefPtr& sc, contents)
|
foreach (const SectionContent::RefPtr& sc, contents)
|
||||||
{
|
{
|
||||||
@ -335,7 +331,7 @@ QMenu* ContainerWidget::createContextMenu() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hidden contents of sections
|
// Hidden contents of sections
|
||||||
QHashIterator<int, HiddenSectionItem> hiddenIter(d->hiddenSectionContents);
|
QHashIterator<int, HiddenSectionItem> hiddenIter(m_HiddenSectionContents);
|
||||||
while (hiddenIter.hasNext())
|
while (hiddenIter.hasNext())
|
||||||
{
|
{
|
||||||
hiddenIter.next();
|
hiddenIter.next();
|
||||||
@ -352,9 +348,9 @@ QMenu* ContainerWidget::createContextMenu() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Floating contents
|
// Floating contents
|
||||||
for (int i = 0; i < d->floatings.size(); ++i)
|
for (int i = 0; i < m_Floatings.size(); ++i)
|
||||||
{
|
{
|
||||||
const FloatingWidget* fw = d->floatings.at(i);
|
const FloatingWidget* fw = m_Floatings.at(i);
|
||||||
const SectionContent::RefPtr sc = fw->content();
|
const SectionContent::RefPtr sc = fw->content();
|
||||||
|
|
||||||
QAction* a = new QAction(QIcon(), sc->visibleTitle(), NULL);
|
QAction* a = new QAction(QIcon(), sc->visibleTitle(), NULL);
|
||||||
@ -373,7 +369,7 @@ QMenu* ContainerWidget::createContextMenu() const
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ContainerWidget::saveState() const
|
QByteArray MainContainerWidget::saveState() const
|
||||||
{
|
{
|
||||||
ADS_NS_SER::InMemoryWriter writer;
|
ADS_NS_SER::InMemoryWriter writer;
|
||||||
|
|
||||||
@ -396,7 +392,7 @@ QByteArray ContainerWidget::saveState() const
|
|||||||
return writer.toByteArray();
|
return writer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::restoreState(const QByteArray& data)
|
bool MainContainerWidget::restoreState(const QByteArray& data)
|
||||||
{
|
{
|
||||||
if (data.isEmpty())
|
if (data.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
@ -415,9 +411,9 @@ bool ContainerWidget::restoreState(const QByteArray& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<SectionContent::RefPtr> ContainerWidget::contents() const
|
QList<SectionContent::RefPtr> MainContainerWidget::contents() const
|
||||||
{
|
{
|
||||||
QList<SectionContent::WeakPtr> wl = d->SectionContentIdMap.values();
|
QList<SectionContent::WeakPtr> wl = m_SectionContentIdMap.values();
|
||||||
QList<SectionContent::RefPtr> sl;
|
QList<SectionContent::RefPtr> sl;
|
||||||
for (int i = 0; i < wl.count(); ++i)
|
for (int i = 0; i < wl.count(); ++i)
|
||||||
{
|
{
|
||||||
@ -428,23 +424,23 @@ QList<SectionContent::RefPtr> ContainerWidget::contents() const
|
|||||||
return sl;
|
return sl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointer<DropOverlay> ContainerWidget::dropOverlay() const
|
QPointer<DropOverlay> MainContainerWidget::sectionDropOverlay() const
|
||||||
{
|
{
|
||||||
return d->SectionDropOverlay;
|
return m_SectionDropOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// PRIVATE API BEGINS HERE
|
// PRIVATE API BEGINS HERE
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SectionWidget* ContainerWidget::newSectionWidget()
|
SectionWidget* MainContainerWidget::newSectionWidget()
|
||||||
{
|
{
|
||||||
SectionWidget* sw = new SectionWidget(this);
|
SectionWidget* sw = new SectionWidget(this);
|
||||||
d->sections.append(sw);
|
m_Sections.append(sw);
|
||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionWidget* ContainerWidget::insertNewSectionWidget(
|
SectionWidget* MainContainerWidget::insertNewSectionWidget(
|
||||||
const InternalContentData& data, SectionWidget* targetSection, SectionWidget* ret,
|
const InternalContentData& data, SectionWidget* targetSection, SectionWidget* ret,
|
||||||
Qt::Orientation Orientation, int InsertIndexOffset)
|
Qt::Orientation Orientation, int InsertIndexOffset)
|
||||||
{
|
{
|
||||||
@ -468,30 +464,30 @@ SectionWidget* ContainerWidget::insertNewSectionWidget(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionWidget* ContainerWidget::dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area, bool autoActive)
|
SectionWidget* MainContainerWidget::dropContent(const InternalContentData& data, SectionWidget* targetSectionWidget, DropArea area, bool autoActive)
|
||||||
{
|
{
|
||||||
ADS_Expects(targetSection != NULL);
|
ADS_Expects(targetSection != NULL);
|
||||||
|
|
||||||
SectionWidget* section_widget = nullptr;
|
SectionWidget* section_widget = nullptr;
|
||||||
|
|
||||||
// If no sections exists yet, create a default one and always drop into it.
|
// If no sections exists yet, create a default one and always drop into it.
|
||||||
if (d->sections.isEmpty())
|
if (m_Sections.isEmpty())
|
||||||
{
|
{
|
||||||
targetSection = newSectionWidget();
|
targetSectionWidget = newSectionWidget();
|
||||||
addSection(targetSection);
|
addSectionWidget(targetSectionWidget);
|
||||||
area = CenterDropArea;
|
area = CenterDropArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop on outer area
|
// Drop on outer area
|
||||||
if (!targetSection)
|
if (!targetSectionWidget)
|
||||||
{
|
{
|
||||||
switch (area)
|
switch (area)
|
||||||
{
|
{
|
||||||
case TopDropArea:return dropContentOuterHelper(d->MainLayout, data, Qt::Vertical, false);
|
case TopDropArea:return dropContentOuterHelper(m_MainLayout, data, Qt::Vertical, false);
|
||||||
case RightDropArea: return dropContentOuterHelper(d->MainLayout, data, Qt::Horizontal, true);
|
case RightDropArea: return dropContentOuterHelper(m_MainLayout, data, Qt::Horizontal, true);
|
||||||
case CenterDropArea:
|
case CenterDropArea:
|
||||||
case BottomDropArea:return dropContentOuterHelper(d->MainLayout, data, Qt::Vertical, true);
|
case BottomDropArea:return dropContentOuterHelper(m_MainLayout, data, Qt::Vertical, true);
|
||||||
case LeftDropArea: return dropContentOuterHelper(d->MainLayout, data, Qt::Horizontal, false);
|
case LeftDropArea: return dropContentOuterHelper(m_MainLayout, data, Qt::Horizontal, false);
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -501,13 +497,13 @@ SectionWidget* ContainerWidget::dropContent(const InternalContentData& data, Sec
|
|||||||
// Drop logic based on area.
|
// Drop logic based on area.
|
||||||
switch (area)
|
switch (area)
|
||||||
{
|
{
|
||||||
case TopDropArea:return insertNewSectionWidget(data, targetSection, section_widget, Qt::Vertical, 0);
|
case TopDropArea:return insertNewSectionWidget(data, targetSectionWidget, section_widget, Qt::Vertical, 0);
|
||||||
case RightDropArea: return insertNewSectionWidget(data, targetSection, section_widget, Qt::Horizontal, 1);
|
case RightDropArea: return insertNewSectionWidget(data, targetSectionWidget, section_widget, Qt::Horizontal, 1);
|
||||||
case BottomDropArea: return insertNewSectionWidget(data, targetSection, section_widget, Qt::Vertical, 1);
|
case BottomDropArea: return insertNewSectionWidget(data, targetSectionWidget, section_widget, Qt::Vertical, 1);
|
||||||
case LeftDropArea: return insertNewSectionWidget(data, targetSection, section_widget, Qt::Horizontal, 0);
|
case LeftDropArea: return insertNewSectionWidget(data, targetSectionWidget, section_widget, Qt::Horizontal, 0);
|
||||||
case CenterDropArea:
|
case CenterDropArea:
|
||||||
targetSection->addContent(data, autoActive);
|
targetSectionWidget->addContent(data, autoActive);
|
||||||
return targetSection;
|
return targetSectionWidget;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -515,30 +511,30 @@ SectionWidget* ContainerWidget::dropContent(const InternalContentData& data, Sec
|
|||||||
return section_widget;
|
return section_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWidget::addSection(SectionWidget* section)
|
void MainContainerWidget::addSectionWidget(SectionWidget* section)
|
||||||
{
|
{
|
||||||
ADS_Expects(section != NULL);
|
ADS_Expects(section != NULL);
|
||||||
|
|
||||||
// Create default splitter.
|
// Create default splitter.
|
||||||
if (!d->splitter)
|
if (!m_Splitter)
|
||||||
{
|
{
|
||||||
d->splitter = newSplitter(d->orientation);
|
m_Splitter = newSplitter(m_Orientation);
|
||||||
d->MainLayout->addWidget(d->splitter, 0, 0);
|
m_MainLayout->addWidget(m_Splitter, 0, 0);
|
||||||
}
|
}
|
||||||
if (d->splitter->indexOf(section) != -1)
|
if (m_Splitter->indexOf(section) != -1)
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << QString("Section has already been added");
|
qWarning() << Q_FUNC_INFO << QString("Section has already been added");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->splitter->addWidget(section);
|
m_Splitter->addWidget(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionWidget* ContainerWidget::sectionAt(const QPoint& pos) const
|
SectionWidget* MainContainerWidget::sectionWidgetAt(const QPoint& pos) const
|
||||||
{
|
{
|
||||||
const QPoint gpos = mapToGlobal(pos);
|
const QPoint gpos = mapToGlobal(pos);
|
||||||
for (int i = 0; i < d->sections.size(); ++i)
|
for (int i = 0; i < m_Sections.size(); ++i)
|
||||||
{
|
{
|
||||||
SectionWidget* sw = d->sections[i];
|
SectionWidget* sw = m_Sections[i];
|
||||||
if (sw->rect().contains(sw->mapFromGlobal(gpos)))
|
if (sw->rect().contains(sw->mapFromGlobal(gpos)))
|
||||||
{
|
{
|
||||||
return sw;
|
return sw;
|
||||||
@ -547,7 +543,7 @@ SectionWidget* ContainerWidget::sectionAt(const QPoint& pos) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionWidget* ContainerWidget::dropContentOuterHelper(QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append)
|
SectionWidget* MainContainerWidget::dropContentOuterHelper(QLayout* l, const InternalContentData& data, Qt::Orientation orientation, bool append)
|
||||||
{
|
{
|
||||||
ADS_Expects(l != NULL);
|
ADS_Expects(l != NULL);
|
||||||
|
|
||||||
@ -615,7 +611,7 @@ SectionWidget* ContainerWidget::dropContentOuterHelper(QLayout* l, const Interna
|
|||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ContainerWidget::saveHierarchy() const
|
QByteArray MainContainerWidget::saveHierarchy() const
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
# Data Format
|
# Data Format
|
||||||
@ -648,40 +644,40 @@ QByteArray ContainerWidget::saveHierarchy() const
|
|||||||
saveFloatingWidgets(out);
|
saveFloatingWidgets(out);
|
||||||
|
|
||||||
// Save state of sections and contents
|
// Save state of sections and contents
|
||||||
if (d->MainLayout->count() <= 0 || d->sections.isEmpty())
|
if (m_MainLayout->count() <= 0 || m_Sections.isEmpty())
|
||||||
{
|
{
|
||||||
// Looks like the user has hidden all contents and no more sections
|
// Looks like the user has hidden all contents and no more sections
|
||||||
// are available. We can simply write a list of all hidden contents.
|
// are available. We can simply write a list of all hidden contents.
|
||||||
out << 0; // Mode
|
out << 0; // Mode
|
||||||
|
|
||||||
out << d->hiddenSectionContents.count();
|
out << m_HiddenSectionContents.count();
|
||||||
QHashIterator<int, HiddenSectionItem> iter(d->hiddenSectionContents);
|
QHashIterator<int, HiddenSectionItem> iter(m_HiddenSectionContents);
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
iter.next();
|
iter.next();
|
||||||
out << iter.value().data.content->uniqueName();
|
out << iter.value().data.content->uniqueName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (d->MainLayout->count() == 1)
|
else if (m_MainLayout->count() == 1)
|
||||||
{
|
{
|
||||||
out << 1; // Mode
|
out << 1; // Mode
|
||||||
|
|
||||||
// There should only be one!
|
// There should only be one!
|
||||||
QLayoutItem* li = d->MainLayout->itemAt(0);
|
QLayoutItem* li = m_MainLayout->itemAt(0);
|
||||||
if (!li->widget())
|
if (!li->widget())
|
||||||
qFatal("Not a widget in d->mainLayout, this shouldn't happen.");
|
qFatal("Not a widget in mainLayout, this shouldn't happen.");
|
||||||
|
|
||||||
// Save sections beginning with the first QSplitter (li->widget()).
|
// Save sections beginning with the first QSplitter (li->widget()).
|
||||||
saveSectionWidgets(out, li->widget());
|
saveSectionWidgets(out, li->widget());
|
||||||
|
|
||||||
// Safe state of hidden contents, which doesn't have an section association
|
// Safe state of hidden contents, which doesn't have an section association
|
||||||
// or the section association points to a no longer existing section.
|
// or the section association points to a no longer existing section.
|
||||||
QHashIterator<int, HiddenSectionItem> iter(d->hiddenSectionContents);
|
QHashIterator<int, HiddenSectionItem> iter(m_HiddenSectionContents);
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
iter.next();
|
iter.next();
|
||||||
if (iter.value().preferredSectionId <= 0 || !d->SectionWidgetIdMap.contains(iter.value().preferredSectionId))
|
if (iter.value().preferredSectionId <= 0 || !m_SectionWidgetIdMap.contains(iter.value().preferredSectionId))
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
out << cnt;
|
out << cnt;
|
||||||
@ -689,7 +685,7 @@ QByteArray ContainerWidget::saveHierarchy() const
|
|||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
iter.next();
|
iter.next();
|
||||||
if (iter.value().preferredSectionId <= 0 || !d->SectionWidgetIdMap.contains(iter.value().preferredSectionId))
|
if (iter.value().preferredSectionId <= 0 || !m_SectionWidgetIdMap.contains(iter.value().preferredSectionId))
|
||||||
out << iter.value().data.content->uniqueName();
|
out << iter.value().data.content->uniqueName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,24 +693,24 @@ QByteArray ContainerWidget::saveHierarchy() const
|
|||||||
{
|
{
|
||||||
// More? Oh oh.. something is wrong :-/
|
// More? Oh oh.. something is wrong :-/
|
||||||
out << -1;
|
out << -1;
|
||||||
qWarning() << "Oh noooz.. Something went wrong. There are too many items in d->mainLayout.";
|
qWarning() << "Oh noooz.. Something went wrong. There are too many items in mainLayout.";
|
||||||
}
|
}
|
||||||
return ba;
|
return ba;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWidget::saveFloatingWidgets(QDataStream& out) const
|
void MainContainerWidget::saveFloatingWidgets(QDataStream& out) const
|
||||||
{
|
{
|
||||||
out << d->floatings.count();
|
out << m_Floatings.count();
|
||||||
for (int i = 0; i < d->floatings.count(); ++i)
|
for (int i = 0; i < m_Floatings.count(); ++i)
|
||||||
{
|
{
|
||||||
FloatingWidget* fw = d->floatings.at(i);
|
FloatingWidget* fw = m_Floatings.at(i);
|
||||||
out << fw->content()->uniqueName();
|
out << fw->content()->uniqueName();
|
||||||
out << fw->saveGeometry();
|
out << fw->saveGeometry();
|
||||||
out << fw->isVisible();
|
out << fw->isVisible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) const
|
void MainContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) const
|
||||||
{
|
{
|
||||||
QSplitter* sp = NULL;
|
QSplitter* sp = NULL;
|
||||||
SectionWidget* sw = NULL;
|
SectionWidget* sw = NULL;
|
||||||
@ -748,7 +744,7 @@ void ContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) cons
|
|||||||
const QList<SectionContent::RefPtr>& contents = sw->contents();
|
const QList<SectionContent::RefPtr>& contents = sw->contents();
|
||||||
QList<HiddenSectionItem> hiddenContents;
|
QList<HiddenSectionItem> hiddenContents;
|
||||||
|
|
||||||
QHashIterator<int, HiddenSectionItem> iter(d->hiddenSectionContents);
|
QHashIterator<int, HiddenSectionItem> iter(m_HiddenSectionContents);
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
iter.next();
|
iter.next();
|
||||||
@ -777,27 +773,27 @@ void ContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) const
|
bool MainContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) const
|
||||||
{
|
{
|
||||||
if (d->sections.count() <= 0)
|
if (m_Sections.count() <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
sid.sectionsCount = d->sections.count();
|
sid.sectionsCount = m_Sections.count();
|
||||||
for (int i = 0; i < sid.sectionsCount; ++i)
|
for (int i = 0; i < sid.sectionsCount; ++i)
|
||||||
{
|
{
|
||||||
ADS_NS_SER::SectionEntity se;
|
ADS_NS_SER::SectionEntity se;
|
||||||
se.x = mapFromGlobal(d->sections[i]->parentWidget()->mapToGlobal(d->sections[i]->pos())).x();
|
se.x = mapFromGlobal(m_Sections[i]->parentWidget()->mapToGlobal(m_Sections[i]->pos())).x();
|
||||||
se.y = mapFromGlobal(d->sections[i]->parentWidget()->mapToGlobal(d->sections[i]->pos())).y();
|
se.y = mapFromGlobal(m_Sections[i]->parentWidget()->mapToGlobal(m_Sections[i]->pos())).y();
|
||||||
se.width = d->sections[i]->geometry().width();
|
se.width = m_Sections[i]->geometry().width();
|
||||||
se.height = d->sections[i]->geometry().height();
|
se.height = m_Sections[i]->geometry().height();
|
||||||
se.currentIndex = d->sections[i]->currentIndex();
|
se.currentIndex = m_Sections[i]->currentIndex();
|
||||||
se.sectionContentsCount = d->sections[i]->contents().count();
|
se.sectionContentsCount = m_Sections[i]->contents().count();
|
||||||
foreach (const SectionContent::RefPtr& sc, d->sections[i]->contents())
|
foreach (const SectionContent::RefPtr& sc, m_Sections[i]->contents())
|
||||||
{
|
{
|
||||||
ADS_NS_SER::SectionContentEntity sce;
|
ADS_NS_SER::SectionContentEntity sce;
|
||||||
sce.uniqueName = sc->uniqueName();
|
sce.uniqueName = sc->uniqueName();
|
||||||
sce.visible = true;
|
sce.visible = true;
|
||||||
sce.preferredIndex = d->sections[i]->indexOfContent(sc);
|
sce.preferredIndex = m_Sections[i]->indexOfContent(sc);
|
||||||
se.sectionContents.append(sce); // std::move()?
|
se.sectionContents.append(sce); // std::move()?
|
||||||
}
|
}
|
||||||
sid.sections.append(se); // std::move()?
|
sid.sections.append(se); // std::move()?
|
||||||
@ -805,7 +801,7 @@ bool ContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
bool MainContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||||
{
|
{
|
||||||
QDataStream in(data);
|
QDataStream in(data);
|
||||||
in.setVersion(QDataStream::Qt_4_5);
|
in.setVersion(QDataStream::Qt_4_5);
|
||||||
@ -820,8 +816,8 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
|||||||
if (version != 1)
|
if (version != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QList<FloatingWidget*> oldFloatings = d->floatings;
|
QList<FloatingWidget*> oldFloatings = m_Floatings;
|
||||||
QList<SectionWidget*> oldSections = d->sections;
|
QList<SectionWidget*> oldSections = m_Sections;
|
||||||
|
|
||||||
// Restore floating widgets
|
// Restore floating widgets
|
||||||
QList<FloatingWidget*> floatings;
|
QList<FloatingWidget*> floatings;
|
||||||
@ -854,7 +850,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
|||||||
QString uname;
|
QString uname;
|
||||||
in >> uname;
|
in >> uname;
|
||||||
|
|
||||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname);
|
const SectionContent::RefPtr sc = m_SectionContentNameMap.value(uname);
|
||||||
if (!sc)
|
if (!sc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -880,7 +876,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
|||||||
{
|
{
|
||||||
QString uname;
|
QString uname;
|
||||||
in >> uname;
|
in >> uname;
|
||||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname);
|
const SectionContent::RefPtr sc = m_SectionContentNameMap.value(uname);
|
||||||
if (!sc)
|
if (!sc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -919,7 +915,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
|||||||
contents.append(contentsToHide.at(i));
|
contents.append(contentsToHide.at(i));
|
||||||
|
|
||||||
// Compare restored contents with available contents
|
// Compare restored contents with available contents
|
||||||
const QList<SectionContent::WeakPtr> allContents = d->SectionContentIdMap.values();
|
const QList<SectionContent::WeakPtr> allContents = m_SectionContentIdMap.values();
|
||||||
for (int i = 0; i < allContents.count(); ++i)
|
for (int i = 0; i < allContents.count(); ++i)
|
||||||
{
|
{
|
||||||
const SectionContent::RefPtr sc = allContents.at(i).toStrongRef();
|
const SectionContent::RefPtr sc = allContents.at(i).toStrongRef();
|
||||||
@ -942,7 +938,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
|||||||
{
|
{
|
||||||
sw = new SectionWidget(this);
|
sw = new SectionWidget(this);
|
||||||
sections.append(sw);
|
sections.append(sw);
|
||||||
addSection(sw);
|
addSectionWidget(sw);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sw = sections.first();
|
sw = sections.first();
|
||||||
@ -955,12 +951,12 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->floatings = floatings;
|
m_Floatings = floatings;
|
||||||
d->sections = sections;
|
m_Sections = sections;
|
||||||
|
|
||||||
// Delete old objects
|
// Delete old objects
|
||||||
QLayoutItem* old = d->MainLayout->takeAt(0);
|
QLayoutItem* old = m_MainLayout->takeAt(0);
|
||||||
d->MainLayout->addWidget(d->splitter);
|
m_MainLayout->addWidget(m_Splitter);
|
||||||
delete old;
|
delete old;
|
||||||
qDeleteAll(oldFloatings);
|
qDeleteAll(oldFloatings);
|
||||||
qDeleteAll(oldSections);
|
qDeleteAll(oldSections);
|
||||||
@ -973,7 +969,7 @@ bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList<FloatingWidget*>& floatings)
|
bool MainContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList<FloatingWidget*>& floatings)
|
||||||
{
|
{
|
||||||
Q_UNUSED(version)
|
Q_UNUSED(version)
|
||||||
|
|
||||||
@ -991,7 +987,7 @@ bool ContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList
|
|||||||
bool visible = false;
|
bool visible = false;
|
||||||
in >> visible;
|
in >> visible;
|
||||||
|
|
||||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname).toStrongRef();
|
const SectionContent::RefPtr sc = m_SectionContentNameMap.value(uname).toStrongRef();
|
||||||
if (!sc)
|
if (!sc)
|
||||||
{
|
{
|
||||||
qWarning() << "Can not find SectionContent:" << uname;
|
qWarning() << "Can not find SectionContent:" << uname;
|
||||||
@ -1016,7 +1012,7 @@ bool ContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplitter* currentSplitter, QList<SectionWidget*>& sections, QList<SectionContent::RefPtr>& contentsToHide)
|
bool MainContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplitter* currentSplitter, QList<SectionWidget*>& sections, QList<SectionContent::RefPtr>& contentsToHide)
|
||||||
{
|
{
|
||||||
if (in.atEnd())
|
if (in.atEnd())
|
||||||
return true;
|
return true;
|
||||||
@ -1047,7 +1043,7 @@ bool ContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplit
|
|||||||
sp->setSizes(sizes);
|
sp->setSizes(sizes);
|
||||||
|
|
||||||
if (!currentSplitter)
|
if (!currentSplitter)
|
||||||
d->splitter = sp;
|
m_Splitter = sp;
|
||||||
else
|
else
|
||||||
currentSplitter->addWidget(sp);
|
currentSplitter->addWidget(sp);
|
||||||
}
|
}
|
||||||
@ -1074,7 +1070,7 @@ bool ContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplit
|
|||||||
int preferredIndex = -1;
|
int preferredIndex = -1;
|
||||||
in >> preferredIndex;
|
in >> preferredIndex;
|
||||||
|
|
||||||
const SectionContent::RefPtr sc = d->SectionContentNameMap.value(uname).toStrongRef();
|
const SectionContent::RefPtr sc = m_SectionContentNameMap.value(uname).toStrongRef();
|
||||||
if (!sc)
|
if (!sc)
|
||||||
{
|
{
|
||||||
qWarning() << "Can not find SectionContent:" << uname;
|
qWarning() << "Can not find SectionContent:" << uname;
|
||||||
@ -1114,29 +1110,29 @@ bool ContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplit
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainerWidget::takeContent(const SectionContent::RefPtr& sc, InternalContentData& data)
|
bool MainContainerWidget::takeContent(const SectionContent::RefPtr& sc, InternalContentData& data)
|
||||||
{
|
{
|
||||||
ADS_Expects(!sc.isNull());
|
ADS_Expects(!sc.isNull());
|
||||||
|
|
||||||
// Search in sections
|
// Search in sections
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < d->sections.count() && !found; ++i)
|
for (int i = 0; i < m_Sections.count() && !found; ++i)
|
||||||
{
|
{
|
||||||
found = d->sections.at(i)->takeContent(sc->uid(), data);
|
found = m_Sections.at(i)->takeContent(sc->uid(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search in floating widgets
|
// Search in floating widgets
|
||||||
for (int i = 0; i < d->floatings.count() && !found; ++i)
|
for (int i = 0; i < m_Floatings.count() && !found; ++i)
|
||||||
{
|
{
|
||||||
found = d->floatings.at(i)->content()->uid() == sc->uid();
|
found = m_Floatings.at(i)->content()->uid() == sc->uid();
|
||||||
if (found)
|
if (found)
|
||||||
d->floatings.at(i)->takeContent(data);
|
m_Floatings.at(i)->takeContent(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search in hidden items
|
// Search in hidden items
|
||||||
if (!found && d->hiddenSectionContents.contains(sc->uid()))
|
if (!found && m_HiddenSectionContents.contains(sc->uid()))
|
||||||
{
|
{
|
||||||
const HiddenSectionItem hsi = d->hiddenSectionContents.take(sc->uid());
|
const HiddenSectionItem hsi = m_HiddenSectionContents.take(sc->uid());
|
||||||
data = hsi.data;
|
data = hsi.data;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
@ -1144,7 +1140,7 @@ bool ContainerWidget::takeContent(const SectionContent::RefPtr& sc, InternalCont
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWidget::onActiveTabChanged()
|
void MainContainerWidget::onActiveTabChanged()
|
||||||
{
|
{
|
||||||
SectionTitleWidget* stw = qobject_cast<SectionTitleWidget*>(sender());
|
SectionTitleWidget* stw = qobject_cast<SectionTitleWidget*>(sender());
|
||||||
if (stw)
|
if (stw)
|
||||||
@ -1153,13 +1149,13 @@ void ContainerWidget::onActiveTabChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
void MainContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
||||||
{
|
{
|
||||||
QAction* a = qobject_cast<QAction*>(sender());
|
QAction* a = qobject_cast<QAction*>(sender());
|
||||||
if (!a)
|
if (!a)
|
||||||
return;
|
return;
|
||||||
const int uid = a->property("uid").toInt();
|
const int uid = a->property("uid").toInt();
|
||||||
const SectionContent::RefPtr sc = d->SectionContentIdMap.value(uid).toStrongRef();
|
const SectionContent::RefPtr sc = m_SectionContentIdMap.value(uid).toStrongRef();
|
||||||
if (sc.isNull())
|
if (sc.isNull())
|
||||||
{
|
{
|
||||||
qCritical() << "Can not find content by ID" << uid;
|
qCritical() << "Can not find content by ID" << uid;
|
||||||
@ -1172,44 +1168,13 @@ void ContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ContainerWidget::hideContainerOverlay()
|
void MainContainerWidget::hideContainerOverlay()
|
||||||
{
|
{
|
||||||
d->ContainerDropOverlay->hideDropOverlay();
|
m_ContainerDropOverlay->hideDropOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ContainerWidget::moveFloatingWidget(const QPoint& TargetPos)
|
FloatingWidget* MainContainerWidget::startFloating(SectionWidget* sectionwidget, int ContentUid, const QPoint& TargetPos)
|
||||||
{
|
|
||||||
std::cout << "moveFloatingWidget" << std::endl;
|
|
||||||
// Mouse is over the container widget
|
|
||||||
if (rect().contains(mapFromGlobal(QCursor::pos())))
|
|
||||||
{
|
|
||||||
std::cout << "over Container" << std::endl;
|
|
||||||
d->ContainerDropOverlay->showDropOverlay(this);
|
|
||||||
d->ContainerDropOverlay->raise();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "-----------------" << std::endl;
|
|
||||||
d->ContainerDropOverlay->hideDropOverlay();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mouse is over a SectionWidget
|
|
||||||
SectionWidget* sectionwidget = sectionAt(mapFromGlobal(QCursor::pos()));
|
|
||||||
if (sectionwidget)
|
|
||||||
{
|
|
||||||
qInfo() << "over sectionWidget";
|
|
||||||
d->SectionDropOverlay->setAllowedAreas(ADS_NS::AllAreas);
|
|
||||||
d->SectionDropOverlay->showDropOverlay(sectionwidget);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
d->SectionDropOverlay->hideDropOverlay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FloatingWidget* ContainerWidget::startFloating(SectionWidget* sectionwidget, int ContentUid, const QPoint& TargetPos)
|
|
||||||
{
|
{
|
||||||
// Create floating widget.
|
// Create floating widget.
|
||||||
InternalContentData data;
|
InternalContentData data;
|
||||||
@ -1221,9 +1186,11 @@ FloatingWidget* ContainerWidget::startFloating(SectionWidget* sectionwidget, int
|
|||||||
|
|
||||||
FloatingWidget* fw = new FloatingWidget(this, data.content, data.titleWidget, data.contentWidget, this);
|
FloatingWidget* fw = new FloatingWidget(this, data.content, data.titleWidget, data.contentWidget, this);
|
||||||
fw->resize(sectionwidget->size());
|
fw->resize(sectionwidget->size());
|
||||||
d->floatings.append(fw);
|
m_Floatings.append(fw);
|
||||||
fw->move(TargetPos);
|
fw->move(TargetPos);
|
||||||
fw->show();
|
fw->show();
|
||||||
|
fw->setObjectName("FloatingWidget");
|
||||||
|
//fw->installEventFilter(this);
|
||||||
|
|
||||||
// Delete old section, if it is empty now.
|
// Delete old section, if it is empty now.
|
||||||
if (sectionwidget->contents().isEmpty())
|
if (sectionwidget->contents().isEmpty())
|
||||||
@ -1233,10 +1200,89 @@ FloatingWidget* ContainerWidget::startFloating(SectionWidget* sectionwidget, int
|
|||||||
}
|
}
|
||||||
deleteEmptySplitter(this);
|
deleteEmptySplitter(this);
|
||||||
|
|
||||||
d->ContainerDropOverlay->setAllowedAreas(OuterAreas);
|
m_ContainerDropOverlay->setAllowedAreas(OuterAreas);
|
||||||
d->ContainerDropOverlay->showDropOverlay(this);
|
m_ContainerDropOverlay->showDropOverlay(this);
|
||||||
d->ContainerDropOverlay->raise();
|
m_ContainerDropOverlay->raise();
|
||||||
return fw;
|
return fw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MainContainerWidget::event(QEvent *e)
|
||||||
|
{
|
||||||
|
//std::cout << "ContainerWidget::event " << e->type() << std::endl;
|
||||||
|
return QFrame::event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainContainerWidget::moveFloatingWidget(const QPoint& TargetPos)
|
||||||
|
{
|
||||||
|
QPoint MousePos = mapFromGlobal(QCursor::pos());
|
||||||
|
|
||||||
|
// Mouse is over the container widget
|
||||||
|
if (rect().contains(MousePos))
|
||||||
|
{
|
||||||
|
//std::cout << "over Container" << std::endl;
|
||||||
|
m_ContainerDropOverlay->showDropOverlay(this);
|
||||||
|
m_ContainerDropOverlay->raise();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "-----------------" << std::endl;
|
||||||
|
m_ContainerDropOverlay->hideDropOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mouse is over a SectionWidget
|
||||||
|
SectionWidget* sectionwidget = sectionWidgetAt(MousePos);
|
||||||
|
if (sectionwidget)
|
||||||
|
{
|
||||||
|
//qInfo() << "over sectionWidget";
|
||||||
|
m_SectionDropOverlay->setAllowedAreas(ADS_NS::AllAreas);
|
||||||
|
m_SectionDropOverlay->showDropOverlay(sectionwidget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_SectionDropOverlay->hideDropOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainContainerWidget::dropFloatingWidget(FloatingWidget* FloatingWidget,
|
||||||
|
const QPoint& TargetPos)
|
||||||
|
{
|
||||||
|
if (!FloatingWidget->isDraggingActive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPoint MousePos = mapFromGlobal(TargetPos);
|
||||||
|
SectionWidget* sectionWidget = sectionWidgetAt(MousePos);
|
||||||
|
DropArea dropArea = InvalidDropArea;
|
||||||
|
if (sectionWidget)
|
||||||
|
{
|
||||||
|
m_SectionDropOverlay->setAllowedAreas(ADS_NS::AllAreas);
|
||||||
|
dropArea = m_SectionDropOverlay->showDropOverlay(sectionWidget);
|
||||||
|
if (dropArea != InvalidDropArea)
|
||||||
|
{
|
||||||
|
InternalContentData data;
|
||||||
|
FloatingWidget->takeContent(data);
|
||||||
|
FloatingWidget->deleteLater();
|
||||||
|
dropContent(data, sectionWidget, dropArea, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mouse is over container
|
||||||
|
if (InvalidDropArea == dropArea)
|
||||||
|
{
|
||||||
|
dropArea = m_ContainerDropOverlay->dropAreaUnderCursor();
|
||||||
|
std::cout << "Cursor location: " << dropArea << std::endl;
|
||||||
|
if (dropArea != InvalidDropArea)
|
||||||
|
{
|
||||||
|
InternalContentData data;
|
||||||
|
FloatingWidget->takeContent(data);
|
||||||
|
FloatingWidget->deleteLater();
|
||||||
|
dropContent(data, nullptr, dropArea, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ADS_NAMESPACE_END
|
ADS_NAMESPACE_END
|
||||||
|
@ -149,19 +149,19 @@ DropAreas DropOverlay::allowedAreas() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DropArea DropOverlay::cursorLocation() const
|
DropArea DropOverlay::dropAreaUnderCursor() const
|
||||||
{
|
{
|
||||||
return _cross->cursorLocation();
|
return _cross->cursorLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
DropArea DropOverlay::showDropOverlay(QWidget* target)
|
DropArea DropOverlay::showDropOverlay(QWidget* target)
|
||||||
{
|
{
|
||||||
std::cout << "DropOverlay::showDropOverlay(QWidget* target)" << std::endl;
|
//std::cout << "DropOverlay::showDropOverlay(QWidget* target)" << std::endl;
|
||||||
if (_target == target)
|
if (_target == target)
|
||||||
{
|
{
|
||||||
qInfo() << "_target == target";
|
qInfo() << "_target == target";
|
||||||
// Hint: We could update geometry of overlay here.
|
// Hint: We could update geometry of overlay here.
|
||||||
DropArea da = cursorLocation();
|
DropArea da = dropAreaUnderCursor();
|
||||||
if (da != _lastLocation)
|
if (da != _lastLocation)
|
||||||
{
|
{
|
||||||
qInfo() << "repaint()";
|
qInfo() << "repaint()";
|
||||||
@ -172,7 +172,7 @@ DropArea DropOverlay::showDropOverlay(QWidget* target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//hideDropOverlay();
|
//hideDropOverlay();
|
||||||
std::cout << "_target != target, hideDropOverlay(), _fullAreaDrop = false" << std::endl;
|
//std::cout << "_target != target, hideDropOverlay(), _fullAreaDrop = false" << std::endl;
|
||||||
_target = target;
|
_target = target;
|
||||||
_targetRect = QRect();
|
_targetRect = QRect();
|
||||||
_lastLocation = InvalidDropArea;
|
_lastLocation = InvalidDropArea;
|
||||||
@ -181,7 +181,7 @@ DropArea DropOverlay::showDropOverlay(QWidget* target)
|
|||||||
resize(target->size());
|
resize(target->size());
|
||||||
move(target->mapToGlobal(target->rect().topLeft()));
|
move(target->mapToGlobal(target->rect().topLeft()));
|
||||||
show();
|
show();
|
||||||
return cursorLocation();
|
return dropAreaUnderCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropOverlay::showDropOverlay(QWidget* target, const QRect& targetAreaRect)
|
void DropOverlay::showDropOverlay(QWidget* target, const QRect& targetAreaRect)
|
||||||
@ -220,8 +220,8 @@ void DropOverlay::paintEvent(QPaintEvent*)
|
|||||||
{
|
{
|
||||||
// Draw rect based on location
|
// Draw rect based on location
|
||||||
QRect r = rect();
|
QRect r = rect();
|
||||||
const DropArea da = cursorLocation();
|
const DropArea da = dropAreaUnderCursor();
|
||||||
std::cout << "CursorLocation: " << cursorLocation() << std::endl;
|
std::cout << "CursorLocation: " << dropAreaUnderCursor() << std::endl;
|
||||||
switch (da)
|
switch (da)
|
||||||
{
|
{
|
||||||
case ADS_NS::TopDropArea:
|
case ADS_NS::TopDropArea:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <ads/ContainerWidget.h>
|
||||||
#include "ads/FloatingWidget.h"
|
#include "ads/FloatingWidget.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
@ -6,7 +7,6 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
#include "ads/ContainerWidget.h"
|
|
||||||
#include "ads/SectionTitleWidget.h"
|
#include "ads/SectionTitleWidget.h"
|
||||||
#include "ads/SectionContentWidget.h"
|
#include "ads/SectionContentWidget.h"
|
||||||
#include "ads/Internal.h"
|
#include "ads/Internal.h"
|
||||||
@ -14,7 +14,9 @@
|
|||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
FloatingWidget::FloatingWidget(ContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent) :
|
unsigned int FloatingWidget::zOrderCounter = 0;
|
||||||
|
|
||||||
|
FloatingWidget::FloatingWidget(MainContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent) :
|
||||||
QWidget(parent, Qt::CustomizeWindowHint | Qt::Tool),
|
QWidget(parent, Qt::CustomizeWindowHint | Qt::Tool),
|
||||||
_container(container),
|
_container(container),
|
||||||
_content(sc),
|
_content(sc),
|
||||||
@ -45,6 +47,8 @@ FloatingWidget::FloatingWidget(ContainerWidget* container, SectionContent::RefPt
|
|||||||
}
|
}
|
||||||
l->addWidget(contentWidget, 1);
|
l->addWidget(contentWidget, 1);
|
||||||
contentWidget->show();
|
contentWidget->show();
|
||||||
|
|
||||||
|
m_zOrderIndex = ++zOrderCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,12 +60,14 @@ FloatingWidget::FloatingWidget(SectionWidget* sectionWidget)
|
|||||||
setLayout(l);
|
setLayout(l);
|
||||||
|
|
||||||
l->addWidget(sectionWidget);
|
l->addWidget(sectionWidget);
|
||||||
|
m_zOrderIndex = ++zOrderCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FloatingWidget::~FloatingWidget()
|
FloatingWidget::~FloatingWidget()
|
||||||
{
|
{
|
||||||
_container->d->floatings.removeAll(this); // Note: I don't like this here, but we have to remove it from list...
|
// maybe we can implement this this via connection to destroyed signal
|
||||||
|
_container->m_Floatings.removeAll(this); // Note: I don't like this here, but we have to remove it from list...
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FloatingWidget::takeContent(InternalContentData& data)
|
bool FloatingWidget::takeContent(InternalContentData& data)
|
||||||
@ -86,5 +92,31 @@ void FloatingWidget::onCloseButtonClicked()
|
|||||||
_container->hideSectionContent(_content);
|
_container->hideSectionContent(_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FloatingWidget::isDraggingActive() const
|
||||||
|
{
|
||||||
|
return _titleWidget->isDraggingFloatingWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FloatingWidget::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::changeEvent(event);
|
||||||
|
if (event->type() != QEvent::ActivationChange)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isActiveWindow())
|
||||||
|
{
|
||||||
|
m_zOrderIndex = ++zOrderCounter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int FloatingWidget::zOrderIndex() const
|
||||||
|
{
|
||||||
|
return m_zOrderIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ADS_NAMESPACE_END
|
ADS_NAMESPACE_END
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
#include <ads/ContainerWidget.h>
|
||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include "ads/Internal.h"
|
#include "ads/Internal.h"
|
||||||
#include "ads/ContainerWidget.h"
|
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -14,10 +14,10 @@ SectionContent::SectionContent() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueName, ContainerWidget* container, QWidget* title, QWidget* content)
|
SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueName, MainContainerWidget* container, QWidget* title, QWidget* content)
|
||||||
{
|
{
|
||||||
auto SectionContentNameMap = container->d->SectionContentNameMap;
|
auto SectionContentNameMap = container->m_SectionContentNameMap;
|
||||||
auto SectionContentIdMap = container->d->SectionContentIdMap;
|
auto SectionContentIdMap = container->m_SectionContentIdMap;
|
||||||
|
|
||||||
if (uniqueName.isEmpty())
|
if (uniqueName.isEmpty())
|
||||||
{
|
{
|
||||||
@ -48,8 +48,8 @@ SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueNa
|
|||||||
|
|
||||||
SectionContent::~SectionContent()
|
SectionContent::~SectionContent()
|
||||||
{
|
{
|
||||||
auto SectionContentNameMap = _containerWidget->d->SectionContentNameMap;
|
auto SectionContentNameMap = _containerWidget->m_SectionContentNameMap;
|
||||||
auto SectionContentIdMap = _containerWidget->d->SectionContentIdMap;
|
auto SectionContentIdMap = _containerWidget->m_SectionContentIdMap;
|
||||||
|
|
||||||
if (_containerWidget)
|
if (_containerWidget)
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ QString SectionContent::uniqueName() const
|
|||||||
return _uniqueName;
|
return _uniqueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerWidget* SectionContent::containerWidget() const
|
MainContainerWidget* SectionContent::containerWidget() const
|
||||||
{
|
{
|
||||||
return _containerWidget;
|
return _containerWidget;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
#include "ads/SectionWidget.h"
|
#include "ads/SectionWidget.h"
|
||||||
#include "ads/FloatingWidget.h"
|
#include "ads/FloatingWidget.h"
|
||||||
#include "ads/ContainerWidget.h"
|
#include <ads/ContainerWidget.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget*
|
|||||||
l->setSpacing(0);
|
l->setSpacing(0);
|
||||||
l->addWidget(content->titleWidget());
|
l->addWidget(content->titleWidget());
|
||||||
setLayout(l);
|
setLayout(l);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionTitleWidget::~SectionTitleWidget()
|
SectionTitleWidget::~SectionTitleWidget()
|
||||||
@ -76,46 +77,15 @@ void SectionTitleWidget::mousePressEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
SectionWidget* section = NULL;
|
SectionWidget* section = nullptr;
|
||||||
ContainerWidget* cw = findParentContainerWidget(this);
|
MainContainerWidget* cw = findParentContainerWidget(this);
|
||||||
|
|
||||||
// Drop contents of FloatingWidget into container or section widget
|
if (isDraggingFloatingWidget() && cw->rect().contains(cw->mapFromGlobal(ev->globalPos())))
|
||||||
if (m_FloatingWidget && cw->rect().contains(cw->mapFromGlobal(ev->globalPos())))
|
|
||||||
{
|
{
|
||||||
SectionWidget* sw = cw->sectionAt(cw->mapFromGlobal(ev->globalPos()));
|
cw->dropFloatingWidget(m_FloatingWidget, ev->globalPos());
|
||||||
DropArea loc = InvalidDropArea;
|
|
||||||
if (sw)
|
|
||||||
{
|
|
||||||
cw->d->SectionDropOverlay->setAllowedAreas(ADS_NS::AllAreas);
|
|
||||||
DropArea loc = cw->d->SectionDropOverlay->showDropOverlay(sw);
|
|
||||||
if (loc != InvalidDropArea)
|
|
||||||
{
|
|
||||||
InternalContentData data;
|
|
||||||
m_FloatingWidget->takeContent(data);
|
|
||||||
m_FloatingWidget->deleteLater();
|
|
||||||
m_FloatingWidget.clear();
|
|
||||||
cw->dropContent(data, sw, loc, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// mouse is over container
|
|
||||||
if (InvalidDropArea == loc)
|
|
||||||
{
|
|
||||||
DropArea loc = cw->d->ContainerDropOverlay->cursorLocation();
|
|
||||||
std::cout << "Cursor location: " << loc << std::endl;
|
|
||||||
if (loc != InvalidDropArea)
|
|
||||||
{
|
|
||||||
InternalContentData data;
|
|
||||||
m_FloatingWidget->takeContent(data);
|
|
||||||
m_FloatingWidget->deleteLater();
|
|
||||||
m_FloatingWidget.clear();
|
|
||||||
cw->dropContent(data, nullptr, loc, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// End of tab moving, change order now
|
// End of tab moving, change order now
|
||||||
else if (m_TabMoving
|
else if (m_TabMoving && (section = findParentSectionWidget(this)) != nullptr)
|
||||||
&& (section = findParentSectionWidget(this)) != NULL)
|
|
||||||
{
|
{
|
||||||
// Find tab under mouse
|
// Find tab under mouse
|
||||||
QPoint pos = ev->globalPos();
|
QPoint pos = ev->globalPos();
|
||||||
@ -138,21 +108,23 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
// Reset
|
// Reset
|
||||||
m_DragStartPosition = QPoint();
|
m_DragStartPosition = QPoint();
|
||||||
m_TabMoving = false;
|
m_TabMoving = false;
|
||||||
cw->d->SectionDropOverlay->hideDropOverlay();
|
cw->m_SectionDropOverlay->hideDropOverlay();
|
||||||
cw->hideContainerOverlay();
|
cw->hideContainerOverlay();
|
||||||
QFrame::mouseReleaseEvent(ev);
|
QFrame::mouseReleaseEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SectionTitleWidget::moveFloatingWidget(QMouseEvent* ev, ContainerWidget* cw)
|
void SectionTitleWidget::moveFloatingWidget(QMouseEvent* ev, MainContainerWidget* cw)
|
||||||
{
|
{
|
||||||
const QPoint moveToPos = ev->globalPos() - (m_DragStartPosition + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
|
const QPoint moveToPos = ev->globalPos() - (m_DragStartPosition + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
|
||||||
m_FloatingWidget->move(moveToPos);
|
m_FloatingWidget->move(moveToPos);
|
||||||
cw->moveFloatingWidget(moveToPos);
|
cw->moveFloatingWidget(moveToPos);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SectionTitleWidget::startFloating(QMouseEvent* ev, ContainerWidget* cw, SectionWidget* sectionwidget)
|
void SectionTitleWidget::startFloating(QMouseEvent* ev, MainContainerWidget* cw, SectionWidget* sectionwidget)
|
||||||
{
|
{
|
||||||
QPoint moveToPos = ev->globalPos() - (m_DragStartPosition + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
|
QPoint moveToPos = ev->globalPos() - (m_DragStartPosition + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
|
||||||
m_FloatingWidget = cw->startFloating(sectionwidget, m_Content->uid(), moveToPos);
|
m_FloatingWidget = cw->startFloating(sectionwidget, m_Content->uid(), moveToPos);
|
||||||
@ -169,6 +141,12 @@ void SectionTitleWidget::moveTab(QMouseEvent* ev)
|
|||||||
move(moveToPos);
|
move(moveToPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SectionTitleWidget::isDraggingFloatingWidget() const
|
||||||
|
{
|
||||||
|
return m_FloatingWidget != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
if (!(ev->buttons() & Qt::LeftButton))
|
if (!(ev->buttons() & Qt::LeftButton))
|
||||||
@ -177,10 +155,31 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPoint Pos = QCursor::pos();
|
||||||
|
MainContainerWidget* cw = findParentContainerWidget(this);
|
||||||
|
auto Floatings = cw->m_Floatings;
|
||||||
|
FloatingWidget* TopWidget = nullptr;
|
||||||
|
for (auto widget : Floatings)
|
||||||
|
{
|
||||||
|
if ((widget != m_FloatingWidget.data()) && widget->geometry().contains(Pos))
|
||||||
|
{
|
||||||
|
if (!TopWidget || widget->zOrderIndex() > TopWidget->zOrderIndex())
|
||||||
|
{
|
||||||
|
TopWidget = widget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TopWidget)
|
||||||
|
{
|
||||||
|
std::cout << "TopWidget " << std::hex << (int)TopWidget << std::dec
|
||||||
|
<< " Z: " << TopWidget->zOrderIndex() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
ev->accept();
|
ev->accept();
|
||||||
ContainerWidget* cw = findParentContainerWidget(this);
|
|
||||||
// Move already existing FloatingWidget
|
// Move already existing FloatingWidget
|
||||||
if (m_FloatingWidget)
|
if (isDraggingFloatingWidget())
|
||||||
{
|
{
|
||||||
moveFloatingWidget(ev, cw);
|
moveFloatingWidget(ev, cw);
|
||||||
return;
|
return;
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
#include "ads/SectionTitleWidget.h"
|
#include "ads/SectionTitleWidget.h"
|
||||||
#include "ads/SectionContentWidget.h"
|
#include "ads/SectionContentWidget.h"
|
||||||
#include "ads/FloatingWidget.h"
|
#include "ads/FloatingWidget.h"
|
||||||
#include "ads/ContainerWidget.h"
|
#include <ads/ContainerWidget.h>
|
||||||
|
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
SectionWidget::SectionWidget(ContainerWidget* parent) :
|
SectionWidget::SectionWidget(MainContainerWidget* parent) :
|
||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
_uid(GetNextUid()),
|
_uid(GetNextUid()),
|
||||||
_container(parent),
|
_container(parent),
|
||||||
@ -93,15 +93,15 @@ SectionWidget::SectionWidget(ContainerWidget* parent) :
|
|||||||
_contentsLayout->setSpacing(0);
|
_contentsLayout->setSpacing(0);
|
||||||
l->addLayout(_contentsLayout, 1);
|
l->addLayout(_contentsLayout, 1);
|
||||||
|
|
||||||
_container->d->SectionWidgetIdMap.insert(_uid, this);
|
_container->m_SectionWidgetIdMap.insert(_uid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionWidget::~SectionWidget()
|
SectionWidget::~SectionWidget()
|
||||||
{
|
{
|
||||||
if (_container)
|
if (_container)
|
||||||
{
|
{
|
||||||
_container->d->SectionWidgetIdMap.remove(_uid);
|
_container->m_SectionWidgetIdMap.remove(_uid);
|
||||||
_container->d->sections.removeAll(this); // Note: I don't like this here, but we have to remove it from list...
|
_container->m_Sections.removeAll(this); // Note: I don't like this here, but we have to remove it from list...
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete empty QSplitter.
|
// Delete empty QSplitter.
|
||||||
@ -117,7 +117,7 @@ int SectionWidget::uid() const
|
|||||||
return _uid;
|
return _uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerWidget* SectionWidget::containerWidget() const
|
MainContainerWidget* SectionWidget::containerWidget() const
|
||||||
{
|
{
|
||||||
return _container;
|
return _container;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ SectionContentListModel::~SectionContentListModel()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SectionContentListModel::init(ADS_NS::ContainerWidget* cw)
|
void SectionContentListModel::init(ADS_NS::MainContainerWidget* cw)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
@ -5,12 +5,11 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
#include "../../../AdvancedDockingSystem/include/ads/ContainerWidget.h"
|
||||||
#include "ads/API.h"
|
#include "ads/API.h"
|
||||||
#include "ads/ContainerWidget.h"
|
|
||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
ADS_NAMESPACE_BEGIN
|
ADS_NAMESPACE_BEGIN
|
||||||
class ContainerWidget;
|
class MainContainerWidget;
|
||||||
ADS_NAMESPACE_END
|
ADS_NAMESPACE_END
|
||||||
|
|
||||||
class SectionContentListModel : public QAbstractTableModel
|
class SectionContentListModel : public QAbstractTableModel
|
||||||
@ -28,7 +27,7 @@ public:
|
|||||||
|
|
||||||
SectionContentListModel(QObject* parent);
|
SectionContentListModel(QObject* parent);
|
||||||
virtual ~SectionContentListModel();
|
virtual ~SectionContentListModel();
|
||||||
void init(ADS_NS::ContainerWidget* cw);
|
void init(ADS_NS::MainContainerWidget* cw);
|
||||||
|
|
||||||
virtual int columnCount(const QModelIndex &parent) const;
|
virtual int columnCount(const QModelIndex &parent) const;
|
||||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
@ -41,7 +40,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QHash<int, QString> _headers;
|
QHash<int, QString> _headers;
|
||||||
|
|
||||||
ADS_NS::ContainerWidget* _cw;
|
ADS_NS::MainContainerWidget* _cw;
|
||||||
QList<ADS_NS::SectionContent::RefPtr> _contents;
|
QList<ADS_NS::SectionContent::RefPtr> _contents;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#define SECTIONCONTENTLISTWIDGET
|
#define SECTIONCONTENTLISTWIDGET
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include "../../../AdvancedDockingSystem/include/ads/ContainerWidget.h"
|
||||||
#include "ui_SectionContentListWidget.h"
|
#include "ui_SectionContentListWidget.h"
|
||||||
|
|
||||||
#include "ads/API.h"
|
#include "ads/API.h"
|
||||||
#include "ads/ContainerWidget.h"
|
|
||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
|
|
||||||
class SectionContentListWidget : public QDialog
|
class SectionContentListWidget : public QDialog
|
||||||
@ -16,7 +16,7 @@ public:
|
|||||||
class Values
|
class Values
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ADS_NS::ContainerWidget* cw;
|
ADS_NS::MainContainerWidget* cw;
|
||||||
};
|
};
|
||||||
|
|
||||||
SectionContentListWidget(QWidget* parent);
|
SectionContentListWidget(QWidget* parent);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
static int CONTENT_COUNT = 0;
|
static int CONTENT_COUNT = 0;
|
||||||
|
|
||||||
static ADS_NS::SectionContent::RefPtr createLongTextLabelSC(ADS_NS::ContainerWidget* container)
|
static ADS_NS::SectionContent::RefPtr createLongTextLabelSC(ADS_NS::MainContainerWidget* container)
|
||||||
{
|
{
|
||||||
QWidget* w = new QWidget();
|
QWidget* w = new QWidget();
|
||||||
QBoxLayout* bl = new QBoxLayout(QBoxLayout::TopToBottom);
|
QBoxLayout* bl = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
@ -39,7 +39,7 @@ static ADS_NS::SectionContent::RefPtr createLongTextLabelSC(ADS_NS::ContainerWid
|
|||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget* container)
|
static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::MainContainerWidget* container)
|
||||||
{
|
{
|
||||||
QCalendarWidget* w = new QCalendarWidget();
|
QCalendarWidget* w = new QCalendarWidget();
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget*
|
|||||||
return ADS_NS::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Calendar %1").arg(index)), w);
|
return ADS_NS::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Calendar %1").arg(index)), w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::ContainerWidget* container)
|
static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::MainContainerWidget* container)
|
||||||
{
|
{
|
||||||
QTreeView* w = new QTreeView();
|
QTreeView* w = new QTreeView();
|
||||||
w->setFrameShape(QFrame::NoFrame);
|
w->setFrameShape(QFrame::NoFrame);
|
||||||
@ -93,7 +93,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->actionContentList, SIGNAL(triggered()), this, SLOT(showSectionContentListDialog()));
|
connect(ui->actionContentList, SIGNAL(triggered()), this, SLOT(showSectionContentListDialog()));
|
||||||
|
|
||||||
// ADS - Create main container (ContainerWidget).
|
// ADS - Create main container (ContainerWidget).
|
||||||
_container = new ADS_NS::ContainerWidget();
|
_container = new ADS_NS::MainContainerWidget();
|
||||||
connect(_container, SIGNAL(activeTabChanged(const SectionContent::RefPtr&, bool)), this, SLOT(onActiveTabChanged(const SectionContent::RefPtr&, bool)));
|
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)));
|
connect(_container, SIGNAL(sectionContentVisibilityChanged(SectionContent::RefPtr,bool)), this, SLOT(onSectionContentVisibilityChanged(SectionContent::RefPtr,bool)));
|
||||||
setCentralWidget(_container);
|
setCentralWidget(_container);
|
||||||
@ -116,8 +116,8 @@ void MainWindow::createContent()
|
|||||||
{
|
{
|
||||||
// ADS - Adding some contents.
|
// ADS - Adding some contents.
|
||||||
// Test #1: Use high-level public API
|
// Test #1: Use high-level public API
|
||||||
ADS_NS::ContainerWidget* cw = _container;
|
ADS_NS::MainContainerWidget* cw = _container;
|
||||||
ADS_NS::SectionWidget* sw = NULL;
|
ADS_NS::SectionWidget* sw = nullptr;
|
||||||
|
|
||||||
sw = _container->addSectionContent(createLongTextLabelSC(cw), nullptr, ADS_NS::CenterDropArea);
|
sw = _container->addSectionContent(createLongTextLabelSC(cw), nullptr, ADS_NS::CenterDropArea);
|
||||||
sw = _container->addSectionContent(createCalendarSC(cw), nullptr, ADS_NS::LeftDropArea);
|
sw = _container->addSectionContent(createCalendarSC(cw), nullptr, ADS_NS::LeftDropArea);
|
||||||
@ -134,7 +134,7 @@ void MainWindow::createContent()
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Issue #2: If the first drop is not into CenterDropArea, the application crashes.
|
// Issue #2: If the first drop is not into CenterDropArea, the application crashes.
|
||||||
ADS_NS::ContainerWidget* cw = _container;
|
ADS_NS::MainContainerWidget* cw = _container;
|
||||||
ADS_NS::SectionWidget* sw = NULL;
|
ADS_NS::SectionWidget* sw = NULL;
|
||||||
|
|
||||||
sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::LeftDropArea);
|
sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::LeftDropArea);
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include "../../AdvancedDockingSystem/include/ads/ContainerWidget.h"
|
||||||
#include "ads/API.h"
|
#include "ads/API.h"
|
||||||
#include "ads/ContainerWidget.h"
|
|
||||||
#include "ads/SectionContent.h"
|
#include "ads/SectionContent.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -37,7 +37,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
ADS_NS::ContainerWidget* _container;
|
ADS_NS::MainContainerWidget* _container;
|
||||||
void createContent();
|
void createContent();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user