mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 00:26:39 +00:00 
			
		
		
		
	Merge remote-tracking branch 'sirherrbatka/Feature#1274'
Conflicts: apps/opencs/view/world/table.cpp
This commit is contained in:
		
						commit
						7f78c29bb5
					
				
					 22 changed files with 578 additions and 103 deletions
				
			
		| 
						 | 
				
			
			@ -60,7 +60,7 @@ 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
 | 
			
		||||
    scenetoolmode infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
opencs_units (view/render
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -453,7 +453,7 @@ CSMWorld::IdCollection<CSMFilter::Filter>& CSMWorld::Data::getFilters()
 | 
			
		|||
    return mFilters;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
 | 
			
		||||
QAbstractItemModel *CSMWorld::Data::getTableModel (const CSMWorld::UniversalId& id)
 | 
			
		||||
{
 | 
			
		||||
    std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,9 @@
 | 
			
		|||
#include "tablemimedata.hpp"
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
#include "universalid.hpp"
 | 
			
		||||
#include "columnbase.hpp"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -11,7 +14,7 @@ mDocument(document)
 | 
			
		|||
    mObjectsFormats << QString::fromUtf8 (("tabledata/" + id.getTypeName()).c_str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id, const CSMDoc::Document& document) :
 | 
			
		||||
CSMWorld::TableMimeData::TableMimeData (const std::vector< CSMWorld::UniversalId >& id, const CSMDoc::Document& document) :
 | 
			
		||||
    mUniversalId (id), mDocument(document)
 | 
			
		||||
{
 | 
			
		||||
    for (std::vector<UniversalId>::iterator it (mUniversalId.begin()); it != mUniversalId.end(); ++it)
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +36,8 @@ std::string CSMWorld::TableMimeData::getIcon() const
 | 
			
		|||
{
 | 
			
		||||
    if (mUniversalId.empty())
 | 
			
		||||
    {
 | 
			
		||||
        throw ("TableMimeData holds no UniversalId");
 | 
			
		||||
        qDebug()<<"TableMimeData object does not hold any records!"; //because throwing in the event loop tends to be problematic
 | 
			
		||||
        throw("TableMimeData object does not hold any records!");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::string tmpIcon;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +54,7 @@ std::string CSMWorld::TableMimeData::getIcon() const
 | 
			
		|||
 | 
			
		||||
        if (tmpIcon != mUniversalId[i].getIcon())
 | 
			
		||||
        {
 | 
			
		||||
            return ":/multitype.png"; //icon stolen from gnome
 | 
			
		||||
            return ":/multitype.png"; //icon stolen from gnome TODO: get new icon
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        tmpIcon = mUniversalId[i].getIcon();
 | 
			
		||||
| 
						 | 
				
			
			@ -531,4 +535,4 @@ CSMWorld::ColumnBase::Display CSMWorld::TableMimeData::convertEnums (CSMWorld::U
 | 
			
		|||
const CSMDoc::Document* CSMWorld::TableMimeData::getDocumentPtr() const
 | 
			
		||||
{
 | 
			
		||||
    return &mDocument;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ namespace CSMWorld
 | 
			
		|||
        public:
 | 
			
		||||
            TableMimeData(UniversalId id, const CSMDoc::Document& document);
 | 
			
		||||
 | 
			
		||||
            TableMimeData(std::vector<UniversalId>& id, const CSMDoc::Document& document);
 | 
			
		||||
            TableMimeData(const std::vector<UniversalId>& id, const CSMDoc::Document& document);
 | 
			
		||||
 | 
			
		||||
            ~TableMimeData();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -56,6 +56,7 @@ namespace CSMWorld
 | 
			
		|||
            UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const;
 | 
			
		||||
 | 
			
		||||
            static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);
 | 
			
		||||
 | 
			
		||||
            static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type);
 | 
			
		||||
 | 
			
		||||
        private:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -64,6 +64,7 @@ namespace
 | 
			
		|||
        { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_TopicInfo, "TopicInfo", 0 },
 | 
			
		||||
        { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_JournalInfo, "JournalInfo", 0 },
 | 
			
		||||
        { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Cell, "Cell", ":./cell.png" },
 | 
			
		||||
        { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Cell_Missing, "Cell", ":./cell.png" },
 | 
			
		||||
        { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Referenceable, "Referenceables", 0 },
 | 
			
		||||
        { CSMWorld::UniversalId::Class_RefRecord, CSMWorld::UniversalId::Type_Activator, "Activator", ":./activator.png" },
 | 
			
		||||
        { CSMWorld::UniversalId::Class_RefRecord, CSMWorld::UniversalId::Type_Potion, "Potion", ":./potion.png" },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,6 +60,7 @@ namespace CSMWorld
 | 
			
		|||
                Type_Spell,
 | 
			
		||||
                Type_Cells,
 | 
			
		||||
                Type_Cell,
 | 
			
		||||
                Type_Cell_Missing, //For cells that does not exist yet.
 | 
			
		||||
                Type_Referenceables,
 | 
			
		||||
                Type_Referenceable,
 | 
			
		||||
                Type_Activator,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,8 +3,12 @@
 | 
			
		|||
 | 
			
		||||
#include <sstream>
 | 
			
		||||
 | 
			
		||||
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent)
 | 
			
		||||
: WorldspaceWidget (parent)
 | 
			
		||||
#include <qt4/QtGui/qevent.h>
 | 
			
		||||
 | 
			
		||||
#include <apps/opencs/model/world/tablemimedata.hpp>
 | 
			
		||||
 | 
			
		||||
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
 | 
			
		||||
: WorldspaceWidget (document, parent)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
 | 
			
		||||
| 
						 | 
				
			
			@ -44,4 +48,45 @@ void CSVRender::PagedWorldspaceWidget::setCellSelection (const CSMWorld::CellSel
 | 
			
		|||
{
 | 
			
		||||
    mSelection = selection;
 | 
			
		||||
    emit cellSelectionChanged (mSelection);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::pair< int, int > CSVRender::PagedWorldspaceWidget::getCoordinatesFromId (const std::string& record) const
 | 
			
		||||
{
 | 
			
		||||
    std::istringstream stream (record.c_str());
 | 
			
		||||
    char ignore;
 | 
			
		||||
    int x, y;
 | 
			
		||||
    stream >> ignore >> x >> y;
 | 
			
		||||
    return std::make_pair(x, y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVRender::PagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::UniversalId >& data)
 | 
			
		||||
{
 | 
			
		||||
    bool selectionChanged = false;
 | 
			
		||||
    for (unsigned i = 0; i < data.size(); ++i)
 | 
			
		||||
    {
 | 
			
		||||
        std::pair<int, int> coordinates(getCoordinatesFromId(data[i].getId()));
 | 
			
		||||
        if (mSelection.add(CSMWorld::CellCoordinates(coordinates.first, coordinates.second)))
 | 
			
		||||
        {
 | 
			
		||||
            selectionChanged = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (selectionChanged)
 | 
			
		||||
    {
 | 
			
		||||
        emit cellSelectionChanged(mSelection);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const
 | 
			
		||||
{
 | 
			
		||||
    switch (type)
 | 
			
		||||
    {
 | 
			
		||||
        case cellsExterior:
 | 
			
		||||
            return canHandle;
 | 
			
		||||
 | 
			
		||||
        case cellsInterior:
 | 
			
		||||
            return needUnpaged;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            return ignored;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -13,17 +13,25 @@ namespace CSVRender
 | 
			
		|||
 | 
			
		||||
            CSMWorld::CellSelection mSelection;
 | 
			
		||||
 | 
			
		||||
        private:
 | 
			
		||||
 | 
			
		||||
            std::pair<int, int> getCoordinatesFromId(const std::string& record) const;
 | 
			
		||||
 | 
			
		||||
        public:
 | 
			
		||||
 | 
			
		||||
            PagedWorldspaceWidget (QWidget *parent);
 | 
			
		||||
            PagedWorldspaceWidget (QWidget *parent, CSMDoc::Document& document);
 | 
			
		||||
            ///< \note Sets the cell area selection to an invalid value to indicate that currently
 | 
			
		||||
            /// no cells are displayed. The cells to be displayed will be specified later through
 | 
			
		||||
            /// hint system.
 | 
			
		||||
 | 
			
		||||
            virtual void useViewHint (const std::string& hint);
 | 
			
		||||
            void useViewHint (const std::string& hint);
 | 
			
		||||
 | 
			
		||||
            void setCellSelection (const CSMWorld::CellSelection& selection);
 | 
			
		||||
 | 
			
		||||
            virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
 | 
			
		||||
 | 
			
		||||
            virtual dropRequirments getDropRequirements(dropType type) const;
 | 
			
		||||
 | 
			
		||||
        signals:
 | 
			
		||||
 | 
			
		||||
            void cellSelectionChanged (const CSMWorld::CellSelection& selection);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -320,7 +320,7 @@ namespace CSVRender
 | 
			
		|||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (mUpdate)
 | 
			
		||||
        if (mUpdate && mWindow)
 | 
			
		||||
        {
 | 
			
		||||
            mUpdate = false;
 | 
			
		||||
            mWindow->update();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ namespace CSVRender
 | 
			
		|||
            SceneWidget(QWidget *parent);
 | 
			
		||||
            virtual ~SceneWidget();
 | 
			
		||||
 | 
			
		||||
            QPaintEngine*	paintEngine() const;
 | 
			
		||||
            QPaintEngine* paintEngine() const;
 | 
			
		||||
 | 
			
		||||
            CSVWorld::SceneToolMode *makeLightingSelector (CSVWorld::SceneToolbar *parent);
 | 
			
		||||
            ///< \attention The created tool is not added to the toolbar (via addTool). Doing that
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,13 @@
 | 
			
		|||
 | 
			
		||||
#include <OgreColourValue.h>
 | 
			
		||||
 | 
			
		||||
#include <qt4/QtGui/qevent.h>
 | 
			
		||||
 | 
			
		||||
#include "../../model/doc/document.hpp"
 | 
			
		||||
 | 
			
		||||
#include "../../model/world/data.hpp"
 | 
			
		||||
#include "../../model/world/idtable.hpp"
 | 
			
		||||
#include "../../model/world/tablemimedata.hpp"
 | 
			
		||||
 | 
			
		||||
void CSVRender::UnpagedWorldspaceWidget::update()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -20,9 +23,8 @@ void CSVRender::UnpagedWorldspaceWidget::update()
 | 
			
		|||
    /// \todo deal with mSunlight and mFog/mForDensity
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId,
 | 
			
		||||
    CSMDoc::Document& document, QWidget *parent)
 | 
			
		||||
: WorldspaceWidget (parent), mCellId (cellId)
 | 
			
		||||
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
 | 
			
		||||
: WorldspaceWidget (document, parent), mCellId (cellId)
 | 
			
		||||
{
 | 
			
		||||
    mCellsModel = &dynamic_cast<CSMWorld::IdTable&> (
 | 
			
		||||
        *document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
 | 
			
		||||
| 
						 | 
				
			
			@ -63,4 +65,26 @@ void CSVRender::UnpagedWorldspaceWidget::cellRowsAboutToBeRemoved (const QModelI
 | 
			
		|||
 | 
			
		||||
    if (cellIndex.row()>=start && cellIndex.row()<=end)
 | 
			
		||||
        emit closeRequest();
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::UniversalId >& data)
 | 
			
		||||
{
 | 
			
		||||
    mCellId = data.begin()->getId();
 | 
			
		||||
    update();
 | 
			
		||||
    emit cellChanged(*data.begin());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const
 | 
			
		||||
{
 | 
			
		||||
    switch(type)
 | 
			
		||||
    {
 | 
			
		||||
        case cellsInterior:
 | 
			
		||||
            return canHandle;
 | 
			
		||||
 | 
			
		||||
        case cellsExterior:
 | 
			
		||||
            return needPaged;
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
            return ignored;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,13 +31,21 @@ namespace CSVRender
 | 
			
		|||
        public:
 | 
			
		||||
 | 
			
		||||
            UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,
 | 
			
		||||
                QWidget *parent);
 | 
			
		||||
                                     QWidget *parent);
 | 
			
		||||
 | 
			
		||||
            virtual dropRequirments getDropRequirements(dropType type) const;
 | 
			
		||||
 | 
			
		||||
            virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
 | 
			
		||||
 | 
			
		||||
        private slots:
 | 
			
		||||
 | 
			
		||||
            void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
 | 
			
		||||
 | 
			
		||||
            void cellRowsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
 | 
			
		||||
 | 
			
		||||
        signals:
 | 
			
		||||
 | 
			
		||||
            void cellChanged(const CSMWorld::UniversalId& id);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,15 +5,20 @@
 | 
			
		|||
#include <OgreSceneManager.h>
 | 
			
		||||
#include <OgreEntity.h>
 | 
			
		||||
 | 
			
		||||
#include "../world/scenetoolmode.hpp"
 | 
			
		||||
#include <qt4/QtGui/qevent.h>
 | 
			
		||||
 | 
			
		||||
CSVRender::WorldspaceWidget::WorldspaceWidget (QWidget *parent)
 | 
			
		||||
: SceneWidget (parent)
 | 
			
		||||
#include "../world/scenetoolmode.hpp"
 | 
			
		||||
#include <apps/opencs/model/world/universalid.hpp>
 | 
			
		||||
 | 
			
		||||
CSVRender::WorldspaceWidget::WorldspaceWidget (const CSMDoc::Document& document, QWidget* parent)
 | 
			
		||||
: SceneWidget (parent), mDocument(document)
 | 
			
		||||
{
 | 
			
		||||
    Ogre::Entity* ent = getSceneManager()->createEntity("cube", Ogre::SceneManager::PT_CUBE);
 | 
			
		||||
    ent->setMaterialName("BaseWhite");
 | 
			
		||||
 | 
			
		||||
    getSceneManager()->getRootSceneNode()->attachObject(ent);
 | 
			
		||||
 | 
			
		||||
    setAcceptDrops(true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
 | 
			
		||||
| 
						 | 
				
			
			@ -46,4 +51,78 @@ CSVWorld::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
 | 
			
		|||
        this, SLOT (selectNavigationMode (const std::string&)));
 | 
			
		||||
 | 
			
		||||
    return tool;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSVRender::WorldspaceWidget::dropType CSVRender::WorldspaceWidget::getDropType (
 | 
			
		||||
    const std::vector< CSMWorld::UniversalId >& data)
 | 
			
		||||
{
 | 
			
		||||
    dropType output = notCells;
 | 
			
		||||
    bool firstIteration = true;
 | 
			
		||||
 | 
			
		||||
    for (unsigned i = 0; i < data.size(); ++i)
 | 
			
		||||
    {
 | 
			
		||||
        if (data[i].getType() == CSMWorld::UniversalId::Type_Cell ||
 | 
			
		||||
                data[i].getType() == CSMWorld::UniversalId::Type_Cell_Missing)
 | 
			
		||||
        {
 | 
			
		||||
            if (*(data[i].getId().begin()) == '#') //exterior
 | 
			
		||||
            {
 | 
			
		||||
                if (firstIteration)
 | 
			
		||||
                {
 | 
			
		||||
                    output = cellsExterior;
 | 
			
		||||
                    firstIteration = false;
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (output == cellsInterior)
 | 
			
		||||
                {
 | 
			
		||||
                    output = cellsMixed;
 | 
			
		||||
                    break;
 | 
			
		||||
                } else {
 | 
			
		||||
                    output = cellsInterior;
 | 
			
		||||
                }
 | 
			
		||||
            } else //interior
 | 
			
		||||
            {
 | 
			
		||||
                if (firstIteration)
 | 
			
		||||
                {
 | 
			
		||||
                    output = cellsInterior;
 | 
			
		||||
                    firstIteration = false;
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (output == cellsExterior)
 | 
			
		||||
                {
 | 
			
		||||
                    output = cellsMixed;
 | 
			
		||||
                    break;
 | 
			
		||||
                } else {
 | 
			
		||||
                    output = cellsInterior;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            output = notCells;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return output;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVRender::WorldspaceWidget::dragEnterEvent (QDragEnterEvent* event)
 | 
			
		||||
{
 | 
			
		||||
    event->accept();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVRender::WorldspaceWidget::dragMoveEvent(QDragMoveEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    event->accept();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event)
 | 
			
		||||
{
 | 
			
		||||
    const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
 | 
			
		||||
 | 
			
		||||
    if (mime->fromDocument (mDocument))
 | 
			
		||||
    {
 | 
			
		||||
        emit dataDropped(mime->getData());
 | 
			
		||||
    } //not handling drops from different documents at the moment
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -6,7 +6,13 @@
 | 
			
		|||
#include "navigation1st.hpp"
 | 
			
		||||
#include "navigationfree.hpp"
 | 
			
		||||
#include "navigationorbit.hpp"
 | 
			
		||||
#include <apps/opencs/model/doc/document.hpp>
 | 
			
		||||
#include <apps/opencs/model/world/tablemimedata.hpp>
 | 
			
		||||
 | 
			
		||||
namespace CSMWorld
 | 
			
		||||
{
 | 
			
		||||
    class UniversalId;
 | 
			
		||||
}
 | 
			
		||||
namespace CSVWorld
 | 
			
		||||
{
 | 
			
		||||
    class SceneToolMode;
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +31,23 @@ namespace CSVRender
 | 
			
		|||
 | 
			
		||||
        public:
 | 
			
		||||
 | 
			
		||||
            WorldspaceWidget (QWidget *parent = 0);
 | 
			
		||||
            enum dropType
 | 
			
		||||
            {
 | 
			
		||||
                cellsMixed,
 | 
			
		||||
                cellsInterior,
 | 
			
		||||
                cellsExterior,
 | 
			
		||||
                notCells
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            enum dropRequirments
 | 
			
		||||
            {
 | 
			
		||||
                canHandle,
 | 
			
		||||
                needPaged,
 | 
			
		||||
                needUnpaged,
 | 
			
		||||
                ignored //either mixed cells, or not cells
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            WorldspaceWidget (const CSMDoc::Document& document, QWidget *parent = 0);
 | 
			
		||||
 | 
			
		||||
            CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent);
 | 
			
		||||
            ///< \attention The created tool is not added to the toolbar (via addTool). Doing that
 | 
			
		||||
| 
						 | 
				
			
			@ -33,9 +55,26 @@ namespace CSVRender
 | 
			
		|||
 | 
			
		||||
            void selectDefaultNavigationMode();
 | 
			
		||||
 | 
			
		||||
            static dropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
 | 
			
		||||
 | 
			
		||||
            virtual dropRequirments getDropRequirements(dropType type) const = 0;
 | 
			
		||||
 | 
			
		||||
            virtual void useViewHint (const std::string& hint);
 | 
			
		||||
            ///< Default-implementation: ignored.
 | 
			
		||||
 | 
			
		||||
            virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data) = 0;
 | 
			
		||||
 | 
			
		||||
        protected:
 | 
			
		||||
        const CSMDoc::Document& mDocument; //for checking if drop comes from same document
 | 
			
		||||
 | 
			
		||||
        private:
 | 
			
		||||
 | 
			
		||||
            void dragEnterEvent(QDragEnterEvent *event);
 | 
			
		||||
 | 
			
		||||
            void dropEvent(QDropEvent* event);
 | 
			
		||||
 | 
			
		||||
            void dragMoveEvent(QDragMoveEvent *event);
 | 
			
		||||
 | 
			
		||||
        private slots:
 | 
			
		||||
 | 
			
		||||
            void selectNavigationMode (const std::string& mode);
 | 
			
		||||
| 
						 | 
				
			
			@ -43,6 +82,7 @@ namespace CSVRender
 | 
			
		|||
        signals:
 | 
			
		||||
 | 
			
		||||
            void closeRequest();
 | 
			
		||||
            void dataDropped(const std::vector<CSMWorld::UniversalId>& data);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										38
									
								
								apps/opencs/view/world/dragrecordtable.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								apps/opencs/view/world/dragrecordtable.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,38 @@
 | 
			
		|||
#include <QDrag>
 | 
			
		||||
 | 
			
		||||
#include "../../model/world/tablemimedata.hpp"
 | 
			
		||||
#include "dragrecordtable.hpp"
 | 
			
		||||
 | 
			
		||||
void CSVWorld::DragRecordTable::startDrag (const CSVWorld::DragRecordTable& table)
 | 
			
		||||
{
 | 
			
		||||
    CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData (table.getDraggedRecords(), mDocument);
 | 
			
		||||
 | 
			
		||||
    if (mime)
 | 
			
		||||
    {
 | 
			
		||||
        QDrag* drag = new QDrag (this);
 | 
			
		||||
        drag->setMimeData (mime);
 | 
			
		||||
        drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str()));
 | 
			
		||||
        drag->exec (Qt::CopyAction);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document, QWidget* parent) :
 | 
			
		||||
mDocument(document),
 | 
			
		||||
QTableView(parent),
 | 
			
		||||
mEditLock(false)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::DragRecordTable::setEditLock (bool locked)
 | 
			
		||||
{
 | 
			
		||||
    mEditLock = locked;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::DragRecordTable::dragEnterEvent(QDragEnterEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    event->acceptProposedAction();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::DragRecordTable::dragMoveEvent(QDragMoveEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    event->accept();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								apps/opencs/view/world/dragrecordtable.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								apps/opencs/view/world/dragrecordtable.hpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
#ifndef CSV_WORLD_DRAGRECORDTABLE_H
 | 
			
		||||
#define CSV_WORLD_DRAGRECORDTABLE_H
 | 
			
		||||
 | 
			
		||||
#include <QTableView>
 | 
			
		||||
#include <QtGui/qevent.h>
 | 
			
		||||
 | 
			
		||||
class QWidget;
 | 
			
		||||
class QAction;
 | 
			
		||||
 | 
			
		||||
namespace CSMDoc
 | 
			
		||||
{
 | 
			
		||||
    class Document;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace CSMWorld
 | 
			
		||||
{
 | 
			
		||||
    class UniversalId;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace CSVWorld
 | 
			
		||||
{
 | 
			
		||||
    class DragRecordTable : public QTableView
 | 
			
		||||
    {
 | 
			
		||||
        protected:
 | 
			
		||||
            CSMDoc::Document& mDocument;
 | 
			
		||||
            bool mEditLock;
 | 
			
		||||
 | 
			
		||||
        public:
 | 
			
		||||
            DragRecordTable(CSMDoc::Document& document, QWidget* parent = NULL);
 | 
			
		||||
 | 
			
		||||
            virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const = 0;
 | 
			
		||||
 | 
			
		||||
            void setEditLock(bool locked);
 | 
			
		||||
 | 
			
		||||
        protected:
 | 
			
		||||
            void startDrag(const DragRecordTable& table);
 | 
			
		||||
 | 
			
		||||
            void dragEnterEvent(QDragEnterEvent *event);
 | 
			
		||||
 | 
			
		||||
            void dragMoveEvent(QDragMoveEvent *event);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -17,6 +17,7 @@
 | 
			
		|||
#include "../../model/world/idtable.hpp"
 | 
			
		||||
#include "../../model/world/commands.hpp"
 | 
			
		||||
#include "../../model/world/columns.hpp"
 | 
			
		||||
#include "../../model/world/tablemimedata.hpp"
 | 
			
		||||
 | 
			
		||||
void CSVWorld::RegionMap::contextMenuEvent (QContextMenuEvent *event)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +181,7 @@ void CSVWorld::RegionMap::setRegion (const std::string& regionId)
 | 
			
		|||
 | 
			
		||||
CSVWorld::RegionMap::RegionMap (const CSMWorld::UniversalId& universalId,
 | 
			
		||||
    CSMDoc::Document& document, QWidget *parent)
 | 
			
		||||
: QTableView (parent), mEditLock (false), mDocument (document)
 | 
			
		||||
:  DragRecordTable(document, parent)
 | 
			
		||||
{
 | 
			
		||||
    verticalHeader()->hide();
 | 
			
		||||
    horizontalHeader()->hide();
 | 
			
		||||
| 
						 | 
				
			
			@ -223,11 +224,8 @@ CSVWorld::RegionMap::RegionMap (const CSMWorld::UniversalId& universalId,
 | 
			
		|||
    mViewInTableAction = new QAction (tr ("View Cells in Table"), this);
 | 
			
		||||
    connect (mViewInTableAction, SIGNAL (triggered()), this, SLOT (viewInTable()));
 | 
			
		||||
    addAction (mViewInTableAction);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::RegionMap::setEditLock (bool locked)
 | 
			
		||||
{
 | 
			
		||||
    mEditLock = locked;
 | 
			
		||||
    setAcceptDrops(true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::RegionMap::selectAll()
 | 
			
		||||
| 
						 | 
				
			
			@ -343,4 +341,65 @@ void CSVWorld::RegionMap::viewInTable()
 | 
			
		|||
    hint << ")";
 | 
			
		||||
 | 
			
		||||
    emit editRequest (CSMWorld::UniversalId::Type_Cells, hint.str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::RegionMap::mouseMoveEvent (QMouseEvent* event)
 | 
			
		||||
{
 | 
			
		||||
    startDrag(*this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::vector< CSMWorld::UniversalId > CSVWorld::RegionMap::getDraggedRecords() const
 | 
			
		||||
{
 | 
			
		||||
    QModelIndexList selected(getSelectedCells(true, false));
 | 
			
		||||
    std::vector<CSMWorld::UniversalId> ids;
 | 
			
		||||
    foreach (QModelIndex it, selected)
 | 
			
		||||
    {
 | 
			
		||||
        ids.push_back(
 | 
			
		||||
            CSMWorld::UniversalId(
 | 
			
		||||
                CSMWorld::UniversalId::Type_Cell,
 | 
			
		||||
                model()->data(it, CSMWorld::RegionMap::Role_CellId).toString().toUtf8().constData()));
 | 
			
		||||
    }
 | 
			
		||||
    selected = getSelectedCells(false, true);
 | 
			
		||||
    foreach (QModelIndex it, selected)
 | 
			
		||||
    {
 | 
			
		||||
        ids.push_back(
 | 
			
		||||
            CSMWorld::UniversalId(
 | 
			
		||||
                CSMWorld::UniversalId::Type_Cell_Missing,
 | 
			
		||||
                model()->data(it, CSMWorld::RegionMap::Role_CellId).toString().toUtf8().constData()));
 | 
			
		||||
    }
 | 
			
		||||
    return ids;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::RegionMap::dropEvent (QDropEvent* event)
 | 
			
		||||
{
 | 
			
		||||
    QModelIndex index = indexAt (event->pos());
 | 
			
		||||
 | 
			
		||||
    bool exists = QTableView::model()->data(index, Qt::BackgroundRole)!=QBrush (Qt::DiagCrossPattern);
 | 
			
		||||
 | 
			
		||||
    if (!index.isValid() || !exists)
 | 
			
		||||
    {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
 | 
			
		||||
    if (mime->fromDocument(mDocument) && mime->holdsType(CSMWorld::UniversalId::Type_Region))
 | 
			
		||||
    {
 | 
			
		||||
        CSMWorld::UniversalId record (mime->returnMatching (CSMWorld::UniversalId::Type_Region));
 | 
			
		||||
 | 
			
		||||
        QAbstractItemModel *regionModel = model();
 | 
			
		||||
 | 
			
		||||
        CSMWorld::IdTable *cellsModel = &dynamic_cast<CSMWorld::IdTable&> (*
 | 
			
		||||
            mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
 | 
			
		||||
 | 
			
		||||
        std::string cellId(regionModel->data (index, CSMWorld::RegionMap::Role_CellId).
 | 
			
		||||
            toString().toUtf8().constData());
 | 
			
		||||
 | 
			
		||||
        QModelIndex index2(cellsModel->getModelIndex (cellId,
 | 
			
		||||
            cellsModel->findColumnIndex (CSMWorld::Columns::ColumnId_Region)));
 | 
			
		||||
 | 
			
		||||
        mDocument.getUndoStack().push(new CSMWorld::ModifyCommand 
 | 
			
		||||
                                        (*cellsModel, index2, QString::fromUtf8(record.getId().c_str())));
 | 
			
		||||
 | 
			
		||||
        mRegionId = record.getId();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +1,14 @@
 | 
			
		|||
#ifndef CSV_WORLD_REGIONMAP_H
 | 
			
		||||
#define CSV_WORLD_REGIONMAP_H
 | 
			
		||||
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QTableView>
 | 
			
		||||
 | 
			
		||||
#include "./dragrecordtable.hpp"
 | 
			
		||||
 | 
			
		||||
class QAction;
 | 
			
		||||
 | 
			
		||||
namespace CSMDoc
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +23,7 @@ namespace CSMWorld
 | 
			
		|||
 | 
			
		||||
namespace CSVWorld
 | 
			
		||||
{
 | 
			
		||||
    class RegionMap : public QTableView
 | 
			
		||||
    class RegionMap : public DragRecordTable
 | 
			
		||||
    {
 | 
			
		||||
            Q_OBJECT
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -29,8 +35,6 @@ namespace CSVWorld
 | 
			
		|||
            QAction *mUnsetRegionAction;
 | 
			
		||||
            QAction *mViewAction;
 | 
			
		||||
            QAction *mViewInTableAction;
 | 
			
		||||
            bool mEditLock;
 | 
			
		||||
            CSMDoc::Document& mDocument;
 | 
			
		||||
            std::string mRegionId;
 | 
			
		||||
 | 
			
		||||
        private:
 | 
			
		||||
| 
						 | 
				
			
			@ -50,12 +54,16 @@ namespace CSVWorld
 | 
			
		|||
            void setRegion (const std::string& regionId);
 | 
			
		||||
            ///< Set region Id of selected cells.
 | 
			
		||||
 | 
			
		||||
            void mouseMoveEvent(QMouseEvent *event);
 | 
			
		||||
 | 
			
		||||
            void dropEvent(QDropEvent* event);
 | 
			
		||||
 | 
			
		||||
        public:
 | 
			
		||||
 | 
			
		||||
            RegionMap (const CSMWorld::UniversalId& universalId, CSMDoc::Document& document,
 | 
			
		||||
                QWidget *parent = 0);
 | 
			
		||||
 | 
			
		||||
            void setEditLock (bool locked);
 | 
			
		||||
            virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const;
 | 
			
		||||
 | 
			
		||||
        signals:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@
 | 
			
		|||
#include <QVBoxLayout>
 | 
			
		||||
#include <QHBoxLayout>
 | 
			
		||||
#include <QLabel>
 | 
			
		||||
#include <cassert>
 | 
			
		||||
 | 
			
		||||
#include "../../model/doc/document.hpp"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,11 +19,10 @@
 | 
			
		|||
 | 
			
		||||
#include "tablebottombox.hpp"
 | 
			
		||||
#include "creator.hpp"
 | 
			
		||||
#include "scenetoolbar.hpp"
 | 
			
		||||
#include "scenetoolmode.hpp"
 | 
			
		||||
 | 
			
		||||
CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
 | 
			
		||||
: SubView (id)
 | 
			
		||||
: SubView (id), mLayout(new QHBoxLayout), mDocument(document), mScene(NULL), mToolbar(NULL)
 | 
			
		||||
{
 | 
			
		||||
    QVBoxLayout *layout = new QVBoxLayout;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -32,33 +32,35 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
 | 
			
		|||
        new TableBottomBox (NullCreatorFactory(), document.getData(), document.getUndoStack(), id,
 | 
			
		||||
        this), 0);
 | 
			
		||||
 | 
			
		||||
    QHBoxLayout *layout2 = new QHBoxLayout;
 | 
			
		||||
    mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
 | 
			
		||||
 | 
			
		||||
    layout2->setContentsMargins (QMargins (0, 0, 0, 0));
 | 
			
		||||
 | 
			
		||||
    SceneToolbar *toolbar = new SceneToolbar (48+6, this);
 | 
			
		||||
    CSVRender::WorldspaceWidget* wordspaceWidget = NULL;
 | 
			
		||||
    widgetType whatWidget;
 | 
			
		||||
 | 
			
		||||
    if (id.getId()=="sys::default")
 | 
			
		||||
    {
 | 
			
		||||
        CSVRender::PagedWorldspaceWidget *widget = new CSVRender::PagedWorldspaceWidget (this);
 | 
			
		||||
        mScene = widget;
 | 
			
		||||
        connect (widget, SIGNAL (cellSelectionChanged (const CSMWorld::CellSelection&)),
 | 
			
		||||
            this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&)));
 | 
			
		||||
        whatWidget = widget_Paged;
 | 
			
		||||
 | 
			
		||||
        CSVRender::PagedWorldspaceWidget *newWidget = new CSVRender::PagedWorldspaceWidget (this, document);
 | 
			
		||||
 | 
			
		||||
        wordspaceWidget = newWidget;
 | 
			
		||||
 | 
			
		||||
        makeConnections(newWidget);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
        mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
 | 
			
		||||
    {
 | 
			
		||||
        whatWidget = widget_Unpaged;
 | 
			
		||||
 | 
			
		||||
    SceneToolMode *navigationTool = mScene->makeNavigationSelector (toolbar);
 | 
			
		||||
    toolbar->addTool (navigationTool);
 | 
			
		||||
        CSVRender::UnpagedWorldspaceWidget *newWidget = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
 | 
			
		||||
 | 
			
		||||
    SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
 | 
			
		||||
    toolbar->addTool (lightingTool);
 | 
			
		||||
        wordspaceWidget = newWidget;
 | 
			
		||||
 | 
			
		||||
    layout2->addWidget (toolbar, 0);
 | 
			
		||||
        makeConnections(newWidget);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    layout2->addWidget (mScene, 1);
 | 
			
		||||
    replaceToolbarAndWorldspace(wordspaceWidget, makeToolbar(wordspaceWidget, whatWidget));
 | 
			
		||||
 | 
			
		||||
    layout->insertLayout (0, layout2, 1);
 | 
			
		||||
    layout->insertLayout (0, mLayout, 1);
 | 
			
		||||
 | 
			
		||||
    CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,10 +71,53 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
 | 
			
		|||
    widget->setLayout (layout);
 | 
			
		||||
 | 
			
		||||
    setWidget (widget);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    mScene->selectDefaultNavigationMode();
 | 
			
		||||
void CSVWorld::SceneSubView::makeConnections (CSVRender::UnpagedWorldspaceWidget* widget)
 | 
			
		||||
{
 | 
			
		||||
    connect (widget, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
 | 
			
		||||
 | 
			
		||||
    connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
 | 
			
		||||
    connect(widget, SIGNAL(dataDropped(const std::vector<CSMWorld::UniversalId>&)),
 | 
			
		||||
            this, SLOT(handleDrop(const std::vector<CSMWorld::UniversalId>&)));
 | 
			
		||||
 | 
			
		||||
    connect(widget, SIGNAL(cellChanged(const CSMWorld::UniversalId&)),
 | 
			
		||||
            this, SLOT(cellSelectionChanged(const CSMWorld::UniversalId&)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::SceneSubView::makeConnections (CSVRender::PagedWorldspaceWidget* widget)
 | 
			
		||||
{
 | 
			
		||||
    connect (widget, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
 | 
			
		||||
 | 
			
		||||
    connect(widget, SIGNAL(dataDropped(const std::vector<CSMWorld::UniversalId>&)),
 | 
			
		||||
            this, SLOT(handleDrop(const std::vector<CSMWorld::UniversalId>&)));
 | 
			
		||||
 | 
			
		||||
    connect (widget, SIGNAL (cellSelectionChanged (const CSMWorld::CellSelection&)),
 | 
			
		||||
             this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSVWorld::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::WorldspaceWidget* widget, widgetType type)
 | 
			
		||||
{
 | 
			
		||||
    CSVWorld::SceneToolbar* toolbar = new SceneToolbar (48+6, this);
 | 
			
		||||
 | 
			
		||||
    SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar);
 | 
			
		||||
    toolbar->addTool (navigationTool);
 | 
			
		||||
 | 
			
		||||
    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:
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case widget_Unpaged:
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
*/
 | 
			
		||||
    return toolbar;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::SceneSubView::setEditLock (bool locked)
 | 
			
		||||
| 
						 | 
				
			
			@ -102,8 +147,19 @@ void CSVWorld::SceneSubView::closeRequest()
 | 
			
		|||
    deleteLater();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::UniversalId& id)
 | 
			
		||||
{
 | 
			
		||||
    setUniversalId(id);
 | 
			
		||||
    std::ostringstream stream;
 | 
			
		||||
    stream << "Scene: " << getUniversalId().getId();
 | 
			
		||||
 | 
			
		||||
    setWindowTitle (QString::fromUtf8 (stream.str().c_str()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::CellSelection& selection)
 | 
			
		||||
{
 | 
			
		||||
    setUniversalId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, "sys::default"));
 | 
			
		||||
    int size = selection.getSize();
 | 
			
		||||
 | 
			
		||||
    std::ostringstream stream;
 | 
			
		||||
| 
						 | 
				
			
			@ -126,4 +182,62 @@ void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::CellSelection
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    setWindowTitle (QString::fromUtf8 (stream.str().c_str()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalId >& data)
 | 
			
		||||
{
 | 
			
		||||
    CSVRender::PagedWorldspaceWidget* pagedNewWidget = NULL;
 | 
			
		||||
    CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = NULL;
 | 
			
		||||
    SceneToolbar* toolbar = NULL;
 | 
			
		||||
 | 
			
		||||
    switch (mScene->getDropRequirements(CSVRender::WorldspaceWidget::getDropType(data)))
 | 
			
		||||
    {
 | 
			
		||||
        case CSVRender::WorldspaceWidget::canHandle:
 | 
			
		||||
            mScene->handleDrop(data);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case CSVRender::WorldspaceWidget::needPaged:
 | 
			
		||||
            pagedNewWidget = new CSVRender::PagedWorldspaceWidget(this, mDocument);
 | 
			
		||||
            toolbar = makeToolbar(pagedNewWidget, widget_Paged);
 | 
			
		||||
            makeConnections(pagedNewWidget);
 | 
			
		||||
            replaceToolbarAndWorldspace(pagedNewWidget, toolbar);
 | 
			
		||||
            mScene->handleDrop(data);
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case CSVRender::WorldspaceWidget::needUnpaged:
 | 
			
		||||
            unPagedNewWidget = new CSVRender::UnpagedWorldspaceWidget(data.begin()->getId(), mDocument, this);
 | 
			
		||||
            toolbar = makeToolbar(unPagedNewWidget, widget_Unpaged);
 | 
			
		||||
            makeConnections(unPagedNewWidget);
 | 
			
		||||
            replaceToolbarAndWorldspace(unPagedNewWidget, toolbar);
 | 
			
		||||
            cellSelectionChanged(*(data.begin()));
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
        case CSVRender::WorldspaceWidget::ignored:
 | 
			
		||||
            return;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWorld::SceneToolbar* toolbar)
 | 
			
		||||
{
 | 
			
		||||
    assert(mLayout);
 | 
			
		||||
 | 
			
		||||
    if (mScene)
 | 
			
		||||
    {
 | 
			
		||||
        mLayout->removeWidget(mScene);
 | 
			
		||||
        mScene->deleteLater();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (mToolbar)
 | 
			
		||||
    {
 | 
			
		||||
        mLayout->removeWidget(mToolbar);
 | 
			
		||||
        mToolbar->deleteLater();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    mScene = widget;
 | 
			
		||||
    mToolbar = toolbar;
 | 
			
		||||
 | 
			
		||||
    mLayout->addWidget (mToolbar, 0);
 | 
			
		||||
    mLayout->addWidget (mScene, 1);
 | 
			
		||||
 | 
			
		||||
    mScene->selectDefaultNavigationMode();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,7 +1,10 @@
 | 
			
		|||
#ifndef CSV_WORLD_SCENESUBVIEW_H
 | 
			
		||||
#define CSV_WORLD_SCENESUBVIEW_H
 | 
			
		||||
 | 
			
		||||
#include <QHBoxLayout>
 | 
			
		||||
 | 
			
		||||
#include "../doc/subview.hpp"
 | 
			
		||||
#include "scenetoolbar.hpp"
 | 
			
		||||
 | 
			
		||||
class QModelIndex;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +21,8 @@ namespace CSMDoc
 | 
			
		|||
namespace CSVRender
 | 
			
		||||
{
 | 
			
		||||
    class WorldspaceWidget;
 | 
			
		||||
    class PagedWorldspaceWidget;
 | 
			
		||||
    class UnpagedWorldspaceWidget;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace CSVWorld
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +37,9 @@ namespace CSVWorld
 | 
			
		|||
 | 
			
		||||
            TableBottomBox *mBottom;
 | 
			
		||||
            CSVRender::WorldspaceWidget *mScene;
 | 
			
		||||
            QHBoxLayout* mLayout;
 | 
			
		||||
            CSMDoc::Document& mDocument;
 | 
			
		||||
            SceneToolbar* mToolbar;
 | 
			
		||||
 | 
			
		||||
        public:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,11 +53,30 @@ namespace CSVWorld
 | 
			
		|||
 | 
			
		||||
            virtual void useHint (const std::string& hint);
 | 
			
		||||
 | 
			
		||||
        private:
 | 
			
		||||
 | 
			
		||||
            void makeConnections(CSVRender::PagedWorldspaceWidget* widget);
 | 
			
		||||
 | 
			
		||||
            void makeConnections(CSVRender::UnpagedWorldspaceWidget* widget);
 | 
			
		||||
 | 
			
		||||
            void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, SceneToolbar* toolbar);
 | 
			
		||||
 | 
			
		||||
            enum widgetType
 | 
			
		||||
            {
 | 
			
		||||
                widget_Paged,
 | 
			
		||||
                widget_Unpaged
 | 
			
		||||
            };
 | 
			
		||||
            SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type);
 | 
			
		||||
 | 
			
		||||
        private slots:
 | 
			
		||||
 | 
			
		||||
            void closeRequest();
 | 
			
		||||
 | 
			
		||||
            void cellSelectionChanged (const CSMWorld::CellSelection& selection);
 | 
			
		||||
 | 
			
		||||
            void cellSelectionChanged (const CSMWorld::UniversalId& id);
 | 
			
		||||
 | 
			
		||||
            void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -188,8 +188,8 @@ std::vector<std::string> CSVWorld::Table::listDeletableSelectedIds() const
 | 
			
		|||
 | 
			
		||||
CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
 | 
			
		||||
    bool createAndDelete, bool sorting, CSMDoc::Document& document)
 | 
			
		||||
: mCreateAction (0), mCloneAction(0), mEditLock (false), mRecordStatusDisplay (0),
 | 
			
		||||
  mDocument (document)
 | 
			
		||||
: mCreateAction (0), mCloneAction(0), mRecordStatusDisplay (0),
 | 
			
		||||
  DragRecordTable(document)
 | 
			
		||||
{
 | 
			
		||||
    mModel = &dynamic_cast<CSMWorld::IdTable&> (*mDocument.getData().getTableModel (id));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -282,7 +282,7 @@ void CSVWorld::Table::setEditLock (bool locked)
 | 
			
		|||
    for (std::vector<CommandDelegate *>::iterator iter (mDelegates.begin()); iter!=mDelegates.end(); ++iter)
 | 
			
		||||
        (*iter)->setEditLock (locked);
 | 
			
		||||
 | 
			
		||||
    mEditLock = locked;
 | 
			
		||||
    DragRecordTable::setEditLock(locked);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSMWorld::UniversalId CSVWorld::Table::getUniversalId (int row) const
 | 
			
		||||
| 
						 | 
				
			
			@ -518,42 +518,8 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
 | 
			
		|||
{
 | 
			
		||||
    if (event->buttons() & Qt::LeftButton)
 | 
			
		||||
    {
 | 
			
		||||
        QModelIndexList selectedRows = selectionModel()->selectedRows();
 | 
			
		||||
 | 
			
		||||
        if (selectedRows.size() == 0)
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        QDrag* drag = new QDrag (this);
 | 
			
		||||
        CSMWorld::TableMimeData* mime = NULL;
 | 
			
		||||
 | 
			
		||||
        if (selectedRows.size() == 1)
 | 
			
		||||
        {
 | 
			
		||||
            mime = new CSMWorld::TableMimeData (getUniversalId (selectedRows.begin()->row()), mDocument);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            std::vector<CSMWorld::UniversalId> idToDrag;
 | 
			
		||||
 | 
			
		||||
            foreach (QModelIndex it, selectedRows) //I had a dream. Dream where you could use C++11 in OpenMW.
 | 
			
		||||
            {
 | 
			
		||||
                idToDrag.push_back (getUniversalId (it.row()));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            mime = new CSMWorld::TableMimeData (idToDrag, mDocument);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        drag->setMimeData (mime);
 | 
			
		||||
        drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str()));
 | 
			
		||||
        drag->exec(Qt::CopyAction);
 | 
			
		||||
        startDrag(*this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    event->acceptProposedAction();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::Table::dropEvent(QDropEvent *event)
 | 
			
		||||
| 
						 | 
				
			
			@ -583,11 +549,6 @@ void CSVWorld::Table::dropEvent(QDropEvent *event)
 | 
			
		|||
    } //TODO handle drops from different document
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    event->accept();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const
 | 
			
		||||
{
 | 
			
		||||
    const int count = mModel->columnCount();
 | 
			
		||||
| 
						 | 
				
			
			@ -605,3 +566,18 @@ std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::Column
 | 
			
		|||
    }
 | 
			
		||||
    return titles;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    QModelIndexList selectedRows = selectionModel()->selectedRows();
 | 
			
		||||
    std::vector<CSMWorld::UniversalId> idToDrag;
 | 
			
		||||
 | 
			
		||||
    foreach (QModelIndex it, selectedRows) //I had a dream. Dream where you could use C++11 in OpenMW.
 | 
			
		||||
    {
 | 
			
		||||
        idToDrag.push_back (getUniversalId (it.row()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return idToDrag;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,11 +4,11 @@
 | 
			
		|||
#include <vector>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include <QTableView>
 | 
			
		||||
#include <QtGui/qevent.h>
 | 
			
		||||
 | 
			
		||||
#include "../../model/filter/node.hpp"
 | 
			
		||||
#include "../../model/world/columnbase.hpp"
 | 
			
		||||
#include "dragrecordtable.hpp"
 | 
			
		||||
 | 
			
		||||
class QUndoStack;
 | 
			
		||||
class QAction;
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ namespace CSVWorld
 | 
			
		|||
    class CommandDelegate;
 | 
			
		||||
 | 
			
		||||
    ///< Table widget
 | 
			
		||||
    class Table : public QTableView
 | 
			
		||||
    class Table : public DragRecordTable
 | 
			
		||||
    {
 | 
			
		||||
            Q_OBJECT
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -47,9 +47,7 @@ namespace CSVWorld
 | 
			
		|||
            QAction *mPreviewAction;
 | 
			
		||||
            CSMWorld::IdTableProxyModel *mProxyModel;
 | 
			
		||||
            CSMWorld::IdTable *mModel;
 | 
			
		||||
            bool mEditLock;
 | 
			
		||||
            int mRecordStatusDisplay;
 | 
			
		||||
            CSMDoc::Document& mDocument;
 | 
			
		||||
 | 
			
		||||
        private:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -61,10 +59,6 @@ namespace CSVWorld
 | 
			
		|||
 | 
			
		||||
            void mouseMoveEvent(QMouseEvent *event);
 | 
			
		||||
 | 
			
		||||
            void dragEnterEvent(QDragEnterEvent *event);
 | 
			
		||||
 | 
			
		||||
            void dragMoveEvent(QDragMoveEvent *event);
 | 
			
		||||
 | 
			
		||||
            void dropEvent(QDropEvent *event);
 | 
			
		||||
 | 
			
		||||
        public:
 | 
			
		||||
| 
						 | 
				
			
			@ -74,12 +68,14 @@ namespace CSVWorld
 | 
			
		|||
            ///< \param createAndDelete Allow creation and deletion of records.
 | 
			
		||||
            /// \param sorting Allow changing order of rows in the view via column headers.
 | 
			
		||||
 | 
			
		||||
            void setEditLock (bool locked);
 | 
			
		||||
            virtual void setEditLock (bool locked);
 | 
			
		||||
 | 
			
		||||
            CSMWorld::UniversalId getUniversalId (int row) const;
 | 
			
		||||
 | 
			
		||||
            std::vector<std::string> getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const;
 | 
			
		||||
 | 
			
		||||
            virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const;
 | 
			
		||||
 | 
			
		||||
        signals:
 | 
			
		||||
 | 
			
		||||
            void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
 | 
			
		||||
| 
						 | 
				
			
			@ -92,6 +88,7 @@ namespace CSVWorld
 | 
			
		|||
            /// \param modified Number of added and modified records
 | 
			
		||||
 | 
			
		||||
            void createRequest();
 | 
			
		||||
 | 
			
		||||
            void cloneRequest(const CSMWorld::UniversalId&);
 | 
			
		||||
 | 
			
		||||
        private slots:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue