mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Started implementing clean improved docking system
This commit is contained in:
parent
842cef2675
commit
94a6f5e2f1
@ -1,4 +1,5 @@
|
||||
include($$(cetoni_repository)/build/qt/qtprojectsettings/shared_library.pri)
|
||||
include(src/v2/v2.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(AdvancedDockingSystem)
|
||||
TEMPLATE = lib
|
||||
|
72
AdvancedDockingSystem/src/v2/DockAreaWidget.cpp
Normal file
72
AdvancedDockingSystem/src/v2/DockAreaWidget.cpp
Normal 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
|
53
AdvancedDockingSystem/src/v2/DockAreaWidget.h
Normal file
53
AdvancedDockingSystem/src/v2/DockAreaWidget.h
Normal 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
|
122
AdvancedDockingSystem/src/v2/DockContainerWidget.cpp
Normal file
122
AdvancedDockingSystem/src/v2/DockContainerWidget.cpp
Normal 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
|
72
AdvancedDockingSystem/src/v2/DockContainerWidget.h
Normal file
72
AdvancedDockingSystem/src/v2/DockContainerWidget.h
Normal 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
|
19
AdvancedDockingSystem/src/v2/DockManager.cpp
Normal file
19
AdvancedDockingSystem/src/v2/DockManager.cpp
Normal 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
|
28
AdvancedDockingSystem/src/v2/DockManager.h
Normal file
28
AdvancedDockingSystem/src/v2/DockManager.h
Normal 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
|
19
AdvancedDockingSystem/src/v2/DockWidget.cpp
Normal file
19
AdvancedDockingSystem/src/v2/DockWidget.cpp
Normal 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
|
29
AdvancedDockingSystem/src/v2/DockWidget.h
Normal file
29
AdvancedDockingSystem/src/v2/DockWidget.h
Normal 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
|
19
AdvancedDockingSystem/src/v2/DockWidgetTitleBar.cpp
Normal file
19
AdvancedDockingSystem/src/v2/DockWidgetTitleBar.cpp
Normal 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
|
26
AdvancedDockingSystem/src/v2/DockWidgetTitleBar.h
Normal file
26
AdvancedDockingSystem/src/v2/DockWidgetTitleBar.h
Normal 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
|
19
AdvancedDockingSystem/src/v2/FloatingDockContainer.cpp
Normal file
19
AdvancedDockingSystem/src/v2/FloatingDockContainer.cpp
Normal 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
|
26
AdvancedDockingSystem/src/v2/FloatingDockContainer.h
Normal file
26
AdvancedDockingSystem/src/v2/FloatingDockContainer.h
Normal 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
|
36
AdvancedDockingSystem/src/v2/ads_globals.cpp
Normal file
36
AdvancedDockingSystem/src/v2/ads_globals.cpp
Normal 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
|
42
AdvancedDockingSystem/src/v2/ads_globals.h
Normal file
42
AdvancedDockingSystem/src/v2/ads_globals.h
Normal 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
|
@ -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;}
|
||||
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user