Started implementing clean improved docking system

This commit is contained in:
Uwe Kindler 2017-02-24 22:44:02 +01:00
parent 842cef2675
commit 94a6f5e2f1
18 changed files with 586 additions and 3 deletions

View File

@ -1,4 +1,5 @@
include($$(cetoni_repository)/build/qt/qtprojectsettings/shared_library.pri)
include(src/v2/v2.pri)
TARGET = $$qtLibraryTarget(AdvancedDockingSystem)
TEMPLATE = lib

View File

@ -0,0 +1,72 @@
//============================================================================
/// \file DockAreaWidget.cpp
/// \author Uwe Kindler
/// \date 24.02.2017
/// \brief Implementation of CDockAreaWidget class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockAreaWidget.h"
#include "DockContainerWidget.h"
namespace ads
{
/**
* Private data class of CDockAreaWidget class (pimpl)
*/
struct DockAreaWidgetPrivate
{
CDockAreaWidget* _this;
/**
* Private data constructor
*/
DockAreaWidgetPrivate(CDockAreaWidget* _public);
};
// struct DockAreaWidgetPrivate
//============================================================================
DockAreaWidgetPrivate::DockAreaWidgetPrivate(CDockAreaWidget* _public) :
_this(_public)
{
}
//============================================================================
CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent) :
QFrame(parent),
d(new DockAreaWidgetPrivate(this))
{
}
//============================================================================
CDockAreaWidget::~CDockAreaWidget()
{
delete d;
}
//============================================================================
CDockContainerWidget* CDockAreaWidget::dockContainerWidget() const
{
QWidget* Parent = parentWidget();
while (Parent)
{
CDockContainerWidget* Container = dynamic_cast<CDockContainerWidget*>(Parent);
if (Container)
{
return Container;
}
Parent = Parent->parentWidget();
}
return 0;
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockAreaWidget.cpp

View File

@ -0,0 +1,53 @@
#ifndef DockAreaWidgetH
#define DockAreaWidgetH
//============================================================================
/// \file DockAreaWidget.h
/// \author Uwe Kindler
/// \date 24.02.2017
/// \brief Declaration of CDockAreaWidget class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QFrame>
namespace ads
{
struct DockAreaWidgetPrivate;
class CDockManager;
class CDockContainerWidget;
/**
* DockAreaWidget manages multiple instances of DckWidgets.
* It displays a title tab, which is clickable and will switch to
* the contents associated to the title when clicked.
*/
class CDockAreaWidget : public QFrame
{
Q_OBJECT
private:
DockAreaWidgetPrivate* d; ///< private data (pimpl)
friend class DockAreaWidgetPrivate;
protected:
public:
/**
* Default Constructor
*/
CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent);
/**
* Virtual Destructor
*/
virtual ~CDockAreaWidget();
/**
* Returns the dock container widget this dock area widget belongs to or 0
* if there is no
*/
CDockContainerWidget* dockContainerWidget() const;
}; // class DockAreaWidget
}
// namespace ads
//-----------------------------------------------------------------------------
#endif // DockAreaWidgetH

View File

@ -0,0 +1,122 @@
//============================================================================
/// \file DockContainerWidget.cpp
/// \author Uwe Kindler
/// \date 24.02.2017
/// \brief Implementation of CDockContainerWidget class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockContainerWidget.h"
#include <QEvent>
#include <QList>
#include <QGridLayout>
#include "DockManager.h"
#include "DockAreaWidget.h"
namespace ads
{
static unsigned int zOrderCounter = 0;
/**
* Private data class of CDockContainerWidget class (pimpl)
*/
struct DockContainerWidgetPrivate
{
CDockContainerWidget* _this;
CDockManager* DockManager = nullptr;
unsigned int zOrderIndex = 0;
QList<CDockAreaWidget*> DockAreas;
QGridLayout* Layout = nullptr;
/**
* Private data constructor
*/
DockContainerWidgetPrivate(CDockContainerWidget* _public);
/**
* Create a new dock area widget and adds it to the list of doc areas
*/
CDockAreaWidget* newDockAreaWidget()
{
auto DockAreaWidget = new CDockAreaWidget(DockManager, _this);
DockAreas.append(DockAreaWidget);
return DockAreaWidget;
}
}; // struct DockContainerWidgetPrivate
//============================================================================
DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) :
_this(_public)
{
}
//============================================================================
CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *parent) :
QFrame(parent),
d(new DockContainerWidgetPrivate(this))
{
d->DockManager = DockManager;
d->Layout = new QGridLayout();
d->Layout->setContentsMargins(0, 1, 0, 0);
d->Layout->setSpacing(0);
setLayout(d->Layout);
}
//============================================================================
CDockContainerWidget::~CDockContainerWidget()
{
delete d;
}
//============================================================================
void CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget)
{
if (d->DockAreas.isEmpty())
{
}
}
//============================================================================
unsigned int CDockContainerWidget::zOrderIndex() const
{
return d->zOrderIndex;
}
//============================================================================
bool CDockContainerWidget::isInFrontOf(CDockContainerWidget* Other) const
{
return this->zOrderIndex() > Other->zOrderIndex();
}
//============================================================================
bool CDockContainerWidget::event(QEvent *e)
{
bool Result = QWidget::event(e);
if (e->type() == QEvent::WindowActivate)
{
d->zOrderIndex = ++zOrderCounter;
}
else if (e->type() == QEvent::Show && !d->zOrderIndex)
{
d->zOrderIndex = ++zOrderCounter;
}
return Result;
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockContainerWidget.cpp

View File

@ -0,0 +1,72 @@
#ifndef DockContainerWidgetH
#define DockContainerWidgetH
//============================================================================
/// \file DockContainerWidget.h
/// \author Uwe Kindler
/// \date 24.02.2017
/// \brief Declaration of CDockContainerWidget class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QFrame>
#include "ads_globals.h"
namespace ads
{
struct DockContainerWidgetPrivate;
class CDockAreaWidget;
class CDockWidget;
class CDockManager;
/**
* Container that manages a number of dock areas with single dock widgets
* or tabyfied dock widtes in each area
*/
class CDockContainerWidget : public QFrame
{
Q_OBJECT
private:
DockContainerWidgetPrivate* d; ///< private data (pimpl)
friend class DockContainerWidgetPrivate;
protected:
/**
* Handles activation events to update zOrderIndex
*/
virtual bool event(QEvent *e) override;
public:
/**
* Default Constructor
*/
CDockContainerWidget(CDockManager* DockManager, QWidget* parent = 0);
/**
* Virtual Destructor
*/
virtual ~CDockContainerWidget();
/**
* Adds dockwidget into the given area.
* If DockAreaWidget is not null, then the area parameter indicates the area
* into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will
* be dropped into the container.
*/
void addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget = nullptr);
/**
* Returns the current zOrderIndex
*/
unsigned int zOrderIndex() const;
/**
* This function returns true if this container widgets z order index is
* higher than the index of the container widget given in Other parameter
*/
bool isInFrontOf(CDockContainerWidget* Other) const;
}; // class DockContainerWidget
} // namespace ads
//-----------------------------------------------------------------------------
#endif // DockContainerWidgetH

View File

@ -0,0 +1,19 @@
//============================================================================
/// \file DockManager.cpp
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Implementation of CDockManager
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockManager.h"
namespace ads
{
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockManager.cpp

View File

@ -0,0 +1,28 @@
#ifndef DockManagerH
#define DockManagerH
//============================================================================
/// \file DockManager.h
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Declaration of CDockManager
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockContainerWidget.h"
namespace ads
{
/**
* @brief
*/
class CDockManager : public CDockContainerWidget
{
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // DockManagerH

View File

@ -0,0 +1,19 @@
//============================================================================
/// \file DockWidget.cpp
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Implementation of CDockWidget
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockWidget.h"
namespace ads
{
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockWidget.cpp

View File

@ -0,0 +1,29 @@
#ifndef DockWidgetH
#define DockWidgetH
//============================================================================
/// \file DockWidget.h
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Declaration of CDockWidget
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QFrame>
namespace ads
{
/**
* @brief
*/
class CDockWidget : public QFrame
{
Q_OBJECT
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // DockWidgetH

View File

@ -0,0 +1,19 @@
//============================================================================
/// \file DockWidgetTitleBar.cpp
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Implementation of DockWidgetTitleBar
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockWidgetTitleBar.h"
namespace ads
{
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockWidgetTitleBar.cpp

View File

@ -0,0 +1,26 @@
#ifndef DockWidgetTitleBarH
#define DockWidgetTitleBarH
//============================================================================
/// \file DockWidgetTitleBar.h
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Declaration of DockWidgetTitleBar
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
namespace ads
{
/**
* @brief
*/
class CDockWidgetTitleBar
{
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // DockWidgetTitleBarH

View File

@ -0,0 +1,19 @@
//============================================================================
/// \file FloatingDockContainer.cpp
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Implementation of CFloatingDockContainer
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "FloatingDockContainer.h"
namespace ads
{
} // namespace ads
//---------------------------------------------------------------------------
// EOF FloatingDockContainer.cpp

View File

@ -0,0 +1,26 @@
#ifndef FloatingDockContainerH
#define FloatingDockContainerH
//============================================================================
/// \file FloatingDockContainer.h
/// \author Uwe Kindler
/// \date 23.02.2017
/// \brief Declaration of CFloatingDockContainer
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
namespace ads
{
/**
* @brief
*/
class CFloatingDockContainer
{
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // FloatingDockContainerH

View File

@ -0,0 +1,36 @@
//============================================================================
/// \file ads_globals.cpp
/// \author Uwe Kindler
/// \date 24.02.2017
/// \brief Implementation of
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QSplitter>
#include <QVariant>
namespace ads
{
namespace internal
{
QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent)
{
QSplitter* s = new QSplitter(orientation, parent);
s->setProperty("ads-splitter", QVariant(true));
s->setChildrenCollapsible(false);
s->setOpaqueResize(false);
return s;
}
} // namespace internal
} // namespace ads
//---------------------------------------------------------------------------
// EOF ads_globals.cpp

View File

@ -0,0 +1,42 @@
#ifndef ads_globalsH
#define ads_globalsH
//============================================================================
/// \file ads_globals.h
/// \author Uwe Kindler
/// \date 24.02.2017
/// \brief Declaration of
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
class QSplitter;
namespace ads
{
enum DockWidgetArea
{
NoDockWidgetArea = 0x00,
LeftDockWidgetArea = 0x01,
RightDockWidgetArea = 0x02,
TopDockWidgetArea = 0x04,
BottomDockWidgetArea = 0x08,
CenterDockWidgetArea = 0x10,
OuterAreas = TopDockWidgetArea | LeftDockWidgetArea | RightDockWidgetArea | BottomDockWidgetArea,
AllAreas = OuterAreas | CenterDockWidgetArea
};
Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)
namespace internal
{
/**
* Helper function to create new splitter widgets
*/
QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent);
} // namespace internal
} // namespace ads
//---------------------------------------------------------------------------
#endif // ads_globalsH

View File

@ -5,9 +5,9 @@
#include <QList>
#include <QString>
#include <QAbstractTableModel>
#include "../../../AdvancedDockingSystem/src/SectionContent.h"
#include "MainContainerWidget.h"
#include "API.h"
#include "SectionContent.h"
namespace ads {class CMainContainerWidget;}

View File

@ -2,11 +2,11 @@
#define SECTIONCONTENTLISTWIDGET
#include <QDialog>
#include "../../../AdvancedDockingSystem/src/SectionContent.h"
#include "MainContainerWidget.h"
#include "ui_SectionContentListWidget.h"
#include "API.h"
#include "SectionContent.h"
class SectionContentListWidget : public QDialog
{

View File

@ -3,8 +3,8 @@
#include <QMainWindow>
#include "../../AdvancedDockingSystem/src/MainContainerWidget.h"
#include "../../AdvancedDockingSystem/src/SectionContent.h"
#include "API.h"
#include "SectionContent.h"
namespace Ui {
class MainWindow;