示例#1
0
void KstTopLevelView::releasePressLayoutModeMove(const QPoint& pos, bool shift) {
  Q_UNUSED(shift)

  QRect obj(_pressTarget->geometry());
  const QRect old(obj);

  // the list of other selected objects
  if (!_selectionList.isEmpty()) {
    for (KstViewObjectList::ConstIterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
      obj = obj.unite((*i)->geometry());
    } 
  }
  const QPoint objOffset(old.topLeft() - obj.topLeft());

  // do the move
  obj.moveTopLeft(pos - _moveOffset - _moveOffsetSticky - old.topLeft() + obj.topLeft());
  if (!_geom.contains(obj, true)) {
    slideInto(_geom, obj);
  }

  // This is not entirely correct.  findDeepestChild could actually return an
  // object inside the selection list or even presstarget.  We should get
  // something that includes none of those.  This is most likely the parent of
  // the returned object in that case.
  KstViewObjectPtr container = findDeepestChild(obj);
  bool updateViewManager = false;
  
  if (!container) {
    container = this;
  }
  if (container != _pressTarget && !container->children().contains(_pressTarget)) {
    _pressTarget->detach();
    container->appendChild(_pressTarget);
    updateViewManager = true;
  }
  _pressTarget->move(obj.topLeft() + objOffset);
  for (KstViewObjectList::Iterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
    if (*i != _pressTarget) {
      KstViewObjectPtr thisObj = *i; // ref
      if (container != thisObj && !container->children().contains(thisObj)) {
        thisObj->detach();
        container->appendChild(thisObj);
        updateViewManager = true;
      }
      thisObj->move(_pressTarget->position() + thisObj->geometry().topLeft() - old.topLeft());
    }
  }
  
  if (updateViewManager) {
    KstApp::inst()->updateViewManager(true);
  }
  _onGrid = false;
}
示例#2
0
KJS::Object KstBindLegend::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() == 0 || args.size() > 2) {
    return createSyntaxError(exec);
  }

  KstViewObjectPtr view = extractViewObject(exec, args[0]);
  if (!view) {
    KstViewWindow *w = extractWindow(exec, args[0]);
    if (w) {
      view = w->view();
    } else {
      return createTypeError(exec, 0);
    }
  }

  QString txt;
  if (args.size() == 2) {
    if (args[1].type() != KJS::StringType) {
      return createTypeError(exec, 1);
    }
    txt = args[1].toString(exec).qstring();
  }

  KstViewLegendPtr b = new KstViewLegend;
  view->appendChild(b.data());
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
  return KJS::Object(new KstBindLegend(exec, b));
}
示例#3
0
KJS::Object KstBindLine::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 1) {
    return createSyntaxError(exec);
  }

  KstViewObjectPtr view = extractViewObject(exec, args[0]);
  if (!view) {
    KstViewWindow *w = extractWindow(exec, args[0]);
    if (w) {
      view = w->view();
    } else {
      return createTypeError(exec, 0);
    }
  }

  KstViewLinePtr b = new KstViewLine;
  view->appendChild(b.data());
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
  return KJS::Object(new KstBindLine(exec, b));
}
KJS::Object KstBindEllipse::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 1) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
    exec->setException(eobj);
    return KJS::Object();
  }

  KstViewObjectPtr view = extractViewObject(exec, args[0]);
  if (!view) {
    KstViewWindow *w = extractWindow(exec, args[0]);
    if (w) {
      view = w->view();
    } else {
      KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
      exec->setException(eobj);
      return KJS::Object();
    }
  }

  KstViewEllipsePtr b = new KstViewEllipse;
  view->appendChild(b.data());
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
  return KJS::Object(new KstBindEllipse(exec, b));
}