void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) { QModelIndexList selectedRows = selectionModel()->selectedRows(); QMenu menu (this); /// \todo add menu items for select all and clear selection if (!mEditLock) { if (selectedRows.size()==1) menu.addAction (mEditAction); if (mCreateAction) menu.addAction (mCreateAction); if (listRevertableSelectedIds().size()>0) menu.addAction (mRevertAction); if (listDeletableSelectedIds().size()>0) menu.addAction (mDeleteAction); } menu.exec (event->globalPos()); }
void CSVWorld::Table::revertRecord() { if (!mEditLock) { std::vector<std::string> revertableIds = listRevertableSelectedIds(); if (revertableIds.size()>0) { if (revertableIds.size()>1) mUndoStack.beginMacro (tr ("Revert multiple records")); for (std::vector<std::string>::const_iterator iter (revertableIds.begin()); iter!=revertableIds.end(); ++iter) mUndoStack.push (new CSMWorld::RevertCommand (*mModel, *iter)); if (revertableIds.size()>1) mUndoStack.endMacro(); } } }
void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) { QModelIndexList selectedRows = selectionModel()->selectedRows(); QMenu menu (this); /// \todo add menu items for select all and clear selection if (!mEditLock) { if (selectedRows.size()==1) { menu.addAction (mEditAction); if (mCreateAction) menu.addAction(mCloneAction); } if (mCreateAction) menu.addAction (mCreateAction); /// \todo Reverting temporarily disabled on tables that support reordering, because /// revert logic currently can not handle reordering. if (mModel->getReordering()==CSMWorld::IdTable::Reordering_None) if (listRevertableSelectedIds().size()>0) menu.addAction (mRevertAction); if (listDeletableSelectedIds().size()>0) menu.addAction (mDeleteAction); if (mModel->getReordering()==CSMWorld::IdTable::Reordering_WithinTopic) { /// \todo allow reordering of multiple rows if (selectedRows.size()==1) { int row =selectedRows.begin()->row(); int column = mModel->searchColumnIndex (CSMWorld::Columns::ColumnId_Topic); if (column==-1) column = mModel->searchColumnIndex (CSMWorld::Columns::ColumnId_Journal); if (column!=-1) { if (row>0 && mProxyModel->data (mProxyModel->index (row, column))== mProxyModel->data (mProxyModel->index (row-1, column))) { menu.addAction (mMoveUpAction); } if (row<mProxyModel->rowCount()-1 && mProxyModel->data (mProxyModel->index (row, column))== mProxyModel->data (mProxyModel->index (row+1, column))) { menu.addAction (mMoveDownAction); } } } } } menu.exec (event->globalPos()); }