本文整理汇总了C++中QUndoStack::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QUndoStack::clear方法的具体用法?C++ QUndoStack::clear怎么用?C++ QUndoStack::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUndoStack
的用法示例。
在下文中一共展示了QUndoStack::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteCollection
void CollectionListView::deleteCollection()
{
int collectionId = MetadataEngine::getInstance().getCurrentCollectionId();
if ((collectionId == 0) || SyncSession::IS_READ_ONLY) return; //0 stands for invalid
//ask for confirmation
QMessageBox box(QMessageBox::Question, tr("Delete Collection"),
tr("Are you sure you want to delete the selected collection?"
"<br><br><b>Warning:</b> This cannot be undone!"),
QMessageBox::Yes | QMessageBox::No,
this);
box.setDefaultButton(QMessageBox::Yes);
box.setWindowModality(Qt::WindowModal);
int r = box.exec();
if (r == QMessageBox::No) return;
//check all fields for delete triggers
CollectionFieldCleaner cleaner(this);
cleaner.cleanCollection(collectionId);
//delete metadata and tables
MetadataEngine::getInstance().deleteCollection(collectionId);
//delete from model
m_model->removeRow(currentIndex().row());
//delete settings about collection's column positions in TableView
SettingsManager s;
QString settingsKey = QString("collection_") + QString::number(collectionId);
s.deleteObjectProperties(settingsKey);
//reset cached id
m_currentCollectionId = 0;
//clear undo stack since this action is not undoable
QUndoStack *stack = MainWindow::getUndoStack();
if (stack) stack->clear();
//set first collection as current one
QModelIndex first = m_model->index(0, 1);
if (first.isValid())
setCurrentIndex(first);
else
MetadataEngine::getInstance().setCurrentCollectionId(0); //set invalid
//set local data changed
SyncSession::LOCAL_DATA_CHANGED = true;
}
示例2: sipNoMethod
static PyObject *meth_QUndoStack_clear(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QUndoStack *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QUndoStack, &sipCpp))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->clear();
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QUndoStack, sipName_clear, NULL);
return NULL;
}