Ejemplo n.º 1
0
void DrawZone::contentsDragEnterEvent(QDragEnterEvent*e) {
  if (!KURLDrag::canDecode(e))
    return;

//   bool accept = false;
  KURL::List uris;
  KURLDrag::decode(e,uris);
  KMimeType::Ptr ptr = KMimeType::findByURL(uris.first());
//  kdDebug() << "***** " << ptr.data()->name() << endl;
  if ((ptr.data()->name() == "text/html")
      || (ptr.data()->name().left(6) == "image/"))
    e->accept();
}
Ejemplo n.º 2
0
//===========================================================
//
QString ImportWizard::driverNameForSelectedSource()
{
	if (fileBasedSrcSelected()) {
		KMimeType::Ptr ptr = KMimeType::findByFileContent( m_srcConn->selectedFileName() );
		if (!ptr || ptr.data()->name()=="application/octet-stream" || ptr.data()->name()=="text/plain") {
			//try by URL:
			ptr = KMimeType::findByURL( m_srcConn->selectedFileName() );
		}
		return ptr ? m_migrateManager.driverForMimeType( ptr.data()->name() ) : QString::null;
	}

	//server-based
	if (m_predefinedConnectionData) {
		return m_predefinedConnectionData->driverName;
	}

	return m_srcConn->selectedConnectionData() 
		? m_srcConn->selectedConnectionData()->driverName : QString::null;
}
Ejemplo n.º 3
0
                KIO::MimetypeJob* typeJob = KIO::mimetype( mediaUrl, KIO::HideProgressInfo );

                connect( typeJob, SIGNAL( mimetype( KIO::Job *, const QString & ) ), 
                        this,  SLOT( sltRemoteFileTypeFound( KIO::Job *, const QString & ) ) );

                addOtherMediaAttributes();

            } else {
                media->setLocalUrl( mediaUrl.toLocalFile() );
                media->setRemoteUrl( mediaUrl.url() );
                media->setUploaded( false );

                KMimeType::Ptr typePtr;
                typePtr = KMimeType::findByUrl( mediaUrl, 0, true, false );
                name = typePtr.data()->name();
                kDebug() << name ;
                media->setMimeType( name );
                Q_EMIT sigMediaTypeFound( media );

                addOtherMediaAttributes();
            }
        } else {
            KMessageBox::error( this, i18n( "The selected media address is an invalid url." ) );
        }
    }
}

void AddMediaDialog::sltRemoteFileTypeFound( KIO::Job *job, const QString &type )
{
    kDebug() << type ;