class MediatorInterface : public QObject{ Q_OBJECTpublic: MediatorInterface(QObject *parent = 0); virtual ~MediatorInterface(); ComponentOneInterface *componentOne() const; ComponentTwoInterface *componentTwo() const; ComponentThreeInterface *componentThree() const; void setComponentOne(ComponentOneInterface *componentOne); void setComponentTwo(ComponentTwoInterface *componentTwo); protected: void setComponentThree(ComponentThreeInterface *componentThree);private: MediatorInterfacePrivate *d;private: MediatorInterface(const MediatorInterface &other); void operator = (const MediatorInterface &other);};//конструкторMediatorInterface::MediatorInterface(QObject *parent) : QObject(parent), d(new MediatorInterfacePrivate()){}//деструкторMediatorInterface::~MediatorInterface(){ delete d;}//возвращает интерфейс компонентаComponentOneInterface *MediatorInterface::componentOne() const{ return d->m_componentOne;}//устанавливает компонентvoid MediatorInterface::setComponentOne(ComponentOneInterface *componentOne){ d->m_componentOne = componentOne;}
class MediatorInterfacePrivate {public: MediatorInterfacePrivate(); ~MediatorInterfacePrivate(); QPointer<ComponentOneInterface> m_componentOne; QPointer<ComponentTwoInterface> m_componentTwo; QPointer<ComponentThreeInterface> m_componentThree; };//конструкторMediatorInterfacePrivate::MediatorInterfacePrivate() : m_componentOne(0), m_componentTwo(0), m_componentThree(0){}//деструкторMediatorInterfacePrivate::~MediatorInterfacePrivate(){ delete m_componentOne; delete m_componentTwo; delete m_componentThree;}
class Mediator : public MediatorInterface{ Q_OBJECTpublic: Mediator(QObject *parent = 0); virtual ~Mediator();};Mediator::Mediator(QObject *parent) : MediatorInterface(parent){ ComponentThree *componentThree = new ComponentThree(this); setComponentThree(componentThree); ............ создание компонентов чья функция set находится в секции protected}
class ComponentOne: public ComponentOneInterface{ Q_OBJECTpublic: ComponentOne(MediatorInterface *core, QObject *parent = 0); virtual ~ComponentOne(); .....}
class ActionEditor: public QDesignerActionEditorInterface{ Q_OBJECTpublic: explicit ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent = 0, Qt::WindowFlags flags = 0); virtual ~ActionEditor();....
class QDesignerActionEditorInterface: public QWidget{ Q_OBJECTpublic: QDesignerActionEditorInterface(QWidget *parent, Qt::WindowFlags flags = 0); virtual ~QDesignerActionEditorInterface(); virtual QDesignerFormEditorInterface *core() const;...........};
void ActionEditor::restoreSettings(){ QDesignerSettingsInterface *settings = m_core->settingsManager(); m_actionView->setViewMode(settings->value(QLatin1String(actionEditorViewModeKey), 0).toInt()); updateViewModeActions();}...void ActionEditor::manageAction(QAction *action){ ..... core()->metaDataBase()->add(action); ....... QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); sheet->setChanged(sheet->indexOf(QLatin1String(objectNamePropertyC)), true); sheet->setChanged(sheet->indexOf(QLatin1String(textPropertyC)), true); refreshIconPropertyChanged(action, sheet); ...............}