QDragObject *KstViewWidget::dragObject() {
  KMultipleDrag *drag = new KMultipleDrag(this);
  QStringList plots;
  KstViewObjectList vol;
  QString window = static_cast<KstViewWindow*>(parent())->caption();

  if (_view->selectionList().isEmpty()) {
    if (_view->pressTarget()) {
      plots.append(_view->pressTarget()->tagName());
      vol.append(_view->pressTarget());
    } else {
      for (size_t i=0; i<_view->children().size(); i++) {
        plots.append(_view->children()[i]->tagName());
        vol.append(_view->children()[i]);
      }
    }
  } else {
    for (size_t i=0; i<_view->selectionList().size(); i++) {
      plots.append(_view->selectionList()[i]->tagName());
      vol.append(_view->selectionList()[i]);
    }
  }

  drag->addDragObject(new PlotMimeSource(window, plots, 0L));
  KstViewObjectImageDrag *imd = new KstViewObjectImageDrag(this);
  imd->setObjects(vol);
  drag->addDragObject(imd);

  return drag;
}
KstViewObjectList KstPlotDrag::decodedContents(QByteArray& a) {
  uint x;
  QDataStream ds(a, IO_ReadOnly);
  ds >> x;
  KstViewObjectList c;
  for (uint i = 0; i < x; ++i) {
    QString type;
    ds >> type;
    KstViewObjectPtr p = KstViewObjectFactory::self()->createA(type);
    if (p) {
      ds >> p;
      c.append(p);
    } else {
      // FIXME: how to recover?
      abort();
    }
  }
Esempio n. 3
0
KstViewObjectList KstPlotDrag::decodedContents(QByteArray& a) {
  QDataStream ds(&a, QIODevice::ReadOnly);
  KstViewObjectList c;
  uint x;

  ds >> x;
  for (uint i = 0; i < x; ++i) {
    KstViewObjectPtr p;
    QString type;

    ds >> type;
    p = KstViewObjectFactory::self()->createA(type);
    if (p) {
      ds >> p;
      c.append(p);
    } else {
      break;
    }
  }