From b7a5918974b1c1e3c6ce82942158e8f923515262 Mon Sep 17 00:00:00 2001 From: Luca Beldi Date: Wed, 16 Jan 2019 17:52:53 +0000 Subject: [PATCH] Fixed project files Fixed compilation on compilers that do not support C++14 Only 2 minor places required C++14, no need to impose it --- src/DockAreaWidget.cpp | 15 ++++++--------- src/DockContainerWidget.cpp | 27 ++++++++++++++------------- src/DockContainerWidget.h | 2 -- src/DockManager.cpp | 2 +- src/ads_globals.cpp | 13 ++++++++++++- src/ads_globals.h | 5 ++++- src/src.pro | 6 +----- 7 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 5e05f36..b1b4218 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -98,7 +98,7 @@ public: */ void insertWidget(int index, QWidget* Widget) { - Widget->setParent(0); + Widget->setParent(nullptr); if (index < 0) { index = m_Widgets.count(); @@ -127,7 +127,7 @@ public: auto LayoutItem = m_ParentLayout->takeAt(1); if (LayoutItem) { - LayoutItem->widget()->setParent(0); + LayoutItem->widget()->setParent(nullptr); } m_CurrentWidget = nullptr; m_CurrentIndex = -1; @@ -167,7 +167,7 @@ public: auto LayoutItem = m_ParentLayout->takeAt(1); if (LayoutItem) { - LayoutItem->widget()->setParent(0); + LayoutItem->widget()->setParent(nullptr); } m_ParentLayout->addWidget(next); @@ -315,12 +315,9 @@ void DockAreaWidgetPrivate::createTitleBar() { TitleBar = new CDockAreaTitleBar(_this); Layout->addWidget(TitleBar); - _this->connect(tabBar(), SIGNAL(tabCloseRequested(int)), - SLOT(onTabCloseRequested(int))); - _this->connect(TitleBar, SIGNAL(tabBarClicked(int)), - SLOT(setCurrentIndex(int))); - _this->connect(tabBar(), SIGNAL(tabMoved(int, int)), - SLOT(reorderDockWidget(int, int))); + QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested); + QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex); + QObject::connect(tabBar(), &CDockAreaTabBar::tabMoved, _this, &CDockAreaWidget::reorderDockWidget); } diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 3c58e87..10d7b80 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -47,6 +47,7 @@ #include "ads_globals.h" #include "DockSplitter.h" +#include #include #if QT_VERSION < 0x050900 @@ -64,7 +65,7 @@ QByteArray qByteArrayToHex(const QByteArray& src, char separator) const int length = separator ? (src.size() * 3 - 1) : (src.size() * 2); QByteArray hex(length, Qt::Uninitialized); char *hexData = hex.data(); - const uchar *data = (const uchar *)src.data(); + const uchar *data = reinterpret_cast(src.data()); for (int i = 0, o = 0; i < src.size(); ++i) { hexData[o++] = toHexLower(data[i] >> 4); hexData[o++] = toHexLower(data[i] & 0xf); @@ -96,8 +97,6 @@ static int areaIdToIndex(DockWidgetArea area) default: return 4; } - - return 4; } /** @@ -128,7 +127,7 @@ public: QGridLayout* Layout = nullptr; QSplitter* RootSplitter = nullptr; bool isFloating = false; - CDockAreaWidget* LastAddedAreaCache[5]{0, 0, 0, 0, 0}; + CDockAreaWidget* LastAddedAreaCache[5]; int VisibleDockAreaCount = -1; CDockAreaWidget* TopLevelDockArea = nullptr; @@ -267,7 +266,7 @@ public: /** * Helper function for creation of new splitter */ - CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = 0) + CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = nullptr) { CDockSplitter* s = new CDockSplitter(orientation, parent); s->setOpaqueResize(DockManager->configFlags().testFlag(CDockManager::OpaqueSplitterResize)); @@ -291,7 +290,7 @@ public: DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) : _this(_public) { - + std::fill(std::begin(LastAddedAreaCache),std::end(LastAddedAreaCache), nullptr); } @@ -541,7 +540,10 @@ void DockContainerWidgetPrivate::appendDockAreas(const QList N DockAreas.append(NewDockAreas); for (auto DockArea : NewDockAreas) { - _this->connect(DockArea, SIGNAL(viewToggled(bool)), SLOT(onDockAreaViewToggled(bool))); + QObject::connect(DockArea, + &CDockAreaWidget::viewToggled, + _this, + std::bind(&DockContainerWidgetPrivate::onDockAreaViewToggled, this, std::placeholders::_1)); } } @@ -611,7 +613,7 @@ bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s, QSplitter* Splitter = nullptr; if (!Testing) { - Splitter = newSplitter((Qt::Orientation)Orientation); + Splitter = newSplitter(static_cast(Orientation)); } bool Visible = false; QList Sizes; @@ -1052,7 +1054,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area) // Remove are from parent splitter and recursively hide tree of parent // splitters if it has no visible content - area->setParent(0); + area->setParent(nullptr); internal::hideEmptyParentSplitters(Splitter); // If splitter has more than 1 widgets, we are finished and can leave @@ -1083,7 +1085,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area) } // We replace the superfluous RootSplitter with the ChildSplitter - ChildSplitter->setParent(0); + ChildSplitter->setParent(nullptr); QLayoutItem* li = d->Layout->replaceWidget(Splitter, ChildSplitter); d->RootSplitter = ChildSplitter; delete li; @@ -1124,14 +1126,14 @@ CDockAreaWidget* CDockContainerWidget::dockAreaAt(const QPoint& GlobalPos) const } } - return 0; + return nullptr; } //============================================================================ CDockAreaWidget* CDockContainerWidget::dockArea(int Index) const { - return (Index < dockAreaCount()) ? d->DockAreas[Index] : 0; + return (Index < dockAreaCount()) ? d->DockAreas[Index] : nullptr; } @@ -1465,6 +1467,5 @@ void CDockContainerWidget::closeOtherAreas(CDockAreaWidget* KeepOpenArea) } // namespace ads -#include "moc_DockContainerWidget.cpp" //--------------------------------------------------------------------------- // EOF DockContainerWidget.cpp diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h index 75bf54d..0483137 100644 --- a/src/DockContainerWidget.h +++ b/src/DockContainerWidget.h @@ -65,8 +65,6 @@ private: friend class CFloatingDockContainer; friend struct FloatingDockContainerPrivate; friend class CDockWidget; - Q_PRIVATE_SLOT(d, void onDockAreaViewToggled(bool Visible)) - protected: /** * Handles activation events to update zOrderIndex diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 35d79c0..638bfc0 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -72,7 +72,7 @@ struct DockManagerPrivate QMenu* ViewMenu; CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted; bool RestoringState = false; - CDockManager::ConfigFlags ConfigFlags{CDockManager::DefaultConfig}; + CDockManager::ConfigFlags ConfigFlags = CDockManager::DefaultConfig; /** * Private data constructor diff --git a/src/ads_globals.cpp b/src/ads_globals.cpp index 877e853..86133b5 100644 --- a/src/ads_globals.cpp +++ b/src/ads_globals.cpp @@ -44,7 +44,7 @@ namespace internal void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To) { int index = Splitter->indexOf(From); - From->setParent(0); + From->setParent(nullptr); Splitter->insertWidget(index, To); } @@ -90,6 +90,17 @@ void hideEmptyParentSplitters(CDockSplitter* Splitter) } } +CDockInsertParam::CDockInsertParam(Qt::Orientation orient, bool bottomRight) + : QPair(orient,bottomRight) +{} + +CDockInsertParam::CDockInsertParam(const CDockInsertParam &p) + : QPair(p) +{} + +CDockInsertParam::CDockInsertParam(CDockInsertParam &&p) + : QPair(std::move(p)) +{} } // namespace internal } // namespace ads diff --git a/src/ads_globals.h b/src/ads_globals.h index aa5c99f..caa76af 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -110,7 +110,10 @@ void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter); class CDockInsertParam : public QPair { public: - using QPair::QPair; + CDockInsertParam() = default; + CDockInsertParam(Qt::Orientation orient, bool append); + CDockInsertParam(const CDockInsertParam &p); + CDockInsertParam(CDockInsertParam &&p); Qt::Orientation orientation() const {return this->first;} bool append() const {return this->second;} int insertOffset() const {return append() ? 1 : 0;} diff --git a/src/src.pro b/src/src.pro index 68320d6..513ef3b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -2,10 +2,6 @@ ADS_OUT_ROOT = $${OUT_PWD}/.. CONFIG += c++11 TARGET = $$qtLibraryTarget(qtadvanceddocking) DEFINES += QT_DEPRECATED_WARNINGS -CONFIG(debug, debug|release) { - mac: TARGET = $$join(TARGET,,,_debug) - win32: TARGET = $$join(TARGET,,,d) -} TEMPLATE = lib DESTDIR = $${ADS_OUT_ROOT}/lib QT += core gui widgets @@ -68,4 +64,4 @@ isEmpty(PREFIX){ headers.path=$$PREFIX/include headers.files=$$HEADERS target.path=$$PREFIX/lib -INSTALLS += headers target \ No newline at end of file +INSTALLS += headers target