mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: adjust to KUrl changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
cdb188800e
commit
03c195810d
5 changed files with 23 additions and 43 deletions
|
@ -27,15 +27,16 @@
|
||||||
#include "historyimageitem.h"
|
#include "historyimageitem.h"
|
||||||
#include "historyurlitem.h"
|
#include "historyurlitem.h"
|
||||||
|
|
||||||
HistoryItem::HistoryItem(const QByteArray& uuid) : m_uuid(uuid) {
|
HistoryItem::HistoryItem(const QByteArray &uuid)
|
||||||
|
: m_uuid(uuid)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem::~HistoryItem() {
|
HistoryItem::~HistoryItem()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem* HistoryItem::create( const QMimeData* data )
|
HistoryItem* HistoryItem::create(const QMimeData *data)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
int i=0;
|
int i=0;
|
||||||
|
@ -45,11 +46,10 @@ HistoryItem* HistoryItem::create( const QMimeData* data )
|
||||||
#endif
|
#endif
|
||||||
if (KUrl::List::canDecode(data))
|
if (KUrl::List::canDecode(data))
|
||||||
{
|
{
|
||||||
KUrl::MetaDataMap metaData;
|
KUrl::List urls = KUrl::List::fromMimeData(data);
|
||||||
KUrl::List urls = KUrl::List::fromMimeData(data, &metaData);
|
|
||||||
QByteArray bytes = data->data("application/x-kde-cutselection");
|
QByteArray bytes = data->data("application/x-kde-cutselection");
|
||||||
bool cut = !bytes.isEmpty() && (bytes.at(0) == '1'); // true if 1
|
bool cut = !bytes.isEmpty() && (bytes.at(0) == '1'); // true if 1
|
||||||
return new HistoryURLItem(urls, metaData, cut);
|
return new HistoryURLItem(urls, cut);
|
||||||
}
|
}
|
||||||
if (data->hasText())
|
if (data->hasText())
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,8 @@ HistoryItem* HistoryItem::create( const QMimeData* data )
|
||||||
return 0; // Failed.
|
return 0; // Failed.
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem* HistoryItem::create( QDataStream& dataStream ) {
|
HistoryItem* HistoryItem::create(QDataStream &dataStream)
|
||||||
|
{
|
||||||
if ( dataStream.atEnd() ) {
|
if ( dataStream.atEnd() ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -72,12 +73,10 @@ HistoryItem* HistoryItem::create( QDataStream& dataStream ) {
|
||||||
dataStream >> type;
|
dataStream >> type;
|
||||||
if ( type == "url" ) {
|
if ( type == "url" ) {
|
||||||
KUrl::List urls;
|
KUrl::List urls;
|
||||||
QMap< QString, QString > metaData;
|
int cut = 0;
|
||||||
int cut;
|
|
||||||
dataStream >> urls;
|
dataStream >> urls;
|
||||||
dataStream >> metaData;
|
|
||||||
dataStream >> cut;
|
dataStream >> cut;
|
||||||
return new HistoryURLItem( urls, metaData, cut );
|
return new HistoryURLItem( urls, cut );
|
||||||
}
|
}
|
||||||
if ( type == "string" ) {
|
if ( type == "string" ) {
|
||||||
QString text;
|
QString text;
|
||||||
|
|
|
@ -24,24 +24,19 @@
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
QByteArray compute_uuid(const KUrl::List& _urls, KUrl::MetaDataMap _metaData, bool _cut ) {
|
QByteArray compute_uuid(const KUrl::List& _urls, bool _cut ) {
|
||||||
QCryptographicHash hash(KlipperHashAlgorithm);
|
QCryptographicHash hash(KlipperHashAlgorithm);
|
||||||
foreach(const KUrl& url, _urls) {
|
foreach(const KUrl& url, _urls) {
|
||||||
hash.addData(url.toEncoded());
|
hash.addData(url.toEncoded());
|
||||||
hash.addData("\0", 1); // Use binary zero as that is not a valid path character
|
hash.addData("\0", 1); // Use binary zero as that is not a valid path character
|
||||||
}
|
}
|
||||||
QByteArray buffer;
|
|
||||||
QDataStream out(&buffer, QIODevice::WriteOnly);
|
|
||||||
out << _metaData << _cut;
|
|
||||||
hash.addData(buffer);
|
|
||||||
return hash.result();
|
return hash.result();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryURLItem::HistoryURLItem( const KUrl::List& _urls, KUrl::MetaDataMap _metaData, bool _cut )
|
HistoryURLItem::HistoryURLItem( const KUrl::List& _urls, bool _cut )
|
||||||
: HistoryItem(compute_uuid(_urls, _metaData, _cut))
|
: HistoryItem(compute_uuid(_urls, _cut))
|
||||||
, m_urls( _urls )
|
, m_urls( _urls )
|
||||||
, m_metaData( _metaData )
|
|
||||||
, m_cut( _cut )
|
, m_cut( _cut )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -49,7 +44,7 @@ HistoryURLItem::HistoryURLItem( const KUrl::List& _urls, KUrl::MetaDataMap _meta
|
||||||
/* virtual */
|
/* virtual */
|
||||||
void HistoryURLItem::write( QDataStream& stream ) const
|
void HistoryURLItem::write( QDataStream& stream ) const
|
||||||
{
|
{
|
||||||
stream << QString( "url" ) << m_urls << m_metaData << (int)m_cut;
|
stream << QString( "url" ) << m_urls << (int)m_cut;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HistoryURLItem::text() const {
|
QString HistoryURLItem::text() const {
|
||||||
|
@ -58,7 +53,7 @@ QString HistoryURLItem::text() const {
|
||||||
|
|
||||||
QMimeData* HistoryURLItem::mimeData() const {
|
QMimeData* HistoryURLItem::mimeData() const {
|
||||||
QMimeData *data = new QMimeData();
|
QMimeData *data = new QMimeData();
|
||||||
m_urls.populateMimeData(data, m_metaData);
|
m_urls.populateMimeData(data);
|
||||||
data->setData("application/x-kde-cutselection", QByteArray(m_cut ? "1" : "0"));
|
data->setData("application/x-kde-cutselection", QByteArray(m_cut ? "1" : "0"));
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -66,10 +61,7 @@ QMimeData* HistoryURLItem::mimeData() const {
|
||||||
bool HistoryURLItem::operator==( const HistoryItem& rhs) const
|
bool HistoryURLItem::operator==( const HistoryItem& rhs) const
|
||||||
{
|
{
|
||||||
if ( const HistoryURLItem* casted_rhs = dynamic_cast<const HistoryURLItem*>( &rhs ) ) {
|
if ( const HistoryURLItem* casted_rhs = dynamic_cast<const HistoryURLItem*>( &rhs ) ) {
|
||||||
return casted_rhs->m_urls == m_urls
|
return casted_rhs->m_urls == m_urls && casted_rhs->m_cut == m_cut;
|
||||||
&& casted_rhs->m_metaData.count() == m_metaData.count()
|
|
||||||
&& qEqual( casted_rhs->m_metaData.begin(), casted_rhs->m_metaData.end(), m_metaData.begin())
|
|
||||||
&& casted_rhs->m_cut == m_cut;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
class HistoryURLItem : public HistoryItem
|
class HistoryURLItem : public HistoryItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HistoryURLItem( const KUrl::List& urls, KUrl::MetaDataMap metaData, bool cut );
|
HistoryURLItem( const KUrl::List& urls, bool cut );
|
||||||
virtual QString text() const;
|
virtual QString text() const;
|
||||||
virtual bool operator==( const HistoryItem& rhs) const;
|
virtual bool operator==( const HistoryItem& rhs) const;
|
||||||
virtual QMimeData* mimeData() const;
|
virtual QMimeData* mimeData() const;
|
||||||
|
@ -40,7 +40,6 @@ public:
|
||||||
virtual void write( QDataStream& stream ) const;
|
virtual void write( QDataStream& stream ) const;
|
||||||
private:
|
private:
|
||||||
KUrl::List m_urls;
|
KUrl::List m_urls;
|
||||||
KUrl::MetaDataMap m_metaData;
|
|
||||||
bool m_cut;
|
bool m_cut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -285,15 +285,9 @@ KonqOperations *KonqOperations::doDrop( const KFileItem & destItem, const KUrl &
|
||||||
const QList<QAction*> & userActions )
|
const QList<QAction*> & userActions )
|
||||||
{
|
{
|
||||||
kDebug(1203) << "dest:" << dest;
|
kDebug(1203) << "dest:" << dest;
|
||||||
KIO::MetaData metaData;
|
|
||||||
// Prefer local urls if possible, to avoid problems with desktop:/ urls from other users (#184403)
|
// 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);
|
const KUrl::List lst = KUrl::List::fromMimeData(ev->mimeData(), KUrl::List::PreferLocalUrls);
|
||||||
if (!lst.isEmpty()) { // Are they urls ?
|
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
|
// Check if we dropped something on itself
|
||||||
KUrl::List::ConstIterator it = lst.begin();
|
KUrl::List::ConstIterator it = lst.begin();
|
||||||
for (; it != lst.end() ; it++) {
|
for (; it != lst.end() ; it++) {
|
||||||
|
@ -322,7 +316,7 @@ KonqOperations *KonqOperations::doDrop( const KFileItem & destItem, const KUrl &
|
||||||
}
|
}
|
||||||
|
|
||||||
KonqOperations * op = new KonqOperations(parent);
|
KonqOperations * op = new KonqOperations(parent);
|
||||||
op->setDropInfo( new DropInfo( modifiers, lst, metaData, QCursor::pos(), action, userActions ) );
|
op->setDropInfo( new DropInfo( modifiers, lst, QCursor::pos(), action, userActions ) );
|
||||||
|
|
||||||
// Ok, now we need destItem.
|
// Ok, now we need destItem.
|
||||||
if ( !destItem.isNull() )
|
if ( !destItem.isNull() )
|
||||||
|
@ -620,7 +614,6 @@ void KonqOperations::doDropFileCopy()
|
||||||
switch ( action ) {
|
switch ( action ) {
|
||||||
case Qt::MoveAction :
|
case Qt::MoveAction :
|
||||||
job = KIO::move( lst, m_destUrl );
|
job = KIO::move( lst, m_destUrl );
|
||||||
job->setMetaData( m_info->metaData );
|
|
||||||
setOperation( job, m_method == TRASH ? TRASH : MOVE, m_destUrl );
|
setOperation( job, m_method == TRASH ? TRASH : MOVE, m_destUrl );
|
||||||
KIO::FileUndoManager::self()->recordJob(
|
KIO::FileUndoManager::self()->recordJob(
|
||||||
m_method == TRASH ? KIO::FileUndoManager::Trash : KIO::FileUndoManager::Move,
|
m_method == TRASH ? KIO::FileUndoManager::Trash : KIO::FileUndoManager::Move,
|
||||||
|
@ -628,14 +621,12 @@ void KonqOperations::doDropFileCopy()
|
||||||
break;
|
break;
|
||||||
case Qt::CopyAction :
|
case Qt::CopyAction :
|
||||||
job = KIO::copy( lst, m_destUrl );
|
job = KIO::copy( lst, m_destUrl );
|
||||||
job->setMetaData( m_info->metaData );
|
|
||||||
setOperation( job, COPY, m_destUrl );
|
setOperation( job, COPY, m_destUrl );
|
||||||
KIO::FileUndoManager::self()->recordCopyJob(job);
|
KIO::FileUndoManager::self()->recordCopyJob(job);
|
||||||
break;
|
break;
|
||||||
case Qt::LinkAction :
|
case Qt::LinkAction :
|
||||||
kDebug(1203) << "lst.count=" << lst.count();
|
kDebug(1203) << "lst.count=" << lst.count();
|
||||||
job = KIO::link( lst, m_destUrl );
|
job = KIO::link( lst, m_destUrl );
|
||||||
job->setMetaData( m_info->metaData );
|
|
||||||
setOperation( job, LINK, m_destUrl );
|
setOperation( job, LINK, m_destUrl );
|
||||||
KIO::FileUndoManager::self()->recordCopyJob(job);
|
KIO::FileUndoManager::self()->recordCopyJob(job);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -243,13 +243,12 @@ private:
|
||||||
|
|
||||||
struct DropInfo
|
struct DropInfo
|
||||||
{
|
{
|
||||||
DropInfo( Qt::KeyboardModifiers k, const KUrl::List & u, KIO::MetaData &m,
|
DropInfo( Qt::KeyboardModifiers k, const KUrl::List & u,
|
||||||
const QPoint& pos, Qt::DropAction a, const QList<QAction *> &actions) :
|
const QPoint& pos, Qt::DropAction a, const QList<QAction *> &actions) :
|
||||||
keyboardModifiers(k), urls(u), metaData(m), mousePos(pos), action(a), userActions(actions)
|
keyboardModifiers(k), urls(u), mousePos(pos), action(a), userActions(actions)
|
||||||
{}
|
{}
|
||||||
Qt::KeyboardModifiers keyboardModifiers;
|
Qt::KeyboardModifiers keyboardModifiers;
|
||||||
KUrl::List urls;
|
KUrl::List urls;
|
||||||
KIO::MetaData metaData;
|
|
||||||
QPoint mousePos;
|
QPoint mousePos;
|
||||||
Qt::DropAction action;
|
Qt::DropAction action;
|
||||||
QList<QAction*> userActions;
|
QList<QAction*> userActions;
|
||||||
|
|
Loading…
Add table
Reference in a new issue