void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *form, const QString &old_name, const QString &new_name) { QExtensionManager* extensionManager = form->core()->extensionManager(); typedef QList<QLabel*> LabelList; const LabelList label_list = qFindChildren<QLabel*>(form); if (label_list.empty()) return; const QString buddyProperty = QLatin1String("buddy"); const QByteArray oldNameU8 = old_name.toUtf8(); const QByteArray newNameU8 = new_name.toUtf8(); const LabelList::const_iterator cend = label_list.constEnd(); for (LabelList::const_iterator it = label_list.constBegin(); it != cend; ++it ) { if (QDesignerPropertySheetExtension* sheet = qt_extension<QDesignerPropertySheetExtension*>(extensionManager, *it)) { const int idx = sheet->indexOf(buddyProperty); if (idx != -1) { const QByteArray oldBuddy = sheet->property(idx).toByteArray(); if (oldBuddy == oldNameU8) sheet->setProperty(idx, newNameU8); } } } }
// Find the label whose buddy the widget is. QLabel *buddyLabelOf(QDesignerFormWindowInterface *fw, QWidget *w) { typedef QList<QLabel*> LabelList; const LabelList labelList = fw->findChildren<QLabel*>(); if (labelList.empty()) return 0; const LabelList::const_iterator cend = labelList.constEnd(); for (LabelList::const_iterator it = labelList.constBegin(); it != cend; ++it ) if ( (*it)->buddy() == w) return *it; return 0; }