当前位置: 首页>>代码示例>>C++>>正文


C++ QUndoStack::isClean方法代码示例

本文整理汇总了C++中QUndoStack::isClean方法的典型用法代码示例。如果您正苦于以下问题:C++ QUndoStack::isClean方法的具体用法?C++ QUndoStack::isClean怎么用?C++ QUndoStack::isClean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QUndoStack的用法示例。


在下文中一共展示了QUndoStack::isClean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
    }
}
开发者ID:lixunguang,项目名称:myhelloworld,代码行数:47,代码来源:QtnStatusBarDsgnPlugin.cpp

示例2: widgetManaged

void RibbonStyleDsgnPlugin::widgetManaged(QWidget* widget)
{
    QDesignerFormWindowInterface* formWindow = static_cast<QDesignerFormWindowInterface *>(sender());
    QDesignerFormEditorInterface* core = formWindow->core();
    QDesignerContainerExtension* container = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), formWindow->mainContainer());

    if (widget->metaObject()->className() == QString("Qtitan::RibbonStyle"))
    {
        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 Style"), 
                tr("You can't drag-drop the style to this QWidget form. The style can be placed only onto the form of QMainWindow successor."));
            widget->deleteLater();
            return;
        }

        QWidget* widgetStyle = Q_NULL;
        for (int i = 0; i < container->count() && widgetStyle == Q_NULL; ++i)
        {
            QWidget* w = container->widget(i);
            if (w->metaObject()->className() == QString("Qtitan::OfficeStyle") ||
                w->metaObject()->className() == QString("Qtitan::RibbonStyle"))
                widgetStyle = w;
        }

        if (widgetStyle && widgetStyle->metaObject()->className() == QString("Qtitan::RibbonStyle"))
        {
            QMessageBox::critical(
                formWindow->mainContainer(),
                tr("Can't add Ribbon Style"), 
                tr("Only one instance of the Ribbon Style can be adding to the main form."));
            widget->deleteLater();
            return;
        }

        if (widgetStyle)
        {
            g_removeBlock = true;
            const QString description = tr("Delete '%1'").arg(widgetStyle->objectName());
            formWindow->commandHistory()->beginMacro(description);

            DeleteStyleCommand* cmd = new DeleteStyleCommand(formWindow);
            cmd->init(widgetStyle);
            formWindow->commandHistory()->push(cmd);
            formWindow->commandHistory()->endMacro();
            g_removeBlock = false;
        }

        container->addWidget(widget);
        formWindow->core()->metaDataBase()->add(widget);
        widget->setCursor(Qt::PointingHandCursor);
    }
    else if (DesignerMainWindowStyleContainer* styelContainer = dynamic_cast<DesignerMainWindowStyleContainer*>(container))
    {
        if (QMainWindow* mainindow = static_cast<QMainWindow*>(styelContainer->mainWindow()))
        {
            if (Qtitan::CommonStyle* currentStyle = qobject_cast<Qtitan::CommonStyle*>(mainindow->style()))
                ::setChildStyle(widget, currentStyle);
        }
    }
}
开发者ID:lixunguang,项目名称:myhelloworld,代码行数:72,代码来源:QtnRibbonStyleDsgnPlugin.cpp


注:本文中的QUndoStack::isClean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。