コード例 #1
0
ファイル: kurlmimetest.cpp プロジェクト: fluxer/kdelibs
void KUrlMimeTest::testMostLocalUrlList()
{
    QMimeData* mimeData = new QMimeData;
    KUrl::List urls;
    urls.append(KUrl("desktop:/foo"));
    urls.append(KUrl("desktop:/bar"));
    KUrl::List localUrls;
    localUrls.append(KUrl("file:/home/dfaure/Desktop/foo"));
    localUrls.append(KUrl("file:/home/dfaure/Desktop/bar"));

    urls.populateMimeData(localUrls, mimeData);

    QVERIFY(KUrl::List::canDecode(mimeData));
    QVERIFY(mimeData->hasUrls());
    QVERIFY(mimeData->hasText());
    QVERIFY(mimeData->hasFormat("text/plain"));

    // KUrl decodes the real "kde" urls by default
    KUrl::List decodedURLs = KUrl::List::fromMimeData(mimeData);
    QVERIFY(!decodedURLs.isEmpty());
    QCOMPARE(decodedURLs.toStringList().join(" "), urls.toStringList().join(" ") );

    // KUrl can also be told to decode the "most local" urls
    decodedURLs = KUrl::List::fromMimeData(mimeData, 0, KUrl::List::PreferLocalUrls);
    QVERIFY(!decodedURLs.isEmpty());
    QCOMPARE(decodedURLs.toStringList().join(" "), localUrls.toStringList().join(" ") );

    // QMimeData decodes the "most local" urls
    const QList<QUrl> qurls = mimeData->urls();
    QCOMPARE(qurls.count(), localUrls.count());
    for (int i = 0; i < qurls.count(); ++i )
        QCOMPARE(qurls[i], static_cast<QUrl>(localUrls[i]));

}
コード例 #2
0
    QMimeData *mimeData()
    {
      // create a list of the URL:s that we want to drag
      KUrl::List urls;
      QStringList labels;
      for ( Q3IconViewItem *it = firstItem(); it; it = it->nextItem() ) {
        if ( it->isSelected() ) {
          AttachmentIconItem *item = static_cast<AttachmentIconItem *>( it );
          if ( item->isBinary() ) {
            urls.append( tempFileForAttachment( item->attachment() ) );
          } else {
            urls.append( item->uri() );
          }
          labels.append( KUrl::toPercentEncoding( item->label() ) );
        }
      }
      if ( selectionMode() == Q3IconView::NoSelection ) {
        AttachmentIconItem *item = static_cast<AttachmentIconItem *>( currentItem() );
        if ( item ) {
          urls.append( item->uri() );
          labels.append( KUrl::toPercentEncoding( item->label() ) );
        }
      }

      QMap<QString, QString> metadata;
      metadata["labels"] = labels.join( ":" );

      QMimeData *mimeData = new QMimeData;
      urls.populateMimeData( mimeData, metadata );
      return mimeData;
    }
コード例 #3
0
ファイル: JobRunner.cpp プロジェクト: fluxer/kde-workspace
void CJobRunner::getAssociatedUrls(const KUrl &url, KUrl::List &list, bool afmAndPfm, QWidget *widget)
{
    QString ext(url.path());
    int     dotPos(ext.lastIndexOf('.'));
    bool    check(false);

    if(-1==dotPos) // Hmm, no extension - check anyway...
        check=true;
    else           // Cool, got an extension - see if it is a Type1 font...
    {
        ext=ext.mid(dotPos+1);
        check=0==ext.compare("pfa", Qt::CaseInsensitive) ||
              0==ext.compare("pfb", Qt::CaseInsensitive);
    }

    if(check)
    {
        const char *afm[]={"afm", "AFM", "Afm", NULL},
                   *pfm[]={"pfm", "PFM", "Pfm", NULL};
        bool       gotAfm(false),
                   localFile(url.isLocalFile());
        int        e;

        for(e=0; afm[e]; ++e)
        {
            KUrl          statUrl(url);
            KIO::UDSEntry uds;
            statUrl.setPath(Misc::changeExt(url.path(), afm[e]));
            if(localFile ? Misc::fExists(statUrl.toLocalFile()) : KIO::NetAccess::stat(statUrl, uds, widget))
            {
                list.append(statUrl);
                gotAfm=true;
                break;
            }
        }

        if(afmAndPfm || !gotAfm)
            for(e=0; pfm[e]; ++e)
            {
                KUrl          statUrl(url);
                KIO::UDSEntry uds;
                statUrl.setPath(Misc::changeExt(url.path(), pfm[e]));
                if(localFile ? Misc::fExists(statUrl.toLocalFile()) : KIO::NetAccess::stat(statUrl, uds, widget))
                {
                    list.append(statUrl);
                    break;
                }
            }
    }
}
コード例 #4
0
ファイル: quickbutton.cpp プロジェクト: serghei/kde3-kdebase
void QuickButton::mouseMoveEvent(QMouseEvent *e)
{
    if((e->state() & LeftButton) == 0)
        return;
    QPoint p(e->pos() - _dragPos);
    if(p.manhattanLength() <= KGlobalSettings::dndEventDelay())
        return;
    DEBUGSTR << "dragstart" << endl << flush;
    setDown(false);
    if(_dragEnabled)
    {
        KURL::List uris;
        uris.append(_qurl->kurl());
        DEBUGSTR << "creating KURLDrag" << endl << flush;
        KURLDrag *dd = new KURLDrag(uris, this);
        dd->setPixmap(_icon); // PIX
        DEBUGSTR << "ready to drag" << endl << flush;
        grabKeyboard();
        dd->drag();
        releaseKeyboard();
    }
    else
    {
        setCursor(Qt::ForbiddenCursor);
    }
}
コード例 #5
0
void MrmlViewItem::mouseMoveEvent( QMouseEvent *e )
{
    if ( hitsPixmap( e->pos() ) ) {
        if ( !ownCursor() ) { // nice hacklet :)
            setCursor( KCursor::handCursor() );
            emit view()->onItem( m_url );
        }
    }
    else {
        if ( ownCursor() ) {
            unsetCursor();
            emit view()->onItem( KURL() );
        }
    }

    if ( (e->state() & LeftButton) && !pressedPos.isNull() ) {
        QPoint dist = e->pos() - pressedPos;
        if ( dist.manhattanLength() > KGlobalSettings::dndEventDelay() ) {
            // start drag here
            KURL::List urls;
            // ### support multiple files?
            urls.append( m_url );
            KURLDrag *drag = new KURLDrag( urls, this );
            drag->setPixmap( KMimeType::pixmapForURL( m_url ) );
            drag->drag();
        }
    }
}
コード例 #6
0
ファイル: docpart.cpp プロジェクト: fagu/kileip
bool DocumentationViewer::urlSelected(const QString &url, int button, int state, const QString &_target, const KParts::OpenUrlArguments &args, const KParts::BrowserArguments & /* browserArgs */)
{
	KUrl cURL = completeURL(url);
	QString mime = KMimeType::findByUrl(cURL).data()->name();

	//load this URL in the embedded viewer if KHTML can handle it, or when mimetype detection failed
	KService::Ptr service = KService::serviceByDesktopName("khtml");
	if(( mime == KMimeType::defaultMimeType() ) || (service && service->hasServiceType(mime))) {
		KHTMLPart::urlSelected(url, button, state, _target, args);
		openUrl(cURL);
		addToHistory(cURL.url());
	}
	//KHTML can't handle it, look for an appropriate application
	else {
		KService::List offers = KMimeTypeTrader::self()->query(mime, "Type == 'Application'");
		if(offers.isEmpty()) {
			KMessageBox::error(view(), i18n("No KDE service found for the MIME type \"%1\".", mime));
			return false;
		}
		KUrl::List lst;
		lst.append(cURL);
		KRun::run(*(offers.first()), lst, view());
	}
	return true;
}
コード例 #7
0
ファイル: kfwin.cpp プロジェクト: Fat-Zer/tdebase
TQDragObject * KfindWindow::dragObject()
{
  KURL::List uris;
  TQPtrList<TQListViewItem> selected = selectedItems();

  // create a list of URIs from selection
  for ( uint i = 0; i < selected.count(); i++ )
  {
    KfFileLVI *item = (KfFileLVI *) selected.at( i );
    if (item)
    {
      uris.append( item->fileitem.url() );
    }
  }

  if ( uris.count() <= 0 )
     return 0;

  TQUriDrag *ud = new KURLDrag( uris, (TQWidget *) this, "kfind uridrag" );

  const TQPixmap *pix = currentItem()->pixmap(0);
  if ( pix && !pix->isNull() )
    ud->setPixmap( *pix );

  return ud;
}
コード例 #8
0
ファイル: mediadirnotify.cpp プロジェクト: Fat-Zer/tdebase
KURL::List MediaDirNotify::toMediaURL(const KURL &url)
{
	kdDebug(1219) << "MediaDirNotify::toMediaURL(" << url << ")" << endl;

	KURL::List result;
	
	const TQPtrList<Medium> list = m_mediaList.list();

	TQPtrList<Medium>::const_iterator it = list.begin();
	TQPtrList<Medium>::const_iterator end = list.end();

	for (; it!=end; ++it)
	{
		const Medium *m = *it;
		KURL base = m->prettyBaseURL();

		if ( base.isParentOf(url) )
		{
			TQString path = KURL::relativePath(base.path(),
			                                  url.path());

			KURL new_url("media:/"+m->name()+"/"+path );
			new_url.cleanPath();
		
			result.append(new_url);
		}
	}

	kdDebug(1219) << result << endl;
	return result;
}
コード例 #9
0
ファイル: katefiletree.cpp プロジェクト: azat-archive/kate
void KateFileTree::slotOpenWithMenuAction(QAction* a)
{
  KUrl::List list;
  
  KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
  if (!doc) return;

  
  list.append( doc->url() );

  const QString openWith = a->data().toString();
  if (openWith.isEmpty())
  {
    // display "open with" dialog
    KOpenWithDialog dlg(list);
    if (dlg.exec())
      KRun::run(*dlg.service(), list, this);
    return;
  }

  KService::Ptr app = KService::serviceByDesktopPath(openWith);
  if (app)
  {
    KRun::run(*app, list, this);
  }
  else
  {
    KMessageBox::error(this, i18n("Application '%1' not found.", openWith), i18n("Application not found"));
  }
}
コード例 #10
0
ファイル: netaccess.cpp プロジェクト: vasi/kdelibs
bool NetAccess::move( const KUrl& src, const KUrl& target, QWidget* window )
{
  KUrl::List srcList;
  srcList.append( src );
  NetAccess kioNet;
  return kioNet.dircopyInternal( srcList, target, window, true /*move*/ );
}
コード例 #11
0
void PlaylistModel::sort(int column, Qt::SortOrder order)
{
    if (m_tracks.count() < 2)
    {
        return;
    }

    QMultiMap<QString, KUrl> keyMap;
    QMultiMap<qint64, KUrl> durationMap;
    KUrl::List tracks;
    const KUrl url = m_tracks.value(m_currentTrack);

    if (column == DurationColumn)
    {
        for (int i = 0; i < m_tracks.count(); ++i)
        {
            durationMap.insert(MetaDataManager::duration(m_tracks.at(i)), m_tracks.at(i));
        }

        tracks = durationMap.values();
    }
    else if (column > FileNameColumn && column < DurationColumn)
    {
        const MetaDataKey key = translateColumn(column);

        for (int i = 0; i < m_tracks.count(); ++i)
        {
            keyMap.insert(MetaDataManager::metaData(m_tracks.at(i), key), m_tracks.at(i));
        }

        tracks = keyMap.values();
    }
    else
    {
        for (int i = 0; i < m_tracks.count(); ++i)
        {
            keyMap.insert(m_tracks.at(i).pathOrUrl(), m_tracks.at(i));
        }

        tracks = keyMap.values();
    }

    if (order == Qt::AscendingOrder)
    {
        KUrl::List items;

        for (int i = (tracks.count() - 1); i >= 0; --i)
        {
            items.append(tracks.at(i));
        }

        tracks = items;
    }

    m_tracks = tracks;

    setCurrentTrack(findTrack(url));

    emit tracksChanged();
}
コード例 #12
0
ファイル: soundtrackdialog.cpp プロジェクト: UIKit0/digikam
void SoundtrackDialog::slotPreviewButtonClicked()
{
    KUrl::List urlList;

    for (int i = 0 ; i < m_SoundFilesListBox->count() ; ++i)
    {
        SoundItem *pitem = static_cast<SoundItem*>( m_SoundFilesListBox->item(i) );
        QString path = pitem->url().toLocalFile();

        if (!QFile::exists(path))
        {
            KMessageBox::error(this,
                               i18n("Cannot access file %1. Please check the path is correct.", path));
            return;
        }

        urlList.append(path);  // Input sound files.
    }

    if ( urlList.isEmpty() )
    {
        KMessageBox::error(this,
                           i18n("Cannot create a preview of an empty file list."));
        return;
    }

    // Update SharedContainer from interface
    saveSettings();

    QPointer<SoundtrackPreview> preview = new SoundtrackPreview(this, urlList, m_sharedData);
    preview->exec();

    delete preview;
    return;
}
コード例 #13
0
KURL::List ProjectNewLocal::files()
{
  //return fileList;
  KURL::List r;

  QListViewItem *item;
  QListViewItemIterator it(listView);
  for ( ; it.current(); ++it )
  {
   item = it.current();
   if ( listView->isSelected( item ))
   {
     KURL u;
     if (dynamic_cast<UploadTreeFolder*>(item))
     {
      u = dynamic_cast<UploadTreeFolder*>(item)->url();
     } else
     {
      u = dynamic_cast<UploadTreeFile*>(item)->url();
     }

     if (!u.isEmpty()) r.append(u);
   }
  }
  return r;
}
コード例 #14
0
KURL::List K3b::convertToLocalUrls( const KURL::List& urls )
{
  KURL::List r;
  for( KURL::List::const_iterator it = urls.constBegin(); it != urls.constEnd(); ++it )
    r.append( convertToLocalUrl( *it ) );
  return r;
}
コード例 #15
0
KURL::List FileBrowser::selectedItems()
{
    KURL::List list;
    for( KFileItemListIterator it( m_dir->selectedItems()->count() ? *m_dir->selectedItems() : *m_dir->view()->items() ); *it; ++it )
        list.append( (*it)->url() );

    return list;
}
コード例 #16
0
ファイル: popupview.cpp プロジェクト: blue-shell/folderview
KUrl::List PopupView::selectedUrls() const
{
    Q_ASSERT(m_model);

    KUrl::List urls;
    foreach (const QModelIndex &index, m_selectionModel->selectedIndexes())
    {
        KFileItem item = m_model->itemForIndex(index);
        // Prefer the local URL if there is one, since we can't trash remote URL's
        const QString path = item.localPath();
        if (!path.isEmpty()) {
            urls.append(path);
        } else {
            urls.append(item.url());
        }
    }
    return urls;
}
コード例 #17
0
KUrl::List ReplayGainFileListItem::urls()
{
    KUrl::List urls;

    if( type == ReplayGainFileListItem::Track )
    {
        urls.append( url );
    }
    else
    {
        for( int j=0; j<childCount(); j++ )
        {
            urls.append( static_cast<ReplayGainFileListItem*>(child(j))->url );
        }
    }

    return urls;
}
コード例 #18
0
ファイル: iconview.cpp プロジェクト: MagicGroup/kndesktop
void IconView::deleteSelectedItems()
{
    KUrl::List urls;
    foreach (const QModelIndex &index, m_selectionModel->selectedIndexes()) {
        KFileItem item = m_model->itemForIndex( m_proxyModel->mapToSource( index ) );
        urls.append( item.url() );
    }
    KonqOperations::del( QApplication::desktop(), KonqOperations::DEL, urls );
}
コード例 #19
0
void KNewFileMenuPrivate::executeStrategy()
{
    m_tempFileToDelete = m_copyData.tempFileToDelete();
    const QString src = m_copyData.sourceFileToCopy();
    QString chosenFileName = expandTilde(m_copyData.chosenFileName(), true);

    if (src.isEmpty())
        return;
    KUrl uSrc(src);
    if (uSrc.isLocalFile()) {
        // In case the templates/.source directory contains symlinks, resolve
        // them to the target files. Fixes bug #149628.
        KFileItem item(uSrc, QString(), KFileItem::Unknown);
        if (item.isLink())
            uSrc.setPath(item.linkDest());

        if (!m_copyData.m_isSymlink) {
            // If the file is not going to be detected as a desktop file, due to a
            // known extension (e.g. ".pl"), append ".desktop". #224142.
            QFile srcFile(uSrc.toLocalFile());
            if (srcFile.open(QIODevice::ReadOnly)) {
                KMimeType::Ptr wantedMime = KMimeType::findByUrl(uSrc);
                KMimeType::Ptr mime = KMimeType::findByNameAndContent(m_copyData.m_chosenFileName, srcFile.read(1024));
                //kDebug() << "mime=" << mime->name() << "wantedMime=" << wantedMime->name();
                if (!mime->is(wantedMime->name()))
                    chosenFileName += wantedMime->mainExtension();
            }
        }
    }

    // The template is not a desktop file [or it's a URL one]
    // Copy it.
    KUrl::List::const_iterator it = m_popupFiles.constBegin();
    for (; it != m_popupFiles.constEnd(); ++it)
    {
        KUrl dest(*it);
        dest.addPath(KIO::encodeFileName(chosenFileName));

        KUrl::List lstSrc;
        lstSrc.append(uSrc);
        KIO::Job* kjob;
        if (m_copyData.m_isSymlink) {
            kjob = KIO::symlink(src, dest);
            // This doesn't work, FileUndoManager registers new links in copyingLinkDone,
            // which KIO::symlink obviously doesn't emit... Needs code in FileUndoManager.
            //KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Link, lstSrc, dest, kjob);
        } else {
            //kDebug(1203) << "KIO::copyAs(" << uSrc.url() << "," << dest.url() << ")";
            KIO::CopyJob * job = KIO::copyAs(uSrc, dest);
            job->setDefaultPermissions(true);
            kjob = job;
            KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Copy, lstSrc, dest, job);
        }
        kjob->ui()->setWindow(m_parentWidget);
        QObject::connect(kjob, SIGNAL(result(KJob*)), q, SLOT(slotResult(KJob*)));
    }
}
コード例 #20
0
void BaseTreeView::slotOpenWith()
{
  if (currentItem())
  {
    KURL::List list;
    KURL urlToOpen = currentURL();
    list.append( urlToOpen );
    KRun::displayOpenWithDialog( list );
  }
}
コード例 #21
0
ファイル: project.cpp プロジェクト: serghei/kde3-kdewebdev
KURL::List Project::files()
{
  KURL::List list;
  ProjectList::Iterator  it( d->m_projectFiles );
  for ( ; it.current(); ++it) {
    if (!it.current()->fileName(false).isEmpty())
      list.append((*it.current()));
  }
  return list;
}
コード例 #22
0
ファイル: queuelist.cpp プロジェクト: UIKit0/digikam
QMimeData* QueueListView::mimeData(const QList<QTreeWidgetItem*> items) const
{
    KUrl::List urls;
    KUrl::List kioURLs;
    QList<int> albumIDs;
    QList<qlonglong> imageIDs;

    foreach(QTreeWidgetItem* itm, items)
    {
        QueueListViewItem* vitem = dynamic_cast<QueueListViewItem*>(itm);

        if (vitem)
        {
            urls.append(vitem->info().fileUrl());
            kioURLs.append(vitem->info().databaseUrl());
            albumIDs.append(vitem->info().albumId());
            imageIDs.append(vitem->info().id());
        }
    }
コード例 #23
0
 void saveListOfOpenedProjects()
 {
     KSharedConfig::Ptr config = Core::self()->activeSession()->config();
     KConfigGroup group = config->group( "General Options" );
 
     KUrl::List openProjects;
 
     foreach( IProject* project, m_projects ) {
         openProjects.append(project->projectFileUrl());
     }
コード例 #24
0
ファイル: notedrag.cpp プロジェクト: tytycoon/basket
void NoteDrag::serializeLinks(NoteSelection *noteList, K3MultipleDrag *multipleDrag, bool cutting)
{
	KUrl::List  urls;
	QStringList titles;
	KUrl    url;
	QString title;
	for (NoteSelection *node = noteList->firstStacked(); node; node = node->nextStacked()) {
		node->note->content()->toLink(&url, &title, node->fullPath);
		if (!url.isEmpty()) {
			urls.append(url);
			titles.append(title);
		}
	}
	if (!urls.isEmpty()) {
		// First, the standard text/uri-list MIME format:
#if KDE_IS_VERSION( 3, 3, 90 )
		K3URLDrag *urlsDrag = new K3URLDrag(urls);
		// ONLY export as text/uri-list, and not as text/plain* as we wil do that better ourself
		urlsDrag->setExportAsText(false);
		multipleDrag->addDragObject(urlsDrag);
#else
		K3URLDrag2 *urlsDrag = new K3URLDrag2(urls);
		QByteArray byteArray = urlsDrag->encodedData2("text/uri-list");
		Q3StoredDrag *uriListDrag = new Q3StoredDrag("text/uri-list");
		uriListDrag->setEncodedData(byteArray);
		multipleDrag->addDragObject(uriListDrag);
		delete urlsDrag;
#endif
		// Then, also provide it in the Mozilla proprietary format (that also allow to add titles to URLs):
		// A version for Mozilla applications (convert to "theUrl\ntheTitle", into UTF-16):
		// FIXME: Does Mozilla support the drag of several URLs at once?
		// FIXME: If no, only provide that if theire is only ONE URL.
		QString xMozUrl;
		for (int i = 0; i < urls.count(); ++i)
			xMozUrl += (xMozUrl.isEmpty() ? "" : "\n") + urls[i].prettyUrl() + "\n" + titles[i];
/*		Code for only one: ===============
		xMozUrl = note->title() + "\n" + note->url().prettyUrl();*/
		QByteArray baMozUrl;
		QTextStream stream(baMozUrl, QIODevice::WriteOnly);
		stream.setEncoding(QTextStream::RawUnicode); // It's UTF16 (aka UCS2), but with the first two order bytes
		stream << xMozUrl;
		Q3StoredDrag *xMozUrlDrag = new Q3StoredDrag("text/x-moz-url");
		xMozUrlDrag->setEncodedData(baMozUrl);
		multipleDrag->addDragObject(xMozUrlDrag);

		if (cutting) {
			QByteArray  arrayCut(2);
			Q3StoredDrag *storedDragCut = new Q3StoredDrag("application/x-kde-cutselection");
			arrayCut[0] = '1';
			arrayCut[1] = 0;
			storedDragCut->setEncodedData(arrayCut);
			multipleDrag->addDragObject(storedDragCut);
		}
	}
}
コード例 #25
0
ファイル: wmwidget.cpp プロジェクト: tejastank/kipi-plugins
void WmWidget::slotApplyTitle()
{
    kDebug() << "ApplyTitle";

    QString givenTitle = title();
    QString imageTitle;
    QString number;
    QString originalExtension;
    QString currentExtension;
    KUrl::List urls;
    QMap<QString, QString> imageMetaData;
    QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
    QStringList parts;

    const int minLength = givenTitle.count("#");

    // Build the list of items to rename
    for (int i = 0; i < selectedItems.size(); ++i)
    {
        KPImagesListViewItem* l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
        urls.append(l_item->url());
    }

    for (int i = 0; i < urls.size(); ++i)
    {
        imageMetaData = d->imagesDescInfo[urls.at(i).path()];
        imageTitle = givenTitle;

        // If there is at least one #, replace it the correct number
        if(minLength > 0)
        {
            parts = imageTitle.split("#", QString::KeepEmptyParts);
            imageTitle = parts.first().append("#").append(parts.last());
            number = QString::number(i + 1);
            while (number.length() < minLength)
            {
                number.prepend("0");
            }
            imageTitle.replace(imageTitle.indexOf("#"), 1, number);
        }

        // Add original extension if removed
        currentExtension = imageTitle.split('.').last();
        originalExtension = urls.at(i).path().split('.').last();
        if(QString::compare(currentExtension, originalExtension, Qt::CaseInsensitive) != 0)
        {
            imageTitle.append(".").append(originalExtension);
            d->titleEdit->setText(imageTitle);
        }

        kDebug() << urls.at(i).path() << "renamed to" << imageTitle;
        imageMetaData["title"] = imageTitle;
        d->imagesDescInfo[urls.at(i).path()] = imageMetaData;
    }
}
コード例 #26
0
/**
 * Called when a link in the info view is activated.
 * Parameters are coming from KParts::BrowserExtension::openURLRequest().
 */
void PackageInfoView::openURLRequest( const KURL& url, const KParts::URLArgs& )
{
	// get service for web browsing
	KService::Ptr ptr =
		KServiceTypeProfile::preferredService("text/html", "Application");

	KURL::List lst;
	// append 'url' parameter to the service and run it
	lst.append( url );
	KRun::run( *ptr, lst );
}
コード例 #27
0
ファイル: iconview.cpp プロジェクト: MagicGroup/kndesktop
void IconView::pasteTo()

{
    KUrl::List urls;
    foreach (const QModelIndex &index, m_selectionModel->selectedIndexes()) {
        KFileItem item = m_model->itemForIndex( m_proxyModel->mapToSource( index ) );
        urls.append( item.url() );
    }
    Q_ASSERT(urls.count() == 1);
    KonqOperations::doPaste( QApplication::desktop(), urls.first() );
}
コード例 #28
0
void KMMimePartTree::slotCopy()
{
  KURL::List urls;
  KMMimePartTreeItem *item = static_cast<KMMimePartTreeItem*>( currentItem() );
  if ( !item ) return;
  KURL url = mReaderWin->tempFileUrlFromPartNode( item->node() );
  if ( !url.isValid() ) return;
  urls.append( url );
  KURLDrag* drag = new KURLDrag( urls, this );
  QApplication::clipboard()->setData( drag, QClipboard::Clipboard );
}
コード例 #29
0
void ListSoundItems::dropEvent(QDropEvent* e)
{
    QList<QUrl> list = e->mimeData()->urls();
    KUrl::List urls;

    foreach(const QUrl &url, list)
    {
        QFileInfo fi(url.toLocalFile());
        if (fi.isFile() && fi.exists())
            urls.append(KUrl(url));
    }
コード例 #30
0
ファイル: imageslist.cpp プロジェクト: ruphy/kipi-plugins
void ImagesListView::dropEvent(QDropEvent *e)
{
    QList<QUrl> list = e->mimeData()->urls();
    KUrl::List urls;

    foreach (const QUrl &url, list)
    {
        QFileInfo fi(url.path());
        if (fi.isFile() && fi.exists())
            urls.append(KUrl(url));
    }