#include <qdesigner_command_p.h>
Inheritance diagram for qdesigner_internal::InsertWidgetCommand:


Definition at line 253 of file qdesigner_command_p.h.
Public Member Functions | |
| InsertWidgetCommand (QDesignerFormWindowInterface *formWindow) | |
| void | init (QWidget *widget, bool already_in_form=false) |
| virtual void | redo () |
| virtual void | undo () |
Private Attributes | |
| QPointer< QWidget > | m_widget |
| QDesignerLayoutDecorationExtension::InsertMode | m_insertMode |
| QPair< int, int > | m_cell |
| bool | m_widgetWasManaged |
| qdesigner_internal::InsertWidgetCommand::InsertWidgetCommand | ( | QDesignerFormWindowInterface * | formWindow | ) |
Definition at line 609 of file qdesigner_command.cpp.
00610 : QDesignerFormWindowCommand(QString(), formWindow) 00611 { 00612 }
| void qdesigner_internal::InsertWidgetCommand::init | ( | QWidget * | widget, | |
| bool | already_in_form = false | |||
| ) |
Definition at line 614 of file qdesigner_command.cpp.
References QDesignerFormWindowInterface::core(), qdesigner_internal::QDesignerFormWindowCommand::core(), QDesignerLayoutDecorationExtension::currentCell(), QDesignerLayoutDecorationExtension::currentInsertMode(), QDesignerFormEditorInterface::extensionManager(), qdesigner_internal::QDesignerFormWindowCommand::formWindow(), QDesignerLayoutDecorationExtension::InsertWidgetMode, m_cell, m_insertMode, m_widget, m_widgetWasManaged, QObject::objectName(), qMakePair(), QUndoCommand::setText(), and QCoreApplication::translate().
Referenced by qdesigner_internal::FormWindow::insertWidget(), and qdesigner_internal::FormWindow::paste().
00615 { 00616 m_widget = widget; 00617 00618 setText(QApplication::translate("Command", "Insert '%1'").arg(widget->objectName())); 00619 00620 QWidget *parentWidget = m_widget->parentWidget(); 00621 QDesignerFormEditorInterface *core = formWindow()->core(); 00622 QDesignerLayoutDecorationExtension *deco = qt_extension<QDesignerLayoutDecorationExtension*>(core->extensionManager(), parentWidget); 00623 00624 m_insertMode = deco ? deco->currentInsertMode() : QDesignerLayoutDecorationExtension::InsertWidgetMode; 00625 m_cell = deco ? deco->currentCell() : qMakePair(0, 0); 00626 m_widgetWasManaged = already_in_form; 00627 }
Here is the call graph for this function:

| void qdesigner_internal::InsertWidgetCommand::redo | ( | ) | [virtual] |
Applies a change to the document. This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this funciton leads to undefined beahavior.
The default implementation calls redo() on all child commands.
Reimplemented from qdesigner_internal::QDesignerFormWindowCommand.
Definition at line 641 of file qdesigner_command.cpp.
References qdesigner_internal::QDesignerFormWindowCommand::checkObjectName(), QDesignerFormWindowInterface::core(), qdesigner_internal::QDesignerFormWindowCommand::core(), QDesignerFormWindowInterface::emitSelectionChanged(), QDesignerFormEditorInterface::extensionManager(), QPair< T1, T2 >::first, qdesigner_internal::QDesignerFormWindowCommand::formWindow(), qdesigner_internal::LayoutInfo::Grid, QDesignerPropertySheetExtension::indexOf(), QDesignerLayoutDecorationExtension::insertColumn(), QDesignerLayoutDecorationExtension::InsertColumnMode, QDesignerLayoutDecorationExtension::insertRow(), QDesignerLayoutDecorationExtension::InsertRowMode, QDesignerLayoutDecorationExtension::insertWidget(), QLayout::invalidate(), QWidget::layout(), qdesigner_internal::LayoutInfo::layoutType(), m_cell, m_insertMode, m_widget, m_widgetWasManaged, QDesignerFormWindowInterface::manageWidget(), QDesignerPropertySheetExtension::property(), qdesigner_internal::recursiveUpdate(), QPair< T1, T2 >::second, QDesignerPropertySheetExtension::setProperty(), and QVariant::toString().
00642 { 00643 checkObjectName(m_widget); 00644 00645 QWidget *parentWidget = m_widget->parentWidget(); 00646 Q_ASSERT(parentWidget); 00647 00648 QDesignerFormEditorInterface *core = formWindow()->core(); 00649 QDesignerLayoutDecorationExtension *deco = qt_extension<QDesignerLayoutDecorationExtension*>(core->extensionManager(), parentWidget); 00650 00651 if (deco != 0) { 00652 if (LayoutInfo::layoutType(core, parentWidget) == LayoutInfo::Grid) { 00653 switch (m_insertMode) { 00654 case QDesignerLayoutDecorationExtension::InsertRowMode: { 00655 deco->insertRow(m_cell.first); 00656 } break; 00657 00658 case QDesignerLayoutDecorationExtension::InsertColumnMode: { 00659 deco->insertColumn(m_cell.second); 00660 } break; 00661 00662 default: break; 00663 } // end switch 00664 } 00665 deco->insertWidget(m_widget, m_cell); 00666 } 00667 00668 if (!m_widgetWasManaged) 00669 formWindow()->manageWidget(m_widget); 00670 m_widget->show(); 00671 formWindow()->emitSelectionChanged(); 00672 00673 if (parentWidget && parentWidget->layout()) { 00674 recursiveUpdate(parentWidget); 00675 parentWidget->layout()->invalidate(); 00676 } 00677 00678 QList<QDesignerLabel*> label_list = qFindChildren<QDesignerLabel*>(formWindow()); 00679 foreach (QDesignerLabel *label, label_list) { 00680 QDesignerPropertySheetExtension* propertySheet 00681 = qt_extension<QDesignerPropertySheetExtension*> 00682 (core->extensionManager(), label); 00683 if (propertySheet == 0) 00684 continue; 00685 int idx = propertySheet->indexOf(QLatin1String("buddy")); 00686 if (idx == -1) 00687 continue; 00688 if (propertySheet->property(idx).toString() == m_widget->objectName()) 00689 propertySheet->setProperty(idx, m_widget->objectName()); 00690 } 00691 }
Here is the call graph for this function:

| void qdesigner_internal::InsertWidgetCommand::undo | ( | ) | [virtual] |
Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this funciton leads to undefined beahavior.
The default implementation calls undo() on all child commands in reverse order.
Reimplemented from qdesigner_internal::QDesignerFormWindowCommand.
Definition at line 693 of file qdesigner_command.cpp.
References QDesignerFormWindowInterface::core(), qdesigner_internal::QDesignerFormWindowCommand::core(), QDesignerFormWindowInterface::emitSelectionChanged(), QDesignerFormEditorInterface::extensionManager(), qdesigner_internal::QDesignerFormWindowCommand::formWindow(), QDesignerPropertySheetExtension::indexOf(), m_widget, m_widgetWasManaged, QDesignerPropertySheetExtension::property(), QDesignerLayoutDecorationExtension::removeWidget(), QDesignerPropertySheetExtension::setProperty(), QDesignerLayoutDecorationExtension::simplify(), QVariant::toString(), and QDesignerFormWindowInterface::unmanageWidget().
00694 { 00695 QWidget *parentWidget = m_widget->parentWidget(); 00696 00697 QDesignerFormEditorInterface *core = formWindow()->core(); 00698 QDesignerLayoutDecorationExtension *deco = qt_extension<QDesignerLayoutDecorationExtension*>(core->extensionManager(), parentWidget); 00699 00700 if (deco) { 00701 deco->removeWidget(m_widget); 00702 deco->simplify(); 00703 } 00704 00705 if (!m_widgetWasManaged) { 00706 formWindow()->unmanageWidget(m_widget); 00707 m_widget->hide(); 00708 } 00709 formWindow()->emitSelectionChanged(); 00710 00711 QList<QDesignerLabel*> label_list = qFindChildren<QDesignerLabel*>(formWindow()); 00712 foreach (QDesignerLabel *label, label_list) { 00713 QDesignerPropertySheetExtension* propertySheet 00714 = qt_extension<QDesignerPropertySheetExtension*> 00715 (core->extensionManager(), label); 00716 if (propertySheet == 0) 00717 continue; 00718 int idx = propertySheet->indexOf(QLatin1String("buddy")); 00719 if (idx == -1) 00720 continue; 00721 if (propertySheet->property(idx).toString() == m_widget->objectName()) 00722 propertySheet->setProperty(idx, m_widget->objectName()); 00723 } 00724 }
Here is the call graph for this function:

QPair<int, int> qdesigner_internal::InsertWidgetCommand::m_cell [private] |
bool qdesigner_internal::InsertWidgetCommand::m_widgetWasManaged [private] |
1.5.1