Molecule signals

Hi all,

While working on some extensions, I started getting annoyed with the
signals currently used by Molecule – there is no easy way to trigger
a slot when something about the molecule changes without creating
connections to each of atomAdded, atomRemoved, atomUpdated,
bondAdded… etc. I also recall discussions about scaling issues with
the current setup.

I was thinking of a potential solution to this problem, and I’ve
pushed a first draft to my github branch here:

I don’t want to submit to Gerrit quite yet, as I’d like to start some
discussion about this. The approach above adds two signals that could
replace most of the existing ones:

fineUpdate(UpdateType, Primitive*=0)

The first is emitted on every change, allowing fine-grained monitoring
of the molecule, while the second is emitted no more than once every
10th of a second. This is useful for GUI elements that don’t need to
refresh for every little change. courseUpdate also collects all of the
UpdateType flags passed to fineUpdate so that slots connected to it
can know roughly what the change was about.

The UpdateType(s) are flags describing the changes made to the molecule:

long long enum UpdateType {
  OtherUpdate              = 0x1,
  OtherPrimitiveAdded      = 0x2,
  OtherPrimitiveRemoved    = 0x4,
  OtherPrimitiveUpdated    = 0x8,
  AtomAdded                = 0x10,
  AtomRemoved              = 0x20,
  AtomUpdated              = 0x40,
  BondAdded                = 0x80,
  BondUpdated              = 0x100,
  BondRemoved              = 0x200,
  CubeAdded                = 0x400,
  CubeRemoved              = 0x800,
  CubeUpdated              = 0x1000,
  MeshAdded                = 0x2000,
  MeshRemoved              = 0x4000,
  MeshUpdated              = 0x8000,
  ResidueAdded             = 0x10000,
  ResidueRemoved           = 0x20000,
  ResidueUpdated           = 0x40000,
  RingAdded                = 0x80000,
  RingRemoved              = 0x100000,
  RingUpdated              = 0x200000
Q_DECLARE_FLAGS(UpdateTypes, UpdateType)

I think this approach is a lot cleaner than what we currently have,
but I’d like to hear what others think.

Comments? Suggestions?