1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

added Preview submenu item; fixed View issues regarding exterior cells

This commit is contained in:
Marc Zinnschlag 2014-03-10 12:44:34 +01:00
parent 2b17f5dde9
commit 7812427836
8 changed files with 60 additions and 21 deletions

View File

@ -250,9 +250,9 @@ CSMWorld::Data::Data() : mRefs (mCells)
addModel (new IdTable (&mTopicInfos, IdTable::Reordering_WithinTopic), UniversalId::Type_TopicInfos, UniversalId::Type_TopicInfo);
addModel (new IdTable (&mJournalInfos, IdTable::Reordering_WithinTopic), UniversalId::Type_JournalInfos, UniversalId::Type_JournalInfo);
addModel (new IdTable (&mCells, IdTable::Reordering_None, IdTable::Viewing_Id), UniversalId::Type_Cells, UniversalId::Type_Cell);
addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables,
UniversalId::Type_Referenceable);
addModel (new IdTable (&mRefs, IdTable::Reordering_None, IdTable::Viewing_Cell), UniversalId::Type_References, UniversalId::Type_Reference, false);
addModel (new IdTable (&mReferenceables, IdTable::Reordering_None, IdTable::Viewing_None, true),
UniversalId::Type_Referenceables, UniversalId::Type_Referenceable);
addModel (new IdTable (&mRefs, IdTable::Reordering_None, IdTable::Viewing_Cell, true), UniversalId::Type_References, UniversalId::Type_Reference, false);
addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter, false);
}

View File

@ -5,8 +5,8 @@
#include "columnbase.hpp"
CSMWorld::IdTable::IdTable (CollectionBase *idCollection, Reordering reordering,
Viewing viewing)
: mIdCollection (idCollection), mReordering (reordering), mViewing (viewing)
Viewing viewing, bool preview)
: mIdCollection (idCollection), mReordering (reordering), mViewing (viewing), mPreview (preview)
{}
CSMWorld::IdTable::~IdTable()
@ -196,6 +196,11 @@ CSMWorld::IdTable::Viewing CSMWorld::IdTable::getViewing() const
return mViewing;
}
bool CSMWorld::IdTable::hasPreview() const
{
return mPreview;
}
std::pair<CSMWorld::UniversalId, std::string> CSMWorld::IdTable::view (int row) const
{
std::string id;

View File

@ -39,6 +39,7 @@ namespace CSMWorld
CollectionBase *mIdCollection;
Reordering mReordering;
Viewing mViewing;
bool mPreview;
// not implemented
IdTable (const IdTable&);
@ -47,7 +48,7 @@ namespace CSMWorld
public:
IdTable (CollectionBase *idCollection, Reordering reordering = Reordering_None,
Viewing viewing = Viewing_None);
Viewing viewing = Viewing_None, bool preview = false);
///< The ownership of \a idCollection is not transferred.
virtual ~IdTable();
@ -100,6 +101,8 @@ namespace CSMWorld
Viewing getViewing() const;
bool hasPreview() 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, "").

View File

@ -92,6 +92,8 @@ namespace
{ CSMWorld::UniversalId::Class_SubRecord, CSMWorld::UniversalId::Type_Filter, "Filter", ":./filter.png" },
{ CSMWorld::UniversalId::Class_Collection, CSMWorld::UniversalId::Type_Scene, "Scene", 0 },
{ CSMWorld::UniversalId::Class_Collection, CSMWorld::UniversalId::Type_Preview, "Preview", 0 },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker
};

View File

@ -95,7 +95,8 @@ namespace CSMWorld
Type_TopicInfo,
Type_JournalInfos,
Type_JournalInfo,
Type_Scene
Type_Scene,
Type_Preview
};
enum { NumberOfTypes = Type_Scene+1 };

View File

@ -34,7 +34,7 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
SceneToolbar *toolbar = new SceneToolbar (48, this);
if (id.getId()[0]=='#')
if (id.getId()=="sys::default")
mScene = new CSVRender::PagedWorldspaceWidget (this);
else
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);

View File

@ -39,18 +39,6 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
if (mCreateAction)
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)
@ -95,6 +83,28 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
}
}
if (selectedRows.size()==1)
{
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;
int index = mDocument.getData().getCells().searchId (id.getId());
// index==-1: the ID references a worldspace instead of a cell (ignore for now and go
// ahead)
if (index==-1 || !mDocument.getData().getCells().getRecord (index).isDeleted())
menu.addAction (mViewAction);
}
if (mModel->hasPreview())
menu.addAction (mPreviewAction);
}
menu.exec (event->globalPos());
}
@ -249,6 +259,10 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord()));
addAction (mViewAction);
mPreviewAction = new QAction (tr ("Preview"), this);
connect (mPreviewAction, SIGNAL (triggered()), this, SLOT (previewRecord()));
addAction (mPreviewAction);
connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
this, SLOT (tableSizeUpdate()));
@ -406,7 +420,7 @@ void CSVWorld::Table::viewRecord()
if (selectedRows.size()==1)
{
int row =selectedRows.begin()->row();
int row = selectedRows.begin()->row();
row = mProxyModel->mapToSource (mProxyModel->index (row, 0)).row();
@ -417,6 +431,17 @@ void CSVWorld::Table::viewRecord()
}
}
void CSVWorld::Table::previewRecord()
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
if (selectedRows.size()==1)
{
std::string id = getUniversalId (selectedRows.begin()->row()).getId();
emit editRequest (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Preview, id) , "");
}
}
void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QString &settingValue)
{
int columns = mModel->columnCount();

View File

@ -44,6 +44,7 @@ namespace CSVWorld
QAction *mMoveUpAction;
QAction *mMoveDownAction;
QAction *mViewAction;
QAction *mPreviewAction;
CSMWorld::IdTableProxyModel *mProxyModel;
CSMWorld::IdTable *mModel;
bool mEditLock;
@ -111,6 +112,8 @@ namespace CSVWorld
void viewRecord();
void previewRecord();
public slots:
void tableSizeUpdate();