Refactors directory structure and file naming.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "ads.h"
|
||||
#include "ads/API.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSplitter>
|
||||
|
||||
#include "container_widget.h"
|
||||
#include "ads/ContainerWidget.h"
|
||||
|
||||
const QString DragData::MIMETYPE = QString("qt/ads-dragdata");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "container_widget.h"
|
||||
#include "ads/ContainerWidget.h"
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "drop_overlay.h"
|
||||
#include "ads/DropOverlay.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPointer>
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "floating_widget.h"
|
||||
#include "ads/FloatingWidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QBoxLayout>
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QStyle>
|
||||
|
||||
#include "container_widget.h"
|
||||
#include "section_title_widget.h"
|
||||
#include "section_content_widget.h"
|
||||
#include "ads/ContainerWidget.h"
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
#include "ads/SectionContentWidget.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "section_content.h"
|
||||
#include "ads/SectionContent.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "section_content_widget.h"
|
||||
#include "ads/SectionContentWidget.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "section_title_widget.h"
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
@@ -16,11 +16,11 @@
|
||||
#include <QParallelAnimationGroup>
|
||||
#endif
|
||||
|
||||
#include "drop_overlay.h"
|
||||
#include "section_content.h"
|
||||
#include "section_widget.h"
|
||||
#include "floating_widget.h"
|
||||
#include "container_widget.h"
|
||||
#include "ads/DropOverlay.h"
|
||||
#include "ads/SectionContent.h"
|
||||
#include "ads/SectionWidget.h"
|
||||
#include "ads/FloatingWidget.h"
|
||||
#include "ads/ContainerWidget.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "section_widget.h"
|
||||
#include "ads/SectionWidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
@@ -14,12 +14,12 @@
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#endif
|
||||
|
||||
#include "drop_overlay.h"
|
||||
#include "section_content.h"
|
||||
#include "section_title_widget.h"
|
||||
#include "section_content_widget.h"
|
||||
#include "floating_widget.h"
|
||||
#include "container_widget.h"
|
||||
#include "ads/DropOverlay.h"
|
||||
#include "ads/SectionContent.h"
|
||||
#include "ads/SectionTitleWidget.h"
|
||||
#include "ads/SectionContentWidget.h"
|
||||
#include "ads/FloatingWidget.h"
|
||||
#include "ads/ContainerWidget.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
#ifndef ADS_H
|
||||
#define ADS_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include <QIODevice>
|
||||
#include <QSharedPointer>
|
||||
class QSplitter;
|
||||
|
||||
/*
|
||||
* ADS - Advanced Docking System for Qt
|
||||
* Developed by Manuel Freiholz
|
||||
*/
|
||||
|
||||
#define ADS_NAMESPACE_BEGIN namespace ads {
|
||||
#define ADS_NAMESPACE_END }
|
||||
|
||||
// Width of the native window frame border (based on OS).
|
||||
#define ADS_WINDOW_FRAME_BORDER_WIDTH 7
|
||||
|
||||
// Indicates whether ADS should include animations.
|
||||
//#define ADS_ANIMATIONS_ENABLED 1
|
||||
//#define ADS_ANIMATION_DURATION 150
|
||||
|
||||
// DragData contains information about dragged contents (SectionContent).
|
||||
// e.g. from where is has been dragged.
|
||||
class DragData
|
||||
{
|
||||
public:
|
||||
static const QString MIMETYPE;
|
||||
|
||||
QByteArray serialize() const
|
||||
{
|
||||
QByteArray ba;
|
||||
QDataStream out(&ba, QIODevice::WriteOnly);
|
||||
out << contentUid;
|
||||
out << sectionUid;
|
||||
return ba;
|
||||
}
|
||||
|
||||
void deserialize(const QByteArray& bytes)
|
||||
{
|
||||
QDataStream in(bytes);
|
||||
in >> contentUid;
|
||||
in >> sectionUid;
|
||||
}
|
||||
|
||||
QString toString() const
|
||||
{
|
||||
return QString("content-uid=%1; section-uid=%2").arg(contentUid).arg(sectionUid);
|
||||
}
|
||||
|
||||
public:
|
||||
int contentUid;
|
||||
int sectionUid;
|
||||
};
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
enum DropArea
|
||||
{
|
||||
TopDropArea,
|
||||
RightDropArea,
|
||||
BottomDropArea,
|
||||
LeftDropArea,
|
||||
CenterDropArea,
|
||||
InvalidDropArea
|
||||
};
|
||||
|
||||
class InternalContentData
|
||||
{
|
||||
public:
|
||||
InternalContentData() : titleWidget(0), contentWidget(0) {}
|
||||
QSharedPointer<class SectionContent> content;
|
||||
class SectionTitleWidget* titleWidget;
|
||||
class SectionContentWidget* contentWidget;
|
||||
};
|
||||
|
||||
class ContainerWidget* findParentContainerWidget(class QWidget* w);
|
||||
class SectionWidget* findParentSectionWidget(class QWidget* w);
|
||||
QSplitter* findParentSplitter(class QWidget* w);
|
||||
QSplitter* findImmediateSplitter(class QWidget* w);
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
|
||||
#endif // ADC_H
|
||||
@@ -1,73 +0,0 @@
|
||||
#ifndef ADS_CONTAINERWIDGET_H
|
||||
#define ADS_CONTAINERWIDGET_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QPoint>
|
||||
#include <QList>
|
||||
class QSplitter;
|
||||
class QMenu;
|
||||
|
||||
#include "ads.h"
|
||||
#include "section_content.h"
|
||||
#include "section_widget.h"
|
||||
#include "floating_widget.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
// ContainerWidget is the main container to provide the docking
|
||||
// functionality. It manages mulitple Sections and all possible areas.
|
||||
class ContainerWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
|
||||
|
||||
friend class SectionWidget;
|
||||
friend class FloatingWidget;
|
||||
|
||||
public:
|
||||
explicit ContainerWidget(QWidget *parent = NULL);
|
||||
|
||||
Qt::Orientation orientation() const;
|
||||
void setOrientation(Qt::Orientation orientation);
|
||||
|
||||
void dropContent(const InternalContentData& data, SectionWidget* targetSection, DropArea area);
|
||||
|
||||
void addSection(SectionWidget* section);
|
||||
void splitSections(SectionWidget* section1, SectionWidget* section2, Qt::Orientation orientation = Qt::Horizontal);
|
||||
SectionWidget* sectionAt(const QPoint& pos) const;
|
||||
|
||||
// Drop areas for the ContainerWidget
|
||||
QRect outerTopDropRect() const;
|
||||
QRect outerRightDropRect() const;
|
||||
QRect outerBottomDropRect() const;
|
||||
QRect outerLeftDropRect() const;
|
||||
|
||||
// Geometry and state serialization
|
||||
QByteArray saveGeometry() const;
|
||||
bool restoreGeometry(const QByteArray& data);
|
||||
|
||||
QMenu* createContextMenu() const;
|
||||
|
||||
private: // Make private!
|
||||
|
||||
|
||||
signals:
|
||||
void orientationChanged();
|
||||
|
||||
public:
|
||||
// Existing sections.
|
||||
// SectionWidgets are always visible.
|
||||
QList<SectionWidget*> _sections;
|
||||
|
||||
// All currently active Floatingwidgets.
|
||||
QList<FloatingWidget*> _floatingWidgets;
|
||||
|
||||
// Layout stuff
|
||||
QGridLayout* _mainLayout;
|
||||
Qt::Orientation _orientation; ///< Default orientation of new sections.
|
||||
QSplitter* _splitter; ///< Default/main splitter.
|
||||
};
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
#endif
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifndef DROP_OVERLAY_H
|
||||
#define DROP_OVERLAY_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QRect>
|
||||
|
||||
#include "ads.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
// DropOverlay paints a translucent rectangle over another widget.
|
||||
// It can also show different types of drop area indicators.
|
||||
class DropOverlay : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DropOverlay(QWidget* parent);
|
||||
virtual ~DropOverlay();
|
||||
DropArea cursorLocation() const;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *e);
|
||||
virtual void resizeEvent(QResizeEvent* e);
|
||||
virtual void moveEvent(QMoveEvent* e);
|
||||
|
||||
private:
|
||||
class DropSplitAreas* _splitAreas;
|
||||
};
|
||||
|
||||
// AbstractDropAreas is used as base for drop area indicator widgets.
|
||||
class AbstractDropAreas : public QWidget
|
||||
{
|
||||
public:
|
||||
AbstractDropAreas(QWidget* parent) : QWidget(parent) {}
|
||||
virtual DropArea cursorLocation() const = 0;
|
||||
};
|
||||
|
||||
// DropSplitAreas shows a cross with 5 different drop area possibilities.
|
||||
class DropSplitAreas : public AbstractDropAreas
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DropSplitAreas(QWidget* parent);
|
||||
virtual DropArea cursorLocation() const;
|
||||
|
||||
private:
|
||||
QWidget* _top;
|
||||
QWidget* _right;
|
||||
QWidget* _bottom;
|
||||
QWidget* _left;
|
||||
QWidget* _center;
|
||||
};
|
||||
|
||||
|
||||
DropArea showDropOverlay(QWidget* parent);
|
||||
void showDropOverlay(QWidget* parent, const QRect& areaRect);
|
||||
void hideDropOverlay();
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef FLOATINGWIDGET_H
|
||||
#define FLOATINGWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
|
||||
#include "ads.h"
|
||||
#include "section_content.h"
|
||||
|
||||
class QBoxLayout;
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
class ContainerWidget;
|
||||
class SectionTitleWidget;
|
||||
class SectionContentWidget;
|
||||
|
||||
// FloatingWidget holds and displays SectionContent as a floating window.
|
||||
// It can be resized, moved and dropped back into a SectionWidget.
|
||||
class FloatingWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FloatingWidget(ContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent = nullptr);
|
||||
virtual ~FloatingWidget();
|
||||
|
||||
InternalContentData takeContent();
|
||||
SectionContent::RefPtr content() const { return _content; }
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* e);
|
||||
|
||||
private:
|
||||
ContainerWidget* _container;
|
||||
SectionContent::RefPtr _content;
|
||||
SectionTitleWidget* _titleWidget;
|
||||
SectionContentWidget* _contentWidget;
|
||||
|
||||
QBoxLayout* _titleLayout;
|
||||
};
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
#endif
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef SECTIONCONTENT_H
|
||||
#define SECTIONCONTENT_H
|
||||
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
#include <QHash>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "ads.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
class SectionContent
|
||||
{
|
||||
public:
|
||||
typedef QSharedPointer<SectionContent> RefPtr;
|
||||
|
||||
SectionContent(QWidget* title, QWidget* content, const QString& uniqueName = QString()); ///< Do not use!
|
||||
virtual ~SectionContent();
|
||||
|
||||
int uid() const;
|
||||
QString uniqueName() const;
|
||||
QWidget* titleWidget() const;
|
||||
QWidget* contentWidget() const;
|
||||
|
||||
static RefPtr newSectionContent(QWidget* title, QWidget* content);
|
||||
static RefPtr newSectionContent(const QString& title, QWidget* content);
|
||||
|
||||
public:
|
||||
const int _uid;
|
||||
const QString _uniqueName;
|
||||
QPointer<QWidget> _title;
|
||||
QPointer<QWidget> _content;
|
||||
|
||||
static int NextUid;
|
||||
static QHash<int, SectionContent*> LookupMap;
|
||||
};
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
#endif
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef SECTION_CONTENT_WIDGET_H
|
||||
#define SECTION_CONTENT_WIDGET_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include "ads.h"
|
||||
#include "section_content.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
class SectionWidget;
|
||||
|
||||
class SectionContentWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SectionContentWidget(SectionContent::RefPtr c, QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
SectionContent::RefPtr _content;
|
||||
};
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
#ifndef SECTION_TITLE_WIDGET_H
|
||||
#define SECTION_TITLE_WIDGET_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QPoint>
|
||||
#include "ads.h"
|
||||
#include "section_content.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
class SectionWidget;
|
||||
class FloatingWidget;
|
||||
|
||||
class SectionTitleWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool activeTab MEMBER _activeTab NOTIFY activeTabChanged)
|
||||
|
||||
friend class SectionWidget;
|
||||
|
||||
SectionContent::RefPtr _content;
|
||||
|
||||
// Drag & Drop (Floating)
|
||||
QPointer<FloatingWidget> _fw;
|
||||
QPoint _dragStartPos;
|
||||
|
||||
// Drag & Drop (Title/Tabs)
|
||||
bool _tabMoving;
|
||||
|
||||
// Property values
|
||||
bool _activeTab;
|
||||
|
||||
public:
|
||||
SectionTitleWidget(SectionContent::RefPtr content, QWidget* parent);
|
||||
|
||||
bool isActiveTab() const;
|
||||
void setActiveTab(bool active);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent* ev);
|
||||
virtual void mouseReleaseEvent(QMouseEvent* ev);
|
||||
virtual void mouseMoveEvent(QMouseEvent* ev);
|
||||
|
||||
signals:
|
||||
void activeTabChanged();
|
||||
void clicked();
|
||||
};
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
#endif
|
||||
@@ -1,76 +0,0 @@
|
||||
#ifndef SECTION_WIDGET_H
|
||||
#define SECTION_WIDGET_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QFrame>
|
||||
|
||||
#include "ads.h"
|
||||
#include "section_content.h"
|
||||
|
||||
class QBoxLayout;
|
||||
class QStackedLayout;
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
|
||||
class ContainerWidget;
|
||||
class SectionTitleWidget;
|
||||
class SectionContentWidget;
|
||||
|
||||
// SectionWidget manages multiple instances of SectionContent.
|
||||
// It displays a title TAB, which is clickable and will switch to
|
||||
// the contents associated to the title when clicked.
|
||||
class SectionWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SectionWidget(ContainerWidget* parent);
|
||||
virtual ~SectionWidget();
|
||||
|
||||
int uid() const;
|
||||
ContainerWidget* containerWidget() const;
|
||||
|
||||
QRect titleAreaGeometry() const;
|
||||
QRect contentAreaGeometry() const;
|
||||
|
||||
QList<SectionContent::RefPtr> contents() const { return _contents; }
|
||||
void addContent(SectionContent::RefPtr c);
|
||||
void addContent(const InternalContentData& data, bool autoActivate);
|
||||
InternalContentData take(int uid, bool del = true);
|
||||
int indexOfContent(SectionContent::RefPtr c) const;
|
||||
int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = NULL) const;
|
||||
|
||||
void moveContent(int from, int to);
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent*);
|
||||
|
||||
private slots:
|
||||
void onSectionTitleClicked();
|
||||
|
||||
private:
|
||||
const int _uid;
|
||||
|
||||
ContainerWidget* _container;
|
||||
QList<SectionContent::RefPtr> _contents;
|
||||
QList<SectionTitleWidget*> _sectionTitles;
|
||||
QList<SectionContentWidget*> _sectionContents;
|
||||
|
||||
QBoxLayout *_tabsLayout;
|
||||
QStackedLayout *_contentsLayout;
|
||||
|
||||
QPoint _mousePressPoint;
|
||||
SectionContent::RefPtr _mousePressContent;
|
||||
SectionTitleWidget* _mousePressTitleWidget;
|
||||
|
||||
static int NextUid;
|
||||
static QHash<int, SectionWidget*> LookupMap;
|
||||
};
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
#endif
|
||||
Reference in New Issue
Block a user