Exemplo n.º 1
0
void KFileDetailView::contentsDropEvent( TQDropEvent *e )
{
    d->dropItem = 0;
    d->autoOpenTimer.stop();

    if ( ! acceptDrag( e ) ) { // can we decode this ?
        e->ignore();            // No
        return;
    }
    e->acceptAction();     // Yes

    KFileListViewItem *item = dynamic_cast<KFileListViewItem*>(itemAt( contentsToViewport( e->pos() ) ));
    KFileItem * fileItem = 0;
    if (item)
        fileItem = item->fileInfo();

    emit dropped(e, fileItem);

    KURL::List urls;
    if (KURLDrag::decode( e, urls ) && !urls.isEmpty())
    {
        emit dropped(e, urls, fileItem ? fileItem->url() : KURL());
        sig->dropURLs(fileItem, e, urls);
    }
}
Exemplo n.º 2
0
void k2send::dropEvent(QDropEvent *event)
{
    KURL::List urls;
    if (KURLDrag::decode(event, urls) && !urls.isEmpty())
    {
        const KURL &url = urls.first();
        load(url);
    }
}
Exemplo n.º 3
0
int K3bDataUrlAddingDialog::addUrls( const KURL::List& urls,
				     K3bDirItem* dir,
				     QWidget* parent )
{
  if( urls.isEmpty() )
    return 0;

  //
  // A common mistake by beginners is to try to burn an iso image
  // with a data project. Let's warn them
  //
  if( urls.count() == 1 ) {
    K3bIso9660 isoF( urls.first().path() );
    if( isoF.open() ) {
     if( KMessageBox::warningYesNo( parent,
				    i18n("<p>The file you are about to add to the project is an ISO9660 image. As such "
					 "it can be burned to a medium directly since it already contains a file "
					 "system.<br>"
					 "Are you sure you want to add this file to the project?"),
				    i18n("Adding image file to project"),
				    i18n("Add the file to the project"),
				    i18n("Burn the image directly") ) == KMessageBox::No ) {
       // very rough dvd image size test
       if( K3b::filesize( urls.first() ) > 1000*1024*1024 )
	 k3bappcore->k3bMainWindow()->slotWriteDvdIsoImage( urls.first() );
       else
	 k3bappcore->k3bMainWindow()->slotWriteCdImage( urls.first() );
       return 0;
     }
    }
  }

  K3bDataUrlAddingDialog dlg( dir->doc(), parent );
  dlg.m_urls = urls;
  for( KURL::List::ConstIterator it = urls.begin(); it != urls.end(); ++it )
    dlg.m_urlQueue.append( qMakePair( K3b::convertToLocalUrl(*it), dir ) );

  dlg.slotAddUrls();
  int ret = QDialog::Accepted;
  if( !dlg.m_urlQueue.isEmpty() ) {
    dlg.m_dirSizeJob->setUrls( urls );
    dlg.m_dirSizeJob->setFollowSymlinks( dir->doc()->isoOptions().followSymbolicLinks() );
    dlg.m_dirSizeJob->start();
    ret = dlg.exec();
  }

  // make sure the dir size job is finished
  dlg.m_dirSizeJob->cancel();
  K3bSignalWaiter::waitForJob( dlg.m_dirSizeJob );

  QString message = dlg.resultMessage();
  if( !message.isEmpty() )
    KMessageBox::detailedSorry( parent, i18n("Problems while adding files to the project."), message );

  return ret;
}
Exemplo n.º 4
0
/** No descriptions */
void ProjectNewLocal::slotAddFiles()
{
  QExtFileInfo::createDir(baseURL, this);
  KURL::List list = KFileDialog::getOpenURLs(
    baseURL.url(),  i18n("*"), this, i18n("Insert Files in Project"));

  if ( !list.isEmpty() )
  {
    KURL u = list.first();

    u = QExtFileInfo::toRelative( u, baseURL, false );

    if ( u.path().startsWith("..") || u.path().startsWith("/"))
    {
      KURLRequesterDlg *urlRequesterDlg = new KURLRequesterDlg( baseURL.prettyURL(), this, "");
      urlRequesterDlg->setCaption(i18n("Files: Copy to Project"));
      urlRequesterDlg->urlRequester()->setMode( KFile::Directory | KFile::ExistingOnly);
      urlRequesterDlg->exec();
      KURL destination = urlRequesterDlg->selectedURL();
      delete urlRequesterDlg;

      if ( !destination.isEmpty())
      {
        CopyTo *dlg = new CopyTo( baseURL);
        connect(dlg, SIGNAL(addFilesToProject(const KURL::List&)),
                     SLOT  (slotInsertFilesAfterCopying(const KURL::List&)));
        connect(dlg, SIGNAL(deleteDialog(CopyTo *)),
                     SLOT  (slotDeleteCopyToDialog(CopyTo *)));
        list = dlg->copy( list, destination );
        return;
      } else
      {
        return;
      }
    }

    progressBar->setTotalSteps(list.count() - 1);
    progressBar->setTextEnabled(true);
    for (uint i = 0; i < list.count(); i++)
    {
       list[i] = QExtFileInfo::toRelative(list[i], baseURL, false);
       if (!fileList.contains(list[i]))
       {
         fileList.append(list[i]);
         QListViewItem *it = listView->addItem(list[i], KFileItem(KFileItem::Unknown, KFileItem::Unknown, KURL()));
         if (it)  it->setSelected(true);
         progressBar->setValue(i);
       }
    }
    progressBar->setTotalSteps(1);
    progressBar->setValue(0);
    progressBar->setTextEnabled(false);
  }
}
Exemplo n.º 5
0
// the group item itself will be removed automatically,
// when the last child is removed
void KonqSidebarHistoryGroupItem::remove()
{
    KURL::List list;
    KonqSidebarHistoryItem *child = static_cast<KonqSidebarHistoryItem*>( firstChild() );
    while( child ) {
	list.append( child->externalURL() );
	child = static_cast<KonqSidebarHistoryItem*>( child->nextSibling() );
    }

    if ( !list.isEmpty() )
	KonqHistoryManager::kself()->emitRemoveFromHistory( list );
}
Exemplo n.º 6
0
void TopLevel::dropEvent( QDropEvent * event)
{

  KURL::List list;

  if (KURLDrag::decode(event, list) && !list.isEmpty())
  {
    // Load the first file in this window
    const KURL &url = list.first();
    openNetFile( url );
  }
}
Exemplo n.º 7
0
void PlaylistWindow::playAudioCD() //SLOT
{
    KURL::List urls;
    if (EngineController::engine()->getAudioCDContents(QString::null, urls)) {
        if (!urls.isEmpty()) {
            Playlist::instance()->insertMedia(urls, Playlist::Replace);
        }
    } else { // Default behaviour
        m_browsers->showBrowser( "FileBrowser" );
        FileBrowser *fb = static_cast<FileBrowser *>( m_browsers->browser("FileBrowser") );
        fb->setUrl( KURL("audiocd:/Wav/") );
    }
}
void K2sendPlayList::insertDroppedEvent(QDropEvent *event, QListViewItem *p, QListViewItem *after)
{
    KURL::List urls;
    if (KURLDrag::decode(event, urls) && !urls.isEmpty()){
        KURL::List::iterator it;
        for ( it = urls.begin(); it != urls.end(); ++it ){
            if ((*it).isLocalFile()){
                add((*it).path(),(K2sendPlayListItem*)after);
            }
        }
    }
    QString msg = QString("%1 Files").arg(this->childCount());
    emit signalChangeStatusbar(msg);
}
void BookmarksListBox::dropEvent( QDropEvent *event )
{
    KURL::List urls;
    if (KURLDrag::decode(event, urls) && !urls.isEmpty()) {
        KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
        KBookmarkGroup root = manager->root();

        KURL::List::iterator it;
        for(it=urls.begin(); it!=urls.end(); ++it) {
            root.addBookmark(manager, (*it).fileName(), (*it), "", false);
	}
	manager->emitChanged(root);
    }
}
Exemplo n.º 10
0
void RubySupportPart::slotSwitchToTest()
{
    KParts::Part *activePart = partController()->activePart();
    if (!activePart)
        return;
    KParts::ReadOnlyPart *ropart = dynamic_cast<KParts::ReadOnlyPart*>(activePart);
    if (!ropart)
        return;
    QFileInfo file(ropart->url().path());
    if (!file.exists())
        return;
    QString ext = file.extension();
    QString name = file.baseName();
    QString switchTo = "";

    if (ext == "rjs" || ext == "rxml" || ext == "rhtml" || ext == "js.rjs" || ext == "xml.builder" || ext == "html.erb")
    {
        //this is a view already, let's show the list of all views for this model
        switchTo = file.dir().dirName();
    }
    else if (ext == "rb")
        switchTo = name.remove(QRegExp("_controller$")).remove(QRegExp("_controller_test$")).remove(QRegExp("_test$"));

    if (switchTo.isEmpty())
        return;

    if (switchTo.endsWith("s"))
        switchTo = switchTo.mid(0, switchTo.length() - 1);

    KURL::List urls;
    QString testDir = project()->projectDirectory() + "/test/";
    QString functionalTestS = testDir + "functional/" + switchTo + "_controller_test.rb";
    QString functionalTestP = testDir + "functional/" + switchTo + "s_controller_test.rb";
    QString integrationTestS = testDir + "integration/" + switchTo + "_test.rb";
    QString integrationTestP = testDir + "integration/" + switchTo + "s_test.rb";
    QString unitTestS = testDir + "unit/" + switchTo + "_test.rb";
    QString unitTestP = testDir + "unit/" + switchTo + "s_test.rb";
    if (QFile::exists(functionalTestP)) urls << KURL::fromPathOrURL(functionalTestP);
    if (QFile::exists(integrationTestP)) urls << KURL::fromPathOrURL(integrationTestP);
    if (QFile::exists(unitTestP)) urls << KURL::fromPathOrURL(unitTestP);
    if (QFile::exists(functionalTestS)) urls << KURL::fromPathOrURL(functionalTestS);
    if (QFile::exists(integrationTestS)) urls << KURL::fromPathOrURL(integrationTestS);
    if (QFile::exists(unitTestS)) urls << KURL::fromPathOrURL(unitTestS);

    KDevQuickOpen *qo = extension<KDevQuickOpen>("KDevelop/QuickOpen");
    if (qo && !urls.isEmpty())
        qo->quickOpenFile(urls);
}
Exemplo n.º 11
0
QDragObject *KURLBarListBox::dragObject()
{
    KURL::List urls;
    KURLBarItem *item = static_cast< KURLBarItem * >(firstItem());

    while(item)
    {
        if(item->isSelected())
            urls.append(item->url());
        item = static_cast< KURLBarItem * >(item->next());
    }

    if(!urls.isEmpty()) // ### use custom drag-object with description etc.?
        return new KURLDrag(urls, this, "urlbar drag");

    return 0L;
}
Exemplo n.º 12
0
void Korrent::dropEvent(QDropEvent *event)
{
    // this is a very simplistic implementation of a drop event.  we
    // will only accept a dropped URL.  the Qt dnd code can do *much*
    // much more, so please read the docs there
    KURL::List urls;

    // see if we can decode a URI.. if not, just ignore it
    if (KURLDrag::decode(event, urls) && !urls.isEmpty())
    {
        // okay, we have a URI.. process it
        const KURL &url = urls.first();

        // load in the file
        load(url);
    }
}
Exemplo n.º 13
0
void Kooka::dropEvent(QDropEvent *event)
{
    // this is a very simplistic implementation of a drop event.  we
    // will only accept a dropped URL.  the Qt dnd code can do *much*
    // much more, so please read the docs there
    KURL::List uri;

    // see if we can decode a URI.. if not, just ignore it
    if (KURLDrag::decode(event, uri) && !uri.isEmpty())
    {
        // okay, we have a URI.. process it
        const KURL &url = uri.first();
	kdDebug(29000) << "Importing URI " << url.url() << endl;

        // TODO: Do something with url
        // Waba: See also setAcceptDrops() above
    }
}
Exemplo n.º 14
0
QDragObject* K3bDataFileView::dragObject()
{
  QPtrList<QListViewItem> selectedViewItems = selectedItems();
  KURL::List urls;
  for( QPtrListIterator<QListViewItem> it( selectedViewItems ); it.current(); ++it ) {
    K3bDataViewItem* dataViewItem = dynamic_cast<K3bDataViewItem*>( it.current() );
    if( dataViewItem ) {
      urls.append( KURL::fromPathOrURL(dataViewItem->dataItem()->localPath()) );
    }
    else
      kdDebug() << "no dataviewitem" << endl;
  }

  if( urls.isEmpty() )
    return 0;

  return KURLDrag::newDrag( urls, viewport() );
}
Exemplo n.º 15
0
KURL::List MediaDirNotify::toMediaURLList(const KURL::List &list)
{
	KURL::List new_list;

	KURL::List::const_iterator it = list.begin();
	KURL::List::const_iterator end = list.end();

	for (; it!=end; ++it)
	{
		KURL::List urls = toMediaURL(*it);

		if (!urls.isEmpty())
		{
			new_list += urls;
		}
	}

	return new_list;
}
Exemplo n.º 16
0
void ImageButton::dropEvent(QDropEvent *event)
{
    if(mReadOnly)
        return;

    if(QImageDrag::canDecode(event))
    {
        QPixmap pm;

        if(QImageDrag::decode(event, pm))
        {
            mPicture.setData(pm.convertToImage());
            updateGUI();
            emit changed();
        }
    }

    if(QUriDrag::canDecode(event))
    {
        KURL::List urls;
        if(KURLDrag::decode(event, urls))
        {
            if(urls.isEmpty())      // oops, no data
            {
                event->accept(false);
                return;
            }
        }

        if(mImageLoader)
        {
            bool ok = false;
            KABC::Picture pic = mImageLoader->loadPicture(urls[ 0 ], &ok);
            if(ok)
            {
                mPicture = pic;
                updateGUI();
                emit changed();
            }
        }
    }
}
Exemplo n.º 17
0
void PlaylistWindow::slotAddLocation( bool directPlay ) //SLOT
{
    // open a file selector to add media to the playlist
    KURL::List files;
    //files = KFileDialog::getOpenURLs( QString::null, "*.*|" + i18n("All Files"), this, i18n("Add Media") );
    KFileDialog dlg(QString::null, "*.*|", this, "openMediaDialog", true);
    dlg.setCaption(directPlay ? i18n("Play Media (Files or URLs)") : i18n("Add Media (Files or URLs)"));
    dlg.setMode( KFile::Files | KFile::Directory );
    dlg.exec();
    files = dlg.selectedURLs();
    if( files.isEmpty() ) return;
    const int options = directPlay ? Playlist::Append | Playlist::DirectPlay : Playlist::Append;

    const KURL::List::ConstIterator end  = files.constEnd();

    for(  KURL::List::ConstIterator it = files.constBegin(); it != end; ++it )
        if( it == files.constBegin() )
            Playlist::instance()->insertMedia( *it, options );
        else
            Playlist::instance()->insertMedia( *it, Playlist::Append );
}
Exemplo n.º 18
0
KIO_EXPORT QString KIO::pasteActionText()
{
    QMimeSource *data = QApplication::clipboard()->data();
    KURL::List urls;
    if(KURLDrag::canDecode(data) && KURLDrag::decode(data, urls))
    {
        if(urls.isEmpty())
            return QString::null; // nothing to paste
        else if(urls.first().isLocalFile())
            return i18n("&Paste File", "&Paste %n Files", urls.count());
        else
            return i18n("&Paste URL", "&Paste %n URLs", urls.count());
    }
    else if(data->format(0) != 0)
    {
        return i18n("&Paste Clipboard Contents");
    }
    else
    {
        return QString::null;
    }
}
Exemplo n.º 19
0
void KUrlMimeTest::testURLList()
{
    QMimeData* mimeData = new QMimeData;
    QVERIFY( !KUrl::List::canDecode( mimeData ) );
    QVERIFY(!mimeData->hasUrls());

    KUrl::List urls;
    urls.append( KUrl( "http://www.kde.org" ) );
    urls.append( KUrl( "http://*****:*****@example.com/path" ) );
    urls.append( KUrl( "file:///home/dfaure/konqtests/Mat%C3%A9riel" ) );
    QMap<QString, QString> metaData;
    metaData["key"] = "value";
    metaData["key2"] = "value2";

    urls.populateMimeData( mimeData, metaData );

    QVERIFY(KUrl::List::canDecode( mimeData ));
    QVERIFY(mimeData->hasUrls());
    QVERIFY(mimeData->hasText());

    QMap<QString, QString> decodedMetaData;
    KUrl::List decodedURLs = KUrl::List::fromMimeData( mimeData, &decodedMetaData );
    QVERIFY( !decodedURLs.isEmpty() );
    KUrl::List expectedUrls = urls;
    expectedUrls[1] = KUrl("http://[email protected]/path"); // password removed
    QCOMPARE( expectedUrls.toStringList().join(" "), decodedURLs.toStringList().join(" ") );

    const QList<QUrl> qurls = mimeData->urls();
    QCOMPARE(qurls.count(), urls.count());
    for (int i = 0; i < qurls.count(); ++i )
        QCOMPARE(qurls[i], static_cast<QUrl>(decodedURLs[i]));

    QVERIFY( !decodedMetaData.isEmpty() );
    QCOMPARE( decodedMetaData["key"], QString( "value" ) );
    QCOMPARE( decodedMetaData["key2"], QString( "value2" ) );

    delete mimeData;
}
Exemplo n.º 20
0
void MainDialog::slotSelection()
{
    KUrl::List urlList;

    if (m_selectedFilesButton->isChecked())
    {
        m_ImagesFilesListBox->listView()->clear();
        urlList = m_sharedData->iface()->currentSelection().images();
    }
    else if (m_allFilesButton->isChecked())
    {
        KUrl currentPath = m_sharedData->iface()->currentAlbum().path();
        QList<KIPI::ImageCollection> albumList;
        albumList        = m_sharedData->iface()->allAlbums();

        m_ImagesFilesListBox->listView()->clear();
        urlList = m_sharedData->iface()->currentAlbum().images();

        QList<KIPI::ImageCollection>::iterator it;
        for (it = albumList.begin(); it != albumList.end(); ++it)
        {
            if (currentPath.isParentOf((*it).path()) && !((*it).path() == currentPath))
            {
                urlList += (*it).images();
            }
        }
    }

    bool customize = m_customButton->isChecked();

    if (!urlList.isEmpty() && !customize)
    {
        addItems(urlList);
    }

    m_ImagesFilesListBox->enableControlButtons(customize);
    m_ImagesFilesListBox->enableDragAndDrop(customize);
}
Exemplo n.º 21
0
void DropTarget::dropEvent(QDropEvent * event)
{
    KUrl::List list = KUrl::List::fromMimeData(event->mimeData());
    QString str;

    if (!list.isEmpty())
    {
        if (list.count() == 1 && list.first().url().endsWith(QLatin1String(".kgt")))
        {
            int msgBoxResult = KMessageBox::questionYesNoCancel(this, i18n("The dropped file is a KGet Transfer List"), "KGet",
                                   KGuiItem(i18n("&Download"), KIcon("document-save")), 
                                       KGuiItem(i18n("&Load transfer list"), KIcon("list-add")), KStandardGuiItem::cancel());

            if (msgBoxResult == 3) //Download
                NewTransferDialogHandler::showNewTransferDialog(list.first().url());
            if (msgBoxResult == 4) //Load
                KGet::load(list.first().url());
        }
        else
        {
            if (list.count() == 1)
            {
                str = event->mimeData()->text();
                NewTransferDialogHandler::showNewTransferDialog(str);
            }
            else
                NewTransferDialogHandler::showNewTransferDialog(list);
        }
    }
    else
    {
        NewTransferDialogHandler::showNewTransferDialog();
    }

    if ( Settings::animateDropTarget() )
        playAnimationSync();
}
Exemplo n.º 22
0
bool
PlayerWidget::eventFilter(QObject *object, QEvent *event)
{
	if(object == m_layeredWidget) {
		if(event->type() == QEvent::DragEnter) {
			QDragEnterEvent *dragEnterEvent = static_cast<QDragEnterEvent *>(event);
			KUrl::List urls = KUrl::List::fromMimeData(dragEnterEvent->mimeData());
			if(!urls.isEmpty())
				dragEnterEvent->accept();
			else
				dragEnterEvent->ignore();
			return true;
		} else if(event->type() == QEvent::DragMove) {
			return true;            // eat event
		} else if(event->type() == QEvent::Drop) {
			QDropEvent *dropEvent = static_cast<QDropEvent *>(event);

			KUrl::List urls = KUrl::List::fromMimeData(dropEvent->mimeData());
			if(!urls.isEmpty()) {
				for(KUrl::List::ConstIterator it = urls.begin(), end = urls.end(); it != end; ++it) {
					const KUrl &url = *it;

					if(url.protocol() != "file")
						continue;

					app()->openVideo(url);
					break;
				}
			}

			return true;            // eat event
		} else if(event->type() == QEvent::KeyPress) {
			// NOTE: when on full screen mode, the keyboard input is received but
			// for some reason it doesn't trigger the correct actions automatically
			// so we process the event and handle the issue ourselves.

			QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
			return app()->triggerAction(QKeySequence((keyEvent->modifiers() & ~Qt::KeypadModifier) + keyEvent->key()));
		} else if(event->type() == QEvent::MouseMove) {
			QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
			if(mouseEvent->globalPos() != m_currentCursorPos) {
				m_currentCursorPos = mouseEvent->globalPos();
				if(m_layeredWidget->cursor().shape() == Qt::BlankCursor)
					m_layeredWidget->unsetCursor();
				if(m_fullScreenControls->isAttached())
					m_fullScreenControls->toggleVisible(true);
			}
		}
	} else if(object == m_infoControlsGroupBox || object->parent() == m_infoControlsGroupBox) {
		if(event->type() != QEvent::MouseButtonRelease)
			return QWidget::eventFilter(object, event);

		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);

		if(mouseEvent->button() != Qt::RightButton)
			return QWidget::eventFilter(object, event);

		KMenu menu;
		QAction *action = menu.addAction(i18n("Show editable position control"));
		action->setCheckable(true);
		action->setChecked(app()->playerConfig()->showPositionTimeEdit());

		if(menu.exec(mouseEvent->globalPos()) == action)
			app()->playerConfig()->toggleShowPositionTimeEdit();

		return true;                    // eat event
	}

	return QWidget::eventFilter(object, event);
}
Exemplo n.º 23
0
Note* NoteFactory::dropNote(const QMimeData *source, Basket *parent, bool fromDrop, Qt::DropAction action, Note */*noteSource*/)
{
	Note *note = 0L;

	QStringList formats = source->formats();
	/* No data */
	if (formats.size() == 0) {
		// TODO: add a parameter to say if it's from a clipboard paste, a selection paste, or a drop
		//       To be able to say "The clipboard/selection/drop is empty".
//		KMessageBox::error(parent, i18n("There is no data to insert."), i18n("No Data"));
		return 0;
	}

	/* Debug */
	if (Global::debugWindow) {
		*Global::debugWindow << "<b>Drop :</b>";
		for (int i = 0; formats.size(); ++i)
			*Global::debugWindow << "\t[" + QString::number(i) + "] " + formats[i];
		switch (action) { // The source want that we:
			case Qt::CopyAction:       *Global::debugWindow << ">> Drop action: Copy";       break;
			case Qt::MoveAction:       *Global::debugWindow << ">> Drop action: Move";       break;
			case Qt::LinkAction:       *Global::debugWindow << ">> Drop action: Link";       break;
			default:                     *Global::debugWindow << ">> Drop action: Unknown";           //  supported by Qt!
		}
	}

	/* Copy or move a Note */
	if (NoteDrag::canDecode(source)) {
		bool moveFiles = fromDrop && action == Qt::MoveAction;
		bool moveNotes = moveFiles;
		return NoteDrag::decode(source, parent, moveFiles, moveNotes); // Filename will be kept
	}

	/* Else : Drop object to note */

	QImage image = qvariant_cast<QImage>(source->imageData()) ;
	if ( !image.isNull() )
		return createNoteImage(QPixmap::fromImage(image), parent);

	if (source->hasColor()){
		return createNoteColor(qvariant_cast<QColor>(source->colorData()), parent);
	}
	
	// And then the hack (if provide color MIME type or a text that contains color), using createNote Color RegExp:
	QString hack;
	QRegExp exp("^#(?:[a-fA-F\\d]{3}){1,4}$");
	hack = source->text();
	if (source->hasFormat("application/x-color") || (!hack.isNull() && exp.exactMatch(hack)) ) {
		QColor color = qvariant_cast<QColor>(source->colorData()) ;
		if (color.isValid())
			return createNoteColor(color, parent);
//			if ( (note = createNoteColor(color, parent)) )
//				return note;
//			// Theorically it should be returned. If not, continue by dropping other things
	}

	KUrl::List urls = KUrl::List::fromMimeData(source);
	if ( !urls.isEmpty() ){
		// If it's a Paste, we should know if files should be copied (copy&paste) or moved (cut&paste):
		if (!fromDrop && Tools::isAFileCut(source))
			action = Qt::MoveAction;
		return dropURLs(urls, parent, action, fromDrop);
	}

	// FIXME: use dropURLs() also from Mozilla?

	/*
	* Mozilla's stuff sometimes uses utf-16-le - little-endian UTF-16.
	*
	* This has the property that for the ASCII subset case (And indeed, the
	* ISO-8859-1 subset, I think), if you treat it as a C-style string,
	* it'll come out to one character long in most cases, since it looks
	 * like:
	*
	* "<\0H\0T\0M\0L\0>\0"
	*
	* A strlen() call on that will give you 1, which simply isn't correct.
	* That might, I suppose, be the answer, or something close.
	*
	* Also, Mozilla's drag/drop code predates the use of MIME types in XDnD
	* - hence it'll throw about STRING and UTF8_STRING quite happily, hence
	* the odd named types.
	*
	* Thanks to Dave Cridland for having said me that.
	*/
	if (source->hasFormat("text/x-moz-url")) { // FOR MOZILLA
		// Get the array and create a QChar array of 1/2 of the size
		QByteArray mozilla = source->data("text/x-moz-url");
		QVector<QChar> chars( mozilla.count() / 2 );
		// A small debug work to know the value of each bytes
		if (Global::debugWindow)
			for (int i = 0; i < mozilla.count(); i++)
				*Global::debugWindow << QString("'") + QChar(mozilla[i]) + "' " + QString::number(int(mozilla[i]));
		// text/x-moz-url give the URL followed by the link title and separed by OxOA (10 decimal: new line?)
		uint size   = 0;
		QChar *name = 0L;
		// For each little endian mozilla chars, copy it to the array of QChars
		for (int i = 0; i < mozilla.count(); i += 2) {
			chars[i/2] = QChar(mozilla[i], mozilla[i+1]);
			if (mozilla.at(i) == 0x0A) {
				size = i/2;
				name = &(chars[i/2+1]);
			}
		}
		// Create a QString that take the address of the first QChar and a length
		if (name == 0L) { // We haven't found name (FIXME: Is it possible ?)
			QString normalHtml(&(chars[0]), chars.size());
			return createNoteLink(normalHtml, parent);
		} else {
			QString normalHtml(  &(chars[0]), size               );
			QString normalTitle( name,        chars.size()-size-1);
			return createNoteLink(normalHtml, normalTitle, parent);
		}
	}

	if (source->hasFormat("text/html")) {
		QString html;
		QString subtype("html");
		// If the text/html comes from Mozilla or GNOME it can be UTF-16 encoded: we need ExtendedTextDrag to check that
		ExtendedTextDrag::decode(source, html, subtype);
		return createNoteHtml(html, parent);
	}

	QString text;
	// If the text/plain comes from GEdit or GNOME it can be empty: we need ExtendedTextDrag to check other MIME types
	if ( ExtendedTextDrag::decode(source, text) )
		return createNoteFromText(text, parent);

	/* Unsucceful drop */
	note = createNoteUnknown(source, parent);
	QString message = i18n("<p>%1 doesn't support the data you've dropped.<br>"
			"It however created a generic note, allowing you to drag or copy it to an application that understand it.</p>"
			"<p>If you want the support of these data, please contact developer or visit the "
			"<a href=\"http://basket.kde.org/dropdb.php\">BasKet Drop Database</a>.</p>",KGlobal::mainComponent().aboutData()->programName());
	KMessageBox::information(parent, message, i18n("Unsupported MIME Type(s)"),
							 "unsupportedDropInfo", KMessageBox::AllowLink);
	return note;
}
Exemplo n.º 24
0
int KGpgApp::newInstance()
{
	if (!running) {
		running = true;

		const QString gpgPath(KGpgSettings::gpgConfigPath());

		const QString gpgError = GPGProc::getGpgStartupError(KGpgSettings::gpgBinaryPath());
		if (!gpgError.isEmpty()) {
			KMessageBox::detailedError(0, i18n("GnuPG failed to start.<br />You must fix the GnuPG error first before running KGpg."), gpgError, i18n("GnuPG error"));
			KApplication::quit();
		}

		s_keyManager = new KeysManager();

		w = new KGpgExternalActions(s_keyManager, s_keyManager->getModel());

		connect(s_keyManager, SIGNAL(readAgainOptions()), w, SLOT(readOptions()));
		connect(w, SIGNAL(updateDefault(QString)), SLOT(assistantOver(QString)));
		connect(w, SIGNAL(createNewKey()), s_keyManager, SLOT(slotGenerateKey()));

		if (!gpgPath.isEmpty()) {
			if ((KgpgInterface::getGpgBoolSetting(QLatin1String( "use-agent" ), gpgPath)) && (qgetenv("GPG_AGENT_INFO").isEmpty()))
				KMessageBox::sorry(0, i18n("<qt>The use of <b>GnuPG Agent</b> is enabled in GnuPG's configuration file (%1).<br />"
					"However, the agent does not seem to be running. This could result in problems with signing/decryption.<br />"
					"Please disable GnuPG Agent from KGpg settings, or fix the agent.</qt>", gpgPath));
		}
	}

	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

	// parsing of command line args
	if (args->isSet("k") || (!KGpgSettings::showSystray() && (args->count() == 0) && !args->isSet("d"))) {
		s_keyManager->show();
		KWindowSystem::setOnDesktop(s_keyManager->winId(), KWindowSystem::currentDesktop());  //set on the current desktop
		KWindowSystem::unminimizeWindow(s_keyManager->winId());  //de-iconify window
		s_keyManager->raise();  // set on top
	} else if (args->isSet("d")) {
		s_keyManager->slotOpenEditor();
		s_keyManager->hide();
	} else {
		KUrl::List urlList;

		for (int ct = 0; ct < args->count(); ct++)
			urlList.append(args->url(ct));

		bool directoryInside = false;
		foreach (const KUrl &url, urlList)
			if (KMimeType::findByUrl(url)->name() == QLatin1String( "inode/directory" )) {
				directoryInside = true;
				break;
			}

		if (args->isSet("e")) {
			if (urlList.isEmpty())
				KMessageBox::sorry(0, i18n("No files given."));
			else if (!directoryInside)
				KGpgExternalActions::encryptFiles(s_keyManager, urlList);
			else
				KGpgExternalActions::encryptFolders(s_keyManager, urlList);
		} else if (args->isSet("s")) {
			if (urlList.isEmpty())
				KMessageBox::sorry(0, i18n("No files given."));
			else if (!directoryInside)
				w->showDroppedFile(urlList.first());
			else
				KMessageBox::sorry(0, i18n("Cannot decrypt and show folder."));
		} else if (args->isSet("S")) {
			if (urlList.isEmpty())
				KMessageBox::sorry(0, i18n("No files given."));
			else if (!directoryInside)
				KGpgExternalActions::signFiles(s_keyManager, urlList);
			else
				KMessageBox::sorry(0, i18n("Cannot sign folder."));
		} else if (args->isSet("V") != 0) {
			if (urlList.isEmpty())
				KMessageBox::sorry(0, i18n("No files given."));
			else if (!directoryInside)
				w->verifyFile(urlList.first());
			else
				KMessageBox::sorry(0, i18n("Cannot verify folder."));
		} else {
			if (directoryInside && (urlList.count() > 1)) {
				KMessageBox::sorry(0, i18n("Unable to perform requested operation.\nPlease select only one folder, or several files, but do not mix files and folders."));
				return 0;
			}

			if (urlList.isEmpty()) {
				/* do nothing */
			} else if (urlList.first().fileName().endsWith(QLatin1String(".sig"))) {
				w->verifyFile(urlList.first());
			} else {
				bool haskeys = false;
				bool hastext = false;
				foreach (const KUrl &url, urlList) {
					QFile qfile(url.path());
					if (qfile.open(QIODevice::ReadOnly)) {
						const int probelen = 4096;
						QTextStream t(&qfile);
						QString probetext(t.read(probelen));
						qfile.close();

						if (KGpgImport::isKey(probetext, probetext.length() == probelen))
							haskeys = true;
						else
							hastext = true;
					}
				}

				if (hastext) {
					KGpgExternalActions::decryptFiles(s_keyManager, urlList);
				} else if (haskeys) {
					s_keyManager->slotImport(urlList);
				}
			}
		}
	}
Exemplo n.º 25
0
void PicasawebWindow::slotListPhotosDoneForUpload(int errCode, const QString &errMsg,
                                                  const QList <PicasaWebPhoto>& photosList)
{
    disconnect(m_talker, SIGNAL(signalListPhotosDone(int,QString,QList<PicasaWebPhoto>)),
               this, SLOT(slotListPhotosDoneForUpload(int,QString,QList<PicasaWebPhoto>)));

    if (errCode != 0)
    {
        KMessageBox::error(this, i18n("Picasaweb Call Failed: %1\n", errMsg));
        return;
    }

    typedef QPair<KUrl,PicasaWebPhoto> Pair;

    m_transferQueue.clear();

    KUrl::List urlList = m_widget->m_imgList->imageUrls(true);

    if (urlList.isEmpty())
        return;

    for (KUrl::List::ConstIterator it = urlList.constBegin(); it != urlList.constEnd(); ++it)
    {
        KPImageInfo info(*it);
        PicasaWebPhoto temp;
        temp.title = info.name();

        // Picasa doesn't support image titles. Include it in descriptions if needed.
        QStringList descriptions = QStringList() << info.title() << info.description();
        descriptions.removeAll("");
        temp.description = descriptions.join("\n\n");

        // check for existing items
        QString localId;
        KPMetadata meta;
        if (meta.load((*it).toLocalFile()))
        {
            localId = meta.getXmpTagString("Xmp.kipi.picasawebGPhotoId");
        }
        QList<PicasaWebPhoto>::const_iterator itPWP;
        for (itPWP = photosList.begin(); itPWP != photosList.end(); ++itPWP)
        {
            if ((*itPWP).id == localId)
            {
                temp.id       = localId;
                temp.editUrl  = (*itPWP).editUrl;
                temp.thumbURL = (*itPWP).thumbURL;
                break;
            }
        }

        //Tags from the database
        temp.gpsLat.setNum(info.latitude());
        temp.gpsLon.setNum(info.longitude());

        temp.tags = info.tagsPath();
        m_transferQueue.append( Pair( (*it), temp) );
    }

    if (m_transferQueue.isEmpty())
        return;

    m_currentAlbumID = m_widget->m_albumsCoB->itemData(
                                 m_widget->m_albumsCoB->currentIndex()).toString();
    m_imagesTotal = m_transferQueue.count();
    m_imagesCount = 0;

    m_widget->progressBar()->setFormat(i18n("%v / %m"));
    m_widget->progressBar()->setMaximum(m_imagesTotal);
    m_widget->progressBar()->setValue(0);
    m_widget->progressBar()->show();
    m_widget->progressBar()->progressScheduled(i18n("Picasa Export"), true, true);
    m_widget->progressBar()->progressThumbnailChanged(KIcon("kipi").pixmap(22, 22));


    m_renamingOpt = 0;

    uploadNextPhoto();
}
Exemplo n.º 26
0
// this is where we start!
bool MrmlPart::openURL( const KURL& url )
{
    closeURL();

    if ( url.protocol() != "mrml" || !url.isValid() ) {
        qWarning("MrmlPart::openURL: cannot handle url: %s", url.prettyURL().latin1());
        return false; // what to do with that?
    }

    m_url = url;
    QString host = url.host().isEmpty() ?
                   QString::fromLatin1("localhost") : url.host();

    m_hostCombo->setCurrentItem( host );

    // urls we need to download before starting the query
    KURL::List downloadList;

    m_queryList.clear();
    QString param = url.queryItem( "relevant" );
    QStringList list = QStringList::split( ';', param );

    // we can only search by example on localhost
    if ( host != "localhost" )
    {
        if ( !list.isEmpty() )
            KMessageBox::sorry( m_view,
                                i18n("You can only search by example images "
                                     "on a local indexing server."),
                                i18n("Only Local Servers Possible") );
    }

    else // localhost query
    {
        for( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
        {
            KURL u;
            if ( (*it).at(0) == '/' )
                u.setPath( *it );
            else
                u = *it;

            if ( u.isValid() )
            {
                if ( u.isLocalFile() )
                    m_queryList.append( u );
                else
                    downloadList.append( u );
            }
        }


        // ### we need a real solution for this!
        // gift refuses to start when no config file is available.
        if ( !QFile::exists( m_config.mrmldDataDir() + "/gift-config.mrml" ) )
        {
            if ( KMessageBox::questionYesNo(0L,
                             i18n("There are no indexable folders "
                                  "specified. Do you want to configure them "
                                  "now?"),
                                            i18n("Configuration Missing"),
                                            i18n("Configure"),
                                            i18n("Do Not Configure"),
                                            "kmrml_ask_configure_gift" )
                 == KMessageBox::Yes )
            {
                KApplication::kdeinitExec( "kcmshell",
                                           QString::fromLatin1("kcmkmrml"));
                setStatus( NeedCollection );
                return false;
            }
        }
    }


    if ( !downloadList.isEmpty() )
        downloadReferenceFiles( downloadList );
    else
        contactServer( m_url );

    return true;
}
Exemplo n.º 27
0
KonqOperations *KonqOperations::doDrop( const KFileItem & destItem, const KUrl & dest, QDropEvent * ev, QWidget * parent,
                                        const QList<QAction*> & userActions  )
{
    kDebug(1203) << "dest:" << dest;
    QMap<QString, QString> metaData;
    // Prefer local urls if possible, to avoid problems with desktop:/ urls from other users (#184403)
    const KUrl::List lst = KUrl::List::fromMimeData(ev->mimeData(), &metaData, KUrl::List::PreferLocalUrls);
    if (!lst.isEmpty()) { // Are they urls ?
        //kDebug(1203) << "metaData:" << metaData.count() << "entries.";
        //QMap<QString,QString>::ConstIterator mit;
        //for( mit = metaData.begin(); mit != metaData.end(); ++mit ) {
        //    kDebug(1203) << "metaData: key=" << mit.key() << "value=" << mit.value();
        //}
        // Check if we dropped something on itself
        KUrl::List::ConstIterator it = lst.begin();
        for (; it != lst.end() ; it++) {
            kDebug(1203) << "URL:" << (*it);
            if (dest.equals(*it, KUrl::CompareWithoutTrailingSlash)) {
                // The event source may be the view or an item (icon)
                // Note: ev->source() can be 0L! (in case of kdesktop) (Simon)
                if ( !ev->source() || ( ev->source() != parent && ev->source()->parent() != parent ) )
                    KMessageBox::sorry( parent, i18n("You cannot drop a folder on to itself") );
                kDebug(1203) << "Dropped on itself";
                ev->setAccepted( false );
                return 0; // do nothing instead of displaying kfm's annoying error box
            }
        }

        // Check the state of the modifiers key at the time of the drop
        Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();

        Qt::DropAction action = ev->dropAction();
        // Check for the drop of a bookmark -> we want a Link action
        if ( ev->mimeData()->hasFormat( QLatin1String("application/x-xbel")) )
        {
            modifiers |= Qt::ControlModifier | Qt::ShiftModifier;
            action = Qt::LinkAction;
            kDebug(1203) << "Bookmark -> emulating Link";
        }

        KonqOperations * op = new KonqOperations(parent);
        op->setDropInfo( new DropInfo( modifiers, lst, metaData, QCursor::pos(), action, userActions ) );

        // Ok, now we need destItem.
        if ( !destItem.isNull() )
        {
            // We have it already, we could just call asyncDrop.
            // But popping up a menu in the middle of a DND operation confuses and crashes Qt (#157630)
            // So let's delay it.
            qRegisterMetaType<KFileItem>("KFileItem");
            QMetaObject::invokeMethod(op, "asyncDrop", Qt::QueuedConnection, Q_ARG(KFileItem, destItem));
        }
        else
        {
            // we need to stat to get it.
            op->_statUrl( dest, op, SLOT(asyncDrop(KFileItem)) );
        }
        // In both cases asyncDrop will delete op when done

        ev->acceptProposedAction();
        return op;
    }
    else
    {
        //kDebug(1203) << "Pasting to " << dest.url();
        KonqOperations * op = new KonqOperations(parent);
        KIO::Job* job = KIO::pasteMimeData(ev->mimeData(), dest,
                                           i18n( "File name for dropped contents:" ),
                                           parent);
        if (KIO::SimpleJob* simpleJob = qobject_cast<KIO::SimpleJob *>(job)) {
            op->setOperation(job, PUT, simpleJob->url());
            KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Put, KUrl::List(), simpleJob->url(), simpleJob);
        }
        ev->acceptProposedAction();
        return op;
    }
}
Exemplo n.º 28
0
void ProjectFileSystemWatcher::slotDirChangedInternal( const QString &dir, KDevelop::ProjectFolderItem* folderItem )
{
    QDir changedDir( dir );

    if( !changedDir.exists() )
    {
        //directory itself deleted
//         int row = folderItem->row();
//         QStandardItem *parent = folderItem->parent();
//         parent->removeRow( row );
//
//         this->removeDirectory( dir );

        QList<KDevelop::ProjectFolderItem*> deletedList;
        QStandardItem *parent = folderItem->parent();
        KDevelop::ProjectFolderItem *parentItem = dynamic_cast<KDevelop::ProjectFolderItem*>( parent );

        deletedList << folderItem;
        emit directoriesDeleted( deletedList, parentItem );

        return;
    }
    else //subdirectory or file is created or deleted.
    {
        // retrieve current disk info
        QFileInfoList fileEntries = changedDir.entryInfoList(QDir::Files);
        QFileInfoList dirEntries = changedDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs);

        // convert disk info into QStringList
        QStringList fileList;
        for ( int i = 0; i < fileEntries.count(); ++i )
        {
            QFileInfo fileInfo = fileEntries.at( i );
            QString absFilePath = fileInfo.absoluteFilePath();
            fileList << absFilePath;
        }
        QStringList dirList;
        for ( int i = 0; i < dirEntries.count(); ++i )
        {
            QFileInfo fileInfo = dirEntries.at( i );
            QString absFilePath = fileInfo.absoluteFilePath();
            dirList << absFilePath;
        }

        // retrieve model item info, and convert into QStringList
        QList<KDevelop::ProjectFileItem*> itemFileList = folderItem->fileList();
        QStringList itemFileListString;
        Q_FOREACH( KDevelop::ProjectFileItem* _item, itemFileList )
        {
            itemFileListString << _item->url().toLocalFile();
        }

        QList<KDevelop::ProjectFolderItem*> itemFolderList = folderItem->folderList();
        QStringList itemFolderListString;
        Q_FOREACH( KDevelop::ProjectFolderItem *_item, itemFolderList )
        {
            itemFolderListString << _item->url().toLocalFile();
        }

        // Compare the difference between disk file and model items

        // round 1 -- file
//         KUrl::List deletedFileUrl;
        QList< KDevelop::ProjectFileItem* > deletedItems;
        Q_FOREACH( KDevelop::ProjectFileItem* _fileItem, itemFileList )
        {
            if( fileList.contains( _fileItem->url().toLocalFile() ) == false )
            {
                // disk file was deleted, so project file items should be also deleted

                // ### note: if some file, previously added to watching list, was deleted,
                // than QFSW::directoryChanged() is not emitted. Rather fileChanged() is emitted.
//                 int row = _fileItem->row();
//                 folderItem->removeRow( row );

                deletedItems << _fileItem;
            }
        }
        if( !deletedItems.isEmpty() )
            emit filesDeleted( deletedItems, folderItem );

        KUrl::List createdFileUrl;
        Q_FOREACH( QString diskFile, fileList )
        {
            if( itemFileListString.contains( diskFile ) == false )
            {
                // disk file was created, file items should be also created
//                 KDevelop::ProjectFileItem *newitem = new KDevelop::ProjectFileItem(
//                         folderItem->project(), KUrl(diskFile), folderItem );
//                 // if Makefile, parse new targets and add to watcher
//                 if( diskFile.endsWith( "/Makefile" ) ) // TODO portable, setting aware
//                 {
//                     QStringList newTargets = parseCustomMakeFile( KUrl(diskFile) );
//                     Q_FOREACH( QString newTarget, newTargets )
//                     {
//                         new CustomMakeTargetItem( folderItem->project(), newTarget, folderItem );
//                     }
//                     cmpi->fsWatcher()->addFile( diskFile, newitem );
//                 }
                createdFileUrl << KUrl(diskFile);
            }
        }
        if( !createdFileUrl.isEmpty() )
            emit filesCreated( createdFileUrl, folderItem );

        // round 2 -- directory
//         KUrl::List deletedDirs;
        QList< KDevelop::ProjectFolderItem* > deletedDirs;
        Q_FOREACH( KDevelop::ProjectFolderItem* _folderItem, itemFolderList )
        {
            if( dirList.contains( _folderItem->url().toLocalFile() ) == false)
            {
//                 int row = _folderItem->row();
//                 QString tobeRemovedDir = _folderItem->url().toLocalFile();
//                 folderItem->removeRow( row );
//
//                 this->removeDirectory( tobeRemovedDir );
                deletedDirs << _folderItem;
            }
        }
        if( !deletedDirs.isEmpty() )
            emit directoriesDeleted( deletedDirs, folderItem );

        KUrl::List createdDirs;
        Q_FOREACH( QString diskDir, dirList )
        {
            if( itemFolderListString.contains( diskDir ) == false )
            {
//                 KDevelop::ProjectBuildFolderItem *newitem =new KDevelop::ProjectBuildFolderItem(
//                         folderItem->project(), KUrl(diskDir), folderItem );
//
//                 this->addDirectory( diskDir, newitem );
//                 this->parseDirectoryRecursively( newitem, d->m_manager );
                createdDirs << KUrl(diskDir);
            }
        }
        if( !createdDirs.isEmpty() )
            emit directoriesCreated( createdDirs, folderItem );
    }
}
Exemplo n.º 29
0
void KonqOperations::doDropFileCopy()
{
    assert(m_info); // setDropInfo - and asyncDrop - should have been called before asyncDrop
    const KUrl::List lst = m_info->urls;
    Qt::DropAction action = m_info->action;
    bool allItemsAreFromTrash = true;
    KUrl::List mlst; // list of items that can be moved
    for (KUrl::List::ConstIterator it = lst.begin(); it != lst.end(); ++it)
    {
        bool local = (*it).isLocalFile();
        if ( KProtocolManager::supportsDeleting( *it ) ) {
            if (!local) {
                mlst.append(*it);
            } else {
                QFileInfo itemInfo((*it).toLocalFile());
                QFileInfo dirInfo(itemInfo.absolutePath());
                // Posix does not permit the movement of a read-only folder, regardless of the permissions of its parent
                if (dirInfo.isWritable() && (!itemInfo.isDir() || itemInfo.isWritable())) {
                    mlst.append(*it);
                }
            }
        }
        if ( local || (*it).protocol() != "trash" )
            allItemsAreFromTrash = false;
    }

    bool linkOnly = false; // if true, we'll show a popup menu, but with only "link" in it (for confirmation)
    if ( allItemsAreFromTrash && lst.first().path() == "/" ) {
        // Dropping a link to the trash: don't move the full contents, just make a link (#319660)
        linkOnly = true;
    }

    if ( !mlst.isEmpty() && m_destUrl.protocol() == "trash" )
    {
        m_method = TRASH;
        if ( askDeleteConfirmation( mlst, TRASH, DEFAULT_CONFIRMATION, parentWidget() ) )
            action = Qt::MoveAction;
        else
        {
            deleteLater();
            return;
        }
    } else if (!linkOnly && (allItemsAreFromTrash || m_destUrl.protocol() == "trash")) {
        // No point in asking copy/move/link when using dnd from or to the trash.
        action = Qt::MoveAction;
    }
    else if ( (
        ((m_info->keyboardModifiers & Qt::ControlModifier) == 0) &&
        ((m_info->keyboardModifiers & Qt::ShiftModifier) == 0) &&
        ((m_info->keyboardModifiers & Qt::AltModifier) == 0) ) || linkOnly )
    {
        // Neither control, shift or alt are pressed => show popup menu

        // TODO move this code out somehow. Allow user of KonqOperations to add his own actions...
#if 0
        KonqIconViewWidget *iconView = dynamic_cast<KonqIconViewWidget*>(parent());
        bool bSetWallpaper = false;
        if ( iconView && iconView->maySetWallpaper() && lst.count() == 1 )
	{
            KUrl url = lst.first();
            KMimeType::Ptr mime = KMimeType::findByUrl( url );
            if ( mime && ( ( KImageIO::isSupported(mime->name(), KImageIO::Reading) ) ||
                 mime->is( "image/svg+xml" ) ) )
            {
                bSetWallpaper = true;
            }
        }
#endif

        // Check what the source can do
        // we'll assume it's the same for all URLs (hack)
        // TODO: if we had a KFileItemList instead of a KUrl::List,
        // we could use KFileItemsCapabilities
        const KUrl url = lst.first();
        bool sReading = KProtocolManager::supportsReading( url );
        bool sDeleting = KProtocolManager::supportsDeleting( url );
        bool sMoving = KProtocolManager::supportsMoving( url );
        // Check what the destination can do
        bool dWriting = KProtocolManager::supportsWriting( m_destUrl );
        if ( !dWriting )
        {
            deleteLater();
            return;
        }

        bool enableLinking = true;			// for now, but see below

        // We don't want to offer "move" for temp files. They might come from
        // kmail using a tempfile for attachments, or ark using a tempdir for
        // extracting an archive -- in all cases, we can't implement a real move,
        // it's just a copy of the tempfile [and the source app will delete it later].
        // https://www.intevation.de/roundup/kolab/issue2026
        //
        // Similarly, linking to a temp file is pointless.
        if (url.isLocalFile() && url.toLocalFile().startsWith(KStandardDirs::locateLocal("tmp", QString()))) {
            sMoving = false;
            sDeleting = false;
            enableLinking = false;
        }

        QMenu popup;
        QString seq = QKeySequence( Qt::ShiftModifier ).toString();
        seq.chop(1); // chop superfluous '+'
        QAction* popupMoveAction = new QAction(i18n( "&Move Here" ) + '\t' + seq, this);
        popupMoveAction->setIcon(KIcon("go-jump"));
        seq = QKeySequence( Qt::ControlModifier ).toString();
        seq.chop(1);
        QAction* popupCopyAction = new QAction(i18n( "&Copy Here" ) + '\t' + seq, this);
        popupCopyAction->setIcon(KIcon("edit-copy"));
        seq = QKeySequence( Qt::ControlModifier + Qt::ShiftModifier ).toString();
        seq.chop(1);
        QAction* popupLinkAction = new QAction(i18n( "&Link Here" ) + '\t' + seq, this);
        popupLinkAction->setIcon(KIcon("edit-link"));
        QAction* popupWallAction = new QAction( i18n( "Set as &Wallpaper" ), this );
        popupWallAction->setIcon(KIcon("preferences-desktop-wallpaper"));
        QAction* popupCancelAction = new QAction(i18n( "C&ancel" ) + '\t' + QKeySequence( Qt::Key_Escape ).toString(), this);
        popupCancelAction->setIcon(KIcon("process-stop"));

        if (!mlst.isEmpty() && (sMoving || (sReading && sDeleting)) && !linkOnly )
        {
            bool equalDestination = true;
            foreach ( const KUrl & src, lst )
            {
                const bool equalProtocol = ( m_destUrl.protocol() == src.protocol() );
                if ( !equalProtocol || m_destUrl.path(KUrl::RemoveTrailingSlash) != src.directory() )
                {
                    equalDestination = false;
                    break;
                }
            }

            if ( !equalDestination )
                popup.addAction(popupMoveAction);
        }
Exemplo n.º 30
0
void PlaylistDock::dragEnterEvent(QDragEnterEvent *e)
{
    KUrl::List uriList = KUrl::List::fromMimeData(e->mimeData());
    e->setAccepted(!uriList.isEmpty());
}