diff --git a/AdvancedDockingSystem/src/ContainerWidget.cpp b/AdvancedDockingSystem/src/ContainerWidget.cpp index 87ecad3..22076ac 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.cpp +++ b/AdvancedDockingSystem/src/ContainerWidget.cpp @@ -124,31 +124,9 @@ void CContainerWidget::dropFloatingWidget(FloatingWidget* FloatingWidget, } -void CContainerWidget::dropChildSections(QWidget* Parent) -{ - auto Sections = Parent->findChildren(QString(), Qt::FindDirectChildrenOnly); - auto Splitters = Parent->findChildren(QString(), Qt::FindDirectChildrenOnly); - - std::cout << "-----------------------" << std::endl; - std::cout << "Sections " << Sections.size() << std::endl; - std::cout << "Splitters " << Splitters.size() << std::endl; - - for (auto Section : Sections) - { - // drop section - } - - for (auto Splitter : Splitters) - { - dropChildSections(Splitter); - } -} - void CContainerWidget::dropIntoContainer(FloatingWidget* FloatingWidget, DropArea area) { - dropChildSections(FloatingWidget->containerWidget()); - CContainerWidget* FloatingContainer = FloatingWidget->containerWidget(); QSplitter* FloatingMainSplitter = FloatingContainer->findChild(QString(), Qt::FindDirectChildrenOnly); diff --git a/AdvancedDockingSystem/src/ContainerWidget.h b/AdvancedDockingSystem/src/ContainerWidget.h index e1a5bb3..96f784c 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.h +++ b/AdvancedDockingSystem/src/ContainerWidget.h @@ -116,9 +116,6 @@ protected: unsigned int m_zOrderIndex = 0; static unsigned int zOrderCounter; -private: - void dropChildSections(QWidget* Parent); - private slots: void onActiveTabChanged(); }; diff --git a/AdvancedDockingSystem/src/v2/DockAreaWidget.cpp b/AdvancedDockingSystem/src/v2/DockAreaWidget.cpp index 3aaed2c..2428992 100644 --- a/AdvancedDockingSystem/src/v2/DockAreaWidget.cpp +++ b/AdvancedDockingSystem/src/v2/DockAreaWidget.cpp @@ -10,7 +10,10 @@ //============================================================================ #include "DockAreaWidget.h" +#include + #include "DockContainerWidget.h" +#include "DockWidget.h" namespace ads { @@ -20,6 +23,7 @@ namespace ads struct DockAreaWidgetPrivate { CDockAreaWidget* _this; + QStackedLayout* StackedLayout; /** * Private data constructor @@ -40,7 +44,11 @@ CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget QFrame(parent), d(new DockAreaWidgetPrivate(this)) { - + setStyleSheet("background: yellow;"); + d->StackedLayout = new QStackedLayout(); + d->StackedLayout->setContentsMargins(0, 0, 0, 0); + d->StackedLayout->setSpacing(0); + setLayout(d->StackedLayout); } //============================================================================ @@ -66,6 +74,13 @@ CDockContainerWidget* CDockAreaWidget::dockContainerWidget() const return 0; } + + +//============================================================================ +void CDockAreaWidget::addDockWidget(CDockWidget* DockWidget) +{ + d->StackedLayout->addWidget(DockWidget); +} } // namespace ads //--------------------------------------------------------------------------- diff --git a/AdvancedDockingSystem/src/v2/DockAreaWidget.h b/AdvancedDockingSystem/src/v2/DockAreaWidget.h index 8c36bd3..274e201 100644 --- a/AdvancedDockingSystem/src/v2/DockAreaWidget.h +++ b/AdvancedDockingSystem/src/v2/DockAreaWidget.h @@ -17,6 +17,7 @@ namespace ads struct DockAreaWidgetPrivate; class CDockManager; class CDockContainerWidget; +class CDockWidget; /** * DockAreaWidget manages multiple instances of DckWidgets. @@ -46,6 +47,12 @@ public: * if there is no */ CDockContainerWidget* dockContainerWidget() const; + + /** + * Add a new dock widget to dock area. + * All dockwidgets in the dock area tabified in a stacked layout with tabs + */ + void addDockWidget(CDockWidget* DockWidget); }; // class DockAreaWidget } // namespace ads diff --git a/AdvancedDockingSystem/src/v2/DockContainerWidget.cpp b/AdvancedDockingSystem/src/v2/DockContainerWidget.cpp index a54fa06..67de3d4 100644 --- a/AdvancedDockingSystem/src/v2/DockContainerWidget.cpp +++ b/AdvancedDockingSystem/src/v2/DockContainerWidget.cpp @@ -13,14 +13,31 @@ #include #include #include +#include #include "DockManager.h" #include "DockAreaWidget.h" +#include "ads_globals.h" namespace ads { static unsigned int zOrderCounter = 0; +/** + * Helper function to ease insertion of dock area into splitter + */ +static void inserDockAreaIntoSplitter(QSplitter* Splitter, QWidget* widget, bool Append) +{ + if (Append) + { + Splitter->addWidget(widget); + } + else + { + Splitter->insertWidget(0, widget); + } +} + /** * Private data class of CDockContainerWidget class (pimpl) */ @@ -40,12 +57,23 @@ struct DockContainerWidgetPrivate /** * Create a new dock area widget and adds it to the list of doc areas */ - CDockAreaWidget* newDockAreaWidget() + CDockAreaWidget* newDockArea() { auto DockAreaWidget = new CDockAreaWidget(DockManager, _this); DockAreas.append(DockAreaWidget); return DockAreaWidget; } + + /** + * Adds dock widget to container + */ + void dockWidgetIntoContainer(DockWidgetArea area, CDockWidget* Dockwidget); + + /** + * Adds dock widget to a existing DockWidgetArea + */ + void dockWidgetIntoDockArea(DockWidgetArea area, CDockWidget* Dockwidget, + CDockAreaWidget* DockAreaWidget); }; // struct DockContainerWidgetPrivate @@ -56,11 +84,72 @@ DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _pu } + +//============================================================================ +void DockContainerWidgetPrivate::dockWidgetIntoContainer(DockWidgetArea area, + CDockWidget* Dockwidget) +{ + CDockAreaWidget* NewDockArea = new CDockAreaWidget(DockManager, _this); + NewDockArea->addDockWidget(Dockwidget); + auto InsertParam = internal::dockAreaInsertParameters(area); + + if (DockAreas.isEmpty()) + { + Layout->addWidget(NewDockArea, 0, 0); + } + else if (DockAreas.count() == 1) + { + QSplitter* Splitter = internal::newSplitter(InsertParam.first); + auto DockArea = dynamic_cast(Layout->itemAtPosition(0, 0)->widget()); + Layout->replaceWidget(DockArea, Splitter); + Splitter->addWidget(DockArea); + inserDockAreaIntoSplitter(Splitter, NewDockArea, InsertParam.second); + } + else + { + QSplitter* Splitter = _this->findChild(QString(), Qt::FindDirectChildrenOnly); + if (Splitter->orientation() == InsertParam.first) + { + inserDockAreaIntoSplitter(Splitter, NewDockArea, InsertParam.second); + } + else + { + QSplitter* NewSplitter = internal::newSplitter(InsertParam.first); + if (InsertParam.second) + { + QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter); + NewSplitter->addWidget(Splitter); + NewSplitter->addWidget(NewDockArea); + delete li; + } + else + { + NewSplitter->addWidget(NewDockArea); + QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter); + NewSplitter->addWidget(Splitter); + delete li; + } + } + } + + DockAreas.append(NewDockArea); +} + + +//============================================================================ +void DockContainerWidgetPrivate::dockWidgetIntoDockArea(DockWidgetArea area, + CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget) +{ + +} + + //============================================================================ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *parent) : QFrame(parent), d(new DockContainerWidgetPrivate(this)) { + setStyleSheet("background: green;"); d->DockManager = DockManager; d->Layout = new QGridLayout(); @@ -80,9 +169,13 @@ CDockContainerWidget::~CDockContainerWidget() void CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget) { - if (d->DockAreas.isEmpty()) + if (DockAreaWidget) { - + d->dockWidgetIntoDockArea(area, Dockwidget, DockAreaWidget); + } + else + { + d->dockWidgetIntoContainer(area, Dockwidget); } } diff --git a/AdvancedDockingSystem/src/v2/DockManager.cpp b/AdvancedDockingSystem/src/v2/DockManager.cpp index 1764b2c..555304e 100644 --- a/AdvancedDockingSystem/src/v2/DockManager.cpp +++ b/AdvancedDockingSystem/src/v2/DockManager.cpp @@ -1,8 +1,9 @@ + //============================================================================ /// \file DockManager.cpp /// \author Uwe Kindler -/// \date 23.02.2017 -/// \brief Implementation of CDockManager +/// \date 26.02.2017 +/// \brief Implementation of CDockManager class //============================================================================ //============================================================================ @@ -10,9 +11,49 @@ //============================================================================ #include "DockManager.h" +#include + namespace ads { +/** + * Private data class of CDockManager class (pimpl) + */ +struct DockManagerPrivate +{ + CDockManager* _this; + /** + * 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(parent); + if (MainWindow) + { + MainWindow->setCentralWidget(this); + } +} + +//============================================================================ +CDockManager::~CDockManager() +{ + delete d; +} } // namespace ads //--------------------------------------------------------------------------- diff --git a/AdvancedDockingSystem/src/v2/DockManager.h b/AdvancedDockingSystem/src/v2/DockManager.h index ad73772..e6d818f 100644 --- a/AdvancedDockingSystem/src/v2/DockManager.h +++ b/AdvancedDockingSystem/src/v2/DockManager.h @@ -3,8 +3,8 @@ //============================================================================ /// \file DockManager.h /// \author Uwe Kindler -/// \date 23.02.2017 -/// \brief Declaration of CDockManager +/// \date 26.02.2017 +/// \brief Declaration of CDockManager class //============================================================================ //============================================================================ @@ -14,15 +14,31 @@ namespace ads { +struct DockManagerPrivate; /** - * @brief - */ + * The central dock manager that maintains the complete docking system + **/ class CDockManager : public CDockContainerWidget { -}; + Q_OBJECT +private: + DockManagerPrivate* d; ///< private data (pimpl) + friend class DockManagerPrivate; +protected: +public: + /** + * Default Constructor. + * If the given parent is a QMainWindow, the dck manager sets itself as the + * central widget + */ + CDockManager(QWidget* parent = 0); + /** + * Virtual Destructor + */ + virtual ~CDockManager(); +}; // class DockManager } // namespace ads - -//--------------------------------------------------------------------------- +//----------------------------------------------------------------------------- #endif // DockManagerH diff --git a/AdvancedDockingSystem/src/v2/DockWidget.cpp b/AdvancedDockingSystem/src/v2/DockWidget.cpp index 77d49ec..251520a 100644 --- a/AdvancedDockingSystem/src/v2/DockWidget.cpp +++ b/AdvancedDockingSystem/src/v2/DockWidget.cpp @@ -1,8 +1,9 @@ + //============================================================================ /// \file DockWidget.cpp /// \author Uwe Kindler -/// \date 23.02.2017 -/// \brief Implementation of CDockWidget +/// \date 26.02.2017 +/// \brief Implementation of CDockWidget class //============================================================================ //============================================================================ @@ -10,9 +11,72 @@ //============================================================================ #include "DockWidget.h" +#include + namespace ads { +/** + * Private data class of CDockWidget class (pimpl) + */ +struct DockWidgetPrivate +{ + CDockWidget* _this; + QBoxLayout* Layout; + QWidget* Widget = nullptr; + /** + * Private data constructor + */ + DockWidgetPrivate(CDockWidget* _public); +}; +// struct DockWidgetPrivate + +//============================================================================ +DockWidgetPrivate::DockWidgetPrivate(CDockWidget* _public) : + _this(_public) +{ + +} + +//============================================================================ +CDockWidget::CDockWidget(const QString &title, QWidget *parent) : + QFrame(parent), + d(new DockWidgetPrivate(this)) +{ + d->Layout = new QBoxLayout(QBoxLayout::TopToBottom); + d->Layout->setContentsMargins(0, 0, 0, 0); + d->Layout->setSpacing(0); + setLayout(d->Layout); +} + +//============================================================================ +CDockWidget::~CDockWidget() +{ + delete d; +} + + +//============================================================================ +void CDockWidget::setWidget(QWidget* widget) +{ + if (d->Widget) + { + d->Layout->replaceWidget(d->Widget, widget); + } + else + { + d->Layout->addWidget(widget); + } + + d->Widget = widget; +} + + +//============================================================================ +QWidget* CDockWidget::widget() const +{ + return d->Widget; +} } // namespace ads //--------------------------------------------------------------------------- diff --git a/AdvancedDockingSystem/src/v2/DockWidget.h b/AdvancedDockingSystem/src/v2/DockWidget.h index f094b9d..d7018c9 100644 --- a/AdvancedDockingSystem/src/v2/DockWidget.h +++ b/AdvancedDockingSystem/src/v2/DockWidget.h @@ -3,8 +3,8 @@ //============================================================================ /// \file DockWidget.h /// \author Uwe Kindler -/// \date 23.02.2017 -/// \brief Declaration of CDockWidget +/// \date 26.02.2017 +/// \brief Declaration of CDockWidget class //============================================================================ //============================================================================ @@ -14,16 +14,42 @@ namespace ads { +struct DockWidgetPrivate; /** - * @brief + * The QDockWidget class provides a widget that can be docked inside a + * CDockManager or floated as a top-level window on the desktop. */ class CDockWidget : public QFrame { Q_OBJECT -}; +private: + DockWidgetPrivate* d; ///< private data (pimpl) + friend class DockWidgetPrivate; +protected: +public: + /** + * Default Constructor + */ + CDockWidget(const QString &title, QWidget* parent = 0); -} // namespace ads + /** + * Virtual Destructor + */ + virtual ~CDockWidget(); -//--------------------------------------------------------------------------- + /** + * Sets the widget for the dock widget to widget. + */ + void setWidget(QWidget* widget); + + /** + * Returns the widget for the dock widget. This function returns zero if + * the widget has not been set. + */ + QWidget* widget() const; +}; // class DockWidget +} + // namespace ads +//----------------------------------------------------------------------------- #endif // DockWidgetH diff --git a/AdvancedDockingSystem/src/v2/ads_globals.cpp b/AdvancedDockingSystem/src/v2/ads_globals.cpp index 7e1d7d4..61fd2af 100644 --- a/AdvancedDockingSystem/src/v2/ads_globals.cpp +++ b/AdvancedDockingSystem/src/v2/ads_globals.cpp @@ -12,11 +12,14 @@ #include #include +#include "ads_globals.h" + namespace ads { namespace internal { +//============================================================================ QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent) { QSplitter* s = new QSplitter(orientation, parent); @@ -26,6 +29,22 @@ QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent) return s; } +//============================================================================ +QPair dockAreaInsertParameters(DockWidgetArea Area) +{ + switch (Area) + { + case TopDockWidgetArea: return QPair(Qt::Vertical, false); + case RightDockWidgetArea: return QPair(Qt::Horizontal, true); + case CenterDockWidgetArea: + case BottomDockWidgetArea: return QPair(Qt::Vertical, true); + case LeftDockWidgetArea: return QPair(Qt::Horizontal, false); + default: QPair(Qt::Vertical, false); + } // switch (Area) + + return QPair(Qt::Vertical, false); +} + } // namespace internal } // namespace ads diff --git a/AdvancedDockingSystem/src/v2/ads_globals.h b/AdvancedDockingSystem/src/v2/ads_globals.h index 6f1f8e3..a8ea2e5 100644 --- a/AdvancedDockingSystem/src/v2/ads_globals.h +++ b/AdvancedDockingSystem/src/v2/ads_globals.h @@ -11,6 +11,8 @@ //============================================================================ // INCLUDES //============================================================================ +#include + class QSplitter; namespace ads @@ -24,8 +26,8 @@ enum DockWidgetArea BottomDockWidgetArea = 0x08, CenterDockWidgetArea = 0x10, - OuterAreas = TopDockWidgetArea | LeftDockWidgetArea | RightDockWidgetArea | BottomDockWidgetArea, - AllAreas = OuterAreas | CenterDockWidgetArea + OuterDockAreas = TopDockWidgetArea | LeftDockWidgetArea | RightDockWidgetArea | BottomDockWidgetArea, + AllDockAreas = OuterDockAreas | CenterDockWidgetArea }; Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea) @@ -34,7 +36,12 @@ namespace internal /** * Helper function to create new splitter widgets */ -QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent); +QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = 0); + +/** + * Returns the insertion parameters for the given dock area + */ +QPair dockAreaInsertParameters(DockWidgetArea Area); } // namespace internal } // namespace ads diff --git a/AdvancedDockingSystem/src/v2/v2.pri b/AdvancedDockingSystem/src/v2/v2.pri new file mode 100644 index 0000000..968925a --- /dev/null +++ b/AdvancedDockingSystem/src/v2/v2.pri @@ -0,0 +1,20 @@ +DEPENDPATH *= $$PWD +HEADERS += \ + $$PWD/ads_globals.h \ + $$PWD/DockAreaWidget.h \ + $$PWD/DockContainerWidget.h \ + $$PWD/DockManager.h \ + $$PWD/DockWidget.h \ + $$PWD/DockWidgetTitleBar.h \ + $$PWD/FloatingDockContainer.h + + + +SOURCES += \ + $$PWD/ads_globals.cpp \ + $$PWD/DockAreaWidget.cpp \ + $$PWD/DockContainerWidget.cpp \ + $$PWD/DockManager.cpp \ + $$PWD/DockWidget.cpp \ + $$PWD/DockWidgetTitleBar.cpp \ + $$PWD/FloatingDockContainer.cpp \ No newline at end of file diff --git a/AdvancedDockingSystemDemo/src/mainwindow.h b/AdvancedDockingSystemDemo/src/mainwindow.h index 0405619..bda08c3 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.h +++ b/AdvancedDockingSystemDemo/src/mainwindow.h @@ -19,7 +19,6 @@ public: virtual ~MainWindow(); public slots: - void showSectionContentListDialog(); private slots: void onActiveTabChanged(const ads::SectionContent::RefPtr& sc, bool active); diff --git a/AdvancedDockingSystemDemo_v2/AdvancedDockingSystemDemo_v2.pro b/AdvancedDockingSystemDemo_v2/AdvancedDockingSystemDemo_v2.pro new file mode 100644 index 0000000..abcf835 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/AdvancedDockingSystemDemo_v2.pro @@ -0,0 +1,40 @@ +include($$(cetoni_repository)/build/qt/qtprojectsettings/common.pri) + +TARGET = AdvancedDockingSystemDemo_v2 + +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 4): DEFINES += ADS_NAMESPACE_ENABLED + +windows { + # MinGW + *-g++* { + QMAKE_CXXFLAGS += -std=c++11 + } + # MSVC + *-msvc* { + } +} + +SOURCES += \ + src/main.cpp \ + src/mainwindow.cpp + + +HEADERS += \ + src/mainwindow.h + +FORMS += \ + src/mainwindow.ui + + +# Dependency: AdvancedDockingSystem (shared) +win32:CONFIG(release, debug|release): LIBS += -l$$qtLinkLibrary(AdvancedDockingSystem) +else:win32:CONFIG(debug, debug|release): LIBS += -l$$qtLinkLibrary(AdvancedDockingSystem) +else:unix: LIBS += -L$$OUT_PWD/../AdvancedDockingSystem/ -lAdvancedDockingSystem + +INCLUDEPATH += $$PWD/../AdvancedDockingSystem/src \ + $$PWD/../AdvancedDockingSystem/src/v2 + +DEPENDPATH += $$PWD/../AdvancedDockingSystem/src \ + $$PWD/../AdvancedDockingSystem/src/v2 diff --git a/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListModel.cpp b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListModel.cpp new file mode 100644 index 0000000..4f4941c --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListModel.cpp @@ -0,0 +1,90 @@ +#include "SectionContentListModel.h" + +SectionContentListModel::SectionContentListModel(QObject* parent) : + QAbstractTableModel(parent) +{ + _headers.insert(UidColumn, "UID"); + _headers.insert(UniqueNameColumn, "Unique Name"); + _headers.insert(TitleColumn, "Title"); + _headers.insert(VisibleColumn, "Visible"); +} + +SectionContentListModel::~SectionContentListModel() +{ +} + +void SectionContentListModel::init(ads::CMainContainerWidget* cw) +{ + beginResetModel(); + _cw = cw; + _contents = _cw->contents(); + endResetModel(); +} + +int SectionContentListModel::columnCount(const QModelIndex& parent) const +{ + Q_UNUSED(parent) + return _headers.count(); +} + +QVariant SectionContentListModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + return _headers.value(section); + return QVariant(); +} + +int SectionContentListModel::rowCount(const QModelIndex& parent) const +{ + Q_UNUSED(parent) + return _contents.count(); +} + +QVariant SectionContentListModel::data(const QModelIndex& index, int role) const +{ + if (!index.isValid() || index.row() > rowCount(index) - 1) + return QVariant(); + + const ads::SectionContent::RefPtr sc = _contents.at(index.row()); + if (sc.isNull()) + return QVariant(); + + switch (role) + { + case Qt::DisplayRole: + { + switch (index.column()) + { + case UidColumn: + return sc->uid(); + case UniqueNameColumn: + return sc->uniqueName(); + case TitleColumn: + return sc->title(); + case VisibleColumn: + return _cw->isSectionContentVisible(sc); + } + } + } + return QVariant(); +} + +bool SectionContentListModel::removeRows(int row, int count, const QModelIndex& parent) +{ + if (row > rowCount(parent) - 1) + return false; + + const int first = row; + const int last = row + count - 1; + beginRemoveRows(parent, first, last); + + for (int i = last; i >= first; --i) + { + const ads::SectionContent::RefPtr sc = _contents.at(i); + _cw->removeSectionContent(sc); + _contents.removeAt(i); + } + + endRemoveRows(); + return true; +} diff --git a/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListModel.h b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListModel.h new file mode 100644 index 0000000..b066302 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListModel.h @@ -0,0 +1,46 @@ +#ifndef ADS_SECTIONCONTENTMODEL_H +#define ADS_SECTIONCONTENTMODEL_H + +#include +#include +#include +#include +#include "../../../AdvancedDockingSystem/src/SectionContent.h" +#include "MainContainerWidget.h" +#include "API.h" +namespace ads {class CMainContainerWidget;} + + +class SectionContentListModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + enum Column + { + UidColumn, + UniqueNameColumn, + TitleColumn, + VisibleColumn + }; + + SectionContentListModel(QObject* parent); + virtual ~SectionContentListModel(); + void init(ads::CMainContainerWidget* cw); + + virtual int columnCount(const QModelIndex &parent) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; + + virtual int rowCount(const QModelIndex &parent) const; + virtual QVariant data(const QModelIndex &index, int role) const; + + virtual bool removeRows(int row, int count, const QModelIndex &parent); + +private: + QHash _headers; + + ads::CMainContainerWidget* _cw; + QList _contents; +}; + +#endif diff --git a/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.cpp b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.cpp new file mode 100644 index 0000000..a4b060e --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.cpp @@ -0,0 +1,38 @@ +#include "SectionContentListWidget.h" +#include "SectionContentListModel.h" + + +SectionContentListWidget::SectionContentListWidget(QWidget* parent) : + QDialog(parent) +{ + _ui.setupUi(this); + connect(_ui.deleteButton, SIGNAL(clicked(bool)), this, SLOT(onDeleteButtonClicked())); +} + +void SectionContentListWidget::setValues(const SectionContentListWidget::Values& v) +{ + _v = v; + + // Reset + QAbstractItemModel* m = _ui.tableView->model(); + if (m) + { + _ui.tableView->setModel(NULL); + delete m; + m = NULL; + } + + // Fill. + SectionContentListModel* sclm = new SectionContentListModel(this); + sclm->init(_v.cw); + _ui.tableView->setModel(sclm); +} + +void SectionContentListWidget::onDeleteButtonClicked() +{ + const QModelIndex mi = _ui.tableView->currentIndex(); + if (!mi.isValid()) + return; + + _ui.tableView->model()->removeRows(mi.row(), 1, mi.parent()); +} diff --git a/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.h b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.h new file mode 100644 index 0000000..08653b8 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.h @@ -0,0 +1,33 @@ +#ifndef SECTIONCONTENTLISTWIDGET +#define SECTIONCONTENTLISTWIDGET + +#include +#include "../../../AdvancedDockingSystem/src/SectionContent.h" +#include "MainContainerWidget.h" +#include "ui_SectionContentListWidget.h" + +#include "API.h" + +class SectionContentListWidget : public QDialog +{ + Q_OBJECT + +public: + class Values + { + public: + ads::CMainContainerWidget* cw; + }; + + SectionContentListWidget(QWidget* parent); + void setValues(const Values& v); + +private slots: + void onDeleteButtonClicked(); + +private: + Ui::SectionContentListWidgetForm _ui; + Values _v; +}; + +#endif diff --git a/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.ui b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.ui new file mode 100644 index 0000000..e14ed87 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/dialogs/SectionContentListWidget.ui @@ -0,0 +1,61 @@ + + + SectionContentListWidgetForm + + + + 0 + 0 + 522 + 258 + + + + Form + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + + + + + + + Delete + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/AdvancedDockingSystemDemo_v2/src/main.cpp b/AdvancedDockingSystemDemo_v2/src/main.cpp new file mode 100644 index 0000000..cf61070 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/main.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "mainwindow.h" + +static void initStyleSheet(QApplication& a) +{ + //Q_INIT_RESOURCE(ads); // If static linked. + QFile f(":ads/stylesheets/default-windows.css"); + if (f.open(QFile::ReadOnly)) + { + const QByteArray ba = f.readAll(); + f.close(); + a.setStyleSheet(QString(ba)); + } +} + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + a.setQuitOnLastWindowClosed(true); + initStyleSheet(a); + + MainWindow mw; + mw.show(); + return a.exec(); +} diff --git a/AdvancedDockingSystemDemo_v2/src/mainwindow.cpp b/AdvancedDockingSystemDemo_v2/src/mainwindow.cpp new file mode 100644 index 0000000..51a4c36 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/mainwindow.cpp @@ -0,0 +1,91 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DockManager.h" +#include "DockWidget.h" + + +/////////////////////////////////////////////////////////////////////// + +static int CONTENT_COUNT = 0; + +static ads::CDockWidget* createLongTextLabelDockWidget(ads::CDockManager* DockManager) +{ + QLabel* l = new QLabel(); + l->setWordWrap(true); + l->setAlignment(Qt::AlignTop | Qt::AlignLeft); + l->setText(QString("Lorem Ipsum ist ein einfacher Demo-Text für die Print- " + "und Schriftindustrie. Lorem Ipsum ist in der Industrie bereits der " + "Standard Demo-Text seit 1500, als ein unbekannter Schriftsteller eine " + "Hand voll Wörter nahm und diese durcheinander warf um ein Musterbuch zu " + "erstellen. Es hat nicht nur 5 Jahrhunderte überlebt, sondern auch in " + "Spruch in die elektronische Schriftbearbeitung geschafft (bemerke, nahezu " + "unverändert). Bekannt wurde es 1960, mit dem erscheinen von Letrase, " + "welches Passagen von Lorem Ipsum enhielt, so wie Desktop Software wie " + "Aldus PageMaker - ebenfalls mit Lorem Ipsum.")); + + ads::CDockWidget* DockWidget = new ads::CDockWidget("DockWidget1"); + DockWidget->setWidget(l); + return DockWidget; +} + +static ads::CDockWidget* createCalendarDockWidget(ads::CDockManager* DockManager) +{ + QCalendarWidget* w = new QCalendarWidget(); + ads::CDockWidget* DockWidget = new ads::CDockWidget("DockWidget1"); + DockWidget->setWidget(w); + return DockWidget; +} + +static ads::CDockWidget* createFileSystemTreeDockWidget(ads::CDockManager* DockManager) +{ + QTreeView* w = new QTreeView(); + w->setFrameShape(QFrame::NoFrame); + QFileSystemModel* m = new QFileSystemModel(w); + m->setRootPath(QDir::currentPath()); + w->setModel(m); + ads::CDockWidget* DockWidget = new ads::CDockWidget("DockWidget1"); + DockWidget->setWidget(w); + return DockWidget; +} + + + +/////////////////////////////////////////////////////////////////////// + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + m_DockManager = new ads::CDockManager(this); + createContent(); + // Default window geometry + resize(800, 600); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + + +void MainWindow::createContent() +{ + m_DockManager->addDockWidget(ads::LeftDockWidgetArea, createCalendarDockWidget(m_DockManager)); + m_DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(m_DockManager)); + m_DockManager->addDockWidget(ads::BottomDockWidgetArea, createFileSystemTreeDockWidget(m_DockManager)); + m_DockManager->addDockWidget(ads::TopDockWidgetArea, createFileSystemTreeDockWidget(m_DockManager)); +} + + diff --git a/AdvancedDockingSystemDemo_v2/src/mainwindow.h b/AdvancedDockingSystemDemo_v2/src/mainwindow.h new file mode 100644 index 0000000..8a30425 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/mainwindow.h @@ -0,0 +1,25 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include "DockManager.h" + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + virtual ~MainWindow(); + +private: + Ui::MainWindow *ui; + ads::CDockManager* m_DockManager; + void createContent(); +}; + +#endif // MAINWINDOW_H diff --git a/AdvancedDockingSystemDemo_v2/src/mainwindow.ui b/AdvancedDockingSystemDemo_v2/src/mainwindow.ui new file mode 100644 index 0000000..9268de9 --- /dev/null +++ b/AdvancedDockingSystemDemo_v2/src/mainwindow.ui @@ -0,0 +1,79 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + 0 + 0 + 400 + 21 + + + + + File + + + + + + View + + + + + + + + About + + + + + + + + + Add SectionContent + + + + + Contents... + + + + + Demo 2 + + + + + Demo 3 + + + + + Exit + + + + + + + diff --git a/build.pro b/build.pro index b83748a..c58974c 100644 --- a/build.pro +++ b/build.pro @@ -3,4 +3,5 @@ TEMPLATE = subdirs SUBDIRS = \ AdvancedDockingSystem \ AdvancedDockingSystemDemo \ + AdvancedDockingSystemDemo_v2 \ AdvancedDockingSystemUnitTests