Refactoring of project structure
This commit is contained in:
166
src/DockManager.cpp
Normal file
166
src/DockManager.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
/*******************************************************************************
|
||||
** QtAdcancedDockingSystem
|
||||
** Copyright (C) 2017 Uwe Kindler
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//============================================================================
|
||||
/// \file DockManager.cpp
|
||||
/// \author Uwe Kindler
|
||||
/// \date 26.02.2017
|
||||
/// \brief Implementation of CDockManager class
|
||||
//============================================================================
|
||||
|
||||
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include "DockManager.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QList>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "FloatingDockContainer.h"
|
||||
#include "DockOverlay.h"
|
||||
|
||||
namespace ads
|
||||
{
|
||||
/**
|
||||
* Private data class of CDockManager class (pimpl)
|
||||
*/
|
||||
struct DockManagerPrivate
|
||||
{
|
||||
CDockManager* _this;
|
||||
QList<CFloatingDockContainer*> FloatingWidgets;
|
||||
QList<CDockContainerWidget*> Containers;
|
||||
CDockOverlay* ContainerOverlay;
|
||||
CDockOverlay* DockAreaOverlay;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
*/
|
||||
DockManagerPrivate(CDockManager* _public);
|
||||
};
|
||||
// struct DockManagerPrivate
|
||||
|
||||
//============================================================================
|
||||
DockManagerPrivate::DockManagerPrivate(CDockManager* _public) :
|
||||
_this(_public)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockManager::CDockManager(QWidget *parent) :
|
||||
CDockContainerWidget(this, parent),
|
||||
d(new DockManagerPrivate(this))
|
||||
{
|
||||
QMainWindow* MainWindow = dynamic_cast<QMainWindow*>(parent);
|
||||
if (MainWindow)
|
||||
{
|
||||
MainWindow->setCentralWidget(this);
|
||||
}
|
||||
|
||||
d->DockAreaOverlay = new CDockOverlay(this, CDockOverlay::ModeDockAreaOverlay);
|
||||
d->ContainerOverlay = new CDockOverlay(this, CDockOverlay::ModeContainerOverlay);
|
||||
d->Containers.append(this);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
CDockManager::~CDockManager()
|
||||
{
|
||||
auto FloatingWidgets = d->FloatingWidgets;
|
||||
for (auto FloatingWidget : FloatingWidgets)
|
||||
{
|
||||
delete FloatingWidget;
|
||||
}
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::registerFloatingWidget(CFloatingDockContainer* FloatingWidget)
|
||||
{
|
||||
d->FloatingWidgets.append(FloatingWidget);
|
||||
std::cout << "d->FloatingWidgets.count() " << d->FloatingWidgets.count()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::removeFloatingWidget(CFloatingDockContainer* FloatingWidget)
|
||||
{
|
||||
d->FloatingWidgets.removeAll(FloatingWidget);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::registerDockContainer(CDockContainerWidget* DockContainer)
|
||||
{
|
||||
d->Containers.append(DockContainer);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::removeDockContainer(CDockContainerWidget* DockContainer)
|
||||
{
|
||||
if (this != DockContainer)
|
||||
{
|
||||
d->Containers.removeAll(DockContainer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockOverlay* CDockManager::containerOverlay() const
|
||||
{
|
||||
return d->ContainerOverlay;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockOverlay* CDockManager::dockAreaOverlay() const
|
||||
{
|
||||
return d->DockAreaOverlay;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
const QList<CDockContainerWidget*> CDockManager::dockContainers() const
|
||||
{
|
||||
return d->Containers;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
const QList<CFloatingDockContainer*> CDockManager::floatingWidgets() const
|
||||
{
|
||||
return d->FloatingWidgets;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
unsigned int CDockManager::zOrderIndex() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// EOF DockManager.cpp
|
||||
Reference in New Issue
Block a user