diff --git a/app/items/digikamimageview.h b/app/items/digikamimageview.h --- a/app/items/digikamimageview.h +++ b/app/items/digikamimageview.h @@ -59,8 +59,6 @@ void rename(); - void assignPickLabel(const QModelIndex& index, int pickId); - void assignColorLabel(const QModelIndex& index, int colorId); void assignRating(const QList& index, int rating); void setFaceMode(bool on); diff --git a/app/items/digikamimageview.cpp b/app/items/digikamimageview.cpp --- a/app/items/digikamimageview.cpp +++ b/app/items/digikamimageview.cpp @@ -398,19 +398,10 @@ awayFromSelection(); } -void DigikamImageView::assignPickLabel(const QModelIndex& index, int pickId) -{ - FileActionMngr::instance()->assignPickLabel(QList() << imageFilterModel()->imageInfo(index), pickId); -} - -void DigikamImageView::assignColorLabel(const QModelIndex& index, int colorId) -{ - FileActionMngr::instance()->assignColorLabel(QList() << imageFilterModel()->imageInfo(index), colorId); -} - void DigikamImageView::assignRating(const QList& indexes, int rating) { - FileActionMngr::instance()->assignRating(imageFilterModel()->imageInfos(indexes), rating); + ImageInfoList infos = imageInfos(indexes, ApplicationSettings::Metadata); + FileActionMngr::instance()->assignRating(infos, rating); } void DigikamImageView::groupIndicatorClicked(const QModelIndex& index) @@ -458,19 +449,19 @@ void DigikamImageView::slotRotateLeft(const QList& indexes) { - FileActionMngr::instance()->transform(QList() << imageFilterModel()->imageInfos(indexes), - MetaEngineRotation::Rotate270); + ImageInfoList infos = imageInfos(indexes, ApplicationSettings::Metadata); + FileActionMngr::instance()->transform(infos, MetaEngineRotation::Rotate270); } void DigikamImageView::slotRotateRight(const QList& indexes) { - FileActionMngr::instance()->transform(QList() << imageFilterModel()->imageInfos(indexes), - MetaEngineRotation::Rotate90); + ImageInfoList infos = imageInfos(indexes, ApplicationSettings::Metadata); + FileActionMngr::instance()->transform(infos, MetaEngineRotation::Rotate90); } void DigikamImageView::slotFullscreen(const QList& indexes) { - QList infos = imageFilterModel()->imageInfos(indexes); + QList infos = imageInfos(indexes); if (infos.isEmpty()) { diff --git a/app/items/imagecategorizedview.h b/app/items/imagecategorizedview.h --- a/app/items/imagecategorizedview.h +++ b/app/items/imagecategorizedview.h @@ -78,13 +78,19 @@ ImageInfo currentInfo() const; QUrl currentUrl() const; + ImageInfo imageInfo(const QModelIndex& index) const; + ImageInfoList imageInfos(const QList& indexes, + bool grouping = false) const; + ImageInfoList imageInfos(const QList& indexes, + ApplicationSettings::OperationType type) const; + ImageInfoList selectedImageInfos(bool grouping = false) const; ImageInfoList selectedImageInfos(ApplicationSettings::OperationType type) const; ImageInfoList selectedImageInfosCurrentFirst(bool grouping = false) const; QList selectedUrls(bool grouping = false) const; QList selectedUrls(ApplicationSettings::OperationType type) const; - QList allImageInfos(bool grouping = false) const; + ImageInfoList allImageInfos(bool grouping = false) const; QList allUrls(bool grouping = false) const; bool needGroupResolving(ApplicationSettings::OperationType type, @@ -215,6 +221,10 @@ // Adds group members when appropriate ImageInfoList resolveGrouping(const QModelIndexList& indexes) const; ImageInfoList resolveGrouping(const ImageInfoList& infos) const; + bool needGroupResolving(ApplicationSettings::OperationType type, + const QList& indexes) const; + bool needGroupResolving(ApplicationSettings::OperationType type, + const ImageInfoList& infos) const; private Q_SLOTS: diff --git a/app/items/imagecategorizedview.cpp b/app/items/imagecategorizedview.cpp --- a/app/items/imagecategorizedview.cpp +++ b/app/items/imagecategorizedview.cpp @@ -289,33 +289,48 @@ ImageInfo ImageCategorizedView::currentInfo() const { - return d->filterModel->imageInfo(currentIndex()); + return imageInfo(currentIndex()); } QUrl ImageCategorizedView::currentUrl() const { return currentInfo().fileUrl(); } -ImageInfoList ImageCategorizedView::selectedImageInfos(bool grouping) const +ImageInfo ImageCategorizedView::imageInfo(const QModelIndex& index) const +{ + return d->filterModel->imageInfo(index); +} + +ImageInfoList ImageCategorizedView::imageInfos(const QList& indexes, + ApplicationSettings::OperationType type) const +{ + return imageInfos(indexes, needGroupResolving(type, indexes)); +} + +ImageInfoList ImageCategorizedView::imageInfos(const QList& indexes, bool grouping) const { if (grouping) { - return resolveGrouping(selectedIndexes()); + return resolveGrouping(indexes); } - return d->filterModel->imageInfos(selectedIndexes()); + return d->filterModel->imageInfos(indexes); +} + +ImageInfoList ImageCategorizedView::selectedImageInfos(bool grouping) const +{ + return imageInfos(selectedIndexes(), grouping); } ImageInfoList ImageCategorizedView::selectedImageInfos( ApplicationSettings::OperationType type) const { return selectedImageInfos(needGroupResolving(type)); } -ImageInfoList ImageCategorizedView::selectedImageInfosCurrentFirst( - bool grouping) const +ImageInfoList ImageCategorizedView::selectedImageInfosCurrentFirst(bool grouping) const { - QModelIndexList indexes = selectedIndexes(); - const QModelIndex current = currentIndex(); + QModelIndexList indexes = selectedIndexes(); + const QModelIndex current = currentIndex(); if (!indexes.isEmpty()) { @@ -331,10 +346,10 @@ if (grouping) { return resolveGrouping(indexes); } - return d->filterModel->imageInfos(indexes); + return imageInfos(indexes); } -QList ImageCategorizedView::allImageInfos(bool grouping) const +ImageInfoList ImageCategorizedView::allImageInfos(bool grouping) const { if (grouping) { return resolveGrouping(d->filterModel->imageInfosSorted()); @@ -357,39 +372,12 @@ bool ImageCategorizedView::needGroupResolving(ApplicationSettings::OperationType type, bool all) const { - ApplicationSettings::ApplyToEntireGroup applyAll = - ApplicationSettings::instance()->getGroupingOperateOnAll(type); - - if (applyAll == ApplicationSettings::No) - { - return false; - } - else if (applyAll == ApplicationSettings::Yes) - { - return true; - } - - ImageInfoList infos; - if (all) { - infos = allImageInfos(); - } - else - { - infos = d->filterModel->imageInfos(selectedIndexes()); + return needGroupResolving(type, allImageInfos()); } - foreach(const ImageInfo& info, infos) - { - if (info.hasGroupedImages() && !imageFilterModel()->isGroupOpen(info.id())) - { - // Ask whether should be performed on all and return info if no - return ApplicationSettings::instance()->askGroupingOperateOnAll(type); - } - } - - return false; + return needGroupResolving(type, selectedIndexes()); } QList ImageCategorizedView::selectedUrls(bool grouping) const @@ -429,22 +417,22 @@ return ImageInfo(); } - return d->filterModel->imageInfo(d->filterModel->index(index.row() + nth, 0, QModelIndex())); + return imageInfo(d->filterModel->index(index.row() + nth, 0, QModelIndex())); } QModelIndex ImageCategorizedView::nextIndexHint(const QModelIndex& anchor, const QItemSelectionRange& removed) const { QModelIndex hint = ItemViewCategorized::nextIndexHint(anchor, removed); - ImageInfo info = d->filterModel->imageInfo(anchor); + ImageInfo info = imageInfo(anchor); //qCDebug(DIGIKAM_GENERAL_LOG) << "Having initial hint" << hint << "for" << anchor << d->model->numberOfIndexesForImageInfo(info); // Fixes a special case of multiple (face) entries for the same image. // If one is removed, any entry of the same image shall be preferred. if (d->model->numberOfIndexesForImageInfo(info) > 1) { // The hint is for a different info, but we may have a hint for the same info - if (info != d->filterModel->imageInfo(hint)) + if (info != imageInfo(hint)) { int minDiff = d->filterModel->rowCount(); QList indexesForImageInfo = d->filterModel->mapListFromSource(d->model->indexesForImageInfo(info)); @@ -715,7 +703,7 @@ void ImageCategorizedView::indexActivated(const QModelIndex& index, Qt::KeyboardModifiers modifiers) { - ImageInfo info = d->filterModel->imageInfo(index); + ImageInfo info = imageInfo(index); if (!info.isNull()) { @@ -728,21 +716,21 @@ { ItemViewCategorized::currentChanged(index, previous); - emit currentChanged(d->filterModel->imageInfo(index)); + emit currentChanged(imageInfo(index)); } void ImageCategorizedView::selectionChanged(const QItemSelection& selectedItems, const QItemSelection& deselectedItems) { ItemViewCategorized::selectionChanged(selectedItems, deselectedItems); if (!selectedItems.isEmpty()) { - emit selected(d->filterModel->imageInfos(selectedItems.indexes())); + emit selected(imageInfos(selectedItems.indexes())); } if (!deselectedItems.isEmpty()) { - emit deselected(d->filterModel->imageInfos(deselectedItems.indexes())); + emit deselected(imageInfos(deselectedItems.indexes())); } } @@ -769,8 +757,7 @@ void ImageCategorizedView::showContextMenuOnIndex(QContextMenuEvent* event, const QModelIndex& index) { - ImageInfo info = d->filterModel->imageInfo(index); - showContextMenuOnInfo(event, info); + showContextMenuOnInfo(event, imageInfo(index)); } void ImageCategorizedView::showContextMenuOnInfo(QContextMenuEvent*, const ImageInfo&) @@ -780,7 +767,7 @@ ImageInfoList ImageCategorizedView::resolveGrouping(const QModelIndexList& indexes) const { - return resolveGrouping(d->filterModel->imageInfos(indexes)); + return resolveGrouping(imageInfos(indexes)); } ImageInfoList ImageCategorizedView::resolveGrouping(const ImageInfoList& infos) const @@ -800,6 +787,39 @@ return outInfos; } +bool ImageCategorizedView::needGroupResolving(ApplicationSettings::OperationType type, + const QList& indexes) const +{ + return needGroupResolving(type, imageInfos(indexes)); +} + +bool ImageCategorizedView::needGroupResolving(ApplicationSettings::OperationType type, + const ImageInfoList& infos) const +{ + ApplicationSettings::ApplyToEntireGroup applyAll = + ApplicationSettings::instance()->getGroupingOperateOnAll(type); + + if (applyAll == ApplicationSettings::No) + { + return false; + } + else if (applyAll == ApplicationSettings::Yes) + { + return true; + } + + foreach(const ImageInfo& info, infos) + { + if (info.hasGroupedImages() && !imageFilterModel()->isGroupOpen(info.id())) + { + // Ask whether should be performed on all and return info if no + return ApplicationSettings::instance()->askGroupingOperateOnAll(type); + } + } + + return false; +} + void ImageCategorizedView::paintEvent(QPaintEvent* e) { // We want the thumbnails to be loaded in order.