Commit 784e195c authored by Marcel Wiesweg's avatar Marcel Wiesweg
Browse files

Implement operation on all selected images for the face overlays.

The pipeline that does the work is now moved to the view, so that
both overlays can connect to it via signals and share it.

CCBUG: 265025
parent 02a8f503
......@@ -72,7 +72,6 @@ public:
TagPropertiesFilterModel filteredModel;
FaceIface faceIface;
FacePipeline editPipeline;
AssignNameWidget* assignNameWidget;
QPersistentModelIndex index;
......@@ -81,10 +80,6 @@ public:
AssignNameOverlay::AssignNameOverlay(QObject* parent)
: AbstractWidgetDelegateOverlay(parent), d(new AssignNameOverlayPriv)
{
d->editPipeline.plugDatabaseEditor();
d->editPipeline.plugTrainer();
d->editPipeline.construct();
d->filteredModel.setSourceAlbumModel(&d->tagModel);
d->filterModel.setSourceFilterModel(&d->filteredModel);
}
......@@ -252,6 +247,7 @@ void AssignNameOverlay::viewportLeaveEvent(QObject*, QEvent*)
void AssignNameOverlay::slotAssigned(const TaggingAction& action, const ImageInfo& info, const QVariant& faceIdentifier)
{
Q_UNUSED(info);
DatabaseFace face = DatabaseFace::fromVariant(faceIdentifier);
//kDebug() << "Confirming" << face << action.shallAssignTag() << action.tagId();
......@@ -273,18 +269,30 @@ void AssignNameOverlay::slotAssigned(const TaggingAction& action, const ImageInf
if (tagId)
{
d->editPipeline.confirm(info, face, tagId);
emit confirmFaces(affectedIndexes(d->index), tagId);
}
//TODO fast-remove if filtered by unconfirmed face etc.
hide();
}
void AssignNameOverlay::slotRejected(const ImageInfo& info, const QVariant& faceIdentifier)
{
DatabaseFace face = DatabaseFace::fromVariant(faceIdentifier);
d->editPipeline.remove(info, face);
Q_UNUSED(info);
Q_UNUSED(faceIdentifier);
//DatabaseFace face = DatabaseFace::fromVariant(faceIdentifier);
emit removeFaces(affectedIndexes(d->index));
hide();
}
void AssignNameOverlay::widgetEnterEvent()
{
widgetEnterNotifyMultiple(d->index);
}
void AssignNameOverlay::widgetLeaveEvent()
{
widgetLeaveNotifyMultiple();
}
} // namespace Digikam
......@@ -56,8 +56,8 @@ public:
Q_SIGNALS:
void faceConfirmed(const DatabaseFace& face);
void faceRejected(const DatabaseFace& face);
void confirmFaces(const QList<QModelIndex>& indexes, int tagId);
void removeFaces(const QList<QModelIndex>& indexes);
protected Q_SLOTS:
......@@ -73,6 +73,8 @@ protected:
virtual void hide();
virtual bool checkIndex(const QModelIndex& index) const;
virtual void viewportLeaveEvent(QObject* obj, QEvent* event);
virtual void widgetEnterEvent();
virtual void widgetLeaveEvent();
void updatePosition();
void updateFace();
......
......@@ -86,7 +86,10 @@ DigikamImageView::DigikamImageView(QWidget* parent)
{
installDefaultModels();
d->faceiface = new FaceIface;
d->editPipeline.plugDatabaseEditor();
d->editPipeline.plugTrainer();
d->editPipeline.construct();
d->normalDelegate = new DigikamImageDelegate(this);
d->faceDelegate = new DigikamImageFaceDelegate(this);
setItemDelegate(d->normalDelegate);
......@@ -161,7 +164,6 @@ DigikamImageView::DigikamImageView(QWidget* parent)
DigikamImageView::~DigikamImageView()
{
delete d->faceiface;
delete d;
}
......@@ -204,14 +206,15 @@ void DigikamImageView::setFaceMode(bool on)
void DigikamImageView::addRejectionOverlay(ImageDelegate* delegate)
{
FaceRejectionOverlay* rejectionOverlay = new FaceRejectionOverlay(this);
connect(rejectionOverlay, SIGNAL(rejectFace(const QModelIndex&)),
this, SLOT(slotUntagFace(const QModelIndex&)));
connect(rejectionOverlay, SIGNAL(rejectFaces(const QList<QModelIndex>&)),
this, SLOT(removeFaces(const QList<QModelIndex>&)));
addOverlay(rejectionOverlay, delegate);
}
void DigikamImageView::addTagEditOverlay(ImageDelegate* delegate)
/*void DigikamImageView::addTagEditOverlay(ImageDelegate* delegate)
{
TagsLineEditOverlay* tagOverlay = new TagsLineEditOverlay(this);
......@@ -219,20 +222,39 @@ void DigikamImageView::addTagEditOverlay(ImageDelegate* delegate)
this, SLOT(assignTag(QModelIndex, QString)));
addOverlay(tagOverlay, delegate);
}
}*/
void DigikamImageView::addAssignNameOverlay(ImageDelegate* delegate)
{
AssignNameOverlay* nameOverlay = new AssignNameOverlay(this);
addOverlay(nameOverlay, delegate);
connect(nameOverlay, SIGNAL(confirmFaces(const QList<QModelIndex>&, int)),
this, SLOT(confirmFaces(const QList<QModelIndex>&, int)));
connect(nameOverlay, SIGNAL(removeFaces(const QList<QModelIndex>&)),
this, SLOT(removeFaces(const QList<QModelIndex>&)));
}
void DigikamImageView::slotUntagFace(const QModelIndex& index)
void DigikamImageView::confirmFaces(const QList<QModelIndex>& indexes, int tagId)
{
ImageInfo info = ImageModel::retrieveImageInfo(index);
DatabaseFace face = d->faceDelegate->face(index);
kDebug()<<"Untagging face in image " << info.filePath() << "and rect " << face.region().toRect();
d->faceiface->removeFace(face);
foreach (const QModelIndex& index, indexes)
{
ImageInfo info = ImageModel::retrieveImageInfo(index);
DatabaseFace face = d->faceDelegate->face(index);
d->editPipeline.confirm(info, face, tagId);
//TODO fast-remove if filtered by unconfirmed face etc.
}
}
void DigikamImageView::removeFaces(const QList<QModelIndex>& indexes)
{
foreach (const QModelIndex& index, indexes)
{
ImageInfo info = ImageModel::retrieveImageInfo(index);
DatabaseFace face = d->faceDelegate->face(index);
d->editPipeline.remove(info, face);
}
}
void DigikamImageView::activated(const ImageInfo& info)
......@@ -590,15 +612,6 @@ void DigikamImageView::assignRating(const QList<QModelIndex>& indexes, int ratin
MetadataManager::instance()->assignRating(imageFilterModel()->imageInfos(indexes), rating);
}
void DigikamImageView::assignTag(const QModelIndex& index, const QString& name)
{
ImageInfo info = ImageModel::retrieveImageInfo(index);
DatabaseFace face = d->faceDelegate->face(index);
int tagId = d->faceiface->tagForPerson(name);
kDebug()<<"Untagging face in image " << info.filePath() << "name" << name << "tag" << tagId << "region" << face.region().toRect();
d->faceiface->confirmName(face, tagId);
}
void DigikamImageView::setAsAlbumThumbnail(const ImageInfo& setAsThumbnail)
{
d->utilities->setAsAlbumThumbnail(currentAlbum(), setAsThumbnail);
......
......@@ -82,16 +82,14 @@ public Q_SLOTS:
void assignPickLabel(const QModelIndex& index, int pickId);
void assignColorLabel(const QModelIndex& index, int colorId);
void assignRating(const QList<QModelIndex>& index, int rating);
void assignTag(const QModelIndex& index, const QString& name);
void createGroupFromSelection();
void ungroupSelected();
void removeSelectedFromGroup();
void setFaceMode(bool on);
void addRejectionOverlay(ImageDelegate* delegate = 0);
void addTagEditOverlay(ImageDelegate* delegate = 0);
void addAssignNameOverlay(ImageDelegate* delegate = 0);
void confirmFaces(const QList<QModelIndex>& indexes, int tagId);
void removeFaces(const QList<QModelIndex>& indexes);
Q_SIGNALS:
......@@ -108,6 +106,9 @@ protected Q_SLOTS:
protected:
void addRejectionOverlay(ImageDelegate* delegate = 0);
void addAssignNameOverlay(ImageDelegate* delegate = 0);
virtual void activated(const ImageInfo& info);
virtual void showContextMenuOnInfo(QContextMenuEvent* event, const ImageInfo& info);
virtual void showContextMenu(QContextMenuEvent* event);
......@@ -117,7 +118,6 @@ private Q_SLOTS:
void slotRotateLeft(const QList<QModelIndex>&);
void slotRotateRight(const QList<QModelIndex>&);
void slotUntagFace(const QModelIndex& index);
private:
......
......@@ -45,7 +45,6 @@ DigikamImageViewPriv::DigikamImageViewPriv(DigikamImageView* qq)
rotateRightOverlay = 0;
normalDelegate = 0;
faceDelegate = 0;
faceiface = 0;
}
DigikamImageViewPriv::~DigikamImageViewPriv()
......
......@@ -34,7 +34,7 @@
#include "digikamimageview.h"
#include "digikamimagedelegate.h"
#include "faceiface.h"
#include "facepipeline.h"
#include "imagerotationoverlay.h"
#include "albumsettings.h"
......@@ -60,7 +60,7 @@ public:
public:
ImageViewUtilities* utilities;
FaceIface* faceiface;
FacePipeline editPipeline;
DigikamImageDelegate* normalDelegate;
DigikamImageFaceDelegate* faceDelegate;
......
......@@ -106,7 +106,7 @@ void FaceRejectionOverlay::slotClicked()
if (index.isValid())
{
emit rejectFace(index);
emit rejectFaces(affectedIndexes(index));
}
}
......@@ -115,4 +115,15 @@ bool FaceRejectionOverlay::checkIndex(const QModelIndex& index) const
return !index.data(ImageModel::ExtraDataRole).isNull();
}
void FaceRejectionOverlay::widgetEnterEvent()
{
widgetEnterNotifyMultiple(button()->index());
}
void FaceRejectionOverlay::widgetLeaveEvent()
{
widgetLeaveNotifyMultiple();
}
} // namespace Digikam
......@@ -67,6 +67,8 @@ protected:
virtual ItemViewHoverButton* createButton();
virtual void updateButton(const QModelIndex& index);
virtual bool checkIndex(const QModelIndex& index) const;
virtual void widgetEnterEvent();
virtual void widgetLeaveEvent();
protected Q_SLOTS:
......@@ -74,7 +76,7 @@ protected Q_SLOTS:
Q_SIGNALS:
void rejectFace(const QModelIndex& index);
void rejectFaces(const QList<QModelIndex>& indexes);
};
} // namespace Digikam
......
......@@ -304,7 +304,7 @@ void AbstractWidgetDelegateOverlay::widgetLeaveNotifyMultiple()
QString AbstractWidgetDelegateOverlay::notifyMultipleMessage(const QModelIndex&, int number)
{
return i18nc("@info", "<i>Applying operation on <br/><b>%1</b> selected pictures</i>", number);
return i18nc("@info", "<i>Applying operation to <br/><b>%1</b> selected pictures</i>", number);
}
bool AbstractWidgetDelegateOverlay::eventFilter(QObject* obj, QEvent* event)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment