SVN commit 705140 by cgilles:
digiKam from KDE3 branch : Camera Gui improvements. Implement Drag & Drop between Camera Gui and Album Gui to Download pictures from camera to a physical album. Before, only inverse function has been implemented : Upload pictures to camera when you Drag & Drop items between Album Gui and Camera Gui. CCMAIL: [hidden email] M +42 -0 digikam/albumfolderview.cpp M +34 -2 digikam/albumiconview.cpp M +43 -4 utilities/cameragui/cameraiconview.cpp M +22 -17 utilities/cameragui/cameraui.cpp M +5 -1 utilities/cameragui/cameraui.h --- branches/extragear/kde3/graphics/digikam/digikam/albumfolderview.cpp #705139:705140 @@ -64,6 +64,7 @@ #include "thumbnailsize.h" #include "albumpropsedit.h" #include "folderitem.h" +#include "cameraui.h" #include "dio.h" #include "dragobjects.h" #include "albumthumbnailloader.h" @@ -888,6 +889,11 @@ return true; } + if (CameraItemListDrag::canDecode(e)) + { + return true; + } + return false; } @@ -1080,6 +1086,42 @@ return; } + // -- DnD from Camera GUI ------------------------------------------------ + + if(CameraItemListDrag::canDecode(e)) + { + Album *album = dynamic_cast<Album*>(itemDrop->getAlbum()); + if (!album) return; + + CameraUI *ui = dynamic_cast<CameraUI*>(e->source()); + if (ui) + { + KPopupMenu popMenu(this); + popMenu.insertTitle(SmallIcon("digikam"), i18n("My Albums")); + popMenu.insertItem(SmallIcon("down"), i18n("Download from camera"), 10); + popMenu.insertItem(SmallIcon("down"), i18n("Download && Delete from camera"), 11); + popMenu.insertSeparator(-1); + popMenu.insertItem(SmallIcon("cancel"), i18n("&Cancel")); + popMenu.setMouseTracking(true); + int id = popMenu.exec(QCursor::pos()); + switch(id) + { + case 10: // Download from camera + { + ui->slotDownload(true, false, album); + break; + } + case 11: // Download and Delete from camera + { + ui->slotDownload(true, true, album); + break; + } + default: + break; + } + } + } + // -- DnD from an external source ---------------------------------------- if(QUriDrag::canDecode(e)) --- branches/extragear/kde3/graphics/digikam/digikam/albumiconview.cpp #705139:705140 @@ -115,6 +115,7 @@ #include "ratingpopupmenu.h" #include "pixmapmanager.h" #include "cameradragobject.h" +#include "cameraui.h" #include "dragobjects.h" #include "dmetadata.h" #include "albumdb.h" @@ -1167,7 +1168,8 @@ !QUriDrag::canDecode(event) && !CameraDragObject::canDecode(event) && !TagListDrag::canDecode(event) && - !TagDrag::canDecode(event)) + !TagDrag::canDecode(event) && + !CameraItemListDrag::canDecode(event)) || event->source() == this) { event->ignore(); @@ -1185,7 +1187,8 @@ !QUriDrag::canDecode(event) && !CameraDragObject::canDecode(event) && !TagListDrag::canDecode(event) && - !TagDrag::canDecode(event)) + !TagDrag::canDecode(event) && + !CameraItemListDrag::canDecode(event)) || event->source() == this) { event->ignore(); @@ -1389,6 +1392,35 @@ break; } } + else if(CameraItemListDrag::canDecode(event)) + { + CameraUI *ui = dynamic_cast<CameraUI*>(event->source()); + if (ui) + { + QPopupMenu popMenu(this); + popMenu.insertItem(SmallIcon("down"), i18n("Download from camera"), 10); + popMenu.insertItem(SmallIcon("down"), i18n("Download && Delete from camera"), 11); + popMenu.insertSeparator(-1); + popMenu.insertItem(SmallIcon("cancel"), i18n("&Cancel")); + popMenu.setMouseTracking(true); + int id = popMenu.exec(QCursor::pos()); + switch(id) + { + case 10: // Download from camera + { + ui->slotDownload(true, false, d->currentAlbum); + break; + } + case 11: // Download and Delete from camera + { + ui->slotDownload(true, true, d->currentAlbum); + break; + } + default: + break; + } + } + } else { event->ignore(); --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/cameraiconview.cpp #705139:705140 @@ -22,15 +22,12 @@ * * ============================================================ */ -// C++ includes. - -#include <ctime> - // Qt includes. #include <qfile.h> #include <qfileinfo.h> #include <qtimer.h> +#include <qpainter.h> #include <qpixmap.h> #include <qcursor.h> #include <qfontmetrics.h> @@ -56,6 +53,7 @@ #include "renamecustomizer.h" #include "icongroupitem.h" #include "dpopupmenu.h" +#include "dragobjects.h" #include "cameraui.h" #include "cameradragobject.h" #include "cameraiconitem.h" @@ -518,6 +516,47 @@ void CameraIconView::startDrag() { + QStringList lst; + + for (IconItem* item = firstItem(); item; item = item->nextItem()) + { + if (!item->isSelected()) + continue; + + CameraIconViewItem* iconItem = static_cast<CameraIconViewItem*>(item); + QString itemPath = iconItem->itemInfo()->folder + iconItem->itemInfo()->name; + lst.append(itemPath); + } + + QDragObject * drag = new CameraItemListDrag(lst, d->cameraUI); + if (drag) + { + QPixmap icon(DesktopIcon("image", 48)); + int w = icon.width(); + int h = icon.height(); + + QPixmap pix(w+4,h+4); + QString text(QString::number(lst.count())); + + QPainter p(&pix); + p.fillRect(0, 0, w+4, h+4, QColor(Qt::white)); + p.setPen(QPen(Qt::black, 1)); + p.drawRect(0, 0, w+4, h+4); + p.drawPixmap(2, 2, icon); + QRect r = p.boundingRect(2,2,w,h,Qt::AlignLeft|Qt::AlignTop,text); + r.setWidth(QMAX(r.width(),r.height())); + r.setHeight(QMAX(r.width(),r.height())); + p.fillRect(r, QColor(0,80,0)); + p.setPen(Qt::white); + QFont f(font()); + f.setBold(true); + p.setFont(f); + p.drawText(r, Qt::AlignCenter, text); + p.end(); + + drag->setPixmap(pix); + drag->drag(); + } } void CameraIconView::contentsDropEvent(QDropEvent *event) --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/cameraui.cpp #705139:705140 @@ -1079,20 +1079,9 @@ slotDownload(false, true); } -void CameraUI::slotDownload(bool onlySelected, bool deleteAfter) +void CameraUI::slotDownload(bool onlySelected, bool deleteAfter, Album *album) { - // -- Get the destination album from digiKam library --------------- - - AlbumManager* man = AlbumManager::instance(); - - Album* album = man->currentAlbum(); - if (album && album->type() != Album::PHYSICAL) - album = 0; - - QString header(i18n("<p>Please select the destination album from the digiKam library to " - "import the camera pictures into.</p>")); - - QString newDirName; + QString newDirName; IconItem* firstItem = d->view->firstItem(); if (firstItem) { @@ -1115,16 +1104,32 @@ } } - album = AlbumSelectDialog::selectAlbum(this, (PAlbum*)album, header, newDirName, - d->autoAlbumDateCheck->isChecked()); + // -- Get the destination album from digiKam library if necessary --------------- if (!album) - return; + { + AlbumManager* man = AlbumManager::instance(); + album = man->currentAlbum(); + if (album && album->type() != Album::PHYSICAL) + album = 0; + + QString header(i18n("<p>Please select the destination album from the digiKam library to " + "import the camera pictures into.</p>")); + + album = AlbumSelectDialog::selectAlbum(this, (PAlbum*)album, header, newDirName, + d->autoAlbumDateCheck->isChecked()); + + if (!album) return; + } + + PAlbum *pAlbum = dynamic_cast<PAlbum*>(album); + if (!pAlbum) return; + // -- Prepare downloading of camera items ------------------------ KURL url; - url.setPath(((PAlbum*)album)->folderPath()); + url.setPath(pAlbum->folderPath()); d->controller->downloadPrep(); --- branches/extragear/kde3/graphics/digikam/utilities/cameragui/cameraui.h #705139:705140 @@ -43,6 +43,7 @@ namespace Digikam { +class Album; class CameraIconViewItem; class CameraUIPriv; @@ -71,6 +72,10 @@ void signalLastDestination(const KURL&); void signalAlbumSettingsChanged(); +public slots: + + void slotDownload(bool onlySelected, bool deleteAfter, Album *pAlbum=0); + protected: void closeEvent(QCloseEvent* e); @@ -109,7 +114,6 @@ void slotUploadItems(const KURL::List&); void slotDownloadSelected(); void slotDownloadAll(); - void slotDownload(bool onlySelected, bool deleteAfter); void slotDeleteSelected(); void slotDownloadAndDeleteSelected(); void slotDeleteAll(); _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |