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 EvaChatView::slotCopyImage()
{
#ifndef QT_NO_MIMECLIPBOARD
    KURL safeURL(d->m_imageURL);
    safeURL.setPass(TQString::null);

    KURL::List lst;
    lst.append( safeURL );
    KMultipleDrag *drag = new KMultipleDrag(view(), "Image");

    drag->addDragObject( new TQImageDrag(d->m_imageURL.path()) );
    drag->addDragObject( new KURLDrag(lst, view(), "Image URL") );

    // Set it in both the mouse selection and in the clipboard
    TQApplication::clipboard()->setData( drag, TQClipboard::Clipboard );
    TQApplication::clipboard()->setData( new KURLDrag(lst), TQClipboard::Selection );
#else
    // do nothing
#endif
}
示例#3
0
void ViewManager::startDrag()
{
    // Get the list of all the selected addressees
    KABC::Addressee::List addrList;
    const QStringList uidList = selectedUids();
    if(uidList.isEmpty())
        return;

    kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;

    QStringList::ConstIterator it;
    for(it = uidList.begin(); it != uidList.end(); ++it)
        addrList.append(mCore->addressBook()->findByUid(*it));

    KMultipleDrag *drag = new KMultipleDrag(this);

    KABC::VCardConverter converter;
    QString vcards = converter.createVCards(addrList);

    // Best text representation is given by textdrag, so it must be first
    drag->addDragObject(new QTextDrag(AddresseeUtil::addresseesToEmails(addrList), this));
    drag->addDragObject(new KVCardDrag(vcards, this));

    KTempDir tempDir;
    // can't set tempDir to autoDelete, in case of dropping on the desktop, the copy is async...
    if(tempDir.status() == 0)
    {
        QString fileName;
        if(addrList.count() == 1)
            fileName = addrList[ 0 ].givenName() + "_" + addrList[ 0 ].familyName() + ".vcf";
        else
            fileName = "contacts.vcf";

        QFile tempFile(tempDir.name() + "/" + fileName);
        if(tempFile.open(IO_WriteOnly))
        {
            tempFile.writeBlock(vcards.utf8());
            tempFile.close();

            KURLDrag *urlDrag = new KURLDrag(KURL(tempFile.name()), this);
            drag->addDragObject(urlDrag);
        }
    }

    drag->setPixmap(KGlobal::iconLoader()->loadIcon("vcard", KIcon::Desktop));
    drag->dragCopy();
}