19 #include "scribusapi.h"
25 #include "updatemanager.h"
34 void emitSignal(QObject* what)
36 emit changedObject(what);
39 void emitSignal(QVariant what)
41 emit changedData(what);
44 bool connectSignal(QObject*, QObject* o,
const char* slot)
46 return QObject::connect(
this, SIGNAL(changedObject(QObject*)), o, slot);
49 bool disconnectSignal(QObject*, QObject* o,
const char* slot)
51 return QObject::disconnect(
this, SIGNAL(changedObject(QObject*)), o, slot);
54 bool connectSignal(QVariant, QObject* o,
const char* slot)
56 return QObject::connect(
this, SIGNAL(changedData(QVariant)), o, slot);
59 bool disconnectSignal(QVariant, QObject* o,
const char* slot)
61 return QObject::disconnect(
this, SIGNAL(changedData(QVariant)), o, slot);
65 void changedObject(QObject* what);
66 void changedData(QVariant what);
71 template<
class OBSERVED>
75 Private_Memento(OBSERVED data,
bool layout) : m_data(data), m_layout(layout) {};
86 template<
class OBSERVED>
89 virtual void changed(OBSERVED,
bool doLayout) = 0;
110 template<
class OBSERVED>
128 virtual void update(OBSERVED what);
138 bool connectObserver(QObject* o,
const char* slot);
139 bool disconnectObserver(QObject* o,
const char* slot = 0);
147 QSet<Observer<OBSERVED>*> m_observers;
158 template<
class OBSERVED>
173 m_massObservable = massObservable;
176 virtual void update()
178 m_massObservable->update(dynamic_cast<OBSERVED*>(
this));
181 virtual void updateLayout()
183 m_massObservable->updateLayout(dynamic_cast<OBSERVED*>(
this));
205 template<
class OBSERVED>
226 template<
class OBSERVED>
231 template<
class OBSERVED>
235 delete changedSignal;
239 template<
class OBSERVED>
246 template<
class OBSERVED>
250 if (m_um == NULL || m_um->requestUpdate(
this, memento))
256 template<
class OBSERVED>
260 if (m_um == NULL || m_um->requestUpdate(
this, memento))
266 template<
class OBSERVED>
272 obs->changed(memento->m_data, memento->m_layout);
274 changedSignal->emitSignal(QVariant::fromValue(memento->m_data));
279 template<
class OBSERVED>
282 m_observers.insert(o);
285 template<
class OBSERVED>
288 m_observers.remove(o);
292 template <
typename T>
293 inline void Private_Init(T& dummy) {}
296 inline void Private_Init(QObject*& dummy)
303 template<
class OBSERVED>
308 return changedSignal->connectSignal(QVariant::fromValue(dummy), o, slot);
311 template<
class OBSERVED>
316 return changedSignal->disconnectSignal(QVariant::fromValue(dummy), o, slot);
Definition: observable.h:87
Definition: updatemanager.h:29
Definition: observable.h:159
virtual void updateNow(UpdateMemento *what)
Definition: observable.h:267
Definition: observable.h:29
Definition: observable.h:206
virtual void update(OBSERVED what)
Definition: observable.h:247
Definition: updatemanager.h:41
SingleObservable(MassObservable< OBSERVED * > *massObservable)
Definition: observable.h:165
void setUpdateManager(UpdateManager *um)
Definition: observable.h:240
Definition: observable.h:111
Definition: updatemanager.h:66
Definition: observable.h:72
virtual void updateLayout(OBSERVED what)
Definition: observable.h:257