From 842cef2675d3fbb408fc5d69e766f8db939f8bd5 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Thu, 23 Feb 2017 22:26:13 +0100 Subject: [PATCH] Remove macro usage for ads namespace --- .../AdvancedDockingSystem.pri | 24 ------- .../AdvancedDockingSystem.pro | 26 +++++++- AdvancedDockingSystem/src/API.cpp | 11 ++-- AdvancedDockingSystem/src/API.h | 25 +------- AdvancedDockingSystem/src/ContainerWidget.cpp | 18 +++--- AdvancedDockingSystem/src/ContainerWidget.h | 12 ++-- AdvancedDockingSystem/src/DropOverlay.cpp | 64 ++++++++----------- AdvancedDockingSystem/src/DropOverlay.h | 7 +- AdvancedDockingSystem/src/FloatingWidget.cpp | 22 +++---- AdvancedDockingSystem/src/FloatingWidget.h | 10 +-- AdvancedDockingSystem/src/Internal.cpp | 7 +- AdvancedDockingSystem/src/Internal.h | 13 ++-- .../src/MainContainerWidget.cpp | 38 +++++------ .../src/MainContainerWidget.h | 21 +++--- AdvancedDockingSystem/src/SectionContent.cpp | 11 ++-- AdvancedDockingSystem/src/SectionContent.h | 10 ++- .../src/SectionContentWidget.cpp | 6 +- .../src/SectionContentWidget.h | 4 +- .../src/SectionTitleWidget.cpp | 19 +++--- .../src/SectionTitleWidget.h | 10 +-- AdvancedDockingSystem/src/SectionWidget.cpp | 29 ++++----- AdvancedDockingSystem/src/SectionWidget.h | 17 ++--- AdvancedDockingSystem/src/Serialization.cpp | 7 +- AdvancedDockingSystem/src/Serialization.h | 7 +- .../AdvancedDockingSystemDemo.pro | 4 +- .../src/dialogs/SectionContentListModel.cpp | 6 +- .../src/dialogs/SectionContentListModel.h | 17 +++-- .../src/dialogs/SectionContentListWidget.h | 8 +-- AdvancedDockingSystemDemo/src/mainwindow.cpp | 56 ++++++++-------- AdvancedDockingSystemDemo/src/mainwindow.h | 17 ++--- 30 files changed, 249 insertions(+), 277 deletions(-) diff --git a/AdvancedDockingSystem/AdvancedDockingSystem.pri b/AdvancedDockingSystem/AdvancedDockingSystem.pri index b6a92ad..99a8091 100644 --- a/AdvancedDockingSystem/AdvancedDockingSystem.pri +++ b/AdvancedDockingSystem/AdvancedDockingSystem.pri @@ -1,26 +1,2 @@ -SOURCES += \ - $$PWD/src/API.cpp \ - $$PWD/src/MainContainerWidget.cpp \ - $$PWD/src/SectionWidget.cpp \ - $$PWD/src/SectionContent.cpp \ - $$PWD/src/SectionTitleWidget.cpp \ - $$PWD/src/SectionContentWidget.cpp \ - $$PWD/src/DropOverlay.cpp \ - $$PWD/src/FloatingWidget.cpp \ - $$PWD/src/Internal.cpp \ - $$PWD/src/Serialization.cpp \ - $$PWD/src/ContainerWidget.cpp -HEADERS += \ - $$PWD/include/ads/API.h \ - $$PWD/include/ads/MainContainerWidget.h \ - $$PWD/include/ads/SectionWidget.h \ - $$PWD/include/ads/SectionContent.h \ - $$PWD/include/ads/SectionTitleWidget.h \ - $$PWD/include/ads/SectionContentWidget.h \ - $$PWD/include/ads/DropOverlay.h \ - $$PWD/include/ads/FloatingWidget.h \ - $$PWD/include/ads/Internal.h \ - $$PWD/include/ads/Serialization.h \ - $$PWD/include/ads/ContainerWidget.h diff --git a/AdvancedDockingSystem/AdvancedDockingSystem.pro b/AdvancedDockingSystem/AdvancedDockingSystem.pro index e817f26..65bc533 100644 --- a/AdvancedDockingSystem/AdvancedDockingSystem.pro +++ b/AdvancedDockingSystem/AdvancedDockingSystem.pro @@ -34,4 +34,28 @@ windows { RESOURCES += \ res/ads.qrc -include(AdvancedDockingSystem.pri) +SOURCES += \ + $$PWD/src/API.cpp \ + $$PWD/src/MainContainerWidget.cpp \ + $$PWD/src/SectionWidget.cpp \ + $$PWD/src/SectionContent.cpp \ + $$PWD/src/SectionTitleWidget.cpp \ + $$PWD/src/SectionContentWidget.cpp \ + $$PWD/src/DropOverlay.cpp \ + $$PWD/src/FloatingWidget.cpp \ + $$PWD/src/Internal.cpp \ + $$PWD/src/Serialization.cpp \ + $$PWD/src/ContainerWidget.cpp + +HEADERS += \ + $$PWD/src/API.h \ + $$PWD/src/MainContainerWidget.h \ + $$PWD/src/SectionWidget.h \ + $$PWD/src/SectionContent.h \ + $$PWD/src/SectionTitleWidget.h \ + $$PWD/src/SectionContentWidget.h \ + $$PWD/src/DropOverlay.h \ + $$PWD/src/FloatingWidget.h \ + $$PWD/src/Internal.h \ + $$PWD/src/Serialization.h \ + $$PWD/src/ContainerWidget.h diff --git a/AdvancedDockingSystem/src/API.cpp b/AdvancedDockingSystem/src/API.cpp index dbf654a..51d6bda 100644 --- a/AdvancedDockingSystem/src/API.cpp +++ b/AdvancedDockingSystem/src/API.cpp @@ -17,17 +17,18 @@ ******************************************************************************/ -#include -#include "ads/API.h" +#include "MainContainerWidget.h" +#include "API.h" #include #include #include #include -#include "ads/SectionWidget.h" +#include "SectionWidget.h" -ADS_NAMESPACE_BEGIN +namespace ads +{ static bool splitterContainsSectionWidget(QSplitter* splitter) { @@ -108,4 +109,4 @@ QSplitter* findImmediateSplitter(QWidget* w) return sp; } -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/API.h b/AdvancedDockingSystem/src/API.h index fa73ad6..2f867f6 100644 --- a/AdvancedDockingSystem/src/API.h +++ b/AdvancedDockingSystem/src/API.h @@ -35,26 +35,6 @@ class QSplitter; #define ADS_EXPORT_API #endif -// Use namespace -// Disabled with Qt4, it makes problems with signals and slots. -#ifdef ADS_NAMESPACE_ENABLED - #define ADS_NAMESPACE_BEGIN namespace ads { - #define ADS_NAMESPACE_END } - #define ADS_NS ::ads -#else - #define ADS_NAMESPACE_BEGIN - #define ADS_NAMESPACE_END - #define ADS_NS -#endif - -// Always enable "serialization" namespace. -// It is not required for signals and slots. -#define ADS_NAMESPACE_SER_BEGIN namespace ads { namespace serialization { -#define ADS_NAMESPACE_SER_END }} -#define ADS_NS_SER ::ads::serialization - -// Width of the native window frame border (based on OS). -#define ADS_WINDOW_FRAME_BORDER_WIDTH 7 // Beautiful C++ stuff. #define ADS_Expects(cond) @@ -64,7 +44,8 @@ class QSplitter; //#define ADS_ANIMATIONS_ENABLED 1 //#define ADS_ANIMATION_DURATION 150 -ADS_NAMESPACE_BEGIN +namespace ads +{ class CMainContainerWidget; class SectionWidget; @@ -86,5 +67,5 @@ void deleteEmptySplitter(CMainContainerWidget* container); QSplitter* findParentSplitter(QWidget* w); QSplitter* findImmediateSplitter(QWidget* w); -ADS_NAMESPACE_END +} // namespace ads #endif diff --git a/AdvancedDockingSystem/src/ContainerWidget.cpp b/AdvancedDockingSystem/src/ContainerWidget.cpp index b6f2f0b..87ecad3 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.cpp +++ b/AdvancedDockingSystem/src/ContainerWidget.cpp @@ -20,9 +20,9 @@ //============================================================================ // INCLUDES //============================================================================ -#include -#include -#include "ads/ContainerWidget.h" +#include "MainContainerWidget.h" +#include "SectionContentWidget.h" +#include "ContainerWidget.h" #include #include @@ -38,11 +38,11 @@ #include -#include "ads/Internal.h" -#include "ads/SectionWidget.h" -#include "ads/SectionTitleWidget.h" -#include "ads/DropOverlay.h" -#include "ads/Serialization.h" +#include "Internal.h" +#include "SectionWidget.h" +#include "SectionTitleWidget.h" +#include "DropOverlay.h" +#include "Serialization.h" namespace ads { @@ -97,7 +97,7 @@ void CContainerWidget::dropFloatingWidget(FloatingWidget* FloatingWidget, if (sectionWidget) { auto dropOverlay = m_MainContainerWidget->sectionDropOverlay(); - dropOverlay->setAllowedAreas(ADS_NS::AllAreas); + dropOverlay->setAllowedAreas(AllAreas); dropArea = dropOverlay->showDropOverlay(sectionWidget); if (dropArea != InvalidDropArea) { diff --git a/AdvancedDockingSystem/src/ContainerWidget.h b/AdvancedDockingSystem/src/ContainerWidget.h index 0399505..e1a5bb3 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.h +++ b/AdvancedDockingSystem/src/ContainerWidget.h @@ -23,12 +23,12 @@ //============================================================================ #include -#include "ads/API.h" -#include "ads/Internal.h" -#include "ads/SectionContent.h" -#include "ads/FloatingWidget.h" -#include "ads/Serialization.h" -#include "ads/DropOverlay.h" +#include "API.h" +#include "Internal.h" +#include "SectionContent.h" +#include "FloatingWidget.h" +#include "Serialization.h" +#include "DropOverlay.h" namespace ads { diff --git a/AdvancedDockingSystem/src/DropOverlay.cpp b/AdvancedDockingSystem/src/DropOverlay.cpp index 8ac8b1a..ea52837 100644 --- a/AdvancedDockingSystem/src/DropOverlay.cpp +++ b/AdvancedDockingSystem/src/DropOverlay.cpp @@ -16,7 +16,7 @@ ** along with this program. If not, see . ******************************************************************************/ -#include "ads/DropOverlay.h" +#include "DropOverlay.h" #include #include @@ -32,7 +32,8 @@ #include -ADS_NAMESPACE_BEGIN +namespace ads +{ // Helper ///////////////////////////////////////////////////////////// @@ -240,23 +241,12 @@ void DropOverlay::paintEvent(QPaintEvent*) std::cout << "CursorLocation: " << dropAreaUnderCursor() << std::endl; switch (da) { - case ADS_NS::TopDropArea: - r.setHeight(r.height() / 2); - break; - case ADS_NS::RightDropArea: - r.setX(r.width() / 2); - break; - case ADS_NS::BottomDropArea: - r.setY(r.height() / 2); - break; - case ADS_NS::LeftDropArea: - r.setWidth(r.width() / 2); - break; - case ADS_NS::CenterDropArea: - r = rect(); - break; - default: - return; + case TopDropArea: r.setHeight(r.height() / 2); break; + case RightDropArea: r.setX(r.width() / 2); break; + case BottomDropArea: r.setY(r.height() / 2); break; + case LeftDropArea: r.setWidth(r.width() / 2); break; + case CenterDropArea: r = rect();break; + default: return; } QPainter painter(this); QColor Color = palette().color(QPalette::Active, QPalette::Highlight); @@ -294,11 +284,11 @@ static int areaAlignment(const DropArea area) { switch (area) { - case ADS_NS::TopDropArea: return (int) Qt::AlignHCenter | Qt::AlignBottom; - case ADS_NS::RightDropArea: return (int) Qt::AlignLeft | Qt::AlignVCenter; - case ADS_NS::BottomDropArea: return (int) Qt::AlignHCenter | Qt::AlignTop; - case ADS_NS::LeftDropArea: return (int) Qt::AlignRight | Qt::AlignVCenter; - case ADS_NS::CenterDropArea: return (int) Qt::AlignCenter; + case TopDropArea: return (int) Qt::AlignHCenter | Qt::AlignBottom; + case RightDropArea: return (int) Qt::AlignLeft | Qt::AlignVCenter; + case BottomDropArea: return (int) Qt::AlignHCenter | Qt::AlignTop; + case LeftDropArea: return (int) Qt::AlignRight | Qt::AlignVCenter; + case CenterDropArea: return (int) Qt::AlignCenter; default: return Qt::AlignCenter; } } @@ -310,11 +300,11 @@ QPoint DropOverlayCross::areaGridPosition(const DropArea area) { switch (area) { - case ADS_NS::TopDropArea: return QPoint(1, 2); - case ADS_NS::RightDropArea: return QPoint(2, 3); - case ADS_NS::BottomDropArea: return QPoint(3, 2); - case ADS_NS::LeftDropArea: return QPoint(2, 1); - case ADS_NS::CenterDropArea: return QPoint(2, 2); + case TopDropArea: return QPoint(1, 2); + case RightDropArea: return QPoint(2, 3); + case BottomDropArea: return QPoint(3, 2); + case LeftDropArea: return QPoint(2, 1); + case CenterDropArea: return QPoint(2, 2); default: return QPoint(); } } @@ -322,11 +312,11 @@ QPoint DropOverlayCross::areaGridPosition(const DropArea area) { switch (area) { - case ADS_NS::TopDropArea: return QPoint(0, 2); - case ADS_NS::RightDropArea: return QPoint(2, 4); - case ADS_NS::BottomDropArea: return QPoint(4, 2); - case ADS_NS::LeftDropArea: return QPoint(2, 0); - case ADS_NS::CenterDropArea: return QPoint(2, 2); + case TopDropArea: return QPoint(0, 2); + case RightDropArea: return QPoint(2, 4); + case BottomDropArea: return QPoint(4, 2); + case LeftDropArea: return QPoint(2, 0); + case CenterDropArea: return QPoint(2, 2); default: return QPoint(); } } @@ -451,8 +441,8 @@ void DropOverlayCross::showEvent(QShowEvent*) void DropOverlayCross::reset() { QList allAreas; - allAreas << ADS_NS::TopDropArea << ADS_NS::RightDropArea - << ADS_NS::BottomDropArea << ADS_NS::LeftDropArea << ADS_NS::CenterDropArea; + allAreas << TopDropArea << RightDropArea + << BottomDropArea << LeftDropArea << CenterDropArea; const DropAreas allowedAreas = m_DropOverlay->allowedAreas(); // Update visibility of area widgets based on allowedAreas. @@ -468,4 +458,4 @@ void DropOverlayCross::reset() } } -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/DropOverlay.h b/AdvancedDockingSystem/src/DropOverlay.h index 02f2e89..9c4cd85 100644 --- a/AdvancedDockingSystem/src/DropOverlay.h +++ b/AdvancedDockingSystem/src/DropOverlay.h @@ -23,9 +23,10 @@ #include class QGridLayout; -#include "ads/API.h" +#include "API.h" -ADS_NAMESPACE_BEGIN +namespace ads +{ class DropOverlayCross; /*! @@ -115,5 +116,5 @@ private: QGridLayout* m_GridLayout; }; -ADS_NAMESPACE_END +} // namespace ads #endif diff --git a/AdvancedDockingSystem/src/FloatingWidget.cpp b/AdvancedDockingSystem/src/FloatingWidget.cpp index a5436ed..6f63229 100644 --- a/AdvancedDockingSystem/src/FloatingWidget.cpp +++ b/AdvancedDockingSystem/src/FloatingWidget.cpp @@ -16,9 +16,7 @@ ** along with this program. If not, see . ******************************************************************************/ -#include -#include -#include "ads/FloatingWidget.h" +#include "FloatingWidget.h" #include #include @@ -28,14 +26,17 @@ #include #include -#include "ads/SectionTitleWidget.h" -#include "ads/Internal.h" -#include "ads/SectionWidget.h" -#include "ads/ContainerWidget.h" +#include "SectionTitleWidget.h" +#include "Internal.h" +#include "SectionWidget.h" +#include "ContainerWidget.h" +#include "MainContainerWidget.h" +#include "SectionContentWidget.h" #include -ADS_NAMESPACE_BEGIN +namespace ads +{ unsigned int FloatingWidget::zOrderCounter = 0; @@ -400,7 +401,7 @@ void FloatingWidget::updateDropOverlays(const QPoint& GlobalPos) SectionWidget* sectionwidget = TopContainer->sectionWidgetAt(GlobalPos); if (sectionwidget) { - SectionDropOverlay->setAllowedAreas(ADS_NS::AllAreas); + SectionDropOverlay->setAllowedAreas(AllAreas); SectionDropOverlay->showDropOverlay(sectionwidget); } else @@ -420,5 +421,4 @@ void FloatingWidget::updateDropOverlays(const QPoint& GlobalPos) } } - -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/FloatingWidget.h b/AdvancedDockingSystem/src/FloatingWidget.h index 20d1718..d49d4f8 100644 --- a/AdvancedDockingSystem/src/FloatingWidget.h +++ b/AdvancedDockingSystem/src/FloatingWidget.h @@ -21,10 +21,12 @@ #include class QBoxLayout; -#include "ads/API.h" -#include "ads/SectionContent.h" +#include "API.h" +#include "SectionContent.h" + +namespace ads +{ -ADS_NAMESPACE_BEGIN class CMainContainerWidget; class SectionTitleWidget; class CSectionContentWidget; @@ -110,5 +112,5 @@ private: static unsigned int zOrderCounter; }; -ADS_NAMESPACE_END +} // namespace ads #endif diff --git a/AdvancedDockingSystem/src/Internal.cpp b/AdvancedDockingSystem/src/Internal.cpp index add7fa1..a9c42d1 100644 --- a/AdvancedDockingSystem/src/Internal.cpp +++ b/AdvancedDockingSystem/src/Internal.cpp @@ -16,9 +16,10 @@ ** along with this program. If not, see . ******************************************************************************/ -#include "ads/Internal.h" +#include "Internal.h" -ADS_NAMESPACE_BEGIN +namespace ads +{ InternalContentData::InternalContentData() : titleWidget(NULL), @@ -30,4 +31,4 @@ InternalContentData::~InternalContentData() { } -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/Internal.h b/AdvancedDockingSystem/src/Internal.h index 5a19726..fd6ef55 100644 --- a/AdvancedDockingSystem/src/Internal.h +++ b/AdvancedDockingSystem/src/Internal.h @@ -20,15 +20,10 @@ #include #include -#include "ads/API.h" +#include "API.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -#else -#include "ads/SectionContent.h" -#endif - - -ADS_NAMESPACE_BEGIN +namespace ads +{ class SectionContent; class SectionTitleWidget; class CSectionContentWidget; @@ -63,5 +58,5 @@ public: }; -ADS_NAMESPACE_END +} // namespace ads #endif diff --git a/AdvancedDockingSystem/src/MainContainerWidget.cpp b/AdvancedDockingSystem/src/MainContainerWidget.cpp index 1941054..067c52b 100644 --- a/AdvancedDockingSystem/src/MainContainerWidget.cpp +++ b/AdvancedDockingSystem/src/MainContainerWidget.cpp @@ -16,7 +16,8 @@ ** along with this program. If not, see . ******************************************************************************/ -#include +#include "SectionContentWidget.h" + #include #include #include @@ -29,16 +30,17 @@ #include #include -#include "ads/Internal.h" -#include "ads/SectionWidget.h" -#include "ads/SectionTitleWidget.h" -#include "ads/DropOverlay.h" -#include "ads/Serialization.h" +#include "Internal.h" +#include "SectionWidget.h" +#include "SectionTitleWidget.h" +#include "DropOverlay.h" +#include "Serialization.h" #include -#include "../include/ads/MainContainerWidget.h" +#include "MainContainerWidget.h" -ADS_NAMESPACE_BEGIN +namespace ads +{ QSplitter* CMainContainerWidget::newSplitter(Qt::Orientation orientation, QWidget* parent) @@ -369,17 +371,17 @@ QMenu* CMainContainerWidget::createContextMenu() const QByteArray CMainContainerWidget::saveState() const { - ADS_NS_SER::InMemoryWriter writer; + InMemoryWriter writer; // Hierarchy data. const QByteArray hierarchyData = saveHierarchy(); if (!hierarchyData.isEmpty()) { - writer.write(ADS_NS_SER::ET_Hierarchy, hierarchyData); + writer.write(ET_Hierarchy, hierarchyData); } // SectionIndex data. - ADS_NS_SER::SectionIndexData sid; + SectionIndexData sid; if (saveSectionIndex(sid)) { writer.write(sid); @@ -395,13 +397,13 @@ bool CMainContainerWidget::restoreState(const QByteArray& data) if (data.isEmpty()) return false; - ADS_NS_SER::InMemoryReader reader(data); + InMemoryReader reader(data); if (!reader.initReadHeader()) return false; // Basic hierarchy data. QByteArray hierarchyData; - if (reader.read(ADS_NS_SER::ET_Hierarchy, hierarchyData)) + if (reader.read(ET_Hierarchy, hierarchyData)) { restoreHierarchy(hierarchyData); } @@ -599,7 +601,7 @@ void CMainContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) } } -bool CMainContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) const +bool CMainContainerWidget::saveSectionIndex(SectionIndexData& sid) const { if (m_Sections.count() <= 0) return false; @@ -607,7 +609,7 @@ bool CMainContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) c sid.sectionsCount = m_Sections.count(); for (int i = 0; i < sid.sectionsCount; ++i) { - ADS_NS_SER::SectionEntity se; + SectionEntity se; se.x = mapFromGlobal(m_Sections[i]->parentWidget()->mapToGlobal(m_Sections[i]->pos())).x(); se.y = mapFromGlobal(m_Sections[i]->parentWidget()->mapToGlobal(m_Sections[i]->pos())).y(); se.width = m_Sections[i]->geometry().width(); @@ -616,7 +618,7 @@ bool CMainContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) c se.sectionContentsCount = m_Sections[i]->contents().count(); foreach (const SectionContent::RefPtr& sc, m_Sections[i]->contents()) { - ADS_NS_SER::SectionContentEntity sce; + SectionContentEntity sce; sce.uniqueName = sc->uniqueName(); sce.visible = true; sce.preferredIndex = m_Sections[i]->indexOfContent(sc); @@ -1014,7 +1016,7 @@ void CMainContainerWidget::moveFloatingWidget(const QPoint& TargetPos) if (sectionwidget) { //qInfo() << "over sectionWidget"; - m_SectionDropOverlay->setAllowedAreas(ADS_NS::AllAreas); + m_SectionDropOverlay->setAllowedAreas(AllAreas); m_SectionDropOverlay->showDropOverlay(sectionwidget); } else @@ -1024,4 +1026,4 @@ void CMainContainerWidget::moveFloatingWidget(const QPoint& TargetPos) } -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/MainContainerWidget.h b/AdvancedDockingSystem/src/MainContainerWidget.h index ed18e6d..de38284 100644 --- a/AdvancedDockingSystem/src/MainContainerWidget.h +++ b/AdvancedDockingSystem/src/MainContainerWidget.h @@ -27,15 +27,16 @@ class QPoint; class QMenu; -#include "ads/API.h" -#include "ads/Internal.h" -#include "ads/SectionContent.h" -#include "ads/FloatingWidget.h" -#include "ads/Serialization.h" -#include "ads/DropOverlay.h" -#include "ads/ContainerWidget.h" +#include "API.h" +#include "Internal.h" +#include "SectionContent.h" +#include "FloatingWidget.h" +#include "Serialization.h" +#include "DropOverlay.h" +#include "ContainerWidget.h" -ADS_NAMESPACE_BEGIN +namespace ads +{ class SectionWidget; class DropOverlay; class InternalContentData; @@ -143,7 +144,7 @@ private: void saveFloatingWidgets(QDataStream& out) const; void saveSectionWidgets(QDataStream& out, QWidget* widget) const; - bool saveSectionIndex(ADS_NS_SER::SectionIndexData &sid) const; + bool saveSectionIndex(SectionIndexData &sid) const; bool restoreHierarchy(const QByteArray& data); bool restoreFloatingWidgets(QDataStream& in, int version, QList& floatings); @@ -184,5 +185,5 @@ private: }; -ADS_NAMESPACE_END +} // namespace ads #endif diff --git a/AdvancedDockingSystem/src/SectionContent.cpp b/AdvancedDockingSystem/src/SectionContent.cpp index a42b211..eaa2518 100644 --- a/AdvancedDockingSystem/src/SectionContent.cpp +++ b/AdvancedDockingSystem/src/SectionContent.cpp @@ -16,15 +16,16 @@ ** along with this program. If not, see . ******************************************************************************/ -#include -#include "ads/SectionContent.h" +#include "MainContainerWidget.h" +#include "SectionContent.h" #include #include -#include "ads/Internal.h" +#include "Internal.h" -ADS_NAMESPACE_BEGIN +namespace ads +{ SectionContent::SectionContent() : _uid(GetNextUid()), @@ -136,4 +137,4 @@ int SectionContent::GetNextUid() return ++NextUid; } -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/SectionContent.h b/AdvancedDockingSystem/src/SectionContent.h index b7fdf60..90ff68c 100644 --- a/AdvancedDockingSystem/src/SectionContent.h +++ b/AdvancedDockingSystem/src/SectionContent.h @@ -20,11 +20,15 @@ #include #include #include + + class QWidget; -#include "ads/API.h" +#include "API.h" + +namespace ads +{ -ADS_NAMESPACE_BEGIN class CMainContainerWidget; class ADS_EXPORT_API SectionContent @@ -91,5 +95,5 @@ private: static int GetNextUid(); }; -ADS_NAMESPACE_END +} // namespace ads #endif diff --git a/AdvancedDockingSystem/src/SectionContentWidget.cpp b/AdvancedDockingSystem/src/SectionContentWidget.cpp index 6a411ad..b374982 100644 --- a/AdvancedDockingSystem/src/SectionContentWidget.cpp +++ b/AdvancedDockingSystem/src/SectionContentWidget.cpp @@ -16,10 +16,10 @@ ** along with this program. If not, see . ******************************************************************************/ -#include +#include "MainContainerWidget.h" #include -#include "../include/ads/SectionContentWidget.h" -#include "../include/ads/SectionTitleWidget.h" +#include "SectionContentWidget.h" +#include "SectionTitleWidget.h" namespace ads { diff --git a/AdvancedDockingSystem/src/SectionContentWidget.h b/AdvancedDockingSystem/src/SectionContentWidget.h index 0c859ab..4796b1a 100644 --- a/AdvancedDockingSystem/src/SectionContentWidget.h +++ b/AdvancedDockingSystem/src/SectionContentWidget.h @@ -19,8 +19,8 @@ ******************************************************************************/ #include -#include "ads/API.h" -#include "ads/SectionContent.h" +#include "API.h" +#include "SectionContent.h" namespace ads { diff --git a/AdvancedDockingSystem/src/SectionTitleWidget.cpp b/AdvancedDockingSystem/src/SectionTitleWidget.cpp index 0479241..3a9eb64 100644 --- a/AdvancedDockingSystem/src/SectionTitleWidget.cpp +++ b/AdvancedDockingSystem/src/SectionTitleWidget.cpp @@ -16,8 +16,8 @@ ** along with this program. If not, see . ******************************************************************************/ -#include -#include "ads/SectionTitleWidget.h" +#include "MainContainerWidget.h" +#include "SectionTitleWidget.h" #include #include @@ -32,14 +32,15 @@ #include -#include "ads/Internal.h" -#include "ads/DropOverlay.h" -#include "ads/SectionContent.h" -#include "ads/SectionWidget.h" -#include "ads/FloatingWidget.h" +#include "Internal.h" +#include "DropOverlay.h" +#include "SectionContent.h" +#include "SectionWidget.h" +#include "FloatingWidget.h" #include -ADS_NAMESPACE_BEGIN +namespace ads +{ SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent) : QFrame(parent), @@ -286,4 +287,4 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev) QFrame::mouseMoveEvent(ev); } -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/SectionTitleWidget.h b/AdvancedDockingSystem/src/SectionTitleWidget.h index 780bfe1..870bb96 100644 --- a/AdvancedDockingSystem/src/SectionTitleWidget.h +++ b/AdvancedDockingSystem/src/SectionTitleWidget.h @@ -21,12 +21,14 @@ #include #include -#include "ads/API.h" -#include "ads/SectionContent.h" +#include "API.h" +#include "SectionContent.h" class QPushButton; -ADS_NAMESPACE_BEGIN +namespace ads +{ + class CMainContainerWidget; class SectionWidget; class FloatingWidget; @@ -74,5 +76,5 @@ signals: void clicked(); }; -ADS_NAMESPACE_END +} // namepsace ads #endif diff --git a/AdvancedDockingSystem/src/SectionWidget.cpp b/AdvancedDockingSystem/src/SectionWidget.cpp index b000bd8..d829438 100644 --- a/AdvancedDockingSystem/src/SectionWidget.cpp +++ b/AdvancedDockingSystem/src/SectionWidget.cpp @@ -16,7 +16,7 @@ ** along with this program. If not, see . ******************************************************************************/ -#include "ads/SectionWidget.h" +#include "SectionWidget.h" #include #include @@ -36,19 +36,16 @@ #include -#if defined(ADS_ANIMATIONS_ENABLED) -#include -#endif +#include "Internal.h" +#include "DropOverlay.h" +#include "SectionContent.h" +#include "SectionTitleWidget.h" +#include "SectionContentWidget.h" +#include "FloatingWidget.h" +#include "MainContainerWidget.h" -#include "ads/Internal.h" -#include "ads/DropOverlay.h" -#include "ads/SectionContent.h" -#include "ads/SectionTitleWidget.h" -#include -#include "ads/FloatingWidget.h" -#include - -ADS_NAMESPACE_BEGIN +namespace ads +{ SectionWidget::SectionWidget(CMainContainerWidget* MainContainer, CContainerWidget* parent) : QFrame(parent), @@ -425,10 +422,6 @@ int SectionWidget::GetNextUid() return ++NextUid; } -bool SectionWidget::eventFilter(QObject *watched, QEvent *event) -{ - -} /*****************************************************************************/ @@ -499,4 +492,4 @@ void SectionWidgetTabsScrollArea::mouseMoveEvent(QMouseEvent* ev) return; } -ADS_NAMESPACE_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/SectionWidget.h b/AdvancedDockingSystem/src/SectionWidget.h index b1ade76..e4ce51f 100644 --- a/AdvancedDockingSystem/src/SectionWidget.h +++ b/AdvancedDockingSystem/src/SectionWidget.h @@ -22,17 +22,20 @@ #include #include #include + class QBoxLayout; class QStackedLayout; class QPushButton; class QMenu; -#include "ads/API.h" -#include "ads/Internal.h" -#include "ads/SectionContent.h" -#include "ads/FloatingWidget.h" +#include "API.h" +#include "Internal.h" +#include "SectionContent.h" +#include "FloatingWidget.h" + +namespace ads +{ -ADS_NAMESPACE_BEGIN class CMainContainerWidget; class SectionTitleWidget; class CSectionContentWidget; @@ -69,8 +72,6 @@ public: int currentIndex() const; void moveContent(int from, int to); - virtual bool eventFilter(QObject *watched, QEvent *event); - inline int contentCount() const {return m_ContentWidgets.size();} protected: @@ -125,5 +126,5 @@ protected: virtual void mouseMoveEvent(QMouseEvent* ev); }; -ADS_NAMESPACE_END +} // namespace ads #endif diff --git a/AdvancedDockingSystem/src/Serialization.cpp b/AdvancedDockingSystem/src/Serialization.cpp index 3ed747e..6d300e4 100644 --- a/AdvancedDockingSystem/src/Serialization.cpp +++ b/AdvancedDockingSystem/src/Serialization.cpp @@ -16,11 +16,12 @@ ** along with this program. If not, see . ******************************************************************************/ -#include "ads/Serialization.h" +#include "Serialization.h" #include -ADS_NAMESPACE_SER_BEGIN +namespace ads +{ /* \namespace ads::serialization @@ -455,4 +456,4 @@ bool InMemoryReader::read(SectionIndexData& sid) /////////////////////////////////////////////////////////////////////////////// -ADS_NAMESPACE_SER_END +} // namespace ads diff --git a/AdvancedDockingSystem/src/Serialization.h b/AdvancedDockingSystem/src/Serialization.h index 172f022..62b776c 100644 --- a/AdvancedDockingSystem/src/Serialization.h +++ b/AdvancedDockingSystem/src/Serialization.h @@ -23,9 +23,10 @@ #include #include -#include "ads/API.h" +#include "API.h" -ADS_NAMESPACE_SER_BEGIN +namespace ads +{ enum EntryType { @@ -177,5 +178,5 @@ private: OffsetsHeaderEntity _offsetsHeader; }; -ADS_NAMESPACE_SER_END +} // namespace ads #endif diff --git a/AdvancedDockingSystemDemo/AdvancedDockingSystemDemo.pro b/AdvancedDockingSystemDemo/AdvancedDockingSystemDemo.pro index f60366d..90c532b 100644 --- a/AdvancedDockingSystemDemo/AdvancedDockingSystemDemo.pro +++ b/AdvancedDockingSystemDemo/AdvancedDockingSystemDemo.pro @@ -53,5 +53,5 @@ win32:CONFIG(release, debug|release): LIBS += -l$$qtLinkLibrary(AdvancedDockingS else:win32:CONFIG(debug, debug|release): LIBS += -l$$qtLinkLibrary(AdvancedDockingSystem) else:unix: LIBS += -L$$OUT_PWD/../AdvancedDockingSystem/ -lAdvancedDockingSystem -INCLUDEPATH += $$PWD/../AdvancedDockingSystem/include -DEPENDPATH += $$PWD/../AdvancedDockingSystem/include +INCLUDEPATH += $$PWD/../AdvancedDockingSystem/src +DEPENDPATH += $$PWD/../AdvancedDockingSystem/src diff --git a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp index b0b6a48..ccfff64 100644 --- a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp +++ b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.cpp @@ -13,7 +13,7 @@ SectionContentListModel::~SectionContentListModel() { } -void SectionContentListModel::init(ADS_NS::CMainContainerWidget* cw) +void SectionContentListModel::init(ads::CMainContainerWidget* cw) { beginResetModel(); _cw = cw; @@ -45,7 +45,7 @@ QVariant SectionContentListModel::data(const QModelIndex& index, int role) const if (!index.isValid() || index.row() > rowCount(index) - 1) return QVariant(); - const ADS_NS::SectionContent::RefPtr sc = _contents.at(index.row()); + const ads::SectionContent::RefPtr sc = _contents.at(index.row()); if (sc.isNull()) return QVariant(); @@ -80,7 +80,7 @@ bool SectionContentListModel::removeRows(int row, int count, const QModelIndex& for (int i = last; i >= first; --i) { - const ADS_NS::SectionContent::RefPtr sc = _contents.at(i); + const ads::SectionContent::RefPtr sc = _contents.at(i); _cw->removeSectionContent(sc); _contents.removeAt(i); } diff --git a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h index 79502e3..0f8f936 100644 --- a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h +++ b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h @@ -5,12 +5,11 @@ #include #include #include -#include "../../../AdvancedDockingSystem/include/ads/MainContainerWidget.h" -#include "ads/API.h" -#include "ads/SectionContent.h" -ADS_NAMESPACE_BEGIN -class CMainContainerWidget; -ADS_NAMESPACE_END +#include "MainContainerWidget.h" +#include "API.h" +#include "SectionContent.h" +namespace ads {class CMainContainerWidget;} + class SectionContentListModel : public QAbstractTableModel { @@ -27,7 +26,7 @@ public: SectionContentListModel(QObject* parent); virtual ~SectionContentListModel(); - void init(ADS_NS::CMainContainerWidget* cw); + void init(ads::CMainContainerWidget* cw); virtual int columnCount(const QModelIndex &parent) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; @@ -40,8 +39,8 @@ public: private: QHash _headers; - ADS_NS::CMainContainerWidget* _cw; - QList _contents; + ads::CMainContainerWidget* _cw; + QList _contents; }; #endif diff --git a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h index eaf4866..6dafb12 100644 --- a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h +++ b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h @@ -2,11 +2,11 @@ #define SECTIONCONTENTLISTWIDGET #include -#include "../../../AdvancedDockingSystem/include/ads/MainContainerWidget.h" +#include "MainContainerWidget.h" #include "ui_SectionContentListWidget.h" -#include "ads/API.h" -#include "ads/SectionContent.h" +#include "API.h" +#include "SectionContent.h" class SectionContentListWidget : public QDialog { @@ -16,7 +16,7 @@ public: class Values { public: - ADS_NS::CMainContainerWidget* cw; + ads::CMainContainerWidget* cw; }; SectionContentListWidget(QWidget* parent); diff --git a/AdvancedDockingSystemDemo/src/mainwindow.cpp b/AdvancedDockingSystemDemo/src/mainwindow.cpp index 4f6aa8e..109c088 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.cpp +++ b/AdvancedDockingSystemDemo/src/mainwindow.cpp @@ -10,8 +10,8 @@ #include #include -#include "ads/SectionWidget.h" -#include "ads/DropOverlay.h" +#include "SectionWidget.h" +#include "DropOverlay.h" #include "dialogs/SectionContentListWidget.h" @@ -21,7 +21,7 @@ static int CONTENT_COUNT = 0; -static ADS_NS::SectionContent::RefPtr createLongTextLabelSC(ADS_NS::CMainContainerWidget* container) +static ads::SectionContent::RefPtr createLongTextLabelSC(ads::CMainContainerWidget* container) { QWidget* w = new QWidget(); QBoxLayout* bl = new QBoxLayout(QBoxLayout::TopToBottom); @@ -34,20 +34,20 @@ static ADS_NS::SectionContent::RefPtr createLongTextLabelSC(ADS_NS::CMainContain bl->addWidget(l); const int index = ++CONTENT_COUNT; - ADS_NS::SectionContent::RefPtr sc = ADS_NS::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Label %1").arg(index)), w); + ads::SectionContent::RefPtr sc = ads::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Label %1").arg(index)), w); sc->setTitle("Ein Label " + QString::number(index)); return sc; } -static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::CMainContainerWidget* container) +static ads::SectionContent::RefPtr createCalendarSC(ads::CMainContainerWidget* container) { QCalendarWidget* w = new QCalendarWidget(); const int index = ++CONTENT_COUNT; - return ADS_NS::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Calendar %1").arg(index)), w); + return ads::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::CMainContainerWidget* container) +static ads::SectionContent::RefPtr createFileSystemTreeSC(ads::CMainContainerWidget* container) { QTreeView* w = new QTreeView(); w->setFrameShape(QFrame::NoFrame); @@ -56,7 +56,7 @@ static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::CMainContai // w->setModel(m); const int index = ++CONTENT_COUNT; - return ADS_NS::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Filesystem %1").arg(index)), w); + return ads::SectionContent::newSectionContent(QString("uname-%1").arg(index), container, new IconTitleWidget(QIcon(), QString("Filesystem %1").arg(index)), w); } static void storeDataHelper(const QString& fname, const QByteArray& ba) @@ -93,7 +93,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionContentList, SIGNAL(triggered()), this, SLOT(showSectionContentListDialog())); // ADS - Create main container (ContainerWidget). - _container = new ADS_NS::CMainContainerWidget(); + _container = new ads::CMainContainerWidget(); 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))); setCentralWidget(_container); @@ -117,35 +117,35 @@ void MainWindow::createContent() { // ADS - Adding some contents. // Test #1: Use high-level public API - ADS_NS::CMainContainerWidget* cw = _container; - ADS_NS::SectionWidget* sw = nullptr; + ads::CMainContainerWidget* cw = _container; + ads::SectionWidget* sw = nullptr; - 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); - sw = _container->addSectionContent(createCalendarSC(cw), nullptr, ADS_NS::BottomDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), nullptr, ads::CenterDropArea); + sw = _container->addSectionContent(createCalendarSC(cw), nullptr, ads::LeftDropArea); + sw = _container->addSectionContent(createFileSystemTreeSC(cw), nullptr, ads::BottomDropArea); + sw = _container->addSectionContent(createCalendarSC(cw), nullptr, ads::BottomDropArea); /*_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); + ads::SectionContent::RefPtr sc = createLongTextLabelSC(cw); + sc->setFlags(ads::SectionContent::AllFlags ^ ads::SectionContent::Closeable); _container->addSectionContent(sc);*/ #if 0 // Issue #2: If the first drop is not into CenterDropArea, the application crashes. - ADS_NS::CMainContainerWidget* cw = _container; - ADS_NS::SectionWidget* sw = NULL; + ads::CMainContainerWidget* cw = _container; + ads::SectionWidget* sw = NULL; - sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::LeftDropArea); - sw = _container->addSectionContent(createCalendarSC(cw), sw, ADS_NS::LeftDropArea); - sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea); - sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea); - sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::CenterDropArea); - sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::RightDropArea); - sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ADS_NS::BottomDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ads::LeftDropArea); + sw = _container->addSectionContent(createCalendarSC(cw), sw, ads::LeftDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ads::CenterDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ads::CenterDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ads::CenterDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ads::RightDropArea); + sw = _container->addSectionContent(createLongTextLabelSC(cw), sw, ads::BottomDropArea); #endif } @@ -159,7 +159,7 @@ void MainWindow::showSectionContentListDialog() w.exec(); } -void MainWindow::onActiveTabChanged(const ADS_NS::SectionContent::RefPtr& sc, bool active) +void MainWindow::onActiveTabChanged(const ads::SectionContent::RefPtr& sc, bool active) { Q_UNUSED(active); IconTitleWidget* itw = dynamic_cast(sc->titleWidgetContent()); @@ -169,7 +169,7 @@ void MainWindow::onActiveTabChanged(const ADS_NS::SectionContent::RefPtr& sc, bo } } -void MainWindow::onSectionContentVisibilityChanged(const ADS_NS::SectionContent::RefPtr& sc, bool visible) +void MainWindow::onSectionContentVisibilityChanged(const ads::SectionContent::RefPtr& sc, bool visible) { qDebug() << Q_FUNC_INFO << sc->uniqueName() << visible; } diff --git a/AdvancedDockingSystemDemo/src/mainwindow.h b/AdvancedDockingSystemDemo/src/mainwindow.h index 4eeb4fa..2a071b1 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.h +++ b/AdvancedDockingSystemDemo/src/mainwindow.h @@ -2,9 +2,9 @@ #define MAINWINDOW_H #include -#include "../../AdvancedDockingSystem/include/ads/MainContainerWidget.h" -#include "ads/API.h" -#include "ads/SectionContent.h" +#include "../../AdvancedDockingSystem/src/MainContainerWidget.h" +#include "API.h" +#include "SectionContent.h" namespace Ui { class MainWindow; @@ -22,13 +22,8 @@ public slots: void showSectionContentListDialog(); private slots: -#if QT_VERSION >= 0x050000 - void onActiveTabChanged(const ADS_NS::SectionContent::RefPtr& sc, bool active); - void onSectionContentVisibilityChanged(const ADS_NS::SectionContent::RefPtr& sc, bool visible); -#else - void onActiveTabChanged(const SectionContent::RefPtr& sc, bool active); - void onSectionContentVisibilityChanged(const SectionContent::RefPtr& sc, bool visible); -#endif + void onActiveTabChanged(const ads::SectionContent::RefPtr& sc, bool active); + void onSectionContentVisibilityChanged(const ads::SectionContent::RefPtr& sc, bool visible); void onActionAddSectionContentTriggered(); protected: @@ -37,7 +32,7 @@ protected: private: Ui::MainWindow *ui; - ADS_NS::CMainContainerWidget* _container; + ads::CMainContainerWidget* _container; void createContent(); };