[Digikam-devel] extragear/graphics/digikam/digikam
Jörn Ahrens
joern.ahrens at kdemail.net
Sun Sep 11 13:45:50 BST 2005
SVN commit 459564 by jahrens:
Some programs aren't able to handle the digikamalbums:/ protocol (like k3b).
Now digikam uses the file:/ protocol in its dragobject, so k3b is able
to get files per drag 'n drop from digikam again. This should work for
almost every program (I've tried k3b and gimp which both works now).
Internally digikam still uses digikamalbums:/ for drag 'n drop, so
the database is still updated when moving objects.
CCMAIL: digikam-devel at kde.org
M +5 -4 albumfolderview.cpp
M +4 -2 albumiconview.cpp
M +34 -6 dragobjects.cpp
M +9 -3 dragobjects.h
M +3 -2 tagfilterview.cpp
M +3 -2 tagfolderview.cpp
--- trunk/extragear/graphics/digikam/digikam/albumfolderview.cpp #459563:459564
@@ -917,13 +917,14 @@
PAlbum *srcAlbum;
KURL::List urls;
+ KURL::List kioURLs;
QValueList<int> albumIDs;
QValueList<int> imageIDs;
- if (!ItemDrag::decode(e, urls, albumIDs, imageIDs))
+ if (!ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
return;
- if (urls.isEmpty() || albumIDs.isEmpty() || imageIDs.isEmpty())
+ if (urls.isEmpty() || kioURLs.isEmpty() || albumIDs.isEmpty() || imageIDs.isEmpty())
return;
// all the albumids will be the same
@@ -1003,14 +1004,14 @@
{
case 10:
{
- KIO::Job* job = DIO::move(urls, destAlbum->kurl());
+ KIO::Job* job = DIO::move(kioURLs, destAlbum->kurl());
connect(job, SIGNAL(result(KIO::Job*)),
SLOT(slotDIOResult(KIO::Job*)));
break;
}
case 11:
{
- KIO::Job* job = DIO::copy(urls, destAlbum->kurl());
+ KIO::Job* job = DIO::copy(kioURLs, destAlbum->kurl());
connect(job, SIGNAL(result(KIO::Job*)),
SLOT(slotDIOResult(KIO::Job*)));
break;
--- trunk/extragear/graphics/digikam/digikam/albumiconview.cpp #459563:459564
@@ -836,6 +836,7 @@
return;
KURL::List urls;
+ KURL::List kioURLs;
QValueList<int> albumIDs;
QValueList<int> imageIDs;
@@ -844,7 +845,8 @@
if (it->isSelected())
{
AlbumIconItem *albumItem = static_cast<AlbumIconItem *>(it);
- urls.append(albumItem->imageInfo()->kurlForKIO());
+ urls.append(albumItem->imageInfo()->kurl());
+ kioURLs.append(albumItem->imageInfo()->kurlForKIO());
imageIDs.append(albumItem->imageInfo()->id());
}
}
@@ -878,7 +880,7 @@
QDragObject* drag = 0;
- drag = new ItemDrag(urls, albumIDs, imageIDs, this);
+ drag = new ItemDrag(urls, kioURLs, albumIDs, imageIDs, this);
if (drag)
{
drag->setPixmap(pix);
--- trunk/extragear/graphics/digikam/digikam/dragobjects.cpp #459563:459564
@@ -26,11 +26,13 @@
#include "dragobjects.h"
-ItemDrag::ItemDrag(const KURL::List &urls,
+ItemDrag::ItemDrag(const KURL::List &urls,
+ const KURL::List &kioURLs,
const QValueList<int>& albumIDs,
const QValueList<int>& imageIDs,
QWidget* dragSource, const char* name)
: KURLDrag(urls, dragSource, name),
+ m_kioURLs(kioURLs),
m_albumIDs(albumIDs), m_imageIDs(imageIDs)
{
}
@@ -39,13 +41,15 @@
{
return e->provides("digikam/item-ids") ||
e->provides("digikam/album-ids") ||
- e->provides("digikam/image-ids");
+ e->provides("digikam/image-ids") ||
+ e->provides("digikam/digikamalbums");
}
-bool ItemDrag::decode(const QMimeSource* e, KURL::List &urls,
+bool ItemDrag::decode(const QMimeSource* e, KURL::List &urls, KURL::List &kioURLs,
QValueList<int>& albumIDs, QValueList<int>& imageIDs)
{
urls.clear();
+ kioURLs.clear();
albumIDs.clear();
imageIDs.clear();
@@ -53,8 +57,9 @@
{
QByteArray albumarray = e->encodedData("digikam/album-ids");
QByteArray imagearray = e->encodedData("digikam/image-ids");
+ QByteArray kioarray = e->encodedData("digikam/digikamalbums");
- if (albumarray.size() && imagearray.size())
+ if (albumarray.size() && imagearray.size() && kioarray.size())
{
int id;
@@ -72,6 +77,14 @@
imageIDs.append(id);
}
+ KURL u;
+ QDataStream dsKio(kioarray, IO_ReadOnly);
+ while (!dsKio.atEnd())
+ {
+ dsKio >> u;
+ kioURLs.append(u);
+ }
+
return true;
}
}
@@ -109,6 +122,19 @@
return byteArray;
}
+ else if (mimetype == "digikam/digikamalbums")
+ {
+ QByteArray byteArray;
+ QDataStream ds(byteArray, IO_WriteOnly);
+
+ KURL::List::const_iterator it;
+ for (it = m_kioURLs.begin(); it != m_kioURLs.end(); ++it)
+ {
+ ds << (*it);
+ }
+
+ return byteArray;
+ }
else
{
return KURLDrag::encodedData(mime);
@@ -120,11 +146,13 @@
if (i == 0)
return "text/uri-list";
else if (i == 1)
- return "digikam/item-ids";
+ return "digikam/item-ids";
else if (i == 2)
return "digikam/album-ids";
else if (i == 3)
- return "digikam/image-ids";
+ return "digikam/image-ids";
+ else if (i == 4)
+ return "digikam/digikamalbums";
else
return 0;
}
--- trunk/extragear/graphics/digikam/digikam/dragobjects.h #459563:459564
@@ -4,7 +4,7 @@
* Date : 2004-06-26
* Description :
*
- * Copyright 2004 by Renchi Raju, Joern Ahrens
+ * Copyright 2004, 2005 by Renchi Raju, Joern Ahrens
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
@@ -38,17 +38,22 @@
* another application which understands KURLDrag, like konqueror, to
* copy the images. Digikam can use the IDs, if ItemDrag is dropped
* on digikam itself.
+ * The kioURLs are internally used with the digikamalbums kioslave.
+ * The "normal" KURLDrag urls are used for external drops (k3b, gimp, ...)
*/
class ItemDrag : public KURLDrag
{
public:
- ItemDrag(const KURL::List& urls, const QValueList<int>& albumIDs,
+ ItemDrag(const KURL::List& urls, const KURL::List& kioURLs,
const QValueList<int>& albumIDs,
+ const QValueList<int>& albumIDs,
QWidget* dragSource=0, const char* name=0);
static bool canDecode(const QMimeSource* e);
- static bool decode(const QMimeSource* e, KURL::List &urls,
+ static bool decode(const QMimeSource* e,
+ KURL::List &urls,
+ KURL::List &kioURLs,
QValueList<int>& albumIDs,
QValueList<int>& imageIDs);
@@ -59,6 +64,7 @@
private:
+ KURL::List m_kioURLs;
QValueList<int> m_albumIDs;
QValueList<int> m_imageIDs;
};
--- trunk/extragear/graphics/digikam/digikam/tagfilterview.cpp #459563:459564
@@ -263,13 +263,14 @@
TAlbum *destAlbum = itemDrop->m_tag;
KURL::List urls;
+ KURL::List kioURLs;
QValueList<int> albumIDs;
QValueList<int> imageIDs;
- if (!ItemDrag::decode(e, urls, albumIDs, imageIDs))
+ if (!ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
return;
- if (urls.isEmpty() || albumIDs.isEmpty() || imageIDs.isEmpty())
+ if (urls.isEmpty() || kioURLs.isEmpty() || albumIDs.isEmpty() || imageIDs.isEmpty())
return;
int id = 0;
--- trunk/extragear/graphics/digikam/digikam/tagfolderview.cpp #459563:459564
@@ -608,13 +608,14 @@
TAlbum *srcAlbum;
KURL::List urls;
+ KURL::List kioURLs;
QValueList<int> albumIDs;
QValueList<int> imageIDs;
- if (!ItemDrag::decode(e, urls, albumIDs, imageIDs))
+ if (!ItemDrag::decode(e, urls, kioURLs, albumIDs, imageIDs))
return;
- if (urls.isEmpty() || albumIDs.isEmpty() || imageIDs.isEmpty())
+ if (urls.isEmpty() || kioURLs.isEmpty() || albumIDs.isEmpty() || imageIDs.isEmpty())
return;
// all the albumids will be the same
More information about the Digikam-devel
mailing list