Some refactorings to cleanup code, moved ContainerWidget private data into private data class

This commit is contained in:
Uwe Kindler
2017-01-20 22:43:18 +01:00
parent 68b93f6fa9
commit 889d9bff5b
10 changed files with 206 additions and 221 deletions
+5
View File
@@ -60,6 +60,11 @@ enum DropArea
LeftDropArea = 8,
CenterDropArea = 16,
TopBorderDropArea = 32,
RightBorderDropArea = 64,
BottomBorderDropArea = 128,
LeftBorderDropArea = 256,
AllAreas = TopDropArea | RightDropArea | BottomDropArea | LeftDropArea | CenterDropArea
};
Q_DECLARE_FLAGS(DropAreas, DropArea)
@@ -21,6 +21,30 @@ class SectionWidget;
class DropOverlay;
class InternalContentData;
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> scLookupMapById;
QHash<QString, SectionContent::WeakPtr> scLookupMapByName;
QHash<int, SectionWidget*> swLookupMapById;
// 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> dropOverlay;
};
/*!
* ContainerWidget is the main container to provide the docking
@@ -36,6 +60,7 @@ class ADS_EXPORT_API ContainerWidget : public QFrame
friend class SectionTitleWidget;
friend class SectionContentWidget;
friend class SectionWidgetTabsScrollArea;
friend class ContainerWidgetPrivate;
public:
explicit ContainerWidget(QWidget *parent = NULL);
@@ -169,26 +194,7 @@ signals:
void sectionContentVisibilityChanged(const SectionContent::RefPtr& sc, bool visible);
private:
// Elements inside container.
QList<SectionWidget*> _sections;
QList<FloatingWidget*> _floatings;
QHash<int, HiddenSectionItem> _hiddenSectionContents;
// Helper lookup maps, restricted to this container.
QHash<int, SectionContent::WeakPtr> _scLookupMapById;
QHash<QString, SectionContent::WeakPtr> _scLookupMapByName;
QHash<int, SectionWidget*> _swLookupMapById;
// Layout stuff
QGridLayout* _mainLayout;
Qt::Orientation _orientation;
QPointer<QSplitter> _splitter; // $mfreiholz: I'd like to remove this variable entirely,
// because it changes during user interaction anyway.
// Drop overlay stuff.
QPointer<DropOverlay> _dropOverlay;
ContainerWidgetPrivate* d;///< private data
};
ADS_NAMESPACE_END
@@ -36,6 +36,11 @@ public:
void showDropOverlay(QWidget* target, const QRect& targetAreaRect);
void hideDropOverlay();
/**
* Creates a drop indicator widget for the given drop area
*/
static QWidget* createDropIndicatorWidget(DropArea dropArea);
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void showEvent(QShowEvent* e);
@@ -51,6 +56,7 @@ private:
QPointer<QWidget> _target;
QRect _targetRect;
DropArea _lastLocation;
QWidget* m_LeftBorderDropArea;
};
/*!
@@ -11,9 +11,6 @@
#include "ads/SectionContent.h"
#endif
#define SCLookupMapById(X) X->_scLookupMapById
#define SCLookupMapByName(X) X->_scLookupMapByName
#define SWLookupMapById(X) X->_swLookupMapById
ADS_NAMESPACE_BEGIN
class SectionContent;