forked from mirror/openmw-tes3mp
Merge branch 'scene'
This commit is contained in:
commit
f1353dc84f
27 changed files with 413 additions and 98 deletions
|
@ -64,7 +64,7 @@ opencs_units (view/world
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (view/render
|
opencs_units (view/render
|
||||||
scenewidget
|
scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/render
|
opencs_units_noqt (view/render
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace CSMWorld
|
||||||
UniversalId::Type type = UniversalId::Type_None);
|
UniversalId::Type type = UniversalId::Type_None);
|
||||||
///< \param type Will be ignored, unless the collection supports multiple record types
|
///< \param type Will be ignored, unless the collection supports multiple record types
|
||||||
|
|
||||||
virtual void cloneRecord(const std::string& origin,
|
virtual void cloneRecord(const std::string& origin,
|
||||||
const std::string& destination,
|
const std::string& destination,
|
||||||
const UniversalId::Type type);
|
const UniversalId::Type type);
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ namespace CSMWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ESXRecordT, typename IdAccessorT>
|
template<typename ESXRecordT, typename IdAccessorT>
|
||||||
void Collection<ESXRecordT, IdAccessorT>::cloneRecord(const std::string& origin,
|
void Collection<ESXRecordT, IdAccessorT>::cloneRecord(const std::string& origin,
|
||||||
const std::string& destination,
|
const std::string& destination,
|
||||||
const UniversalId::Type type)
|
const UniversalId::Type type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace CSMWorld
|
||||||
UniversalId::Type type = UniversalId::Type_None) = 0;
|
UniversalId::Type type = UniversalId::Type_None) = 0;
|
||||||
///< If the record type does not match, an exception is thrown.
|
///< If the record type does not match, an exception is thrown.
|
||||||
|
|
||||||
virtual void cloneRecord(const std::string& origin,
|
virtual void cloneRecord(const std::string& origin,
|
||||||
const std::string& destination,
|
const std::string& destination,
|
||||||
const UniversalId::Type type) = 0;
|
const UniversalId::Type type) = 0;
|
||||||
|
|
||||||
|
|
|
@ -247,12 +247,12 @@ CSMWorld::Data::Data() : mRefs (mCells)
|
||||||
addModel (new IdTable (&mSpells), UniversalId::Type_Spells, UniversalId::Type_Spell);
|
addModel (new IdTable (&mSpells), UniversalId::Type_Spells, UniversalId::Type_Spell);
|
||||||
addModel (new IdTable (&mTopics), UniversalId::Type_Topics, UniversalId::Type_Topic);
|
addModel (new IdTable (&mTopics), UniversalId::Type_Topics, UniversalId::Type_Topic);
|
||||||
addModel (new IdTable (&mJournals), UniversalId::Type_Journals, UniversalId::Type_Journal);
|
addModel (new IdTable (&mJournals), UniversalId::Type_Journals, UniversalId::Type_Journal);
|
||||||
addModel (new IdTable (&mTopicInfos), UniversalId::Type_TopicInfos, UniversalId::Type_TopicInfo);
|
addModel (new IdTable (&mTopicInfos, IdTable::Reordering_WithinTopic), UniversalId::Type_TopicInfos, UniversalId::Type_TopicInfo);
|
||||||
addModel (new IdTable (&mJournalInfos), UniversalId::Type_JournalInfos, UniversalId::Type_JournalInfo);
|
addModel (new IdTable (&mJournalInfos, IdTable::Reordering_WithinTopic), UniversalId::Type_JournalInfos, UniversalId::Type_JournalInfo);
|
||||||
addModel (new IdTable (&mCells), UniversalId::Type_Cells, UniversalId::Type_Cell);
|
addModel (new IdTable (&mCells, IdTable::Reordering_None, IdTable::Viewing_Id), UniversalId::Type_Cells, UniversalId::Type_Cell);
|
||||||
addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables,
|
addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables,
|
||||||
UniversalId::Type_Referenceable);
|
UniversalId::Type_Referenceable);
|
||||||
addModel (new IdTable (&mRefs), UniversalId::Type_References, UniversalId::Type_Reference, false);
|
addModel (new IdTable (&mRefs, IdTable::Reordering_None, IdTable::Viewing_Cell), UniversalId::Type_References, UniversalId::Type_Reference, false);
|
||||||
addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter, false);
|
addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
#include "collectionbase.hpp"
|
#include "collectionbase.hpp"
|
||||||
#include "columnbase.hpp"
|
#include "columnbase.hpp"
|
||||||
|
|
||||||
CSMWorld::IdTable::IdTable (CollectionBase *idCollection, Reordering reordering)
|
CSMWorld::IdTable::IdTable (CollectionBase *idCollection, Reordering reordering,
|
||||||
: mIdCollection (idCollection), mReordering (reordering)
|
Viewing viewing)
|
||||||
|
: mIdCollection (idCollection), mReordering (reordering), mViewing (viewing)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSMWorld::IdTable::~IdTable()
|
CSMWorld::IdTable::~IdTable()
|
||||||
|
@ -188,4 +189,45 @@ void CSMWorld::IdTable::reorderRows (int baseIndex, const std::vector<int>& newO
|
||||||
CSMWorld::IdTable::Reordering CSMWorld::IdTable::getReordering() const
|
CSMWorld::IdTable::Reordering CSMWorld::IdTable::getReordering() const
|
||||||
{
|
{
|
||||||
return mReordering;
|
return mReordering;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMWorld::IdTable::Viewing CSMWorld::IdTable::getViewing() const
|
||||||
|
{
|
||||||
|
return mViewing;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<CSMWorld::UniversalId, std::string> CSMWorld::IdTable::view (int row) const
|
||||||
|
{
|
||||||
|
std::string id;
|
||||||
|
std::string hint;
|
||||||
|
|
||||||
|
if (mViewing==Viewing_Cell)
|
||||||
|
{
|
||||||
|
int cellColumn = mIdCollection->searchColumnIndex (Columns::ColumnId_Cell);
|
||||||
|
int idColumn = mIdCollection->searchColumnIndex (Columns::ColumnId_Id);
|
||||||
|
|
||||||
|
if (cellColumn!=-1 && idColumn!=-1)
|
||||||
|
{
|
||||||
|
id = mIdCollection->getData (row, cellColumn).toString().toUtf8().constData();
|
||||||
|
hint = "r:" + std::string (mIdCollection->getData (row, idColumn).toString().toUtf8().constData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mViewing==Viewing_Id)
|
||||||
|
{
|
||||||
|
int column = mIdCollection->searchColumnIndex (Columns::ColumnId_Id);
|
||||||
|
|
||||||
|
if (column!=-1)
|
||||||
|
{
|
||||||
|
id = mIdCollection->getData (row, column).toString().toUtf8().constData();
|
||||||
|
hint = "c:" + id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.empty())
|
||||||
|
return std::make_pair (UniversalId::Type_None, "");
|
||||||
|
|
||||||
|
if (id[0]=='#')
|
||||||
|
id = "sys::default";
|
||||||
|
|
||||||
|
return std::make_pair (UniversalId (UniversalId::Type_Scene, id), hint);
|
||||||
}
|
}
|
|
@ -25,10 +25,20 @@ namespace CSMWorld
|
||||||
Reordering_WithinTopic
|
Reordering_WithinTopic
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Viewing
|
||||||
|
{
|
||||||
|
Viewing_None,
|
||||||
|
Viewing_Id, // use ID column to generate view request (ID is transformed into
|
||||||
|
// worldspace and original ID is passed as hint with c: prefix)
|
||||||
|
Viewing_Cell // use cell column to generate view request (cell ID is transformed
|
||||||
|
// into worldspace and record ID is passed as hint with r: prefix)
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CollectionBase *mIdCollection;
|
CollectionBase *mIdCollection;
|
||||||
Reordering mReordering;
|
Reordering mReordering;
|
||||||
|
Viewing mViewing;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
IdTable (const IdTable&);
|
IdTable (const IdTable&);
|
||||||
|
@ -36,7 +46,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
IdTable (CollectionBase *idCollection, Reordering reordering = Reordering_WithinTopic);
|
IdTable (CollectionBase *idCollection, Reordering reordering = Reordering_None,
|
||||||
|
Viewing viewing = Viewing_None);
|
||||||
///< The ownership of \a idCollection is not transferred.
|
///< The ownership of \a idCollection is not transferred.
|
||||||
|
|
||||||
virtual ~IdTable();
|
virtual ~IdTable();
|
||||||
|
@ -63,8 +74,8 @@ namespace CSMWorld
|
||||||
void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
|
void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
|
||||||
///< \param type Will be ignored, unless the collection supports multiple record types
|
///< \param type Will be ignored, unless the collection supports multiple record types
|
||||||
|
|
||||||
void cloneRecord(const std::string& origin,
|
void cloneRecord(const std::string& origin,
|
||||||
const std::string& destination,
|
const std::string& destination,
|
||||||
UniversalId::Type type = UniversalId::Type_None);
|
UniversalId::Type type = UniversalId::Type_None);
|
||||||
|
|
||||||
QModelIndex getModelIndex (const std::string& id, int column) const;
|
QModelIndex getModelIndex (const std::string& id, int column) const;
|
||||||
|
@ -86,6 +97,12 @@ namespace CSMWorld
|
||||||
/// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex).
|
/// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex).
|
||||||
|
|
||||||
Reordering getReordering() const;
|
Reordering getReordering() const;
|
||||||
|
|
||||||
|
Viewing getViewing() const;
|
||||||
|
|
||||||
|
std::pair<UniversalId, std::string> view (int row) const;
|
||||||
|
///< Return the UniversalId and the hint for viewing \a row. If viewing is not
|
||||||
|
/// supported by this table, return (UniversalId::Type_None, "").
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,14 +90,14 @@ namespace
|
||||||
{ CSMWorld::UniversalId::Class_RefRecord, CSMWorld::UniversalId::Type_Weapon, "Weapon", ":./weapon.png" },
|
{ CSMWorld::UniversalId::Class_RefRecord, CSMWorld::UniversalId::Type_Weapon, "Weapon", ":./weapon.png" },
|
||||||
{ CSMWorld::UniversalId::Class_SubRecord, CSMWorld::UniversalId::Type_Reference, "Reference", 0 },
|
{ CSMWorld::UniversalId::Class_SubRecord, CSMWorld::UniversalId::Type_Reference, "Reference", 0 },
|
||||||
{ CSMWorld::UniversalId::Class_SubRecord, CSMWorld::UniversalId::Type_Filter, "Filter", ":./filter.png" },
|
{ CSMWorld::UniversalId::Class_SubRecord, CSMWorld::UniversalId::Type_Filter, "Filter", ":./filter.png" },
|
||||||
|
{ CSMWorld::UniversalId::Class_Collection, CSMWorld::UniversalId::Type_Scene, "Scene", 0 },
|
||||||
|
|
||||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker
|
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
static const TypeData sIndexArg[] =
|
static const TypeData sIndexArg[] =
|
||||||
{
|
{
|
||||||
{ CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_VerificationResults, "Verification Results", 0 },
|
{ CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_VerificationResults, "Verification Results", 0 },
|
||||||
{ CSMWorld::UniversalId::Class_Collection, CSMWorld::UniversalId::Type_Scene, "Scene", 0 },
|
|
||||||
|
|
||||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker
|
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,6 @@ void CSVDoc::SubView::updateEditorSetting (const QString &settingName, const QSt
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::SubView::setStatusBar (bool show) {}
|
void CSVDoc::SubView::setStatusBar (bool show) {}
|
||||||
|
|
||||||
|
void CSVDoc::SubView::useHint (const std::string& hint) {}
|
|
@ -40,9 +40,12 @@ namespace CSVDoc
|
||||||
virtual void setStatusBar (bool show);
|
virtual void setStatusBar (bool show);
|
||||||
///< Default implementation: ignored
|
///< Default implementation: ignored
|
||||||
|
|
||||||
|
virtual void useHint (const std::string& hint);
|
||||||
|
///< Default implementation: ignored
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void focusId (const CSMWorld::UniversalId& universalId);
|
void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,10 +115,6 @@ void CSVDoc::View::setupWorldMenu()
|
||||||
|
|
||||||
world->addSeparator(); // items that don't represent single record lists follow here
|
world->addSeparator(); // items that don't represent single record lists follow here
|
||||||
|
|
||||||
QAction *scene = new QAction (tr ("Scene"), this);
|
|
||||||
connect (scene, SIGNAL (triggered()), this, SLOT (addSceneSubView()));
|
|
||||||
world->addAction (scene);
|
|
||||||
|
|
||||||
QAction *regionMap = new QAction (tr ("Region Map"), this);
|
QAction *regionMap = new QAction (tr ("Region Map"), this);
|
||||||
connect (regionMap, SIGNAL (triggered()), this, SLOT (addRegionMapSubView()));
|
connect (regionMap, SIGNAL (triggered()), this, SLOT (addRegionMapSubView()));
|
||||||
world->addAction (regionMap);
|
world->addAction (regionMap);
|
||||||
|
@ -310,7 +306,7 @@ void CSVDoc::View::updateProgress (int current, int max, int type, int threads)
|
||||||
mOperations->setProgress (current, max, type, threads);
|
mOperations->setProgress (current, max, type, threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id)
|
void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::string& hint)
|
||||||
{
|
{
|
||||||
/// \todo add an user setting for limiting the number of sub views per top level view. Automatically open a new top level view if this
|
/// \todo add an user setting for limiting the number of sub views per top level view. Automatically open a new top level view if this
|
||||||
/// number is exceeded
|
/// number is exceeded
|
||||||
|
@ -322,12 +318,15 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id)
|
||||||
|
|
||||||
SubView *view = mSubViewFactory.makeSubView (id, *mDocument);
|
SubView *view = mSubViewFactory.makeSubView (id, *mDocument);
|
||||||
|
|
||||||
|
if (!hint.empty())
|
||||||
|
view->useHint (hint);
|
||||||
|
|
||||||
view->setStatusBar (mShowStatusBar->isChecked());
|
view->setStatusBar (mShowStatusBar->isChecked());
|
||||||
|
|
||||||
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
|
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
|
||||||
|
|
||||||
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this,
|
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)), this,
|
||||||
SLOT (addSubView (const CSMWorld::UniversalId&)));
|
SLOT (addSubView (const CSMWorld::UniversalId&, const std::string&)));
|
||||||
|
|
||||||
CSMSettings::UserSettings::instance().updateSettings("Display Format");
|
CSMSettings::UserSettings::instance().updateSettings("Display Format");
|
||||||
|
|
||||||
|
@ -429,11 +428,6 @@ void CSVDoc::View::addFiltersSubView()
|
||||||
addSubView (CSMWorld::UniversalId::Type_Filters);
|
addSubView (CSMWorld::UniversalId::Type_Filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::addSceneSubView()
|
|
||||||
{
|
|
||||||
addSubView (CSMWorld::UniversalId::Type_Scene);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVDoc::View::addTopicsSubView()
|
void CSVDoc::View::addTopicsSubView()
|
||||||
{
|
{
|
||||||
addSubView (CSMWorld::UniversalId::Type_Topics);
|
addSubView (CSMWorld::UniversalId::Type_Topics);
|
||||||
|
|
|
@ -120,7 +120,9 @@ namespace CSVDoc
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void addSubView (const CSMWorld::UniversalId& id);
|
void addSubView (const CSMWorld::UniversalId& id, const std::string& hint = "");
|
||||||
|
///< \param hint Suggested view point (e.g. coordinates in a 3D scene or a line number
|
||||||
|
/// in a script).
|
||||||
|
|
||||||
void abortOperation (int type);
|
void abortOperation (int type);
|
||||||
|
|
||||||
|
@ -166,8 +168,6 @@ namespace CSVDoc
|
||||||
|
|
||||||
void addFiltersSubView();
|
void addFiltersSubView();
|
||||||
|
|
||||||
void addSceneSubView();
|
|
||||||
|
|
||||||
void addTopicsSubView();
|
void addTopicsSubView();
|
||||||
|
|
||||||
void addJournalsSubView();
|
void addJournalsSubView();
|
||||||
|
|
6
apps/opencs/view/render/pagedworldspacewidget.cpp
Normal file
6
apps/opencs/view/render/pagedworldspacewidget.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
#include "pagedworldspacewidget.hpp"
|
||||||
|
|
||||||
|
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent)
|
||||||
|
: WorldspaceWidget (parent)
|
||||||
|
{}
|
18
apps/opencs/view/render/pagedworldspacewidget.hpp
Normal file
18
apps/opencs/view/render/pagedworldspacewidget.hpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
|
||||||
|
#define OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
|
||||||
|
|
||||||
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class PagedWorldspaceWidget : public WorldspaceWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
PagedWorldspaceWidget (QWidget *parent);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -61,6 +61,11 @@ namespace CSVRender
|
||||||
timer->start (20); /// \todo make this configurable
|
timer->start (20); /// \todo make this configurable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneWidget::setAmbient (const Ogre::ColourValue& colour)
|
||||||
|
{
|
||||||
|
mSceneMgr->setAmbientLight (colour);
|
||||||
|
}
|
||||||
|
|
||||||
void SceneWidget::updateOgreWindow()
|
void SceneWidget::updateOgreWindow()
|
||||||
{
|
{
|
||||||
if (mWindow)
|
if (mWindow)
|
||||||
|
@ -96,7 +101,11 @@ namespace CSVRender
|
||||||
|
|
||||||
SceneWidget::~SceneWidget()
|
SceneWidget::~SceneWidget()
|
||||||
{
|
{
|
||||||
Ogre::Root::getSingleton().destroyRenderTarget(mWindow);
|
if (mWindow)
|
||||||
|
Ogre::Root::getSingleton().destroyRenderTarget (mWindow);
|
||||||
|
|
||||||
|
if (mSceneMgr)
|
||||||
|
Ogre::Root::getSingleton().destroySceneManager (mSceneMgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneWidget::setNavigation (Navigation *navigation)
|
void SceneWidget::setNavigation (Navigation *navigation)
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Ogre
|
||||||
class Camera;
|
class Camera;
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
class RenderWindow;
|
class RenderWindow;
|
||||||
|
class ColourValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
|
@ -25,6 +26,11 @@ namespace CSVRender
|
||||||
|
|
||||||
QPaintEngine* paintEngine() const;
|
QPaintEngine* paintEngine() const;
|
||||||
|
|
||||||
|
void setAmbient (const Ogre::ColourValue& colour);
|
||||||
|
///< \note The actual ambient colour may differ based on lighting settings.
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
void setNavigation (Navigation *navigation);
|
void setNavigation (Navigation *navigation);
|
||||||
///< \attention The ownership of \a navigation is not transferred to *this.
|
///< \attention The ownership of \a navigation is not transferred to *this.
|
||||||
|
|
||||||
|
|
66
apps/opencs/view/render/unpagedworldspacewidget.cpp
Normal file
66
apps/opencs/view/render/unpagedworldspacewidget.cpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
|
||||||
|
#include "unpagedworldspacewidget.hpp"
|
||||||
|
|
||||||
|
#include <OgreColourValue.h>
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
|
||||||
|
#include "../../model/world/data.hpp"
|
||||||
|
#include "../../model/world/idtable.hpp"
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::update()
|
||||||
|
{
|
||||||
|
const CSMWorld::Record<CSMWorld::Cell>& record =
|
||||||
|
dynamic_cast<const CSMWorld::Record<CSMWorld::Cell>&> (mCellsModel->getRecord (mCellId));
|
||||||
|
|
||||||
|
Ogre::ColourValue colour;
|
||||||
|
colour.setAsABGR (record.get().mAmbi.mAmbient);
|
||||||
|
setAmbient (colour);
|
||||||
|
|
||||||
|
/// \todo deal with mSunlight and mFog/mForDensity
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId,
|
||||||
|
CSMDoc::Document& document, QWidget *parent)
|
||||||
|
: WorldspaceWidget (parent), mCellId (cellId)
|
||||||
|
{
|
||||||
|
mCellsModel = &dynamic_cast<CSMWorld::IdTable&> (
|
||||||
|
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
|
||||||
|
|
||||||
|
connect (mCellsModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||||
|
this, SLOT (cellDataChanged (const QModelIndex&, const QModelIndex&)));
|
||||||
|
connect (mCellsModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
|
this, SLOT (cellRowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
|
||||||
|
const QModelIndex& bottomRight)
|
||||||
|
{
|
||||||
|
int index = mCellsModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification);
|
||||||
|
QModelIndex cellIndex = mCellsModel->getModelIndex (mCellId, index);
|
||||||
|
|
||||||
|
if (cellIndex.row()>=topLeft.row() && cellIndex.row()<=bottomRight.row())
|
||||||
|
{
|
||||||
|
if (mCellsModel->data (cellIndex).toInt()==CSMWorld::RecordBase::State_Deleted)
|
||||||
|
{
|
||||||
|
emit closeRequest();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/// \todo possible optimisation: check columns and update only if relevant columns have
|
||||||
|
/// changed
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::cellRowsAboutToBeRemoved (const QModelIndex& parent,
|
||||||
|
int start, int end)
|
||||||
|
{
|
||||||
|
QModelIndex cellIndex = mCellsModel->getModelIndex (mCellId, 0);
|
||||||
|
|
||||||
|
if (cellIndex.row()>=start && cellIndex.row()<=end)
|
||||||
|
emit closeRequest();
|
||||||
|
}
|
44
apps/opencs/view/render/unpagedworldspacewidget.hpp
Normal file
44
apps/opencs/view/render/unpagedworldspacewidget.hpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#ifndef OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
|
||||||
|
#define OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
|
class QModelIndex;
|
||||||
|
|
||||||
|
namespace CSMDoc
|
||||||
|
{
|
||||||
|
class Document;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
class IdTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class UnpagedWorldspaceWidget : public WorldspaceWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
std::string mCellId;
|
||||||
|
CSMWorld::IdTable *mCellsModel;
|
||||||
|
|
||||||
|
void update();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,
|
||||||
|
QWidget *parent);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
||||||
|
void cellRowsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
38
apps/opencs/view/render/worldspacewidget.cpp
Normal file
38
apps/opencs/view/render/worldspacewidget.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
|
#include "../world/scenetoolmode.hpp"
|
||||||
|
|
||||||
|
CSVRender::WorldspaceWidget::WorldspaceWidget (QWidget *parent)
|
||||||
|
: SceneWidget (parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
|
||||||
|
{
|
||||||
|
if (mode=="1st")
|
||||||
|
setNavigation (&m1st);
|
||||||
|
else if (mode=="free")
|
||||||
|
setNavigation (&mFree);
|
||||||
|
else if (mode=="orbit")
|
||||||
|
setNavigation (&mOrbit);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
|
||||||
|
{
|
||||||
|
setNavigation (&m1st);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWorld::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
|
CSVWorld::SceneToolbar *parent)
|
||||||
|
{
|
||||||
|
CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent);
|
||||||
|
|
||||||
|
tool->addButton (":door.png", "1st"); /// \todo replace icons
|
||||||
|
tool->addButton (":GMST.png", "free");
|
||||||
|
tool->addButton (":Info.png", "orbit");
|
||||||
|
|
||||||
|
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
||||||
|
this, SLOT (selectNavigationMode (const std::string&)));
|
||||||
|
|
||||||
|
return tool;
|
||||||
|
}
|
46
apps/opencs/view/render/worldspacewidget.hpp
Normal file
46
apps/opencs/view/render/worldspacewidget.hpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H
|
||||||
|
#define OPENCS_VIEW_WORLDSPACEWIDGET_H
|
||||||
|
|
||||||
|
#include "scenewidget.hpp"
|
||||||
|
|
||||||
|
#include "navigation1st.hpp"
|
||||||
|
#include "navigationfree.hpp"
|
||||||
|
#include "navigationorbit.hpp"
|
||||||
|
|
||||||
|
namespace CSVWorld
|
||||||
|
{
|
||||||
|
class SceneToolMode;
|
||||||
|
class SceneToolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class WorldspaceWidget : public SceneWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
CSVRender::Navigation1st m1st;
|
||||||
|
CSVRender::NavigationFree mFree;
|
||||||
|
CSVRender::NavigationOrbit mOrbit;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
WorldspaceWidget (QWidget *parent = 0);
|
||||||
|
|
||||||
|
CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent);
|
||||||
|
///< \important The created tool is not added to the toolbar (via addTool). Doing that
|
||||||
|
/// is the responsibility of the calling function.
|
||||||
|
|
||||||
|
void selectDefaultNavigationMode();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void selectNavigationMode (const std::string& mode);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void closeRequest();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -40,5 +40,5 @@ void CSVTools::ReportSubView::updateEditorSetting (const QString& key, const QSt
|
||||||
|
|
||||||
void CSVTools::ReportSubView::show (const QModelIndex& index)
|
void CSVTools::ReportSubView::show (const QModelIndex& index)
|
||||||
{
|
{
|
||||||
focusId (mModel->getUniversalId (index.row()));
|
focusId (mModel->getUniversalId (index.row()), "");
|
||||||
}
|
}
|
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
#include "../filter/filterbox.hpp"
|
#include "../filter/filterbox.hpp"
|
||||||
|
|
||||||
#include "../render/scenewidget.hpp"
|
#include "../render/pagedworldspacewidget.hpp"
|
||||||
|
#include "../render/unpagedworldspacewidget.hpp"
|
||||||
|
|
||||||
#include "tablebottombox.hpp"
|
#include "tablebottombox.hpp"
|
||||||
#include "creator.hpp"
|
#include "creator.hpp"
|
||||||
|
@ -33,19 +34,16 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
|
|
||||||
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
||||||
|
|
||||||
// navigation mode
|
if (id.getId()[0]=='#')
|
||||||
SceneToolMode *tool = new SceneToolMode (toolbar);
|
mScene = new CSVRender::PagedWorldspaceWidget (this);
|
||||||
tool->addButton (":door.png", "1st"); /// \todo replace icons
|
else
|
||||||
tool->addButton (":GMST.png", "free");
|
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
|
||||||
tool->addButton (":Info.png", "orbit");
|
|
||||||
|
SceneToolMode *tool = mScene->makeNavigationSelector (toolbar);
|
||||||
toolbar->addTool (tool);
|
toolbar->addTool (tool);
|
||||||
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
|
||||||
this, SLOT (selectNavigationMode (const std::string&)));
|
|
||||||
|
|
||||||
layout2->addWidget (toolbar, 0);
|
layout2->addWidget (toolbar, 0);
|
||||||
|
|
||||||
mScene = new CSVRender::SceneWidget(this);
|
|
||||||
|
|
||||||
layout2->addWidget (mScene, 1);
|
layout2->addWidget (mScene, 1);
|
||||||
|
|
||||||
layout->insertLayout (0, layout2, 1);
|
layout->insertLayout (0, layout2, 1);
|
||||||
|
@ -60,7 +58,9 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
|
|
||||||
setWidget (widget);
|
setWidget (widget);
|
||||||
|
|
||||||
mScene->setNavigation (&m1st);
|
mScene->selectDefaultNavigationMode();
|
||||||
|
|
||||||
|
connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::setEditLock (bool locked)
|
void CSVWorld::SceneSubView::setEditLock (bool locked)
|
||||||
|
@ -80,12 +80,7 @@ void CSVWorld::SceneSubView::setStatusBar (bool show)
|
||||||
mBottom->setStatusBar (show);
|
mBottom->setStatusBar (show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::selectNavigationMode (const std::string& mode)
|
void CSVWorld::SceneSubView::closeRequest()
|
||||||
{
|
{
|
||||||
if (mode=="1st")
|
deleteLater();
|
||||||
mScene->setNavigation (&m1st);
|
}
|
||||||
else if (mode=="free")
|
|
||||||
mScene->setNavigation (&mFree);
|
|
||||||
else if (mode=="orbit")
|
|
||||||
mScene->setNavigation (&mOrbit);
|
|
||||||
}
|
|
|
@ -3,10 +3,6 @@
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
#include "../render/navigation1st.hpp"
|
|
||||||
#include "../render/navigationfree.hpp"
|
|
||||||
#include "../render/navigationorbit.hpp"
|
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
|
@ -16,7 +12,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
class SceneWidget;
|
class WorldspaceWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
|
@ -30,10 +26,7 @@ namespace CSVWorld
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
TableBottomBox *mBottom;
|
TableBottomBox *mBottom;
|
||||||
CSVRender::SceneWidget *mScene;
|
CSVRender::WorldspaceWidget *mScene;
|
||||||
CSVRender::Navigation1st m1st;
|
|
||||||
CSVRender::NavigationFree mFree;
|
|
||||||
CSVRender::NavigationOrbit mOrbit;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -47,7 +40,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void selectNavigationMode (const std::string& mode);
|
void closeRequest();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "table.hpp"
|
#include "table.hpp"
|
||||||
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -10,6 +9,8 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <QtCore/qnamespace.h>
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/world/idtableproxymodel.hpp"
|
#include "../../model/world/idtableproxymodel.hpp"
|
||||||
|
@ -35,8 +36,21 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
|
||||||
if (selectedRows.size()==1)
|
if (selectedRows.size()==1)
|
||||||
{
|
{
|
||||||
menu.addAction (mEditAction);
|
menu.addAction (mEditAction);
|
||||||
|
|
||||||
if (mCreateAction)
|
if (mCreateAction)
|
||||||
menu.addAction(mCloneAction);
|
menu.addAction(mCloneAction);
|
||||||
|
|
||||||
|
if (mModel->getViewing()!=CSMWorld::IdTable::Viewing_None)
|
||||||
|
{
|
||||||
|
int row = selectedRows.begin()->row();
|
||||||
|
|
||||||
|
row = mProxyModel->mapToSource (mProxyModel->index (row, 0)).row();
|
||||||
|
|
||||||
|
CSMWorld::UniversalId id = mModel->view (row).first;
|
||||||
|
|
||||||
|
if (!mDocument.getData().getCells().getRecord (id.getId()).isDeleted())
|
||||||
|
menu.addAction (mViewAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCreateAction)
|
if (mCreateAction)
|
||||||
|
@ -162,11 +176,12 @@ std::vector<std::string> CSVWorld::Table::listDeletableSelectedIds() const
|
||||||
return deletableIds;
|
return deletableIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack,
|
CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||||
bool createAndDelete, bool sorting, const CSMDoc::Document& document)
|
bool createAndDelete, bool sorting, CSMDoc::Document& document)
|
||||||
: mUndoStack (undoStack), mCreateAction (0), mCloneAction(0), mEditLock (false), mRecordStatusDisplay (0), mDocument(document)
|
: mCreateAction (0), mCloneAction(0), mEditLock (false), mRecordStatusDisplay (0),
|
||||||
|
mDocument (document)
|
||||||
{
|
{
|
||||||
mModel = &dynamic_cast<CSMWorld::IdTable&> (*data.getTableModel (id));
|
mModel = &dynamic_cast<CSMWorld::IdTable&> (*mDocument.getData().getTableModel (id));
|
||||||
|
|
||||||
mProxyModel = new CSMWorld::IdTableProxyModel (this);
|
mProxyModel = new CSMWorld::IdTableProxyModel (this);
|
||||||
mProxyModel->setSourceModel (mModel);
|
mProxyModel->setSourceModel (mModel);
|
||||||
|
@ -190,7 +205,7 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q
|
||||||
mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
|
mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
|
||||||
|
|
||||||
CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display,
|
CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display,
|
||||||
undoStack, this);
|
mDocument.getUndoStack(), this);
|
||||||
|
|
||||||
mDelegates.push_back (delegate);
|
mDelegates.push_back (delegate);
|
||||||
setItemDelegateForColumn (i, delegate);
|
setItemDelegateForColumn (i, delegate);
|
||||||
|
@ -230,6 +245,10 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q
|
||||||
connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord()));
|
connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord()));
|
||||||
addAction (mMoveDownAction);
|
addAction (mMoveDownAction);
|
||||||
|
|
||||||
|
mViewAction = new QAction (tr ("View"), this);
|
||||||
|
connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord()));
|
||||||
|
addAction (mViewAction);
|
||||||
|
|
||||||
connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||||
this, SLOT (tableSizeUpdate()));
|
this, SLOT (tableSizeUpdate()));
|
||||||
|
|
||||||
|
@ -268,13 +287,13 @@ void CSVWorld::Table::revertRecord()
|
||||||
if (revertableIds.size()>0)
|
if (revertableIds.size()>0)
|
||||||
{
|
{
|
||||||
if (revertableIds.size()>1)
|
if (revertableIds.size()>1)
|
||||||
mUndoStack.beginMacro (tr ("Revert multiple records"));
|
mDocument.getUndoStack().beginMacro (tr ("Revert multiple records"));
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator iter (revertableIds.begin()); iter!=revertableIds.end(); ++iter)
|
for (std::vector<std::string>::const_iterator iter (revertableIds.begin()); iter!=revertableIds.end(); ++iter)
|
||||||
mUndoStack.push (new CSMWorld::RevertCommand (*mModel, *iter));
|
mDocument.getUndoStack().push (new CSMWorld::RevertCommand (*mModel, *iter));
|
||||||
|
|
||||||
if (revertableIds.size()>1)
|
if (revertableIds.size()>1)
|
||||||
mUndoStack.endMacro();
|
mDocument.getUndoStack().endMacro();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,13 +307,13 @@ void CSVWorld::Table::deleteRecord()
|
||||||
if (deletableIds.size()>0)
|
if (deletableIds.size()>0)
|
||||||
{
|
{
|
||||||
if (deletableIds.size()>1)
|
if (deletableIds.size()>1)
|
||||||
mUndoStack.beginMacro (tr ("Delete multiple records"));
|
mDocument.getUndoStack().beginMacro (tr ("Delete multiple records"));
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator iter (deletableIds.begin()); iter!=deletableIds.end(); ++iter)
|
for (std::vector<std::string>::const_iterator iter (deletableIds.begin()); iter!=deletableIds.end(); ++iter)
|
||||||
mUndoStack.push (new CSMWorld::DeleteCommand (*mModel, *iter));
|
mDocument.getUndoStack().push (new CSMWorld::DeleteCommand (*mModel, *iter));
|
||||||
|
|
||||||
if (deletableIds.size()>1)
|
if (deletableIds.size()>1)
|
||||||
mUndoStack.endMacro();
|
mDocument.getUndoStack().endMacro();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +325,7 @@ void CSVWorld::Table::editRecord()
|
||||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
|
|
||||||
if (selectedRows.size()==1)
|
if (selectedRows.size()==1)
|
||||||
emit editRequest (selectedRows.begin()->row());
|
emit editRequest (getUniversalId (selectedRows.begin()->row()), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +366,7 @@ void CSVWorld::Table::moveUpRecord()
|
||||||
for (int i=1; i<row2-row; ++i)
|
for (int i=1; i<row2-row; ++i)
|
||||||
newOrder[i] = i;
|
newOrder[i] = i;
|
||||||
|
|
||||||
mUndoStack.push (new CSMWorld::ReorderRowsCommand (*mModel, row, newOrder));
|
mDocument.getUndoStack().push (new CSMWorld::ReorderRowsCommand (*mModel, row, newOrder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,11 +395,28 @@ void CSVWorld::Table::moveDownRecord()
|
||||||
for (int i=1; i<row2-row; ++i)
|
for (int i=1; i<row2-row; ++i)
|
||||||
newOrder[i] = i;
|
newOrder[i] = i;
|
||||||
|
|
||||||
mUndoStack.push (new CSMWorld::ReorderRowsCommand (*mModel, row, newOrder));
|
mDocument.getUndoStack().push (new CSMWorld::ReorderRowsCommand (*mModel, row, newOrder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::Table::viewRecord()
|
||||||
|
{
|
||||||
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if (selectedRows.size()==1)
|
||||||
|
{
|
||||||
|
int row =selectedRows.begin()->row();
|
||||||
|
|
||||||
|
row = mProxyModel->mapToSource (mProxyModel->index (row, 0)).row();
|
||||||
|
|
||||||
|
std::pair<CSMWorld::UniversalId, std::string> params = mModel->view (row);
|
||||||
|
|
||||||
|
if (params.first.getType()!=CSMWorld::UniversalId::Type_None)
|
||||||
|
emit editRequest (params.first, params.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
{
|
{
|
||||||
int columns = mModel->columnCount();
|
int columns = mModel->columnCount();
|
||||||
|
@ -517,7 +553,7 @@ void CSVWorld::Table::dropEvent(QDropEvent *event)
|
||||||
std::auto_ptr<CSMWorld::ModifyCommand> command (new CSMWorld::ModifyCommand
|
std::auto_ptr<CSMWorld::ModifyCommand> command (new CSMWorld::ModifyCommand
|
||||||
(*mProxyModel, index, QVariant (QString::fromUtf8 (record.getId().c_str()))));
|
(*mProxyModel, index, QVariant (QString::fromUtf8 (record.getId().c_str()))));
|
||||||
|
|
||||||
mUndoStack.push (command.release());
|
mDocument.getUndoStack().push (command.release());
|
||||||
}
|
}
|
||||||
} //TODO handle drops from different document
|
} //TODO handle drops from different document
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,14 @@
|
||||||
#include "../../model/filter/node.hpp"
|
#include "../../model/filter/node.hpp"
|
||||||
#include "../../model/world/columnbase.hpp"
|
#include "../../model/world/columnbase.hpp"
|
||||||
|
|
||||||
namespace CSMDoc {
|
|
||||||
class Document;
|
|
||||||
}
|
|
||||||
|
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
|
namespace CSMDoc
|
||||||
|
{
|
||||||
|
class Document;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class Data;
|
class Data;
|
||||||
|
@ -35,7 +36,6 @@ namespace CSVWorld
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
std::vector<CommandDelegate *> mDelegates;
|
std::vector<CommandDelegate *> mDelegates;
|
||||||
QUndoStack& mUndoStack;
|
|
||||||
QAction *mEditAction;
|
QAction *mEditAction;
|
||||||
QAction *mCreateAction;
|
QAction *mCreateAction;
|
||||||
QAction *mCloneAction;
|
QAction *mCloneAction;
|
||||||
|
@ -43,14 +43,12 @@ namespace CSVWorld
|
||||||
QAction *mDeleteAction;
|
QAction *mDeleteAction;
|
||||||
QAction *mMoveUpAction;
|
QAction *mMoveUpAction;
|
||||||
QAction *mMoveDownAction;
|
QAction *mMoveDownAction;
|
||||||
|
QAction *mViewAction;
|
||||||
CSMWorld::IdTableProxyModel *mProxyModel;
|
CSMWorld::IdTableProxyModel *mProxyModel;
|
||||||
CSMWorld::IdTable *mModel;
|
CSMWorld::IdTable *mModel;
|
||||||
bool mEditLock;
|
bool mEditLock;
|
||||||
int mRecordStatusDisplay;
|
int mRecordStatusDisplay;
|
||||||
|
CSMDoc::Document& mDocument;
|
||||||
/// \brief This variable is used exclusivly for checking if dropEvents came from the same document. Most likely you
|
|
||||||
/// should NOT use it for anything else.
|
|
||||||
const CSMDoc::Document& mDocument;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -70,9 +68,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete,
|
Table (const CSMWorld::UniversalId& id, bool createAndDelete,
|
||||||
bool sorting, const CSMDoc::Document& document);
|
bool sorting, CSMDoc::Document& document);
|
||||||
|
|
||||||
///< \param createAndDelete Allow creation and deletion of records.
|
///< \param createAndDelete Allow creation and deletion of records.
|
||||||
/// \param sorting Allow changing order of rows in the view via column headers.
|
/// \param sorting Allow changing order of rows in the view via column headers.
|
||||||
|
|
||||||
|
@ -86,7 +83,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void editRequest (int row);
|
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||||
|
|
||||||
void selectionSizeChanged (int size);
|
void selectionSizeChanged (int size);
|
||||||
|
|
||||||
|
@ -112,6 +109,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
void moveDownRecord();
|
void moveDownRecord();
|
||||||
|
|
||||||
|
void viewRecord();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void tableSizeUpdate();
|
void tableSizeUpdate();
|
||||||
|
|
|
@ -24,7 +24,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this), 0);
|
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this), 0);
|
||||||
|
|
||||||
layout->insertWidget (0, mTable =
|
layout->insertWidget (0, mTable =
|
||||||
new Table (id, document.getData(), document.getUndoStack(), mBottom->canCreateAndDelete(), sorting, document), 2);
|
new Table (id, mBottom->canCreateAndDelete(), sorting, document), 2);
|
||||||
|
|
||||||
CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this);
|
CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this);
|
||||||
|
|
||||||
|
@ -36,7 +36,8 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
|
|
||||||
setWidget (widget);
|
setWidget (widget);
|
||||||
|
|
||||||
connect (mTable, SIGNAL (editRequest (int)), this, SLOT (editRequest (int)));
|
connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)),
|
||||||
|
this, SLOT (editRequest (const CSMWorld::UniversalId&, const std::string&)));
|
||||||
|
|
||||||
connect (mTable, SIGNAL (selectionSizeChanged (int)),
|
connect (mTable, SIGNAL (selectionSizeChanged (int)),
|
||||||
mBottom, SLOT (selectionSizeChanged (int)));
|
mBottom, SLOT (selectionSizeChanged (int)));
|
||||||
|
@ -81,9 +82,9 @@ void CSVWorld::TableSubView::setEditLock (bool locked)
|
||||||
mBottom->setEditLock (locked);
|
mBottom->setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::TableSubView::editRequest (int row)
|
void CSVWorld::TableSubView::editRequest (const CSMWorld::UniversalId& id, const std::string& hint)
|
||||||
{
|
{
|
||||||
focusId (mTable->getUniversalId (row));
|
focusId (id, hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, const QString &settingValue)
|
void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, const QString &settingValue)
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void editRequest (int row);
|
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||||
void cloneRequest (const CSMWorld::UniversalId& toClone);
|
void cloneRequest (const CSMWorld::UniversalId& toClone);
|
||||||
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types,
|
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types,
|
||||||
Qt::DropAction action);
|
Qt::DropAction action);
|
||||||
|
|
|
@ -249,7 +249,7 @@ bool Cell::getNextMVRF(ESMReader &esm, MovedCellRef &mref)
|
||||||
|
|
||||||
if (id.mPaged)
|
if (id.mPaged)
|
||||||
{
|
{
|
||||||
id.mWorldspace = "default";
|
id.mWorldspace = "sys::default";
|
||||||
id.mIndex.mX = mData.mX;
|
id.mIndex.mX = mData.mX;
|
||||||
id.mIndex.mY = mData.mY;
|
id.mIndex.mY = mData.mY;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue