From 03f67cd6bdc84da0c42f37acd73fe568a054084f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 8 Jul 2014 12:39:12 +0200 Subject: [PATCH] moved low level widgets from CSVWorld into a separate namespace/directory --- apps/opencs/CMakeLists.txt | 18 +++++++++++------- apps/opencs/view/render/scenewidget.cpp | 6 +++--- apps/opencs/view/render/scenewidget.hpp | 4 ++-- apps/opencs/view/render/worldspacewidget.cpp | 11 ++++++----- apps/opencs/view/render/worldspacewidget.hpp | 4 ++-- .../view/{world => widget}/scenetool.cpp | 4 ++-- .../view/{world => widget}/scenetool.hpp | 6 +++--- .../view/{world => widget}/scenetoolbar.cpp | 8 ++++---- .../view/{world => widget}/scenetoolbar.hpp | 6 +++--- .../view/{world => widget}/scenetoolmode.cpp | 8 ++++---- .../view/{world => widget}/scenetoolmode.hpp | 6 +++--- apps/opencs/view/world/previewsubview.cpp | 8 ++++---- apps/opencs/view/world/scenesubview.cpp | 18 ++++++++++-------- apps/opencs/view/world/scenesubview.hpp | 13 +++++++++---- 14 files changed, 66 insertions(+), 54 deletions(-) rename apps/opencs/view/{world => widget}/scenetool.cpp (77%) rename apps/opencs/view/{world => widget}/scenetool.hpp (81%) rename apps/opencs/view/{world => widget}/scenetoolbar.cpp (66%) rename apps/opencs/view/{world => widget}/scenetoolbar.hpp (83%) rename apps/opencs/view/{world => widget}/scenetoolmode.cpp (82%) rename apps/opencs/view/{world => widget}/scenetoolmode.hpp (88%) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 288e0394c..5d8d99f27 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -59,8 +59,17 @@ opencs_hdrs_noqt (view/doc opencs_units (view/world table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator - cellcreator referenceablecreator referencecreator scenesubview scenetoolbar scenetool - scenetoolmode infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable + cellcreator referenceablecreator referencecreator scenesubview + infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable + ) + +opencs_units_noqt (view/world + subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate + scripthighlighter idvalidator dialoguecreator + ) + +opencs_units (view/widget + scenetoolbar scenetool scenetoolmode ) opencs_units (view/render @@ -73,11 +82,6 @@ opencs_units_noqt (view/render lightingbright object cell ) -opencs_units_noqt (view/world - subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate - scripthighlighter idvalidator dialoguecreator - ) - opencs_units (view/tools reportsubview diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 76f6db385..3728dd72d 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -11,7 +11,7 @@ #include #include -#include "../world/scenetoolmode.hpp" +#include "../widget/scenetoolmode.hpp" #include "navigation.hpp" #include "lighting.hpp" @@ -54,9 +54,9 @@ namespace CSVRender timer->start (20); /// \todo make this configurable } - CSVWorld::SceneToolMode *SceneWidget::makeLightingSelector (CSVWorld::SceneToolbar *parent) + CSVWidget::SceneToolMode *SceneWidget::makeLightingSelector (CSVWidget::SceneToolbar *parent) { - CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent); + CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); tool->addButton (":door.png", "day"); /// \todo replace icons tool->addButton (":GMST.png", "night"); diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index f6b41942f..8b01e7185 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -16,7 +16,7 @@ namespace Ogre class RenderWindow; } -namespace CSVWorld +namespace CSVWidget { class SceneToolMode; class SceneToolbar; @@ -38,7 +38,7 @@ namespace CSVRender QPaintEngine* paintEngine() const; - CSVWorld::SceneToolMode *makeLightingSelector (CSVWorld::SceneToolbar *parent); + CSVWidget::SceneToolMode *makeLightingSelector (CSVWidget::SceneToolbar *parent); ///< \attention The created tool is not added to the toolbar (via addTool). Doing that /// is the responsibility of the calling function. diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index fee2f0a16..5b3dc57e2 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -7,8 +7,9 @@ #include -#include "../world/scenetoolmode.hpp" -#include +#include "../../model/world/universalid.hpp" + +#include "../widget/scenetoolmode.hpp" CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) : SceneWidget (parent), mDocument(document) @@ -53,10 +54,10 @@ void CSVRender::WorldspaceWidget::selectDefaultNavigationMode() setNavigation (&m1st); } -CSVWorld::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( - CSVWorld::SceneToolbar *parent) +CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( + CSVWidget::SceneToolbar *parent) { - CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent); + CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); tool->addButton (":door.png", "1st"); /// \todo replace icons tool->addButton (":GMST.png", "free"); diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 2af90b0fe..3b96779a8 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -13,7 +13,7 @@ namespace CSMWorld { class UniversalId; } -namespace CSVWorld +namespace CSVWidget { class SceneToolMode; class SceneToolbar; @@ -49,7 +49,7 @@ namespace CSVRender WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0); - CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent); + CSVWidget::SceneToolMode *makeNavigationSelector (CSVWidget::SceneToolbar *parent); ///< \attention The created tool is not added to the toolbar (via addTool). Doing that /// is the responsibility of the calling function. diff --git a/apps/opencs/view/world/scenetool.cpp b/apps/opencs/view/widget/scenetool.cpp similarity index 77% rename from apps/opencs/view/world/scenetool.cpp rename to apps/opencs/view/widget/scenetool.cpp index 612b4c6d3..e498fdf63 100644 --- a/apps/opencs/view/world/scenetool.cpp +++ b/apps/opencs/view/widget/scenetool.cpp @@ -3,7 +3,7 @@ #include "scenetoolbar.hpp" -CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent) +CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent) { setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); setIconSize (QSize (parent->getIconSize(), parent->getIconSize())); @@ -12,7 +12,7 @@ CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent) connect (this, SIGNAL (clicked()), this, SLOT (openRequest())); } -void CSVWorld::SceneTool::openRequest() +void CSVWidget::SceneTool::openRequest() { showPanel (parentWidget()->mapToGlobal (pos())); } diff --git a/apps/opencs/view/world/scenetool.hpp b/apps/opencs/view/widget/scenetool.hpp similarity index 81% rename from apps/opencs/view/world/scenetool.hpp rename to apps/opencs/view/widget/scenetool.hpp index 07e8b58d7..312d8e00c 100644 --- a/apps/opencs/view/world/scenetool.hpp +++ b/apps/opencs/view/widget/scenetool.hpp @@ -1,9 +1,9 @@ -#ifndef CSV_WORLD_SCENETOOL_H -#define CSV_WORLD_SCENETOOL_H +#ifndef CSV_WIDGET_SCENETOOL_H +#define CSV_WIDGET_SCENETOOL_H #include -namespace CSVWorld +namespace CSVWidget { class SceneToolbar; diff --git a/apps/opencs/view/world/scenetoolbar.cpp b/apps/opencs/view/widget/scenetoolbar.cpp similarity index 66% rename from apps/opencs/view/world/scenetoolbar.cpp rename to apps/opencs/view/widget/scenetoolbar.cpp index d60240da7..59a3a1d6e 100644 --- a/apps/opencs/view/world/scenetoolbar.cpp +++ b/apps/opencs/view/widget/scenetoolbar.cpp @@ -5,7 +5,7 @@ #include "scenetool.hpp" -CSVWorld::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) +CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) : QWidget (parent), mButtonSize (buttonSize), mIconSize (buttonSize-6) { setFixedWidth (mButtonSize); @@ -18,17 +18,17 @@ CSVWorld::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) setLayout (mLayout); } -void CSVWorld::SceneToolbar::addTool (SceneTool *tool) +void CSVWidget::SceneToolbar::addTool (SceneTool *tool) { mLayout->addWidget (tool, 0, Qt::AlignTop); } -int CSVWorld::SceneToolbar::getButtonSize() const +int CSVWidget::SceneToolbar::getButtonSize() const { return mButtonSize; } -int CSVWorld::SceneToolbar::getIconSize() const +int CSVWidget::SceneToolbar::getIconSize() const { return mIconSize; } \ No newline at end of file diff --git a/apps/opencs/view/world/scenetoolbar.hpp b/apps/opencs/view/widget/scenetoolbar.hpp similarity index 83% rename from apps/opencs/view/world/scenetoolbar.hpp rename to apps/opencs/view/widget/scenetoolbar.hpp index 731806cc5..0ef84f488 100644 --- a/apps/opencs/view/world/scenetoolbar.hpp +++ b/apps/opencs/view/widget/scenetoolbar.hpp @@ -1,11 +1,11 @@ -#ifndef CSV_WORLD_SCENETOOLBAR_H -#define CSV_WORLD_SCENETOOLBAR_H +#ifndef CSV_WIDGET_SCENETOOLBAR_H +#define CSV_WIDGET_SCENETOOLBAR_H #include class QVBoxLayout; -namespace CSVWorld +namespace CSVWidget { class SceneTool; diff --git a/apps/opencs/view/world/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp similarity index 82% rename from apps/opencs/view/world/scenetoolmode.cpp rename to apps/opencs/view/widget/scenetoolmode.cpp index 73b01ae3a..72efae0df 100644 --- a/apps/opencs/view/world/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -7,7 +7,7 @@ #include "scenetoolbar.hpp" -CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent) +CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent) : SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()) { mPanel = new QFrame (this, Qt::Popup); @@ -19,13 +19,13 @@ CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent) mPanel->setLayout (mLayout); } -void CSVWorld::SceneToolMode::showPanel (const QPoint& position) +void CSVWidget::SceneToolMode::showPanel (const QPoint& position) { mPanel->move (position); mPanel->show(); } -void CSVWorld::SceneToolMode::addButton (const std::string& icon, const std::string& id) +void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) { QPushButton *button = new QPushButton (QIcon (QPixmap (icon.c_str())), "", mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); @@ -42,7 +42,7 @@ void CSVWorld::SceneToolMode::addButton (const std::string& icon, const std::str setIcon (button->icon()); } -void CSVWorld::SceneToolMode::selected() +void CSVWidget::SceneToolMode::selected() { std::map::const_iterator iter = mButtons.find (dynamic_cast (sender())); diff --git a/apps/opencs/view/world/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp similarity index 88% rename from apps/opencs/view/world/scenetoolmode.hpp rename to apps/opencs/view/widget/scenetoolmode.hpp index a156c0c95..175c53f96 100644 --- a/apps/opencs/view/world/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -1,5 +1,5 @@ -#ifndef CSV_WORLD_SCENETOOL_MODE_H -#define CSV_WORLD_SCENETOOL_MODE_H +#ifndef CSV_WIDGET_SCENETOOL_MODE_H +#define CSV_WIDGET_SCENETOOL_MODE_H #include "scenetool.hpp" @@ -7,7 +7,7 @@ class QHBoxLayout; -namespace CSVWorld +namespace CSVWidget { class SceneToolbar; diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 49e6d9361..bae0abb8b 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -5,8 +5,8 @@ #include "../render/previewwidget.hpp" -#include "scenetoolbar.hpp" -#include "scenetoolmode.hpp" +#include "../widget/scenetoolbar.hpp" +#include "../widget/scenetoolmode.hpp" CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id) @@ -28,9 +28,9 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo else mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), true, this); - SceneToolbar *toolbar = new SceneToolbar (48+6, this); + CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this); - SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar); + CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar); toolbar->addTool (lightingTool); layout->addWidget (toolbar, 0); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 36cce9ecd..0ff540ec2 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -17,9 +17,11 @@ #include "../render/pagedworldspacewidget.hpp" #include "../render/unpagedworldspacewidget.hpp" +#include "../widget/scenetoolbar.hpp" +#include "../widget/scenetoolmode.hpp" + #include "tablebottombox.hpp" #include "creator.hpp" -#include "scenetoolmode.hpp" CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id), mLayout(new QHBoxLayout), mDocument(document), mScene(NULL), mToolbar(NULL) @@ -95,18 +97,18 @@ void CSVWorld::SceneSubView::makeConnections (CSVRender::PagedWorldspaceWidget* this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&))); } -CSVWorld::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::WorldspaceWidget* widget, widgetType type) +CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::WorldspaceWidget* widget, widgetType type) { - CSVWorld::SceneToolbar* toolbar = new SceneToolbar (48+6, this); + CSVWidget::SceneToolbar* toolbar = new CSVWidget::SceneToolbar (48+6, this); - SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar); + CSVWidget::SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar); toolbar->addTool (navigationTool); - SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); + CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); toolbar->addTool (lightingTool); /* Add buttons specific to the type. For now no need for it. - * + * switch (type) { case widget_Paged: @@ -188,7 +190,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI { CSVRender::PagedWorldspaceWidget* pagedNewWidget = NULL; CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = NULL; - SceneToolbar* toolbar = NULL; + CSVWidget::SceneToolbar* toolbar = NULL; switch (mScene->getDropRequirements(CSVRender::WorldspaceWidget::getDropType(data))) { @@ -217,7 +219,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI } } -void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWorld::SceneToolbar* toolbar) +void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar) { assert(mLayout); diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index b9ecbe931..b9dcdd6a3 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -4,7 +4,6 @@ #include #include "../doc/subview.hpp" -#include "scenetoolbar.hpp" class QModelIndex; @@ -25,6 +24,11 @@ namespace CSVRender class UnpagedWorldspaceWidget; } +namespace CSVWidget +{ + class SceneToolbar; +} + namespace CSVWorld { class Table; @@ -39,7 +43,7 @@ namespace CSVWorld CSVRender::WorldspaceWidget *mScene; QHBoxLayout* mLayout; CSMDoc::Document& mDocument; - SceneToolbar* mToolbar; + CSVWidget::SceneToolbar* mToolbar; public: @@ -59,14 +63,15 @@ namespace CSVWorld void makeConnections(CSVRender::UnpagedWorldspaceWidget* widget); - void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, SceneToolbar* toolbar); + void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar); enum widgetType { widget_Paged, widget_Unpaged }; - SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type); + + CSVWidget::SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type); private slots: