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
This commit is contained in:
Luca Beldi 2019-01-16 17:52:53 +00:00
parent ddfa6c2a43
commit b7a5918974
7 changed files with 38 additions and 32 deletions

View File

@ -98,7 +98,7 @@ public:
*/ */
void insertWidget(int index, QWidget* Widget) void insertWidget(int index, QWidget* Widget)
{ {
Widget->setParent(0); Widget->setParent(nullptr);
if (index < 0) if (index < 0)
{ {
index = m_Widgets.count(); index = m_Widgets.count();
@ -127,7 +127,7 @@ public:
auto LayoutItem = m_ParentLayout->takeAt(1); auto LayoutItem = m_ParentLayout->takeAt(1);
if (LayoutItem) if (LayoutItem)
{ {
LayoutItem->widget()->setParent(0); LayoutItem->widget()->setParent(nullptr);
} }
m_CurrentWidget = nullptr; m_CurrentWidget = nullptr;
m_CurrentIndex = -1; m_CurrentIndex = -1;
@ -167,7 +167,7 @@ public:
auto LayoutItem = m_ParentLayout->takeAt(1); auto LayoutItem = m_ParentLayout->takeAt(1);
if (LayoutItem) if (LayoutItem)
{ {
LayoutItem->widget()->setParent(0); LayoutItem->widget()->setParent(nullptr);
} }
m_ParentLayout->addWidget(next); m_ParentLayout->addWidget(next);
@ -315,12 +315,9 @@ void DockAreaWidgetPrivate::createTitleBar()
{ {
TitleBar = new CDockAreaTitleBar(_this); TitleBar = new CDockAreaTitleBar(_this);
Layout->addWidget(TitleBar); Layout->addWidget(TitleBar);
_this->connect(tabBar(), SIGNAL(tabCloseRequested(int)), QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
SLOT(onTabCloseRequested(int))); QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
_this->connect(TitleBar, SIGNAL(tabBarClicked(int)), QObject::connect(tabBar(), &CDockAreaTabBar::tabMoved, _this, &CDockAreaWidget::reorderDockWidget);
SLOT(setCurrentIndex(int)));
_this->connect(tabBar(), SIGNAL(tabMoved(int, int)),
SLOT(reorderDockWidget(int, int)));
} }

View File

@ -47,6 +47,7 @@
#include "ads_globals.h" #include "ads_globals.h"
#include "DockSplitter.h" #include "DockSplitter.h"
#include <functional>
#include <iostream> #include <iostream>
#if QT_VERSION < 0x050900 #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); const int length = separator ? (src.size() * 3 - 1) : (src.size() * 2);
QByteArray hex(length, Qt::Uninitialized); QByteArray hex(length, Qt::Uninitialized);
char *hexData = hex.data(); char *hexData = hex.data();
const uchar *data = (const uchar *)src.data(); const uchar *data = reinterpret_cast<const uchar *>(src.data());
for (int i = 0, o = 0; i < src.size(); ++i) { for (int i = 0, o = 0; i < src.size(); ++i) {
hexData[o++] = toHexLower(data[i] >> 4); hexData[o++] = toHexLower(data[i] >> 4);
hexData[o++] = toHexLower(data[i] & 0xf); hexData[o++] = toHexLower(data[i] & 0xf);
@ -96,8 +97,6 @@ static int areaIdToIndex(DockWidgetArea area)
default: default:
return 4; return 4;
} }
return 4;
} }
/** /**
@ -128,7 +127,7 @@ public:
QGridLayout* Layout = nullptr; QGridLayout* Layout = nullptr;
QSplitter* RootSplitter = nullptr; QSplitter* RootSplitter = nullptr;
bool isFloating = false; bool isFloating = false;
CDockAreaWidget* LastAddedAreaCache[5]{0, 0, 0, 0, 0}; CDockAreaWidget* LastAddedAreaCache[5];
int VisibleDockAreaCount = -1; int VisibleDockAreaCount = -1;
CDockAreaWidget* TopLevelDockArea = nullptr; CDockAreaWidget* TopLevelDockArea = nullptr;
@ -267,7 +266,7 @@ public:
/** /**
* Helper function for creation of new splitter * 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); CDockSplitter* s = new CDockSplitter(orientation, parent);
s->setOpaqueResize(DockManager->configFlags().testFlag(CDockManager::OpaqueSplitterResize)); s->setOpaqueResize(DockManager->configFlags().testFlag(CDockManager::OpaqueSplitterResize));
@ -291,7 +290,7 @@ public:
DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) : DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) :
_this(_public) _this(_public)
{ {
std::fill(std::begin(LastAddedAreaCache),std::end(LastAddedAreaCache), nullptr);
} }
@ -541,7 +540,10 @@ void DockContainerWidgetPrivate::appendDockAreas(const QList<CDockAreaWidget*> N
DockAreas.append(NewDockAreas); DockAreas.append(NewDockAreas);
for (auto DockArea : 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; QSplitter* Splitter = nullptr;
if (!Testing) if (!Testing)
{ {
Splitter = newSplitter((Qt::Orientation)Orientation); Splitter = newSplitter(static_cast<Qt::Orientation>(Orientation));
} }
bool Visible = false; bool Visible = false;
QList<int> Sizes; QList<int> Sizes;
@ -1052,7 +1054,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
// Remove are from parent splitter and recursively hide tree of parent // Remove are from parent splitter and recursively hide tree of parent
// splitters if it has no visible content // splitters if it has no visible content
area->setParent(0); area->setParent(nullptr);
internal::hideEmptyParentSplitters(Splitter); internal::hideEmptyParentSplitters(Splitter);
// If splitter has more than 1 widgets, we are finished and can leave // 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 // We replace the superfluous RootSplitter with the ChildSplitter
ChildSplitter->setParent(0); ChildSplitter->setParent(nullptr);
QLayoutItem* li = d->Layout->replaceWidget(Splitter, ChildSplitter); QLayoutItem* li = d->Layout->replaceWidget(Splitter, ChildSplitter);
d->RootSplitter = ChildSplitter; d->RootSplitter = ChildSplitter;
delete li; delete li;
@ -1124,14 +1126,14 @@ CDockAreaWidget* CDockContainerWidget::dockAreaAt(const QPoint& GlobalPos) const
} }
} }
return 0; return nullptr;
} }
//============================================================================ //============================================================================
CDockAreaWidget* CDockContainerWidget::dockArea(int Index) const 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 } // namespace ads
#include "moc_DockContainerWidget.cpp"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// EOF DockContainerWidget.cpp // EOF DockContainerWidget.cpp

View File

@ -65,8 +65,6 @@ private:
friend class CFloatingDockContainer; friend class CFloatingDockContainer;
friend struct FloatingDockContainerPrivate; friend struct FloatingDockContainerPrivate;
friend class CDockWidget; friend class CDockWidget;
Q_PRIVATE_SLOT(d, void onDockAreaViewToggled(bool Visible))
protected: protected:
/** /**
* Handles activation events to update zOrderIndex * Handles activation events to update zOrderIndex

View File

@ -72,7 +72,7 @@ struct DockManagerPrivate
QMenu* ViewMenu; QMenu* ViewMenu;
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted; CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
bool RestoringState = false; bool RestoringState = false;
CDockManager::ConfigFlags ConfigFlags{CDockManager::DefaultConfig}; CDockManager::ConfigFlags ConfigFlags = CDockManager::DefaultConfig;
/** /**
* Private data constructor * Private data constructor

View File

@ -44,7 +44,7 @@ namespace internal
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To) void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To)
{ {
int index = Splitter->indexOf(From); int index = Splitter->indexOf(From);
From->setParent(0); From->setParent(nullptr);
Splitter->insertWidget(index, To); Splitter->insertWidget(index, To);
} }
@ -90,6 +90,17 @@ void hideEmptyParentSplitters(CDockSplitter* Splitter)
} }
} }
CDockInsertParam::CDockInsertParam(Qt::Orientation orient, bool bottomRight)
: QPair<Qt::Orientation, bool>(orient,bottomRight)
{}
CDockInsertParam::CDockInsertParam(const CDockInsertParam &p)
: QPair<Qt::Orientation, bool>(p)
{}
CDockInsertParam::CDockInsertParam(CDockInsertParam &&p)
: QPair<Qt::Orientation, bool>(std::move(p))
{}
} // namespace internal } // namespace internal
} // namespace ads } // namespace ads

View File

@ -110,7 +110,10 @@ void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter);
class CDockInsertParam : public QPair<Qt::Orientation, bool> class CDockInsertParam : public QPair<Qt::Orientation, bool>
{ {
public: 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;} Qt::Orientation orientation() const {return this->first;}
bool append() const {return this->second;} bool append() const {return this->second;}
int insertOffset() const {return append() ? 1 : 0;} int insertOffset() const {return append() ? 1 : 0;}

View File

@ -2,10 +2,6 @@ ADS_OUT_ROOT = $${OUT_PWD}/..
CONFIG += c++11 CONFIG += c++11
TARGET = $$qtLibraryTarget(qtadvanceddocking) TARGET = $$qtLibraryTarget(qtadvanceddocking)
DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_DEPRECATED_WARNINGS
CONFIG(debug, debug|release) {
mac: TARGET = $$join(TARGET,,,_debug)
win32: TARGET = $$join(TARGET,,,d)
}
TEMPLATE = lib TEMPLATE = lib
DESTDIR = $${ADS_OUT_ROOT}/lib DESTDIR = $${ADS_OUT_ROOT}/lib
QT += core gui widgets QT += core gui widgets
@ -68,4 +64,4 @@ isEmpty(PREFIX){
headers.path=$$PREFIX/include headers.path=$$PREFIX/include
headers.files=$$HEADERS headers.files=$$HEADERS
target.path=$$PREFIX/lib target.path=$$PREFIX/lib
INSTALLS += headers target INSTALLS += headers target