Started refactoring to improve code quality, overall designa nd to gain knowledge of the impolemented functionality

This commit is contained in:
Uwe Kindler 2017-01-17 07:57:24 +01:00
parent abc8468989
commit 68b93f6fa9
14 changed files with 276 additions and 188 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.pro.user
/ build

View File

@ -1,6 +1,8 @@
TARGET = AdvancedDockingSystem
include($$(cetoni_repository)/build/qt/qtprojectsettings/shared_library.pri)
TARGET = $$qtLibraryTarget(AdvancedDockingSystem)
TEMPLATE = lib
VERSION = 1.0.0
#VERSION = 1.0.0
CONFIG += adsBuildShared

View File

@ -35,6 +35,7 @@ class ADS_EXPORT_API ContainerWidget : public QFrame
friend class FloatingWidget;
friend class SectionTitleWidget;
friend class SectionContentWidget;
friend class SectionWidgetTabsScrollArea;
public:
explicit ContainerWidget(QWidget *parent = NULL);
@ -143,6 +144,9 @@ private:
bool takeContent(const SectionContent::RefPtr& sc, InternalContentData& data);
void moveFloatingWidget(const QPoint& TargetPos);
FloatingWidget* startFloating(SectionWidget* sectionwidget, int ContentUid, const QPoint& TargetPos);
private slots:
void onActiveTabChanged();
void onActionToggleSectionContentVisibility(bool visible);

View File

@ -12,6 +12,7 @@ class ContainerWidget;
class SectionTitleWidget;
class SectionContentWidget;
class InternalContentData;
class SectionWidget;
// FloatingWidget holds and displays SectionContent as a floating window.
// It can be resized, moved and dropped back into a SectionWidget.
@ -23,7 +24,8 @@ class FloatingWidget : public QWidget
public:
FloatingWidget(ContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent = NULL);
virtual ~FloatingWidget();
FloatingWidget(SectionWidget* sectionWidget);
virtual ~FloatingWidget();
SectionContent::RefPtr content() const { return _content; }

View File

@ -21,17 +21,17 @@ class SectionTitleWidget : public QFrame
friend class ContainerWidget;
friend class SectionWidget;
SectionContent::RefPtr _content;
SectionContent::RefPtr m_Content;
// Drag & Drop (Floating)
QPointer<FloatingWidget> _fw;
QPoint _dragStartPos;
QPointer<FloatingWidget> m_FloatingWidget;
QPoint m_DragStartPosition;
// Drag & Drop (Title/Tabs)
bool _tabMoving;
bool m_TabMoving;
// Property values
bool _activeTab;
bool m_IsActiveTab;
public:
SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent);
@ -45,6 +45,11 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
private:
void moveFloatingWidget(QMouseEvent* ev, ContainerWidget* cw);
void startFloating(QMouseEvent* ev, ContainerWidget* cw, SectionWidget* sectionwidget);
void moveTab(QMouseEvent* ev);
signals:
void activeTabChanged();
void clicked();

View File

@ -14,6 +14,7 @@ class QMenu;
#include "ads/API.h"
#include "ads/Internal.h"
#include "ads/SectionContent.h"
#include "ads/FloatingWidget.h"
ADS_NAMESPACE_BEGIN
class ContainerWidget;
@ -50,6 +51,8 @@ public:
int currentIndex() const;
void moveContent(int from, int to);
virtual bool eventFilter(QObject *watched, QEvent *event);
protected:
virtual void showEvent(QShowEvent*);
@ -96,7 +99,11 @@ public:
virtual ~SectionWidgetTabsScrollArea();
protected:
QPoint _dragStartPos;
QPointer<FloatingWidget> _fw;
virtual void wheelEvent(QWheelEvent*);
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
};
ADS_NAMESPACE_END

View File

@ -1111,7 +1111,7 @@ bool ContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList
fw->_contentWidget->setVisible(visible);
}
floatings.append(fw);
data.titleWidget->_fw = fw; // $mfreiholz: Don't look at it :-< It's more than ugly...
data.titleWidget->m_FloatingWidget = fw; // $mfreiholz: Don't look at it :-< It's more than ugly...
}
return true;
}
@ -1249,7 +1249,7 @@ void ContainerWidget::onActiveTabChanged()
SectionTitleWidget* stw = qobject_cast<SectionTitleWidget*>(sender());
if (stw)
{
emit activeTabChanged(stw->_content, stw->isActiveTab());
emit activeTabChanged(stw->m_Content, stw->isActiveTab());
}
}
@ -1271,4 +1271,70 @@ void ContainerWidget::onActionToggleSectionContentVisibility(bool visible)
hideSectionContent(sc);
}
void ContainerWidget::moveFloatingWidget(const QPoint& TargetPos)
{
// Mouse is over a SectionWidget
SectionWidget* sectionwidget = sectionAt(mapFromGlobal(QCursor::pos()));
if (sectionwidget)
{
qInfo() << "over sectionWidget";
_dropOverlay->setAllowedAreas(ADS_NS::AllAreas);
_dropOverlay->showDropOverlay(sectionwidget);
}
// Mouse is at the edge of the ContainerWidget
// Top, Right, Bottom, Left
else if (outerTopDropRect().contains(mapFromGlobal(QCursor::pos())))
{
_dropOverlay->setAllowedAreas(ADS_NS::TopDropArea);
_dropOverlay->showDropOverlay(this, outerTopDropRect());
}
else if (outerRightDropRect().contains(mapFromGlobal(QCursor::pos())))
{
_dropOverlay->setAllowedAreas(ADS_NS::RightDropArea);
_dropOverlay->showDropOverlay(this, outerRightDropRect());
}
else if (outerBottomDropRect().contains(mapFromGlobal(QCursor::pos())))
{
_dropOverlay->setAllowedAreas(ADS_NS::BottomDropArea);
_dropOverlay->showDropOverlay(this, outerBottomDropRect());
}
else if (outerLeftDropRect().contains(mapFromGlobal(QCursor::pos())))
{
_dropOverlay->setAllowedAreas(ADS_NS::LeftDropArea);
_dropOverlay->showDropOverlay(this, outerLeftDropRect());
}
else
{
_dropOverlay->hideDropOverlay();
}
}
FloatingWidget* ContainerWidget::startFloating(SectionWidget* sectionwidget, int ContentUid, const QPoint& TargetPos)
{
// Create floating widget.
InternalContentData data;
if (!sectionwidget->takeContent(ContentUid, data))
{
qWarning() << "THIS SHOULD NOT HAPPEN!!" << ContentUid;
return 0;
}
FloatingWidget* fw = new FloatingWidget(this, data.content, data.titleWidget, data.contentWidget, this);
fw->resize(sectionwidget->size());
_floatings.append(fw);
fw->move(TargetPos);
fw->show();
// Delete old section, if it is empty now.
if (sectionwidget->contents().isEmpty())
{
delete sectionwidget;
sectionwidget = NULL;
}
deleteEmptySplitter(this);
return fw;
}
ADS_NAMESPACE_END

View File

@ -9,6 +9,8 @@
#include <QCursor>
#include <QIcon>
#include <QLabel>
#include <QtGlobal>
#include <QDebug>
ADS_NAMESPACE_BEGIN
@ -139,8 +141,8 @@ DropOverlay::DropOverlay(QWidget* parent) :
areaWidgets.insert(ADS_NS::BottomDropArea, createDropIndicatorWidget(BottomDropArea));//createDropWidget(":/img/split-bottom.png"));
areaWidgets.insert(ADS_NS::LeftDropArea, createDropIndicatorWidget(LeftDropArea));//createDropWidget(":/img/split-left.png"));
areaWidgets.insert(ADS_NS::CenterDropArea, createDropIndicatorWidget(CenterDropArea));//createDropWidget(":/img/dock-center.png"));
_cross->setAreaWidgets(areaWidgets);
_cross->setAreaWidgets(areaWidgets);
_cross->setVisible(false);
setVisible(false);
}
@ -175,12 +177,16 @@ DropArea DropOverlay::cursorLocation() const
DropArea DropOverlay::showDropOverlay(QWidget* target)
{
qInfo() << "DropOverlay::showDropOverlay(QWidget* target)";
_fullAreaDrop = true;
if (_target == target)
{
qInfo() << "_target == target";
// Hint: We could update geometry of overlay here.
DropArea da = cursorLocation();
if (da != _lastLocation)
{
qInfo() << "repaint()";
repaint();
_lastLocation = da;
}
@ -188,6 +194,7 @@ DropArea DropOverlay::showDropOverlay(QWidget* target)
}
hideDropOverlay();
qInfo() << "_target != target, hideDropOverlay(), _fullAreaDrop = false";
_fullAreaDrop = false;
_target = target;
_targetRect = QRect();
@ -204,11 +211,11 @@ DropArea DropOverlay::showDropOverlay(QWidget* target)
void DropOverlay::showDropOverlay(QWidget* target, const QRect& targetAreaRect)
{
qInfo() << "DropOverlay::showDropOverlay(QWidget* target, const QRect& targetAreaRect)";
if (_target == target && _targetRect == targetAreaRect)
{
return;
}
hideDropOverlay();
_fullAreaDrop = true;
_target = target;
@ -226,6 +233,7 @@ void DropOverlay::showDropOverlay(QWidget* target, const QRect& targetAreaRect)
void DropOverlay::hideDropOverlay()
{
qInfo() << "hideDropOverlay() _fullAreaDrop = false";
hide();
_fullAreaDrop = false;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
@ -240,29 +248,19 @@ void DropOverlay::hideDropOverlay()
void DropOverlay::paintEvent(QPaintEvent*)
{
QPainter p(this);
const QColor areaColor = palette().color(QPalette::Active, QPalette::Highlight);//QColor(0, 100, 255)
// Always draw drop-rect over the entire rect()
if (_fullAreaDrop)
{
QRect r = rect();
p.fillRect(r, QBrush(areaColor, Qt::Dense4Pattern));
p.setBrush(QBrush(areaColor));
p.drawRect(r);
return;
}
const QColor areaColor = palette().color(QPalette::Active, QPalette::Highlight);
// Draw rect based on location
QRect r = rect();
const DropArea da = cursorLocation();
switch (da)
{
case ADS_NS::TopDropArea:
case ADS_NS::TopDropArea:
r.setHeight(r.height() / 2);
break;
case ADS_NS::RightDropArea:
r.setX(r.width() / 2);
break;
break;
case ADS_NS::BottomDropArea:
r.setY(r.height() / 2);
break;
@ -273,7 +271,7 @@ void DropOverlay::paintEvent(QPaintEvent*)
r = rect();
break;
default:
r = QRect();
r = QRect();
}
if (!r.isNull())
{
@ -304,11 +302,13 @@ void DropOverlay::hideEvent(QHideEvent*)
void DropOverlay::resizeEvent(QResizeEvent* e)
{
qInfo() << "DropOverlay::resizeEvent" << e->size();
_cross->resize(e->size());
}
void DropOverlay::moveEvent(QMoveEvent* e)
{
qInfo() << "DropOverlay::moveEvent" << e->pos();
_cross->move(e->pos());
}

View File

@ -10,6 +10,7 @@
#include "ads/SectionTitleWidget.h"
#include "ads/SectionContentWidget.h"
#include "ads/Internal.h"
#include "ads/SectionWidget.h"
ADS_NAMESPACE_BEGIN
@ -54,6 +55,18 @@ FloatingWidget::FloatingWidget(ContainerWidget* container, SectionContent::RefPt
// _container->_floatingWidgets.append(this);
}
FloatingWidget::FloatingWidget(SectionWidget* sectionWidget)
{
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
setLayout(l);
l->addWidget(sectionWidget);
}
FloatingWidget::~FloatingWidget()
{
_container->_floatings.removeAll(this); // Note: I don't like this here, but we have to remove it from list...
@ -81,4 +94,5 @@ void FloatingWidget::onCloseButtonClicked()
_container->hideSectionContent(_content);
}
ADS_NAMESPACE_END

View File

@ -26,9 +26,9 @@ ADS_NAMESPACE_BEGIN
SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent) :
QFrame(parent),
_content(content),
_tabMoving(false),
_activeTab(false)
m_Content(content),
m_TabMoving(false),
m_IsActiveTab(false)
{
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
l->setContentsMargins(0, 0, 0, 0);
@ -39,19 +39,19 @@ SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget*
SectionTitleWidget::~SectionTitleWidget()
{
layout()->removeWidget(_content->titleWidget());
layout()->removeWidget(m_Content->titleWidget());
}
bool SectionTitleWidget::isActiveTab() const
{
return _activeTab;
return m_IsActiveTab;
}
void SectionTitleWidget::setActiveTab(bool active)
{
if (active != _activeTab)
if (active != m_IsActiveTab)
{
_activeTab = active;
m_IsActiveTab = active;
style()->unpolish(this);
style()->polish(this);
@ -66,7 +66,7 @@ void SectionTitleWidget::mousePressEvent(QMouseEvent* ev)
if (ev->button() == Qt::LeftButton)
{
ev->accept();
_dragStartPos = ev->pos();
m_DragStartPosition = ev->pos();
return;
}
QFrame::mousePressEvent(ev);
@ -78,7 +78,7 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
ContainerWidget* cw = findParentContainerWidget(this);
// Drop contents of FloatingWidget into SectionWidget.
if (_fw)
if (m_FloatingWidget)
{
SectionWidget* sw = cw->sectionAt(cw->mapFromGlobal(ev->globalPos()));
if (sw)
@ -87,39 +87,11 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
DropArea loc = cw->_dropOverlay->showDropOverlay(sw);
if (loc != InvalidDropArea)
{
#if !defined(ADS_ANIMATIONS_ENABLED)
InternalContentData data;
_fw->takeContent(data);
_fw->deleteLater();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
_fw.clear();
#else
_fw = 0;
#endif
m_FloatingWidget->takeContent(data);
m_FloatingWidget->deleteLater();
m_FloatingWidget.clear();
cw->dropContent(data, sw, loc, true);
#else
QPropertyAnimation* moveAnim = new QPropertyAnimation(_fw, "pos", this);
moveAnim->setStartValue(_fw->pos());
moveAnim->setEndValue(sw->mapToGlobal(sw->rect().topLeft()));
moveAnim->setDuration(ADS_ANIMATION_DURATION);
QPropertyAnimation* resizeAnim = new QPropertyAnimation(_fw, "size", this);
resizeAnim->setStartValue(_fw->size());
resizeAnim->setEndValue(sw->size());
resizeAnim->setDuration(ADS_ANIMATION_DURATION);
QParallelAnimationGroup* animGroup = new QParallelAnimationGroup(this);
QObject::connect(animGroup, &QPropertyAnimation::finished, [this, data, sw, loc]()
{
InternalContentData data = _fw->takeContent();
_fw->deleteLater();
_fw.clear();
cw->dropContent(data, sw, loc);
});
animGroup->addAnimation(moveAnim);
animGroup->addAnimation(resizeAnim);
animGroup->start(QAbstractAnimation::DeleteWhenStopped);
#endif
}
}
// Mouse is over a outer-edge drop area
@ -137,152 +109,117 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
if (dropArea != ADS_NS::InvalidDropArea)
{
#if !defined(ADS_ANIMATIONS_ENABLED)
InternalContentData data;
_fw->takeContent(data);
_fw->deleteLater();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
_fw.clear();
#else
_fw = 0;
#endif
m_FloatingWidget->takeContent(data);
m_FloatingWidget->deleteLater();
m_FloatingWidget.clear();
cw->dropContent(data, NULL, dropArea, true);
#else
#endif
}
}
}
// End of tab moving, change order now
else if (_tabMoving
else if (m_TabMoving
&& (section = findParentSectionWidget(this)) != NULL)
{
// Find tab under mouse
QPoint pos = ev->globalPos();
pos = section->mapFromGlobal(pos);
const int fromIndex = section->indexOfContent(_content);
const int toIndex = section->indexOfContentByTitlePos(pos, this);
int fromIndex = section->indexOfContent(m_Content);
int toIndex = section->indexOfContentByTitlePos(pos, this);
qInfo() << "fromIndex: " << fromIndex << " toIndex: " << toIndex;
if (-1 == toIndex)
{
toIndex = section->indexOfContent(section->contents().last());
}
section->moveContent(fromIndex, toIndex);
}
if (!_dragStartPos.isNull())
if (!m_DragStartPosition.isNull())
emit clicked();
// Reset
_dragStartPos = QPoint();
_tabMoving = false;
m_DragStartPosition = QPoint();
m_TabMoving = false;
cw->_dropOverlay->hideDropOverlay();
QFrame::mouseReleaseEvent(ev);
}
void SectionTitleWidget::moveFloatingWidget(QMouseEvent* ev, ContainerWidget* cw)
{
const QPoint moveToPos = ev->globalPos() - (m_DragStartPosition + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
m_FloatingWidget->move(moveToPos);
cw->moveFloatingWidget(moveToPos);
}
void SectionTitleWidget::startFloating(QMouseEvent* ev, ContainerWidget* cw, SectionWidget* sectionwidget)
{
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);
}
void SectionTitleWidget::moveTab(QMouseEvent* ev)
{
ev->accept();
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QPoint moveToPos = mapToParent(ev->pos()) - m_DragStartPosition;
moveToPos.setY(0/* + top*/);
move(moveToPos);
}
void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
{
ContainerWidget* cw = findParentContainerWidget(this);
SectionWidget* section = NULL;
if (!(ev->buttons() & Qt::LeftButton))
{
QFrame::mouseMoveEvent(ev);
return;
}
ev->accept();
ContainerWidget* cw = findParentContainerWidget(this);
// Move already existing FloatingWidget
if (_fw && (ev->buttons() & Qt::LeftButton))
if (m_FloatingWidget)
{
ev->accept();
const QPoint moveToPos = ev->globalPos() - (_dragStartPos + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
_fw->move(moveToPos);
// Show drop indicator
if (true)
{
// Mouse is over a SectionWidget
section = cw->sectionAt(cw->mapFromGlobal(QCursor::pos()));
if (section)
{
cw->_dropOverlay->setAllowedAreas(ADS_NS::AllAreas);
cw->_dropOverlay->showDropOverlay(section);
}
// Mouse is at the edge of the ContainerWidget
// Top, Right, Bottom, Left
else if (cw->outerTopDropRect().contains(cw->mapFromGlobal(QCursor::pos())))
{
cw->_dropOverlay->setAllowedAreas(ADS_NS::TopDropArea);
cw->_dropOverlay->showDropOverlay(cw, cw->outerTopDropRect());
}
else if (cw->outerRightDropRect().contains(cw->mapFromGlobal(QCursor::pos())))
{
cw->_dropOverlay->setAllowedAreas(ADS_NS::RightDropArea);
cw->_dropOverlay->showDropOverlay(cw, cw->outerRightDropRect());
}
else if (cw->outerBottomDropRect().contains(cw->mapFromGlobal(QCursor::pos())))
{
cw->_dropOverlay->setAllowedAreas(ADS_NS::BottomDropArea);
cw->_dropOverlay->showDropOverlay(cw, cw->outerBottomDropRect());
}
else if (cw->outerLeftDropRect().contains(cw->mapFromGlobal(QCursor::pos())))
{
cw->_dropOverlay->setAllowedAreas(ADS_NS::LeftDropArea);
cw->_dropOverlay->showDropOverlay(cw, cw->outerLeftDropRect());
}
else
{
cw->_dropOverlay->hideDropOverlay();
}
}
moveFloatingWidget(ev, cw);
return;
}
SectionWidget* sectionwidget = findParentSectionWidget(this);
if (!sectionwidget)
{
QFrame::mouseMoveEvent(ev);
return;
}
// move tab
if (m_TabMoving)
{
moveTab(ev);
}
// leave if dragging is not active
if (m_DragStartPosition.isNull())
{
QFrame::mouseMoveEvent(ev);
return;
}
// Begin to drag/float the SectionContent.
else if (!_fw && !_dragStartPos.isNull() && (ev->buttons() & Qt::LeftButton)
&& (section = findParentSectionWidget(this)) != NULL
&& !section->titleAreaGeometry().contains(section->mapFromGlobal(ev->globalPos())))
if (!sectionwidget->titleAreaGeometry().contains(sectionwidget->mapFromGlobal(ev->globalPos())))
{
ev->accept();
// Create floating widget.
InternalContentData data;
if (!section->takeContent(_content->uid(), data))
{
qWarning() << "THIS SHOULD NOT HAPPEN!!" << _content->uid() << _content->uniqueName();
return;
}
_fw = new FloatingWidget(cw, data.content, data.titleWidget, data.contentWidget, cw);
_fw->resize(section->size());
cw->_floatings.append(_fw); // Note: I don't like this...
const QPoint moveToPos = ev->globalPos() - (_dragStartPos + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
_fw->move(moveToPos);
_fw->show();
// Delete old section, if it is empty now.
if (section->contents().isEmpty())
{
delete section;
section = NULL;
}
deleteEmptySplitter(cw);
return;
}
// Handle movement of this tab
else if (_tabMoving
&& (section = findParentSectionWidget(this)) != NULL)
{
ev->accept();
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QPoint moveToPos = mapToParent(ev->pos()) - _dragStartPos;
moveToPos.setY(0/* + top*/);
move(moveToPos);
startFloating(ev, cw, sectionwidget);
return;
}
// Begin to drag title inside the title area to switch its position inside the SectionWidget.
else if (!_dragStartPos.isNull() && (ev->buttons() & Qt::LeftButton)
&& (ev->pos() - _dragStartPos).manhattanLength() >= QApplication::startDragDistance() // Wait a few pixels before start moving
&& (section = findParentSectionWidget(this)) != NULL
&& section->titleAreaGeometry().contains(section->mapFromGlobal(ev->globalPos())))
else if ((ev->pos() - m_DragStartPosition).manhattanLength() >= QApplication::startDragDistance() // Wait a few pixels before start moving
&& sectionwidget->titleAreaGeometry().contains(sectionwidget->mapFromGlobal(ev->globalPos())))
{
ev->accept();
_tabMoving = true;
m_TabMoving = true;
raise(); // Raise current title-widget above other tabs
return;
}
QFrame::mouseMoveEvent(ev);

View File

@ -13,6 +13,7 @@
#include <QPushButton>
#include <QScrollBar>
#include <QMenu>
#include <QtGlobal>
#if defined(ADS_ANIMATIONS_ENABLED)
#include <QGraphicsDropShadowEffect>
@ -349,7 +350,7 @@ void SectionWidget::setCurrentIndex(int index)
{
stw->setActiveTab(true);
_tabsScrollArea->ensureWidgetVisible(stw);
if (stw->_content->flags().testFlag(SectionContent::Closeable))
if (stw->m_Content->flags().testFlag(SectionContent::Closeable))
_closeButton->setEnabled(true);
else
_closeButton->setEnabled(false);
@ -422,6 +423,11 @@ int SectionWidget::GetNextUid()
return ++NextUid;
}
bool SectionWidget::eventFilter(QObject *watched, QEvent *event)
{
}
/*****************************************************************************/
SectionWidgetTabsScrollArea::SectionWidgetTabsScrollArea(SectionWidget*,
@ -455,4 +461,44 @@ void SectionWidgetTabsScrollArea::wheelEvent(QWheelEvent* e)
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
}
void SectionWidgetTabsScrollArea::mousePressEvent(QMouseEvent* ev)
{
qInfo() << "mousePressEvent " << ev->type();
if (ev->button() == Qt::LeftButton)
{
ev->accept();
_dragStartPos = ev->pos();
return;
}
QScrollArea::mousePressEvent(ev);
}
void SectionWidgetTabsScrollArea::mouseMoveEvent(QMouseEvent* ev)
{
/*if (_fw)
{
return;
}
ContainerWidget* cw = findParentContainerWidget(this);
SectionWidget* sectionWidget = findParentSectionWidget(this);
qInfo() << "mousePressEvent " << ev->type();
ev->accept();
_fw = new FloatingWidget(sectionWidget);
_fw->resize(sectionWidget->size());
cw->_floatings.append(_fw); // Note: I don't like this...
const QPoint moveToPos = ev->globalPos() - (_dragStartPos + QPoint(ADS_WINDOW_FRAME_BORDER_WIDTH, ADS_WINDOW_FRAME_BORDER_WIDTH));
_fw->move(moveToPos);
_fw->show();
//delete sectionWidget;
deleteEmptySplitter(cw);*/
QScrollArea::mouseMoveEvent(ev);
return;
}
ADS_NAMESPACE_END

View File

@ -1,3 +1,5 @@
include($$(cetoni_repository)/build/qt/qtprojectsettings/common.pri)
TARGET = AdvancedDockingSystemDemo
QT += core gui
@ -47,8 +49,8 @@ FORMS += \
#else:unix: PRE_TARGETDEPS += $$OUT_PWD/../AdvancedDockingSystem/libAdvancedDockingSystem.a
# Dependency: AdvancedDockingSystem (shared)
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../AdvancedDockingSystem/release/ -lAdvancedDockingSystem1
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../AdvancedDockingSystem/debug/ -lAdvancedDockingSystem1
win32:CONFIG(release, debug|release): LIBS += -l$$qtLinkLibrary(AdvancedDockingSystem)
else:win32:CONFIG(debug, debug|release): LIBS += -l$$qtLinkLibrary(AdvancedDockingSystem)
else:unix: LIBS += -L$$OUT_PWD/../AdvancedDockingSystem/ -lAdvancedDockingSystem
INCLUDEPATH += $$PWD/../AdvancedDockingSystem/include

View File

@ -104,7 +104,7 @@ MainWindow::MainWindow(QWidget *parent) :
setCentralWidget(_container);
// Optional: Use custom drop area widgets.
if (false)
if (false)
{
QHash<ADS_NS::DropArea, QWidget*> areaWidgets;
areaWidgets.insert(ADS_NS::TopDropArea, new QPushButton("TOP"));
@ -122,18 +122,18 @@ MainWindow::MainWindow(QWidget *parent) :
ADS_NS::ContainerWidget* cw = _container;
ADS_NS::SectionWidget* sw = NULL;
sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea);
sw = _container->addSectionContent(createCalendarSC(cw), sw, ADS_NS::RightDropArea);
sw = _container->addSectionContent(createFileSystemTreeSC(cw), sw, ADS_NS::CenterDropArea);
sw = _container->addSectionContent(createLongTextLabelSC(cw), nullptr, ADS_NS::CenterDropArea);
sw = _container->addSectionContent(createCalendarSC(cw), nullptr, ADS_NS::LeftDropArea);
sw = _container->addSectionContent(createFileSystemTreeSC(cw), nullptr, ADS_NS::BottomDropArea);
_container->addSectionContent(createCalendarSC(_container));
/*_container->addSectionContent(createCalendarSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
ADS_NS::SectionContent::RefPtr sc = createLongTextLabelSC(cw);
sc->setFlags(ADS_NS::SectionContent::AllFlags ^ ADS_NS::SectionContent::Closeable);
_container->addSectionContent(sc);
_container->addSectionContent(sc);*/
}
else if (false)
{
@ -155,7 +155,7 @@ MainWindow::MainWindow(QWidget *parent) :
restoreGeometry(loadDataHelper("MainWindow"));
// ADS - Restore geometries and states of contents.
_container->restoreState(loadDataHelper("ContainerWidget"));
//_container->restoreState(loadDataHelper("ContainerWidget"));
}
MainWindow::~MainWindow()

View File

@ -1,3 +1,5 @@
include($$(cetoni_repository)/build/qt/qtprojectsettings/common.pri)
TARGET = AdvancedDockingSystemUnitTests
QT += core gui testlib
@ -11,4 +13,4 @@ INCLUDEPATH += $$PWD/../AdvancedDockingSystem/include
DEPENDPATH += $$PWD/../AdvancedDockingSystem/include
include(AdvancedDockingSystemUnitTests.pri)
include(../AdvancedDockingSystem/AdvancedDockingSystem.pri)
include(../AdvancedDockingSystem/AdvancedDockingSystem.pri)