Refactorings to improve code, started to refactor secion content
This commit is contained in:
@@ -44,7 +44,7 @@ static bool splitterContainsSectionWidget(QSplitter* splitter)
|
||||
return false;
|
||||
}
|
||||
|
||||
void deleteEmptySplitter(MainContainerWidget* container)
|
||||
void deleteEmptySplitter(CMainContainerWidget* container)
|
||||
{
|
||||
bool doAgain = false;
|
||||
do
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <ads/MainContainerWidget.h>
|
||||
#include <ads/SectionContentWidget.h>
|
||||
#include "ads/ContainerWidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
@@ -39,17 +41,15 @@
|
||||
#include "ads/Internal.h"
|
||||
#include "ads/SectionWidget.h"
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
#include "ads/SectionContentWidget.h"
|
||||
#include "ads/DropOverlay.h"
|
||||
#include "ads/Serialization.h"
|
||||
#include "ads/MainContainerWidget.h"
|
||||
|
||||
namespace ads
|
||||
{
|
||||
unsigned int CContainerWidget::zOrderCounter = 0;
|
||||
|
||||
//============================================================================
|
||||
CContainerWidget::CContainerWidget(MainContainerWidget* MainContainer, QWidget *parent)
|
||||
CContainerWidget::CContainerWidget(CMainContainerWidget* MainContainer, QWidget *parent)
|
||||
: QFrame(parent),
|
||||
m_MainContainerWidget(MainContainer)
|
||||
{
|
||||
@@ -185,7 +185,7 @@ void CContainerWidget::dropIntoContainer(FloatingWidget* FloatingWidget, DropAre
|
||||
{
|
||||
std::cout << "Create new splitter" << std::endl;
|
||||
// we have no splitter yet - let us create one
|
||||
QSplitter* sp = MainContainerWidget::newSplitter(FloatingMainSplitter->orientation());
|
||||
QSplitter* sp = CMainContainerWidget::newSplitter(FloatingMainSplitter->orientation());
|
||||
if (l->count() > 0)
|
||||
{
|
||||
qWarning() << "Still items in layout. This should never happen.";
|
||||
@@ -221,7 +221,7 @@ void CContainerWidget::dropIntoContainer(FloatingWidget* FloatingWidget, DropAre
|
||||
{
|
||||
std::cout << "Splitter with wrong orientation" << std::endl;
|
||||
// we have a splitter but with the wrong orientation
|
||||
QSplitter* sp = MainContainerWidget::newSplitter(orientation);
|
||||
QSplitter* sp = CMainContainerWidget::newSplitter(orientation);
|
||||
if (append)
|
||||
{
|
||||
QLayoutItem* li = l->replaceWidget(OldSplitter, sp);
|
||||
@@ -313,7 +313,7 @@ void CContainerWidget::dropIntoSection(FloatingWidget* FloatingWidget,
|
||||
else
|
||||
{
|
||||
std::cout << "targetSectionSplitter->orientation() != Orientation" << std::endl;
|
||||
QSplitter* s = MainContainerWidget::newSplitter(Orientation);
|
||||
QSplitter* s = CMainContainerWidget::newSplitter(Orientation);
|
||||
if (FloatingMainSplitter->orientation() == Orientation || FloatingMainSplitter->count() == 1)
|
||||
{
|
||||
std::cout << "FloatingMainSplitter->orientation() == Orientation || FloatingMainSplitter->count() == 1" << std::endl;
|
||||
@@ -431,7 +431,7 @@ void CContainerWidget::addSectionWidget(SectionWidget* section)
|
||||
// Create default splitter.
|
||||
if (!m_Splitter)
|
||||
{
|
||||
m_Splitter = MainContainerWidget::newSplitter(m_Orientation);
|
||||
m_Splitter = CMainContainerWidget::newSplitter(m_Orientation);
|
||||
m_MainLayout->addWidget(m_Splitter, 0, 0);
|
||||
}
|
||||
if (m_Splitter->indexOf(section) != -1)
|
||||
@@ -459,7 +459,7 @@ SectionWidget* CContainerWidget::dropContentOuterHelper(QLayout* l, const Intern
|
||||
QSplitter* oldsp = findImmediateSplitter(this);
|
||||
if (!oldsp)
|
||||
{
|
||||
QSplitter* sp = MainContainerWidget::newSplitter(orientation);
|
||||
QSplitter* sp = CMainContainerWidget::newSplitter(orientation);
|
||||
if (l->count() > 0)
|
||||
{
|
||||
qWarning() << "Still items in layout. This should never happen.";
|
||||
@@ -480,7 +480,7 @@ SectionWidget* CContainerWidget::dropContentOuterHelper(QLayout* l, const Intern
|
||||
}
|
||||
else
|
||||
{
|
||||
QSplitter* sp = MainContainerWidget::newSplitter(orientation);
|
||||
QSplitter* sp = CMainContainerWidget::newSplitter(orientation);
|
||||
if (append)
|
||||
{
|
||||
QLayoutItem* li = l->replaceWidget(oldsp, sp);
|
||||
@@ -514,7 +514,7 @@ SectionWidget* CContainerWidget::insertNewSectionWidget(
|
||||
else
|
||||
{
|
||||
const int index = targetSectionSplitter->indexOf(targetSection);
|
||||
QSplitter* s = MainContainerWidget::newSplitter(Orientation);
|
||||
QSplitter* s = CMainContainerWidget::newSplitter(Orientation);
|
||||
s->addWidget(sw);
|
||||
s->addWidget(targetSection);
|
||||
targetSectionSplitter->insertWidget(index, s);
|
||||
@@ -531,7 +531,7 @@ SectionWidget* CContainerWidget::addSectionContent(const SectionContent::RefPtr&
|
||||
InternalContentData data;
|
||||
data.content = sc;
|
||||
data.titleWidget = new SectionTitleWidget(sc, NULL);
|
||||
data.contentWidget = new SectionContentWidget(sc, NULL);
|
||||
data.contentWidget = new CSectionContentWidget(sc, NULL);
|
||||
|
||||
connect(data.titleWidget, SIGNAL(activeTabChanged()), this, SLOT(onActiveTabChanged()));
|
||||
return dropContent(data, sw, area, false);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <ads/MainContainerWidget.h>
|
||||
#include <ads/SectionContentWidget.h>
|
||||
#include "ads/FloatingWidget.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
@@ -28,7 +29,6 @@
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
#include "ads/SectionContentWidget.h"
|
||||
#include "ads/Internal.h"
|
||||
#include "ads/SectionWidget.h"
|
||||
#include "ads/ContainerWidget.h"
|
||||
@@ -92,7 +92,7 @@ FloatingWidget* CFloatingTitleWidget::floatingWidget() const
|
||||
return dynamic_cast<FloatingWidget*>(parentWidget());
|
||||
}
|
||||
|
||||
MainContainerWidget* CFloatingTitleWidget::mainContainerWidget() const
|
||||
CMainContainerWidget* CFloatingTitleWidget::mainContainerWidget() const
|
||||
{
|
||||
return floatingWidget()->mainContainerWidget();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ void CFloatingTitleWidget::onMaximizeButtonClicked()
|
||||
|
||||
|
||||
|
||||
FloatingWidget::FloatingWidget(MainContainerWidget* MainContainer, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent) :
|
||||
FloatingWidget::FloatingWidget(CMainContainerWidget* MainContainer, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, CSectionContentWidget* contentWidget, QWidget* parent) :
|
||||
QWidget(MainContainer, Qt::Window),
|
||||
m_MainContainerWidget(MainContainer)
|
||||
{
|
||||
@@ -178,7 +178,7 @@ FloatingWidget::FloatingWidget(MainContainerWidget* MainContainer, SectionConten
|
||||
}
|
||||
|
||||
|
||||
FloatingWidget::FloatingWidget(MainContainerWidget* MainContainer, SectionWidget* sectionWidget)
|
||||
FloatingWidget::FloatingWidget(CMainContainerWidget* MainContainer, SectionWidget* sectionWidget)
|
||||
: QWidget(MainContainer, Qt::Window),
|
||||
m_MainContainerWidget(MainContainer)
|
||||
{
|
||||
@@ -338,7 +338,7 @@ void FloatingWidget::titleMouseReleaseEvent()
|
||||
}
|
||||
|
||||
std::cout << "Dropped" << std::endl;
|
||||
MainContainerWidget* MainContainerWidget = mainContainerWidget();
|
||||
CMainContainerWidget* MainContainerWidget = mainContainerWidget();
|
||||
m_DropContainer->dropFloatingWidget(this, QCursor::pos());
|
||||
MainContainerWidget->dropOverlay()->hideDropOverlay();
|
||||
MainContainerWidget->sectionDropOverlay()->hideDropOverlay();
|
||||
@@ -357,7 +357,7 @@ void FloatingWidget::updateDropOverlays(const QPoint& GlobalPos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MainContainerWidget* MainContainerWidget = mainContainerWidget();
|
||||
CMainContainerWidget* MainContainerWidget = mainContainerWidget();
|
||||
auto Containers = MainContainerWidget->m_Containers;
|
||||
CContainerWidget* TopContainer = nullptr;
|
||||
for (auto ContainerWidget : Containers)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include <ads/MainContainerWidget.h>
|
||||
#include <ads/SectionContentWidget.h>
|
||||
#include <QDebug>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
@@ -32,16 +32,16 @@
|
||||
#include "ads/Internal.h"
|
||||
#include "ads/SectionWidget.h"
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
#include "ads/SectionContentWidget.h"
|
||||
#include "ads/DropOverlay.h"
|
||||
#include "ads/Serialization.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "../include/ads/MainContainerWidget.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
QSplitter* MainContainerWidget::newSplitter(Qt::Orientation orientation, QWidget* parent)
|
||||
QSplitter* CMainContainerWidget::newSplitter(Qt::Orientation orientation, QWidget* parent)
|
||||
{
|
||||
QSplitter* s = new QSplitter(orientation, parent);
|
||||
s->setProperty("ads-splitter", QVariant(true));
|
||||
@@ -51,7 +51,7 @@ QSplitter* MainContainerWidget::newSplitter(Qt::Orientation orientation, QWidget
|
||||
}
|
||||
|
||||
|
||||
MainContainerWidget::MainContainerWidget(QWidget *parent) :
|
||||
CMainContainerWidget::CMainContainerWidget(QWidget *parent) :
|
||||
CContainerWidget(this, parent)
|
||||
{
|
||||
m_SectionDropOverlay = new DropOverlay(this, DropOverlay::ModeSectionOverlay);
|
||||
@@ -61,7 +61,7 @@ MainContainerWidget::MainContainerWidget(QWidget *parent) :
|
||||
m_Containers.append(this);
|
||||
}
|
||||
|
||||
MainContainerWidget::~MainContainerWidget()
|
||||
CMainContainerWidget::~CMainContainerWidget()
|
||||
{
|
||||
// Note: It's required to delete in 2 steps
|
||||
// Remove from list, and then delete.
|
||||
@@ -83,7 +83,7 @@ MainContainerWidget::~MainContainerWidget()
|
||||
}
|
||||
|
||||
|
||||
bool MainContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
||||
bool CMainContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
||||
{
|
||||
ADS_Expects(!sc.isNull());
|
||||
|
||||
@@ -128,7 +128,7 @@ bool MainContainerWidget::removeSectionContent(const SectionContent::RefPtr& sc)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
||||
bool CMainContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
||||
{
|
||||
ADS_Expects(!sc.isNull());
|
||||
|
||||
@@ -183,7 +183,7 @@ bool MainContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
||||
bool CMainContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
||||
{
|
||||
ADS_Expects(!sc.isNull());
|
||||
|
||||
@@ -239,7 +239,7 @@ bool MainContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
|
||||
bool CMainContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
|
||||
{
|
||||
ADS_Expects(!sc.isNull());
|
||||
|
||||
@@ -273,7 +273,7 @@ bool MainContainerWidget::raiseSectionContent(const SectionContent::RefPtr& sc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::isSectionContentVisible(const SectionContent::RefPtr& sc)
|
||||
bool CMainContainerWidget::isSectionContentVisible(const SectionContent::RefPtr& sc)
|
||||
{
|
||||
ADS_Expects(!sc.isNull());
|
||||
|
||||
@@ -304,7 +304,7 @@ bool MainContainerWidget::isSectionContentVisible(const SectionContent::RefPtr&
|
||||
return false;
|
||||
}
|
||||
|
||||
QMenu* MainContainerWidget::createContextMenu() const
|
||||
QMenu* CMainContainerWidget::createContextMenu() const
|
||||
{
|
||||
// Fill map with actions (sorted by key!)
|
||||
QMap<QString, QAction*> actions;
|
||||
@@ -367,7 +367,7 @@ QMenu* MainContainerWidget::createContextMenu() const
|
||||
return m;
|
||||
}
|
||||
|
||||
QByteArray MainContainerWidget::saveState() const
|
||||
QByteArray CMainContainerWidget::saveState() const
|
||||
{
|
||||
ADS_NS_SER::InMemoryWriter writer;
|
||||
|
||||
@@ -390,7 +390,7 @@ QByteArray MainContainerWidget::saveState() const
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
bool MainContainerWidget::restoreState(const QByteArray& data)
|
||||
bool CMainContainerWidget::restoreState(const QByteArray& data)
|
||||
{
|
||||
if (data.isEmpty())
|
||||
return false;
|
||||
@@ -409,7 +409,7 @@ bool MainContainerWidget::restoreState(const QByteArray& data)
|
||||
}
|
||||
|
||||
|
||||
QList<SectionContent::RefPtr> MainContainerWidget::contents() const
|
||||
QList<SectionContent::RefPtr> CMainContainerWidget::contents() const
|
||||
{
|
||||
QList<SectionContent::WeakPtr> wl = m_SectionContentIdMap.values();
|
||||
QList<SectionContent::RefPtr> sl;
|
||||
@@ -422,13 +422,13 @@ QList<SectionContent::RefPtr> MainContainerWidget::contents() const
|
||||
return sl;
|
||||
}
|
||||
|
||||
QPointer<DropOverlay> MainContainerWidget::sectionDropOverlay() const
|
||||
QPointer<DropOverlay> CMainContainerWidget::sectionDropOverlay() const
|
||||
{
|
||||
return m_SectionDropOverlay;
|
||||
}
|
||||
|
||||
|
||||
QPointer<DropOverlay> MainContainerWidget::dropOverlay() const
|
||||
QPointer<DropOverlay> CMainContainerWidget::dropOverlay() const
|
||||
{
|
||||
return m_ContainerDropOverlay;
|
||||
}
|
||||
@@ -437,7 +437,7 @@ QPointer<DropOverlay> MainContainerWidget::dropOverlay() const
|
||||
// PRIVATE API BEGINS HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
QByteArray MainContainerWidget::saveHierarchy() const
|
||||
QByteArray CMainContainerWidget::saveHierarchy() const
|
||||
{
|
||||
/*
|
||||
# Data Format
|
||||
@@ -524,7 +524,7 @@ QByteArray MainContainerWidget::saveHierarchy() const
|
||||
return ba;
|
||||
}
|
||||
|
||||
void MainContainerWidget::saveFloatingWidgets(QDataStream& out) const
|
||||
void CMainContainerWidget::saveFloatingWidgets(QDataStream& out) const
|
||||
{
|
||||
out << m_Floatings.count();
|
||||
for (int i = 0; i < m_Floatings.count(); ++i)
|
||||
@@ -536,7 +536,7 @@ void MainContainerWidget::saveFloatingWidgets(QDataStream& out) const
|
||||
}
|
||||
}
|
||||
|
||||
void MainContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) const
|
||||
void CMainContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) const
|
||||
{
|
||||
QSplitter* sp = NULL;
|
||||
SectionWidget* sw = NULL;
|
||||
@@ -599,7 +599,7 @@ void MainContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget)
|
||||
}
|
||||
}
|
||||
|
||||
bool MainContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) const
|
||||
bool CMainContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) const
|
||||
{
|
||||
if (m_Sections.count() <= 0)
|
||||
return false;
|
||||
@@ -627,7 +627,7 @@ bool MainContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) co
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||
bool CMainContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||
{
|
||||
QDataStream in(data);
|
||||
in.setVersion(QDataStream::Qt_4_5);
|
||||
@@ -795,7 +795,7 @@ bool MainContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList<FloatingWidget*>& floatings)
|
||||
bool CMainContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, QList<FloatingWidget*>& floatings)
|
||||
{
|
||||
Q_UNUSED(version)
|
||||
|
||||
@@ -838,7 +838,7 @@ bool MainContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, Q
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplitter* currentSplitter, QList<SectionWidget*>& sections, QList<SectionContent::RefPtr>& contentsToHide)
|
||||
bool CMainContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QSplitter* currentSplitter, QList<SectionWidget*>& sections, QList<SectionContent::RefPtr>& contentsToHide)
|
||||
{
|
||||
if (in.atEnd())
|
||||
return true;
|
||||
@@ -936,7 +936,7 @@ bool MainContainerWidget::restoreSectionWidgets(QDataStream& in, int version, QS
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainContainerWidget::takeContent(const SectionContent::RefPtr& sc, InternalContentData& data)
|
||||
bool CMainContainerWidget::takeContent(const SectionContent::RefPtr& sc, InternalContentData& data)
|
||||
{
|
||||
ADS_Expects(!sc.isNull());
|
||||
|
||||
@@ -967,7 +967,7 @@ bool MainContainerWidget::takeContent(const SectionContent::RefPtr& sc, Internal
|
||||
}
|
||||
|
||||
|
||||
void MainContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
||||
void CMainContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
||||
{
|
||||
QAction* a = qobject_cast<QAction*>(sender());
|
||||
if (!a)
|
||||
@@ -986,13 +986,13 @@ void MainContainerWidget::onActionToggleSectionContentVisibility(bool visible)
|
||||
}
|
||||
|
||||
|
||||
void MainContainerWidget::hideContainerOverlay()
|
||||
void CMainContainerWidget::hideContainerOverlay()
|
||||
{
|
||||
m_ContainerDropOverlay->hideDropOverlay();
|
||||
}
|
||||
|
||||
|
||||
void MainContainerWidget::moveFloatingWidget(const QPoint& TargetPos)
|
||||
void CMainContainerWidget::moveFloatingWidget(const QPoint& TargetPos)
|
||||
{
|
||||
QPoint MousePos = mapFromGlobal(QCursor::pos());
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ SectionContent::SectionContent() :
|
||||
{
|
||||
}
|
||||
|
||||
SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueName, MainContainerWidget* container, QWidget* title, QWidget* content)
|
||||
SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueName, CMainContainerWidget* container, QWidget* title, QWidget* content)
|
||||
{
|
||||
auto SectionContentNameMap = container->m_SectionContentNameMap;
|
||||
auto SectionContentIdMap = container->m_SectionContentIdMap;
|
||||
@@ -55,9 +55,9 @@ SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueNa
|
||||
|
||||
QSharedPointer<SectionContent> sc(new SectionContent());
|
||||
sc->_uniqueName = uniqueName;
|
||||
sc->_containerWidget = container;
|
||||
sc->_titleWidget = title;
|
||||
sc->_contentWidget = content;
|
||||
sc->m_MainContainerWidget = container;
|
||||
sc->m_TitleWidgetContent = title;
|
||||
sc->m_ContentWidget = content;
|
||||
|
||||
SectionContentIdMap.insert(sc->uid(), sc);
|
||||
SectionContentNameMap.insert(sc->uniqueName(), sc);
|
||||
@@ -66,16 +66,16 @@ SectionContent::RefPtr SectionContent::newSectionContent(const QString& uniqueNa
|
||||
|
||||
SectionContent::~SectionContent()
|
||||
{
|
||||
auto SectionContentNameMap = _containerWidget->m_SectionContentNameMap;
|
||||
auto SectionContentIdMap = _containerWidget->m_SectionContentIdMap;
|
||||
auto SectionContentNameMap = m_MainContainerWidget->m_SectionContentNameMap;
|
||||
auto SectionContentIdMap = m_MainContainerWidget->m_SectionContentIdMap;
|
||||
|
||||
if (_containerWidget)
|
||||
if (m_MainContainerWidget)
|
||||
{
|
||||
SectionContentIdMap.remove(_uid);
|
||||
SectionContentNameMap.remove(_uniqueName);
|
||||
}
|
||||
delete _titleWidget;
|
||||
delete _contentWidget;
|
||||
delete m_TitleWidgetContent;
|
||||
delete m_ContentWidget;
|
||||
}
|
||||
|
||||
int SectionContent::uid() const
|
||||
@@ -88,19 +88,19 @@ QString SectionContent::uniqueName() const
|
||||
return _uniqueName;
|
||||
}
|
||||
|
||||
MainContainerWidget* SectionContent::containerWidget() const
|
||||
CMainContainerWidget* SectionContent::containerWidget() const
|
||||
{
|
||||
return _containerWidget;
|
||||
return m_MainContainerWidget;
|
||||
}
|
||||
|
||||
QWidget* SectionContent::titleWidget() const
|
||||
QWidget* SectionContent::titleWidgetContent() const
|
||||
{
|
||||
return _titleWidget;
|
||||
return m_TitleWidgetContent;
|
||||
}
|
||||
|
||||
QWidget* SectionContent::contentWidget() const
|
||||
{
|
||||
return _contentWidget;
|
||||
return m_ContentWidget;
|
||||
}
|
||||
|
||||
SectionContent::Flags SectionContent::flags() const
|
||||
|
||||
@@ -16,14 +16,49 @@
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include "ads/SectionContentWidget.h"
|
||||
|
||||
#include <ads/MainContainerWidget.h>
|
||||
#include <QBoxLayout>
|
||||
#include "../include/ads/SectionContentWidget.h"
|
||||
#include "../include/ads/SectionTitleWidget.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
namespace ads
|
||||
{
|
||||
struct SectionContentWidgetPrivate
|
||||
{
|
||||
CSectionContentWidget* _this;
|
||||
int Uid;
|
||||
QString UniqueName;
|
||||
QPointer<CMainContainerWidget> MainContainerWidget;
|
||||
QPointer<QWidget> TitleWidgetContent;
|
||||
QPointer<QWidget> ContentWidget;
|
||||
// Optional attributes
|
||||
QString Title;
|
||||
CSectionContentWidget::Flags Flags = CSectionContentWidget::AllFlags;
|
||||
|
||||
SectionContentWidget::SectionContentWidget(SectionContent::RefPtr c, QWidget* parent) :
|
||||
|
||||
|
||||
/* Note: This method could be a problem in static build environment
|
||||
* since it may begin with 0 for every module which uses ADS.
|
||||
*/
|
||||
static int GetNextUid()
|
||||
{
|
||||
static int NextUid = 0;
|
||||
return ++NextUid;
|
||||
}
|
||||
|
||||
|
||||
SectionContentWidgetPrivate(CSectionContentWidget* _public)
|
||||
: _this(_public),
|
||||
Uid(GetNextUid())
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CSectionContentWidget::CSectionContentWidget(SectionContent::RefPtr c, QWidget* parent) :
|
||||
QFrame(parent),
|
||||
d(new SectionContentWidgetPrivate(this)),
|
||||
_content(c)
|
||||
{
|
||||
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||
@@ -33,9 +68,100 @@ SectionContentWidget::SectionContentWidget(SectionContent::RefPtr c, QWidget* pa
|
||||
setLayout(l);
|
||||
}
|
||||
|
||||
SectionContentWidget::~SectionContentWidget()
|
||||
|
||||
CSectionContentWidget* CSectionContentWidget::newSectionContent(const QString& uniqueName,
|
||||
CMainContainerWidget* container, QWidget* title, QWidget* content)
|
||||
{
|
||||
layout()->removeWidget(_content->contentWidget());
|
||||
auto SectionContentNameMap = container->m_SectionContentNameMap;
|
||||
auto SectionContentIdMap = container->m_SectionContentIdMap;
|
||||
|
||||
if (uniqueName.isEmpty())
|
||||
{
|
||||
qFatal("Can not create SectionContent with empty uniqueName");
|
||||
return nullptr;
|
||||
}
|
||||
else if (SectionContentNameMap.contains(uniqueName))
|
||||
{
|
||||
qFatal("Can not create SectionContent with already used uniqueName");
|
||||
return nullptr;
|
||||
}
|
||||
else if (!container || !title || !content)
|
||||
{
|
||||
qFatal("Can not create SectionContent with NULL values");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CSectionContentWidget* sc(new CSectionContentWidget());
|
||||
sc->d->UniqueName = uniqueName;
|
||||
sc->d->MainContainerWidget = container;
|
||||
sc->d->TitleWidgetContent = title;
|
||||
sc->d->ContentWidget = content;
|
||||
|
||||
//SectionContentIdMap.insert(sc->uid(), sc);
|
||||
//SectionContentNameMap.insert(sc->uniqueName(), sc);
|
||||
return sc;
|
||||
}
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
CSectionContentWidget::~CSectionContentWidget()
|
||||
{
|
||||
layout()->removeWidget(_content->contentWidget());
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
int CSectionContentWidget::uid() const
|
||||
{
|
||||
return d->Uid;
|
||||
}
|
||||
|
||||
|
||||
QString CSectionContentWidget::uniqueName() const
|
||||
{
|
||||
return d->UniqueName;
|
||||
}
|
||||
|
||||
|
||||
CMainContainerWidget* CSectionContentWidget::containerWidget() const
|
||||
{
|
||||
return d->MainContainerWidget;
|
||||
}
|
||||
|
||||
QWidget* CSectionContentWidget::titleWidgetContent() const
|
||||
{
|
||||
return d->TitleWidgetContent.data();
|
||||
}
|
||||
|
||||
|
||||
QWidget* CSectionContentWidget::contentWidget() const
|
||||
{
|
||||
return d->ContentWidget;
|
||||
}
|
||||
|
||||
CSectionContentWidget::Flags CSectionContentWidget::flags() const
|
||||
{
|
||||
return d->Flags;
|
||||
}
|
||||
|
||||
|
||||
QString CSectionContentWidget::visibleTitle() const
|
||||
{
|
||||
return d->Title.isEmpty() ? d->UniqueName : d->Title;
|
||||
}
|
||||
|
||||
|
||||
QString CSectionContentWidget::title() const
|
||||
{
|
||||
return d->Title;
|
||||
}
|
||||
|
||||
void CSectionContentWidget::setTitle(const QString& title)
|
||||
{
|
||||
d->Title = title;
|
||||
}
|
||||
|
||||
void CSectionContentWidget::setFlags(const Flags f)
|
||||
{
|
||||
d->Flags = f;
|
||||
}
|
||||
|
||||
} // namespace ads
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include <ads/MainContainerWidget.h>
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
|
||||
#include <QString>
|
||||
@@ -36,8 +37,6 @@
|
||||
#include "ads/SectionContent.h"
|
||||
#include "ads/SectionWidget.h"
|
||||
#include "ads/FloatingWidget.h"
|
||||
#include <ads/MainContainerWidget.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
@@ -51,14 +50,14 @@ SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget*
|
||||
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
l->setContentsMargins(0, 0, 0, 0);
|
||||
l->setSpacing(0);
|
||||
l->addWidget(content->titleWidget());
|
||||
l->addWidget(content->titleWidgetContent());
|
||||
setLayout(l);
|
||||
}
|
||||
|
||||
|
||||
SectionTitleWidget::~SectionTitleWidget()
|
||||
{
|
||||
layout()->removeWidget(m_Content->titleWidget());
|
||||
layout()->removeWidget(m_Content->titleWidgetContent());
|
||||
}
|
||||
|
||||
bool SectionTitleWidget::isActiveTab() const
|
||||
@@ -130,7 +129,7 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||
{
|
||||
SectionWidget* section = nullptr;
|
||||
CContainerWidget* cw = findParentContainerWidget(this);
|
||||
MainContainerWidget* mcw = cw->mainContainerWidget();
|
||||
CMainContainerWidget* mcw = cw->mainContainerWidget();
|
||||
std::cout << "SectionTitleWidget::mouseReleaseEvent" << std::endl;
|
||||
|
||||
//m_FloatingWidget.clear();
|
||||
@@ -164,7 +163,7 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||
}
|
||||
|
||||
|
||||
void SectionTitleWidget::startFloating(QMouseEvent* ev, MainContainerWidget* cw, SectionWidget* sectionwidget)
|
||||
void SectionTitleWidget::startFloating(QMouseEvent* ev, CMainContainerWidget* cw, SectionWidget* sectionwidget)
|
||||
{
|
||||
std::cout << "SectionTitleWidget::startFloating" << std::endl;
|
||||
|
||||
@@ -246,7 +245,7 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
||||
|
||||
// TODO make a member with the main container widget and assign it on
|
||||
// creation
|
||||
MainContainerWidget* MainContainerWidget = findParentContainerWidget(this)->mainContainerWidget();
|
||||
CMainContainerWidget* MainContainerWidget = findParentContainerWidget(this)->mainContainerWidget();
|
||||
ev->accept();
|
||||
|
||||
|
||||
|
||||
@@ -44,13 +44,13 @@
|
||||
#include "ads/DropOverlay.h"
|
||||
#include "ads/SectionContent.h"
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
#include "ads/SectionContentWidget.h"
|
||||
#include <ads/SectionContentWidget.h>
|
||||
#include "ads/FloatingWidget.h"
|
||||
#include <ads/MainContainerWidget.h>
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
SectionWidget::SectionWidget(MainContainerWidget* MainContainer, CContainerWidget* parent) :
|
||||
SectionWidget::SectionWidget(CMainContainerWidget* MainContainer, CContainerWidget* parent) :
|
||||
QFrame(parent),
|
||||
_uid(GetNextUid()),
|
||||
m_MainContainerWidget(MainContainer),
|
||||
@@ -174,7 +174,7 @@ void SectionWidget::addContent(const SectionContent::RefPtr& c)
|
||||
_tabsLayout->insertWidget(_tabsLayout->count() - _tabsLayoutInitCount, title);
|
||||
QObject::connect(title, SIGNAL(clicked()), this, SLOT(onSectionTitleClicked()));
|
||||
|
||||
SectionContentWidget* content = new SectionContentWidget(c, NULL);
|
||||
CSectionContentWidget* content = new CSectionContentWidget(c, NULL);
|
||||
m_ContentWidgets.append(content);
|
||||
_contentsLayout->addWidget(content);
|
||||
|
||||
@@ -247,7 +247,7 @@ bool SectionWidget::takeContentAt(int index, InternalContentData& data)
|
||||
}
|
||||
|
||||
// Content wrapper widget (CONTENT)
|
||||
SectionContentWidget* content = m_ContentWidgets.takeAt(index);
|
||||
CSectionContentWidget* content = m_ContentWidgets.takeAt(index);
|
||||
if (content)
|
||||
{
|
||||
_contentsLayout->removeWidget(content);
|
||||
|
||||
Reference in New Issue
Block a user