Source Code (Use browser search to find items of interest.)

Class Index

killustrator'GroupCmd (./koffice/killustrator/share/GroupCmd.h:34)

class GroupCmd : public Command {
public:
  GroupCmd (GDocument* doc);
  ~GroupCmd ();

  void execute ();
  void unexecute ();

private:
  GDocument* document;
  GGroup* group;
  list<GObject*> objects;
};

killustrator'GroupCmd::GroupCmd() (./koffice/killustrator/share/GroupCmd.cc:34)

GroupCmd::GroupCmd (GDocument* doc) : Command(i18n("Group Objects")) {
  document = doc;
  group = 0L;

  map<int, GObject*, less<int> > idx_map;
  
  for (list<GObject*>::iterator it = doc->getSelection ().begin ();
       it != doc->getSelection ().end (); it++) {
    // remember position of object in order to keep the order of
    // objects in the group
    GObject* o = *it;
    int idx = (int) document->findIndexOfObject (o);
    idx_map[idx] = o;
  }
  for (map<int, GObject*, less<int> >::iterator mi = idx_map.begin ();
       mi != idx_map.end (); mi++) {
    // now insert the objects according their position in the list 
    objects.push_back (mi->second);
  }
}


killustrator'GroupCmd::~GroupCmd() (./koffice/killustrator/share/GroupCmd.cc:55)

GroupCmd::~GroupCmd () {
  if (group)
    group->unref ();
}


killustrator'GroupCmd::execute() (./koffice/killustrator/share/GroupCmd.cc:60)

void GroupCmd::execute () {
  if (! objects.empty ()) {
    group = new GGroup ();
    group->ref ();

    document->setAutoUpdate (false);

    for (list<GObject*>::iterator it = objects.begin ();
	 it != objects.end (); it++) {
      GObject* obj = *it;
      group->addObject (obj);
    }
    // now insert the new group into the document
    document->insertObject (group);

    // and select it (but only it !)
    document->deleteSelectedObjects ();
    document->selectObject (group);
    document->setAutoUpdate (true);
  }
}


killustrator'GroupCmd::unexecute() (./koffice/killustrator/share/GroupCmd.cc:82)

void GroupCmd::unexecute () {
  int pos = document->findIndexOfObject (group);
  if (pos != -1) {
    document->setAutoUpdate (false);
    // extract the members of the group
    const list<GObject*> members = group->getMembers ();
    list<GObject*>::const_iterator mi = members.begin ();
    for (int offs = 0; mi != members.end (); mi++, offs++) {
      GObject* obj = *mi;
      // transform it according to the group transformation matrix
      obj->transform (group->matrix (), true);
      
      // and insert it into the object list at the former position
      // of the group object
      document->insertObjectAtIndex (obj, pos + offs);
      document->selectObject (obj);
    }
    // remove the group object
    document->deleteObject (group);
    document->setAutoUpdate (true);
  }
}