disabled preview function for deleted records

This commit is contained in:
Marc Zinnschlag 2014-06-27 11:38:34 +02:00
parent 36c1170d09
commit a2f514f024

View file

@ -114,13 +114,13 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
} }
if (selectedRows.size()==1) if (selectedRows.size()==1)
{
if (mModel->getFeatures() & CSMWorld::IdTable::Feature_View)
{ {
int row = selectedRows.begin()->row(); int row = selectedRows.begin()->row();
row = mProxyModel->mapToSource (mProxyModel->index (row, 0)).row(); row = mProxyModel->mapToSource (mProxyModel->index (row, 0)).row();
if (mModel->getFeatures() & CSMWorld::IdTable::Feature_View)
{
CSMWorld::UniversalId id = mModel->view (row).first; CSMWorld::UniversalId id = mModel->view (row).first;
int index = mDocument.getData().getCells().searchId (id.getId()); int index = mDocument.getData().getCells().searchId (id.getId());
@ -132,8 +132,17 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
} }
if (mModel->getFeatures() & CSMWorld::IdTable::Feature_Preview) if (mModel->getFeatures() & CSMWorld::IdTable::Feature_Preview)
{
QModelIndex index = mModel->index (row,
mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification));
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State> (
mModel->data (index).toInt());
if (state!=CSMWorld::RecordBase::State_Deleted)
menu.addAction (mPreviewAction); menu.addAction (mPreviewAction);
} }
}
menu.exec (event->globalPos()); menu.exec (event->globalPos());
} }
@ -377,7 +386,12 @@ void CSVWorld::Table::previewRecord()
{ {
std::string id = getUniversalId (selectedRows.begin()->row()).getId(); std::string id = getUniversalId (selectedRows.begin()->row()).getId();
emit editRequest (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Preview, id) , ""); QModelIndex index = mModel->getModelIndex (id,
mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification));
if (mModel->data (index)!=CSMWorld::RecordBase::State_Deleted)
emit editRequest (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Preview, id),
"");
} }
} }