本文整理汇总了C++中QDesignerFormWindowInterface::commandHistory方法的典型用法代码示例。如果您正苦于以下问题:C++ QDesignerFormWindowInterface::commandHistory方法的具体用法?C++ QDesignerFormWindowInterface::commandHistory怎么用?C++ QDesignerFormWindowInterface::commandHistory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDesignerFormWindowInterface
的用法示例。
在下文中一共展示了QDesignerFormWindowInterface::commandHistory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: swapActions
bool QDesignerMenuBar::swapActions(int a, int b)
{
const int left = qMin(a, b);
int right = qMax(a, b);
QAction *action_a = safeActionAt(left);
QAction *action_b = safeActionAt(right);
if (action_a == action_b
|| !action_a
|| !action_b
|| qobject_cast<SpecialMenuAction*>(action_a)
|| qobject_cast<SpecialMenuAction*>(action_b))
return false; // nothing to do
right = qMin(right, realActionCount());
if (right < 0)
return false; // nothing to do
formWindow()->beginCommand(QApplication::translate("Command", "Move action"));
QAction *action_b_before = safeActionAt(right + 1);
QDesignerFormWindowInterface *fw = formWindow();
RemoveActionFromCommand *cmd1 = new RemoveActionFromCommand(fw);
cmd1->init(this, action_b, action_b_before, false);
fw->commandHistory()->push(cmd1);
QAction *action_a_before = safeActionAt(left + 1);
InsertActionIntoCommand *cmd2 = new InsertActionIntoCommand(fw);
cmd2->init(this, action_b, action_a_before, false);
fw->commandHistory()->push(cmd2);
RemoveActionFromCommand *cmd3 = new RemoveActionFromCommand(fw);
cmd3->init(this, action_a, action_b, false);
fw->commandHistory()->push(cmd3);
InsertActionIntoCommand *cmd4 = new InsertActionIntoCommand(fw);
cmd4->init(this, action_a, action_b_before, true);
fw->commandHistory()->push(cmd4);
fw->endCommand();
return true;
}
示例2: editAction
void ActionEditor::editAction(QAction *action)
{
if (!action)
return;
NewActionDialog dlg(this);
dlg.setWindowTitle(tr("Edit action"));
ActionData oldActionData;
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
oldActionData.name = action->objectName();
oldActionData.text = action->text();
oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC));
oldActionData.icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
oldActionData.keysequence = ActionModel::actionShortCut(sheet);
oldActionData.checkable = action->isCheckable();
dlg.setActionData(oldActionData);
if (!dlg.exec())
return;
// figure out changes and whether to start a macro
const ActionData newActionData = dlg.actionData();
const unsigned changeMask = newActionData.compare(oldActionData);
if (changeMask == 0u)
return;
const bool severalChanges = (changeMask != ActionData::TextChanged) && (changeMask != ActionData::NameChanged)
&& (changeMask != ActionData::ToolTipChanged) && (changeMask != ActionData::IconChanged)
&& (changeMask != ActionData::CheckableChanged) && (changeMask != ActionData::KeysequenceChanged);
QDesignerFormWindowInterface *fw = formWindow();
QUndoStack *undoStack = fw->commandHistory();
if (severalChanges)
fw->beginCommand(QStringLiteral("Edit action"));
if (changeMask & ActionData::NameChanged)
undoStack->push(createTextPropertyCommand(QLatin1String(objectNamePropertyC), newActionData.name, action, fw));
if (changeMask & ActionData::TextChanged)
undoStack->push(createTextPropertyCommand(QLatin1String(textPropertyC), newActionData.text, action, fw));
if (changeMask & ActionData::ToolTipChanged)
undoStack->push(createTextPropertyCommand(QLatin1String(toolTipPropertyC), newActionData.toolTip, action, fw));
if (changeMask & ActionData::IconChanged)
undoStack->push(setIconPropertyCommand(newActionData.icon, action, fw));
if (changeMask & ActionData::CheckableChanged)
undoStack->push(setPropertyCommand(QLatin1String(checkablePropertyC), newActionData.checkable, false, action, fw));
if (changeMask & ActionData::KeysequenceChanged)
undoStack->push(setKeySequencePropertyCommand(newActionData.keysequence, action, fw));
if (severalChanges)
fw->endCommand();
}
示例3: addPageAfter
void ContainerWidgetTaskMenu::addPageAfter()
{
if (containerExtension()) {
QDesignerFormWindowInterface *fw = formWindow();
AddContainerWidgetPageCommand *cmd = new AddContainerWidgetPageCommand(fw);
cmd->init(m_containerWidget, m_type, AddContainerWidgetPageCommand::InsertAfter);
fw->commandHistory()->push(cmd);
}
}
示例4: removeStyle
void DesignerStyleInput::removeStyle()
{
if (qobject_cast<QWidget*>(parent()))
{
if (g_removeBlock)
return;
QDesignerFormWindowInterface* formWindow = QDesignerFormWindowInterface::findFormWindow(m_widget);
Q_ASSERT(formWindow != Q_NULL);
const QString description = tr("Delete '%1'").arg(m_widget->objectName());
formWindow->commandHistory()->beginMacro(description);
DeleteStyleCommand* cmd = new DeleteStyleCommand(formWindow);
cmd->init(m_widget);
formWindow->commandHistory()->push(cmd);
formWindow->commandHistory()->endMacro();
}
}
示例5: slotRemoveMenuBar
void QDesignerMenuBar::slotRemoveMenuBar()
{
Q_ASSERT(formWindow() != 0);
QDesignerFormWindowInterface *fw = formWindow();
DeleteMenuBarCommand *cmd = new DeleteMenuBarCommand(fw);
cmd->init(this);
fw->commandHistory()->push(cmd);
}
示例6: slotDemoteFromCustomWidget
void PromotionTaskMenu::slotDemoteFromCustomWidget()
{
QDesignerFormWindowInterface *fw = formWindow();
const PromotionSelectionList promotedWidgets = promotionSelectionList(fw);
Q_ASSERT(!promotedWidgets.empty() && isPromoted(fw->core(), promotedWidgets.front()));
// ### use the undo stack
DemoteFromCustomWidgetCommand *cmd = new DemoteFromCustomWidgetCommand(fw);
cmd->init(promotedWidgets);
fw->commandHistory()->push(cmd);
}
示例7: slotInsertSeparator
void ToolBarEventFilter::slotInsertSeparator()
{
QDesignerFormWindowInterface *fw = formWindow();
QAction *theSender = qobject_cast<QAction*>(sender());
QAction *previous = qvariant_cast<QAction *>(theSender->data());
fw->beginCommand(tr("Insert Separator"));
QAction *action = createAction(fw, QLatin1String("separator"), true);
InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw);
cmd->init(m_toolBar, action, previous);
fw->commandHistory()->push(cmd);
fw->endCommand();
}
示例8: removeCurrentPage
void ContainerWidgetTaskMenu::removeCurrentPage()
{
if (QDesignerContainerExtension *c = containerExtension()) {
if (c->currentIndex() == -1)
return;
QDesignerFormWindowInterface *fw = formWindow();
DeleteContainerWidgetPageCommand *cmd = new DeleteContainerWidgetPageCommand(fw);
cmd->init(m_containerWidget, m_type);
fw->commandHistory()->push(cmd);
}
}
示例9: deleteMenuAction
void QDesignerMenuBar::deleteMenuAction(QAction *action)
{
if (action && !qobject_cast<SpecialMenuAction*>(action)) {
const int pos = actions().indexOf(action);
QAction *action_before = 0;
if (pos != -1)
action_before = safeActionAt(pos + 1);
QDesignerFormWindowInterface *fw = formWindow();
RemoveMenuActionCommand *cmd = new RemoveMenuActionCommand(fw);
cmd->init(action, action_before, this, this);
fw->commandHistory()->push(cmd);
}
}
示例10: leaveEditMode
void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode)
{
m_editor->releaseKeyboard();
if (mode == Default)
return;
if (m_editor->text().isEmpty())
return;
QAction *action = 0;
QDesignerFormWindowInterface *fw = formWindow();
Q_ASSERT(fw);
if (m_currentIndex >= 0 && m_currentIndex < realActionCount()) {
action = safeActionAt(m_currentIndex);
fw->beginCommand(QApplication::translate("Command", "Change Title"));
} else {
fw->beginCommand(QApplication::translate("Command", "Insert Menu"));
const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), QStringLiteral("menu"));
QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(QStringLiteral("QMenu"), this));
fw->core()->widgetFactory()->initialize(menu);
menu->setObjectName(niceObjectName);
menu->setTitle(tr("Menu"));
fw->ensureUniqueObjectName(menu);
action = menu->menuAction();
AddMenuActionCommand *cmd = new AddMenuActionCommand(fw);
cmd->init(action, m_addMenu, this, this);
fw->commandHistory()->push(cmd);
}
SetPropertyCommand *cmd = new SetPropertyCommand(fw);
cmd->init(action, QStringLiteral("text"), m_editor->text());
fw->commandHistory()->push(cmd);
fw->endCommand();
}
示例11: startDrag
void ToolBarEventFilter::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers)
{
const int index = actionIndexAt(m_toolBar, pos, m_toolBar->orientation());
if (index == - 1)
return;
const ActionList actions = m_toolBar->actions();
QAction *action = actions.at(index);
QDesignerFormWindowInterface *fw = formWindow();
const Qt::DropAction dropAction = (modifiers & Qt::ControlModifier) ? Qt::CopyAction : Qt::MoveAction;
if (dropAction == Qt::MoveAction) {
RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw);
const int nextIndex = index + 1;
QAction *nextAction = nextIndex < actions.size() ? actions.at(nextIndex) : 0;
cmd->init(m_toolBar, action, nextAction);
fw->commandHistory()->push(cmd);
}
QDrag *drag = new QDrag(m_toolBar);
drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap( action));
drag->setMimeData(new ActionRepositoryMimeData(action, dropAction));
if (drag->start(dropAction) == Qt::IgnoreAction) {
hideDragIndicator();
if (dropAction == Qt::MoveAction) {
const ActionList currentActions = m_toolBar->actions();
QAction *previous = 0;
if (index >= 0 && index < currentActions.size())
previous = currentActions.at(index);
InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw);
cmd->init(m_toolBar, action, previous);
fw->commandHistory()->push(cmd);
}
}
}
示例12: widgetManaged
void DsgnRibbonStatusBarPlugin::widgetManaged(QWidget* widget)
{
if (widget->metaObject()->className() == QString("Qtitan::RibbonStatusBar"))
{
QDesignerFormWindowInterface* formWindow = static_cast<QDesignerFormWindowInterface *>(sender());
QDesignerFormEditorInterface* core = formWindow->core();
QDesignerContainerExtension* container = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), formWindow->mainContainer());
formWindow->unmanageWidget(widget);
QUndoStack* stack = formWindow->commandHistory();
if (!stack->isClean())
{
//This code check the InsertWidget command on the stack.
const QUndoCommand* command = stack->command(stack->index());
if (command->childCount() == 0)
return;
}
if (qobject_cast<QMainWindow *>(formWindow->mainContainer()) == 0)
{
QMessageBox::critical(
formWindow->mainContainer(),
tr("Can't add Ribbon StatusBar"),
tr("You can add Ribbon StatusBar onto Qtitan::RibbonMainWindow or QMainWindow only."));
widget->deleteLater();
return;
}
for (int i = 0; i < container->count(); ++i)
{
QWidget* w = container->widget(i);
if (w->metaObject()->className() == QString("Qtitan::RibbonStatusBar") ||
w->metaObject()->className() == QString("QStatusBar"))
{
QMessageBox::critical(
formWindow->mainContainer(),
tr("Can't add Ribbon StatusBar"),
tr("Only one instance of the Ribbon StatusBar can be adding to the main form."));
widget->deleteLater();
return;
}
}
container->addWidget(widget);
formWindow->core()->metaDataBase()->add(widget);
}
}
示例13: addDynamicProperty
void QDesignerIntegrationPrivate::addDynamicProperty(const QString &name, const QVariant &value)
{
QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow();
if (!formWindow)
return;
Selection selection;
getSelection(selection);
if (selection.empty())
return;
AddDynamicPropertyCommand *cmd = new AddDynamicPropertyCommand(formWindow);
if (cmd->init(selection.selection(), propertyEditorObject(), name, value)) {
formWindow->commandHistory()->push(cmd);
} else {
delete cmd;
qDebug() << "** WARNING Unable to add dynamic property " << name << '.';
}
}
示例14: handleDropEvent
bool ToolBarEventFilter::handleDropEvent(QDropEvent *event)
{
const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData());
if (!d)
return false;
if (d->actionList().isEmpty()) {
event->ignore();
hideDragIndicator();
return true;
}
QAction *action = d->actionList().first();
const ActionList actions = m_toolBar->actions();
if (!action || actions.contains(action)) {
event->ignore();
hideDragIndicator();
return true;
}
// Try to find action to 'insert before'. Click on action or in free area, else ignore.
QAction *beforeAction = 0;
const QPoint pos = event->pos();
const int index = actionIndexAt(m_toolBar, pos, m_toolBar->orientation());
if (index != -1) {
beforeAction = actions.at(index);
} else {
if (!freeArea(m_toolBar).contains(pos)) {
event->ignore();
hideDragIndicator();
return true;
}
}
event->acceptProposedAction();
QDesignerFormWindowInterface *fw = formWindow();
InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw);
cmd->init(m_toolBar, action, beforeAction);
fw->commandHistory()->push(cmd);
hideDragIndicator();
return true;
}
示例15: resetProperty
void QDesignerIntegrationPrivate::resetProperty(const QString &name)
{
QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow();
if (!formWindow)
return;
Selection selection;
getSelection(selection);
if (selection.empty())
return;
ResetPropertyCommand *cmd = new ResetPropertyCommand(formWindow);
// find a reference object to find the right group
if (cmd->init(selection.selection(), name, propertyEditorObject())) {
formWindow->commandHistory()->push(cmd);
} else {
delete cmd;
qDebug() << "** WARNING Unable to reset property " << name << '.';
}
}