コード例 #1
0
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;
}
コード例 #2
0
void KstPlotDrag::setPlots(const KstViewObjectList& l) {
  QByteArray a;
  QDataStream ds(a, IO_WriteOnly);
  ds << l.count();
  for (KstViewObjectList::ConstIterator i = l.begin(); i != l.end(); ++i) {
    ds << *i;
  }
  setEncodedData(a);
}
コード例 #3
0
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();
    }
  }
コード例 #4
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;
    }
  }
コード例 #5
0
bool KstIfaceImpl::deletePlot(const QString& window, const QString& name) {
  KstViewWindow *pView = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(window));
  if (pView) {
    KstTopLevelViewPtr pTLV = pView->view();
    KstViewObjectList objects = pTLV->findChildrenType<KstViewObject>(true);

    for (KstViewObjectList::Iterator it = objects.begin(); it != objects.end(); ++it) {
      KstViewObjectPtr object = *it;
      if (object->tagName() == name) {
        pTLV->removeChild(object, true);
        _doc->forceUpdate();
        _doc->setModified();
        return true;
      }
    }
  }

  return false;
}