diff --git a/core/utilities/import/views/importcategorizedview.cpp b/core/utilities/import/views/importcategorizedview.cpp index 6f33209caa..9ad3b80f6d 100644 --- a/core/utilities/import/views/importcategorizedview.cpp +++ b/core/utilities/import/views/importcategorizedview.cpp @@ -1,631 +1,631 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2012-07-13 * Description : Qt categorized item view for camera items * * Copyright (C) 2012 by Islam Wazery * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "importcategorizedview.h" // Qt includes #include // Local includes #include "digikam_debug.h" #include "camitemsortsettings.h" #include "iccsettings.h" #include "itemselectionoverlay.h" #include "importdelegate.h" #include "importtooltipfiller.h" #include "importsettings.h" #include "itemviewtooltip.h" #include "loadingcacheinterface.h" #include "thumbnailloadthread.h" namespace Digikam { class Q_DECL_HIDDEN ImportItemViewToolTip : public ItemViewToolTip { public: explicit ImportItemViewToolTip(ImportCategorizedView* const view) : ItemViewToolTip(view) { } ImportCategorizedView* view() const { return static_cast(ItemViewToolTip::view()); } protected: virtual QString tipContents() { CamItemInfo info = ImportItemModel::retrieveCamItemInfo(currentIndex()); return ImportToolTipFiller::CamItemInfoTipContents(info); } }; class Q_DECL_HIDDEN ImportCategorizedView::Private { public: explicit Private() : model(nullptr), filterModel(nullptr), delegate(nullptr), showToolTip(false), scrollToItemId(0), delayedEnterTimer(nullptr), currentMouseEvent(nullptr) { } - ImportItemModel* model; + ImportItemModel* model; ImportSortFilterModel* filterModel; ImportDelegate* delegate; bool showToolTip; qlonglong scrollToItemId; QTimer* delayedEnterTimer; QMouseEvent* currentMouseEvent; }; ImportCategorizedView::ImportCategorizedView(QWidget* const parent) : ItemViewCategorized(parent), d(new Private) { setToolTip(new ImportItemViewToolTip(this)); LoadingCacheInterface::connectToSignalFileChanged(this, SLOT(slotFileChanged(QString))); d->delayedEnterTimer = new QTimer(this); d->delayedEnterTimer->setInterval(10); d->delayedEnterTimer->setSingleShot(true); connect(d->delayedEnterTimer, SIGNAL(timeout()), this, SLOT(slotDelayedEnter())); connect(IccSettings::instance(), SIGNAL(settingsChanged(ICCSettingsContainer,ICCSettingsContainer)), this, SLOT(slotIccSettingsChanged(ICCSettingsContainer,ICCSettingsContainer))); } ImportCategorizedView::~ImportCategorizedView() { d->delegate->removeAllOverlays(); delete d; } void ImportCategorizedView::setModels(ImportItemModel* model, ImportSortFilterModel* filterModel) { if (d->delegate) { d->delegate->setAllOverlaysActive(false); } if (d->filterModel) { disconnect(d->filterModel, SIGNAL(layoutAboutToBeChanged()), this, SLOT(layoutAboutToBeChanged())); disconnect(d->filterModel, SIGNAL(layoutChanged()), this, SLOT(layoutWasChanged())); } if (d->model) { disconnect(d->model, SIGNAL(itemInfosAdded(QList)), this, SLOT(slotCamItemInfosAdded())); } d->model = model; d->filterModel = filterModel; setModel(d->filterModel); connect(d->filterModel, SIGNAL(layoutAboutToBeChanged()), this, SLOT(layoutAboutToBeChanged())); connect(d->filterModel, SIGNAL(layoutChanged()), this, SLOT(layoutWasChanged()), Qt::QueuedConnection); connect(d->model, SIGNAL(itemInfosAdded(QList)), this, SLOT(slotCamItemInfosAdded())); emit modelChanged(); if (d->delegate) { d->delegate->setAllOverlaysActive(true); } } ImportItemModel* ImportCategorizedView::importItemModel() const { return d->model; } ImportSortFilterModel* ImportCategorizedView::importSortFilterModel() const { return d->filterModel; } ImportFilterModel* ImportCategorizedView::importFilterModel() const { return d->filterModel->importFilterModel(); } ImportThumbnailModel* ImportCategorizedView::importThumbnailModel() const { return qobject_cast(d->model); } QSortFilterProxyModel* ImportCategorizedView::filterModel() const { return d->filterModel; } ImportDelegate* ImportCategorizedView::delegate() const { return d->delegate; } void ImportCategorizedView::setItemDelegate(ImportDelegate* delegate) { ThumbnailSize oldSize = thumbnailSize(); ImportDelegate* oldDelegate = d->delegate; if (oldDelegate) { hideIndexNotification(); d->delegate->setAllOverlaysActive(false); d->delegate->setViewOnAllOverlays(nullptr); // Note: Be precise, no wildcard disconnect! disconnect(d->delegate, SIGNAL(requestNotification(QModelIndex,QString)), this, SLOT(showIndexNotification(QModelIndex,QString))); disconnect(d->delegate, SIGNAL(hideNotification()), this, SLOT(hideIndexNotification())); } d->delegate = delegate; delegate->setThumbnailSize(oldSize); if (oldDelegate) { d->delegate->setSpacing(oldDelegate->spacing()); } ItemViewCategorized::setItemDelegate(d->delegate); setCategoryDrawer(d->delegate->categoryDrawer()); updateDelegateSizes(); d->delegate->setViewOnAllOverlays(this); d->delegate->setAllOverlaysActive(true); connect(d->delegate, SIGNAL(requestNotification(QModelIndex,QString)), this, SLOT(showIndexNotification(QModelIndex,QString))); connect(d->delegate, SIGNAL(hideNotification()), this, SLOT(hideIndexNotification())); } CamItemInfo ImportCategorizedView::currentInfo() const { return d->filterModel->camItemInfo(currentIndex()); } QUrl ImportCategorizedView::currentUrl() const { return currentInfo().url(); } QList ImportCategorizedView::selectedCamItemInfos() const { return d->filterModel->camItemInfos(selectedIndexes()); } QList ImportCategorizedView::selectedCamItemInfosCurrentFirst() const { QList indexes = selectedIndexes(); QModelIndex current = currentIndex(); - QList infos; + QList infos; - foreach(const QModelIndex& index, indexes) + foreach (const QModelIndex& index, indexes) { CamItemInfo info = d->filterModel->camItemInfo(index); if (index == current) { infos.prepend(info); } else { infos.append(info); } } return infos; } QList ImportCategorizedView::camItemInfos() const { return d->filterModel->camItemInfosSorted(); } QList ImportCategorizedView::urls() const { QList infos = camItemInfos(); - QList urls; + QList urls; - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { urls << info.url(); } return urls; } QList ImportCategorizedView::selectedUrls() const { QList infos = selectedCamItemInfos(); - QList urls; + QList urls; - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { urls << info.url(); } return urls; } void ImportCategorizedView::toIndex(const QUrl& url) { ItemViewCategorized::toIndex(d->filterModel->indexForPath(url.toLocalFile())); } CamItemInfo ImportCategorizedView::nextInOrder(const CamItemInfo& startingPoint, int nth) { QModelIndex index = d->filterModel->indexForCamItemInfo(startingPoint); if (!index.isValid()) { return CamItemInfo(); } return d->filterModel->camItemInfo(d->filterModel->index(index.row() + nth, 0, QModelIndex())); } QModelIndex ImportCategorizedView::nextIndexHint(const QModelIndex& anchor, const QItemSelectionRange& removed) const { QModelIndex hint = ItemViewCategorized::nextIndexHint(anchor, removed); - CamItemInfo info = d->filterModel->camItemInfo(anchor); + CamItemInfo info = d->filterModel->camItemInfo(anchor); //qCDebug(DIGIKAM_IMPORTUI_LOG) << "Having initial hint" << hint << "for" << anchor << d->model->numberOfIndexesForCamItemInfo(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->numberOfIndexesForCamItemInfo(info) > 1) { // The hint is for a different info, but we may have a hint for the same info if (info != d->filterModel->camItemInfo(hint)) { - int minDiff = d->filterModel->rowCount(); + int minDiff = d->filterModel->rowCount(); QList indexesForCamItemInfo = d->filterModel->mapListFromSource(d->model->indexesForCamItemInfo(info)); - foreach(const QModelIndex& index, indexesForCamItemInfo) + foreach (const QModelIndex& index, indexesForCamItemInfo) { if (index == anchor || !index.isValid() || removed.contains(index)) { continue; } int distance = qAbs(index.row() - anchor.row()); if (distance < minDiff) { minDiff = distance; hint = index; //qCDebug(DIGIKAM_IMPORTUI_LOG) << "Chose index" << hint << "at distance" << minDiff << "to" << anchor; } } } } return hint; } ThumbnailSize ImportCategorizedView::thumbnailSize() const { /* ImportThumbnailModel *thumbModel = importThumbnailModel(); if (thumbModel) return thumbModel->thumbnailSize(); */ if (d->delegate) { return d->delegate->thumbnailSize(); } return ThumbnailSize(); } void ImportCategorizedView::setThumbnailSize(int size) { setThumbnailSize(ThumbnailSize(size)); } void ImportCategorizedView::setThumbnailSize(const ThumbnailSize& s) { // we abuse this pair of method calls to restore scroll position // TODO check if needed layoutAboutToBeChanged(); d->delegate->setThumbnailSize(s); layoutWasChanged(); } void ImportCategorizedView::setCurrentWhenAvailable(qlonglong camItemId) { d->scrollToItemId = camItemId; } void ImportCategorizedView::setCurrentUrl(const QUrl& url) { if (url.isEmpty()) { clearSelection(); setCurrentIndex(QModelIndex()); return; } QString path = url.toLocalFile(); QModelIndex index = d->filterModel->indexForPath(path); if (!index.isValid()) { return; } clearSelection(); setCurrentIndex(index); } void ImportCategorizedView::setCurrentInfo(const CamItemInfo& info) { QModelIndex index = d->filterModel->indexForCamItemInfo(info); clearSelection(); setCurrentIndex(index); } void ImportCategorizedView::setSelectedUrls(const QList& urlList) { QItemSelection mySelection; - for (QList::const_iterator it = urlList.constBegin(); it!=urlList.constEnd(); ++it) + for (QList::const_iterator it = urlList.constBegin() ; it!=urlList.constEnd() ; ++it) { - const QString path = it->toLocalFile(); + const QString path = it->toLocalFile(); const QModelIndex index = d->filterModel->indexForPath(path); if (!index.isValid()) { qCWarning(DIGIKAM_IMPORTUI_LOG) << "no QModelIndex found for" << *it; } else { // TODO: is there a better way? mySelection.select(index, index); } } clearSelection(); selectionModel()->select(mySelection, QItemSelectionModel::Select); } void ImportCategorizedView::setSelectedCamItemInfos(const QList& infos) { QItemSelection mySelection; - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { QModelIndex index = d->filterModel->indexForCamItemInfo(info); mySelection.select(index, index); } selectionModel()->select(mySelection, QItemSelectionModel::ClearAndSelect); } void ImportCategorizedView::hintAt(const CamItemInfo& info) { if (info.isNull()) { return; } QModelIndex index = d->filterModel->indexForCamItemInfo(info); if (!index.isValid()) { return; } selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); scrollTo(index); } void ImportCategorizedView::addOverlay(ItemDelegateOverlay* overlay, ImportDelegate* delegate) { if (!delegate) { delegate = d->delegate; } delegate->installOverlay(overlay); if (delegate == d->delegate) { overlay->setView(this); overlay->setActive(true); } } void ImportCategorizedView::removeOverlay(ItemDelegateOverlay* overlay) { ImportDelegate* delegate = dynamic_cast(overlay->delegate()); if (delegate) { delegate->removeOverlay(overlay); } overlay->setView(nullptr); } void ImportCategorizedView::updateGeometries() { ItemViewCategorized::updateGeometries(); d->delayedEnterTimer->start(); } void ImportCategorizedView::slotDelayedEnter() { // re-emit entered() for index under mouse (after layout). QModelIndex mouseIndex = indexAt(mapFromGlobal(QCursor::pos())); if (mouseIndex.isValid()) { emit DCategorizedView::entered(mouseIndex); } } void ImportCategorizedView::addSelectionOverlay(ImportDelegate* delegate) { addOverlay(new ItemSelectionOverlay(this), delegate); } void ImportCategorizedView::scrollToStoredItem() { if (d->scrollToItemId) { if (d->model->hasImage(d->scrollToItemId)) { QModelIndex index = d->filterModel->indexForCamItemId(d->scrollToItemId); setCurrentIndex(index); scrollToRelaxed(index, QAbstractItemView::PositionAtCenter); d->scrollToItemId = 0; } } } void ImportCategorizedView::slotCamItemInfosAdded() { if (d->scrollToItemId) { scrollToStoredItem(); } } void ImportCategorizedView::slotFileChanged(const QString& filePath) { QModelIndex index = d->filterModel->indexForPath(filePath); if (index.isValid()) { update(index); } } void ImportCategorizedView::indexActivated(const QModelIndex& index, Qt::KeyboardModifiers modifiers) { CamItemInfo info = d->filterModel->camItemInfo(index); if (!info.isNull()) { activated(info, modifiers); emit camItemInfoActivated(info); } } void ImportCategorizedView::currentChanged(const QModelIndex& index, const QModelIndex& previous) { ItemViewCategorized::currentChanged(index, previous); emit currentChanged(d->filterModel->camItemInfo(index)); } void ImportCategorizedView::selectionChanged(const QItemSelection& selectedItems, const QItemSelection& deselectedItems) { ItemViewCategorized::selectionChanged(selectedItems, deselectedItems); if (!selectedItems.isEmpty()) { emit selected(d->filterModel->camItemInfos(selectedItems.indexes())); } if (!deselectedItems.isEmpty()) { emit deselected(d->filterModel->camItemInfos(deselectedItems.indexes())); } } void ImportCategorizedView::activated(const CamItemInfo&, Qt::KeyboardModifiers) { // implemented in subclass } void ImportCategorizedView::showContextMenuOnIndex(QContextMenuEvent* event, const QModelIndex& index) { CamItemInfo info = d->filterModel->camItemInfo(index); showContextMenuOnInfo(event, info); } void ImportCategorizedView::showContextMenuOnInfo(QContextMenuEvent*, const CamItemInfo&) { // implemented in subclass } void ImportCategorizedView::paintEvent(QPaintEvent* e) { ItemViewCategorized::paintEvent(e); } QItemSelectionModel* ImportCategorizedView::getSelectionModel() const { return selectionModel(); } AbstractItemDragDropHandler* ImportCategorizedView::dragDropHandler() const { return d->model->dragDropHandler(); } void ImportCategorizedView::slotIccSettingsChanged(const ICCSettingsContainer&, const ICCSettingsContainer&) { viewport()->update(); } } // namespace Digikam diff --git a/core/utilities/import/views/importiconview.cpp b/core/utilities/import/views/importiconview.cpp index 6fb1addf1a..a89ad20b73 100644 --- a/core/utilities/import/views/importiconview.cpp +++ b/core/utilities/import/views/importiconview.cpp @@ -1,484 +1,484 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2012-22-07 * Description : Icon view for import tool items * * Copyright (C) 2012 by Islam Wazery * Copyright (C) 2012-2019 by Gilles Caulier * * This program is free software you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "importiconview.h" #include "importiconview_p.h" // Qt includes #include #include #include // Local includes #include "importcategorizedview.h" #include "importoverlays.h" #include "importsettings.h" #include "camitemsortsettings.h" #include "fileactionmngr.h" #include "importdelegate.h" #include "advancedrenamedialog.h" #include "advancedrenameprocessdialog.h" #include "itemviewutilities.h" #include "importcontextmenu.h" #include "importdragdrop.h" namespace Digikam { ImportIconView::ImportIconView(QWidget* const parent) : ImportCategorizedView(parent), d(new Private(this)) { ImportThumbnailModel* const model = new ImportThumbnailModel(this); ImportFilterModel* const filterModel = new ImportFilterModel(this); filterModel->setSourceImportModel(model); filterModel->sort(0); // an initial sorting is necessary setModels(model, filterModel); d->normalDelegate = new ImportNormalDelegate(this); setItemDelegate(d->normalDelegate); setSpacing(10); ImportSettings* const settings = ImportSettings::instance(); setThumbnailSize(ThumbnailSize(settings->getDefaultIconSize())); importItemModel()->setDragDropHandler(new ImportDragDropHandler(importItemModel())); setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(false); setToolTipEnabled(settings->showToolTipsIsValid()); // selection overlay addSelectionOverlay(d->normalDelegate); //TODO: addSelectionOverlay(d->faceDelegate); // rotation overlays d->rotateLeftOverlay = ImportRotateOverlay::left(this); d->rotateRightOverlay = ImportRotateOverlay::right(this); addOverlay(new ImportDownloadOverlay(this)); addOverlay(new ImportLockOverlay(this)); addOverlay(new ImportCoordinatesOverlay(this)); d->updateOverlays(); // rating overlay ImportRatingOverlay* const ratingOverlay = new ImportRatingOverlay(this); addOverlay(ratingOverlay); //TODO: GroupIndicatorOverlay* groupOverlay = new GroupIndicatorOverlay(this); //TODO: addOverlay(groupOverlay); connect(ratingOverlay, SIGNAL(ratingEdited(QList,int)), this, SLOT(assignRating(QList,int))); //TODO: connect(groupOverlay, SIGNAL(toggleGroupOpen(QModelIndex)), //this, SLOT(groupIndicatorClicked(QModelIndex))); //TODO: connect(groupOverlay, SIGNAL(showButtonContextMenu(QModelIndex,QContextMenuEvent*)), //this, SLOT(showGroupContextMenu(QModelIndex,QContextMenuEvent*))); //TODO: connect(importItemModel()->dragDropHandler(), SIGNAL(assignTags(QList,QList)), //FileActionMngr::instance(), SLOT(assignTags(QList,QList))); //TODO: connect(importItemModel()->dragDropHandler(), SIGNAL(addToGroup(CamItemInfo,QList)), //FileActionMngr::instance(), SLOT(addToGroup(CamItemInfo,QList))); connect(settings, SIGNAL(setupChanged()), this, SLOT(slotSetupChanged())); slotSetupChanged(); } ImportIconView::~ImportIconView() { delete d; } ItemViewUtilities* ImportIconView::utilities() const { return d->utilities; } void ImportIconView::setThumbnailSize(const ThumbnailSize& size) { ImportCategorizedView::setThumbnailSize(size); } int ImportIconView::fitToWidthIcons() { return delegate()->calculatethumbSizeToFit(viewport()->size().width()); } CamItemInfo ImportIconView::camItemInfo(const QString& folder, const QString& file) { QUrl url = QUrl::fromLocalFile(folder); url = url.adjusted(QUrl::StripTrailingSlash); url.setPath(url.path() + QLatin1Char('/') + file); QModelIndex indexForCamItemInfo = importFilterModel()->indexForPath(url.toLocalFile()); if (indexForCamItemInfo.isValid()) { return importFilterModel()->camItemInfo(indexForCamItemInfo); } return CamItemInfo(); } CamItemInfo& ImportIconView::camItemInfoRef(const QString& folder, const QString& file) { QUrl url = QUrl::fromLocalFile(folder); url = url.adjusted(QUrl::StripTrailingSlash); url.setPath(url.path() + QLatin1Char('/') + file); QModelIndex indexForCamItemInfo = importFilterModel()->indexForPath(url.toLocalFile()); QModelIndex mappedIndex = importFilterModel()->mapToSource(indexForCamItemInfo); return importItemModel()->camItemInfoRef(mappedIndex); } void ImportIconView::slotSetupChanged() { setToolTipEnabled(ImportSettings::instance()->showToolTipsIsValid()); setFont(ImportSettings::instance()->getIconViewFont()); d->updateOverlays(); ImportCategorizedView::slotSetupChanged(); } void ImportIconView::rename() { QList urls = selectedUrls(); NewNamesList newNamesList; QPointer dlg = new AdvancedRenameDialog(this); dlg->slotAddImages(urls); if (dlg->exec() == QDialog::Accepted) { newNamesList = dlg->newNames(); } delete dlg; if (!newNamesList.isEmpty()) { QPointer dlg = new AdvancedRenameProcessDialog(newNamesList); dlg->exec(); delete dlg; } } void ImportIconView::deleteSelected(bool /*permanently*/) { CamItemInfoList camItemInfoList = selectedCamItemInfos(); //FIXME: This way of deletion may not working with camera items. /* if (d->utilities->deleteImages(camItemInfoList, permanently)) { awayFromSelection(); } */ } void ImportIconView::deleteSelectedDirectly(bool /*permanently*/) { CamItemInfoList camItemInfoList = selectedCamItemInfos(); //FIXME: This way of deletion may not working with camera items. //d->utilities->deleteImagesDirectly(camItemInfoList, permanently); awayFromSelection(); } void ImportIconView::createGroupFromSelection() { //TODO: Implement grouping in import tool. /* QList selectedInfos = selectedCamItemInfosCurrentFirst(); CamItemInfo groupLeader = selectedInfos.takeFirst(); FileActionMngr::instance()->addToGroup(groupLeader, selectedInfos); */ } void ImportIconView::createGroupByTimeFromSelection() { //TODO: Implement grouping in import tool. /* QList selectedInfos = selectedCamItemInfosCurrentFirst(); while (selectedInfos.size() > 0) { QList group; CamItemInfo groupLeader = selectedInfos.takeFirst(); QDateTime dateTime = groupLeader.dateTime(); while (selectedInfos.size() > 0 && abs(dateTime.secsTo(selectedInfos.first().dateTime())) < 2) { group.push_back(selectedInfos.takeFirst()); } FileActionMngr::instance()->addToGroup(groupLeader, group); } */ } void ImportIconView::ungroupSelected() { //TODO: Implement grouping in import tool. //FileActionMngr::instance()->ungroup(selectedCamItemInfos()); } void ImportIconView::removeSelectedFromGroup() { //TODO: Implement grouping in import tool. //FileActionMngr::instance()->removeFromGroup(selectedCamItemInfos()); } void ImportIconView::slotRotateLeft(const QList& /*indexes*/) { /* QList imageInfos; foreach(const QModelIndex& index, indexes) { ItemInfo imageInfo(importFilterModel()->camItemInfo(index).url()); imageInfos << imageInfo; } FileActionMngr::instance()->transform(imageInfos, MetaEngineRotation::Rotate270); */ } void ImportIconView::slotRotateRight(const QList& /*indexes*/) { /* QList imageInfos; foreach(const QModelIndex& index, indexes) { ItemInfo imageInfo(importFilterModel()->camItemInfo(index).url()); imageInfos << imageInfo; } FileActionMngr::instance()->transform(imageInfos, MetaEngineRotation::Rotate90); */ } void ImportIconView::activated(const CamItemInfo& info, Qt::KeyboardModifiers) { if (info.isNull()) { return; } if (ImportSettings::instance()->getItemLeftClickAction() == ImportSettings::ShowPreview) { emit previewRequested(info, false); } else { //TODO: openFile(info); } } void ImportIconView::showContextMenuOnInfo(QContextMenuEvent* event, const CamItemInfo& /*info*/) { QList selectedInfos = selectedCamItemInfosCurrentFirst(); QList selectedItemIDs; - foreach(const CamItemInfo& info, selectedInfos) + foreach (const CamItemInfo& info, selectedInfos) { selectedItemIDs << info.id; } // -------------------------------------------------------- QMenu popmenu(this); ImportContextMenuHelper cmhelper(&popmenu); cmhelper.addAction(QLatin1String("importui_fullscreen")); cmhelper.addAction(QLatin1String("options_show_menubar")); cmhelper.addAction(QLatin1String("import_zoomfit2window")); cmhelper.addSeparator(); // -------------------------------------------------------- cmhelper.addAction(QLatin1String("importui_imagedownload")); cmhelper.addAction(QLatin1String("importui_imagemarkasdownloaded")); cmhelper.addAction(QLatin1String("importui_imagelock")); cmhelper.addAction(QLatin1String("importui_delete")); cmhelper.addSeparator(); cmhelper.addAction(QLatin1String("importui_item_view")); cmhelper.addServicesMenu(selectedUrls()); //TODO: cmhelper.addRotateMenu(selectedItemIDs); cmhelper.addSeparator(); // -------------------------------------------------------- cmhelper.addAction(QLatin1String("importui_selectall")); cmhelper.addAction(QLatin1String("importui_selectnone")); cmhelper.addAction(QLatin1String("importui_selectinvert")); cmhelper.addSeparator(); // -------------------------------------------------------- //cmhelper.addAssignTagsMenu(selectedItemIDs); //cmhelper.addRemoveTagsMenu(selectedItemIDs); //cmhelper.addSeparator(); // -------------------------------------------------------- cmhelper.addLabelsAction(); //if (!d->faceMode) //{ // cmhelper.addGroupMenu(selectedItemIDs); //} // special action handling -------------------------------- //connect(&cmhelper, SIGNAL(signalAssignTag(int)), // this, SLOT(assignTagToSelected(int))); //TODO: Implement tag view for import tool. //connect(&cmhelper, SIGNAL(signalPopupTagsView()), // this, SIGNAL(signalPopupTagsView())); //connect(&cmhelper, SIGNAL(signalRemoveTag(int)), // this, SLOT(removeTagFromSelected(int))); //connect(&cmhelper, SIGNAL(signalGotoTag(int)), //this, SIGNAL(gotoTagAndImageRequested(int))); connect(&cmhelper, SIGNAL(signalAssignPickLabel(int)), this, SLOT(assignPickLabelToSelected(int))); connect(&cmhelper, SIGNAL(signalAssignColorLabel(int)), this, SLOT(assignColorLabelToSelected(int))); connect(&cmhelper, SIGNAL(signalAssignRating(int)), this, SLOT(assignRatingToSelected(int))); //connect(&cmhelper, SIGNAL(signalAddToExistingQueue(int)), //this, SLOT(insertSelectedToExistingQueue(int))); //FIXME: connect(&cmhelper, SIGNAL(signalCreateGroup()), //this, SLOT(createGroupFromSelection())); //connect(&cmhelper, SIGNAL(signalUngroup()), //this, SLOT(ungroupSelected())); //connect(&cmhelper, SIGNAL(signalRemoveFromGroup()), //this, SLOT(removeSelectedFromGroup())); // -------------------------------------------------------- cmhelper.exec(event->globalPos()); } void ImportIconView::showContextMenu(QContextMenuEvent* event) { QMenu popmenu(this); ImportContextMenuHelper cmhelper(&popmenu); cmhelper.addAction(QLatin1String("importui_fullscreen")); cmhelper.addAction(QLatin1String("options_show_menubar")); cmhelper.addSeparator(); cmhelper.addAction(QLatin1String("importui_close")); // -------------------------------------------------------- cmhelper.exec(event->globalPos()); } void ImportIconView::assignTagToSelected(int tagID) { CamItemInfoList infos = selectedCamItemInfos(); - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { importItemModel()->camItemInfoRef(importItemModel()->indexForCamItemInfo(info)).tagIds.append(tagID); } } void ImportIconView::removeTagFromSelected(int tagID) { CamItemInfoList infos = selectedCamItemInfos(); - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { importItemModel()->camItemInfoRef(importItemModel()->indexForCamItemInfo(info)).tagIds.removeAll(tagID); } } void ImportIconView::assignPickLabel(const QModelIndex& index, int pickId) { importItemModel()->camItemInfoRef(index).pickLabel = pickId; } void ImportIconView::assignPickLabelToSelected(int pickId) { CamItemInfoList infos = selectedCamItemInfos(); - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { importItemModel()->camItemInfoRef(importItemModel()->indexForCamItemInfo(info)).pickLabel = pickId; } } void ImportIconView::assignColorLabel(const QModelIndex& index, int colorId) { importItemModel()->camItemInfoRef(index).colorLabel = colorId; } void ImportIconView::assignColorLabelToSelected(int colorId) { CamItemInfoList infos = selectedCamItemInfos(); - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { importItemModel()->camItemInfoRef(importItemModel()->indexForCamItemInfo(info)).colorLabel = colorId; } } void ImportIconView::assignRating(const QList& indexes, int rating) { - foreach(const QModelIndex& index, indexes) + foreach (const QModelIndex& index, indexes) { if (index.isValid()) { importItemModel()->camItemInfoRef(index).rating = rating; } } } void ImportIconView::assignRatingToSelected(int rating) { CamItemInfoList infos = selectedCamItemInfos(); - foreach(const CamItemInfo& info, infos) + foreach (const CamItemInfo& info, infos) { importItemModel()->camItemInfoRef(importItemModel()->indexForCamItemInfo(info)).rating = rating; } } } // namespace Digikam diff --git a/core/utilities/import/views/importstackedview.cpp b/core/utilities/import/views/importstackedview.cpp index 357562283c..c25b13ce02 100644 --- a/core/utilities/import/views/importstackedview.cpp +++ b/core/utilities/import/views/importstackedview.cpp @@ -1,518 +1,518 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2012-05-07 * Description : QStackedWidget to handle different types of views * (icon view, image preview, media view) * * Copyright (C) 2012 by Islam Wazery * Copyright (C) 2012-2019 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "importstackedview.h" // Qt includes #include // Local includes #include "digikam_debug.h" #include "previewlayout.h" #include "importsettings.h" namespace Digikam { class MediaPlayerView; class Q_DECL_HIDDEN ImportStackedView::Private { public: explicit Private() { dockArea = nullptr; splitter = nullptr; thumbBar = nullptr; thumbBarDock = nullptr; importIconView = nullptr; importPreviewView = nullptr; #ifdef HAVE_MARBLE mapWidgetView = nullptr; #endif // HAVE_MARBLE #ifdef HAVE_MEDIAPLAYER mediaPlayerView = nullptr; #endif // HAVE_MEDIAPLAYER syncingSelection = false; } QMainWindow* dockArea; QSplitter* splitter; ImportThumbnailBar* thumbBar; ThumbBarDock* thumbBarDock; ImportIconView* importIconView; ImportPreviewView* importPreviewView; #ifdef HAVE_MARBLE MapWidgetView* mapWidgetView; #endif // HAVE_MARBLE #ifdef HAVE_MEDIAPLAYER MediaPlayerView* mediaPlayerView; // Reuse of albumgui mediaplayer view. #endif // HAVE_MEDIAPLAYER bool syncingSelection; }; ImportStackedView::ImportStackedView(QWidget* const parent) : QStackedWidget(parent), d(new Private) { d->importIconView = new ImportIconView(this); d->importPreviewView = new ImportPreviewView(this); d->thumbBarDock = new ThumbBarDock(); d->thumbBar = new ImportThumbnailBar(d->thumbBarDock); d->thumbBar->setModelsFiltered(d->importIconView->importItemModel(), d->importIconView->importFilterModel()); d->thumbBar->installOverlays(); d->thumbBarDock->setWidget(d->thumbBar); d->thumbBarDock->setObjectName(QLatin1String("import_thumbbar")); d->thumbBarDock->setWindowTitle(i18n("Import Thumbnail Dock")); #ifdef HAVE_MARBLE // TODO refactor MapWidgetView not to require the models on startup? d->mapWidgetView = new MapWidgetView(d->importIconView->getSelectionModel(), d->importIconView->importFilterModel(), this, MapWidgetView::ApplicationImportUI); d->mapWidgetView->setObjectName(QLatin1String("import_mapwidgetview")); #endif // HAVE_MARBLE #ifdef HAVE_MEDIAPLAYER d->mediaPlayerView = new MediaPlayerView(this); #endif //HAVE_MEDIAPLAYER insertWidget(PreviewCameraMode, d->importIconView); insertWidget(PreviewImageMode, d->importPreviewView); #ifdef HAVE_MARBLE insertWidget(MapWidgetMode, d->mapWidgetView); #endif // HAVE_MARBLE #ifdef HAVE_MEDIAPLAYER insertWidget(MediaPlayerMode, d->mediaPlayerView); #endif //HAVE_MEDIAPLAYER setAttribute(Qt::WA_DeleteOnClose); readSettings(); // ----------------------------------------------------------------- //FIXME: connect(d->importPreviewView, SIGNAL(signalPopupTagsView()), //d->importIconView, SIGNAL(signalPopupTagsView())); //connect(d->importPreviewView, SIGNAL(signalGotoFolderAndItem(CamItemInfo)), //this, SIGNAL(signalGotoFolderAndItem(CamItemInfo))); //connect(d->importPreviewView, SIGNAL(signalGotoDateAndItem(CamItemInfo)), //this, SIGNAL(signalGotoDateAndItem(CamItemInfo))); //FIXME: connect(d->importPreviewView, SIGNAL(signalGotoTagAndItem(int)), //this, SIGNAL(signalGotoTagAndItem(int))); connect(d->importPreviewView, SIGNAL(signalNextItem()), this, SIGNAL(signalNextItem())); connect(d->importPreviewView, SIGNAL(signalPrevItem()), this, SIGNAL(signalPrevItem())); //FIXME: connect(d->importPreviewView, SIGNAL(signalDeleteItem()), //this, SIGNAL(signalDeleteItem())); connect(d->importPreviewView, SIGNAL(signalEscapePreview()), this, SIGNAL(signalEscapePreview())); // A workaround to assign pickLabel, colorLabel, and rating in the preview view. connect(d->importPreviewView, SIGNAL(signalAssignPickLabel(int)), d->importIconView, SLOT(assignPickLabelToSelected(int))); connect(d->importPreviewView, SIGNAL(signalAssignColorLabel(int)), d->importIconView, SLOT(assignColorLabelToSelected(int))); connect(d->importPreviewView, SIGNAL(signalAssignRating(int)), d->importIconView, SLOT(assignRatingToSelected(int))); connect(d->importPreviewView->layout(), SIGNAL(zoomFactorChanged(double)), this, SLOT(slotZoomFactorChanged(double))); //FIXME: connect(d->importPreviewView, SIGNAL(signalAddToExistingQueue(int)), //this, SIGNAL(signalAddToExistingQueue(int))); connect(d->thumbBar, SIGNAL(selectionChanged()), this, SLOT(slotThumbBarSelectionChanged())); connect(d->importIconView, SIGNAL(selectionChanged()), this, SLOT(slotIconViewSelectionChanged())); connect(d->thumbBarDock, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), d->thumbBar, SLOT(slotDockLocationChanged(Qt::DockWidgetArea))); connect(d->importPreviewView, SIGNAL(signalPreviewLoaded(bool)), this, SLOT(slotPreviewLoaded(bool))); #ifdef HAVE_MEDIAPLAYER connect(d->mediaPlayerView, SIGNAL(signalNextItem()), this, SIGNAL(signalNextItem())); connect(d->mediaPlayerView, SIGNAL(signalPrevItem()), this, SIGNAL(signalPrevItem())); connect(d->mediaPlayerView, SIGNAL(signalEscapePreview()), this, SIGNAL(signalEscapePreview())); #endif //HAVE_MEDIAPLAYER } ImportStackedView::~ImportStackedView() { delete d; } void ImportStackedView::readSettings() { ImportSettings* const settings = ImportSettings::instance(); bool showThumbbar = settings->getShowThumbbar(); d->thumbBarDock->setShouldBeVisible(showThumbbar); } void ImportStackedView::setDockArea(QMainWindow* dockArea) { // Attach the thumbbar dock to the given dock area and place it initially on top. d->dockArea = dockArea; d->thumbBarDock->setParent(d->dockArea); d->dockArea->addDockWidget(Qt::TopDockWidgetArea, d->thumbBarDock); d->thumbBarDock->setFloating(false); } ThumbBarDock* ImportStackedView::thumbBarDock() const { return d->thumbBarDock; } ImportThumbnailBar* ImportStackedView::thumbBar() const { return d->thumbBar; } void ImportStackedView::slotEscapePreview() { #ifdef HAVE_MEDIAPLAYER if (viewMode() == MediaPlayerMode) { d->mediaPlayerView->escapePreview(); } #endif //HAVE_MEDIAPLAYER } ImportIconView* ImportStackedView::importIconView() const { return d->importIconView; } ImportPreviewView* ImportStackedView::importPreviewView() const { return d->importPreviewView; } #ifdef HAVE_MARBLE MapWidgetView* ImportStackedView::mapWidgetView() const { return d->mapWidgetView; } #endif // HAVE_MARBLE #ifdef HAVE_MEDIAPLAYER MediaPlayerView* ImportStackedView::mediaPlayerView() const { return d->mediaPlayerView; } #endif //HAVE_MEDIAPLAYER bool ImportStackedView::isInSingleFileMode() const { return currentIndex() == PreviewImageMode || currentIndex() == MediaPlayerMode; } bool ImportStackedView::isInMultipleFileMode() const { return currentIndex() == PreviewCameraMode || currentIndex() == MapWidgetMode; } void ImportStackedView::setPreviewItem(const CamItemInfo& info, const CamItemInfo& previous, const CamItemInfo& next) { if (info.isNull()) { if (viewMode() == MediaPlayerMode) { #ifdef HAVE_MEDIAPLAYER d->mediaPlayerView->setCurrentItem(); #endif //HAVE_MEDIAPLAYER } else if (viewMode() == PreviewImageMode) { d->importPreviewView->setCamItemInfo(); } } else { if (identifyCategoryforMime(info.mime) == QLatin1String("audio") || identifyCategoryforMime(info.mime) == QLatin1String("video")) { // Stop image viewer if (viewMode() == PreviewImageMode) { d->importPreviewView->setCamItemInfo(); } #ifdef HAVE_MEDIAPLAYER setViewMode(MediaPlayerMode); d->mediaPlayerView->setCurrentItem(info.url(), !previous.isNull(), !next.isNull()); #endif //HAVE_MEDIAPLAYER } else { // Stop media player if running... if (viewMode() == MediaPlayerMode) { #ifdef HAVE_MEDIAPLAYER d->mediaPlayerView->setCurrentItem(); #endif //HAVE_MEDIAPLAYER } d->importPreviewView->setCamItemInfo(info, previous, next); // NOTE: No need to toggle immediately in PreviewImageMode here, // because we will receive a signal for that when the image preview will be loaded. // This will prevent a flicker effect with the old image preview loaded in stack. } // do not touch the selection, only adjust current info QModelIndex currentIndex = d->thumbBar->importSortFilterModel()->indexForCamItemInfo(info); d->thumbBar->selectionModel()->setCurrentIndex(currentIndex, QItemSelectionModel::NoUpdate); } } QString ImportStackedView::identifyCategoryforMime(const QString& mime) const { return mime.split(QLatin1Char('/')).at(0); } ImportStackedView::StackedViewMode ImportStackedView::viewMode() const { return (StackedViewMode)(indexOf(currentWidget())); } void ImportStackedView::setViewMode(const StackedViewMode mode) { if (mode != PreviewCameraMode && mode != PreviewImageMode && mode != MediaPlayerMode && mode != MapWidgetMode) { return; } if (mode == PreviewImageMode || mode == MediaPlayerMode) { d->thumbBarDock->restoreVisibility(); syncSelection(d->importIconView, d->thumbBar); } else { d->thumbBarDock->hide(); } if (mode == PreviewCameraMode || mode == MapWidgetMode) { setPreviewItem(); setCurrentIndex(mode); } else { setCurrentIndex(mode); } #ifdef HAVE_MARBLE d->mapWidgetView->setActive(mode == MapWidgetMode); #endif // HAVE_MARBLE if (mode == PreviewCameraMode) { d->importIconView->setFocus(); } #ifdef HAVE_MARBLE else if (mode == MapWidgetMode) { d->mapWidgetView->setFocus(); } #endif // HAVE_MARBLE emit signalViewModeChanged(); } void ImportStackedView::syncSelection(ImportCategorizedView* const from, ImportCategorizedView* const to) { ImportSortFilterModel* const fromModel = from->importSortFilterModel(); ImportSortFilterModel* const toModel = to->importSortFilterModel(); QModelIndex currentIndex = toModel->indexForCamItemInfo(from->currentInfo()); // sync selection QItemSelection selection = from->selectionModel()->selection(); QItemSelection newSelection; - foreach(const QItemSelectionRange& range, selection) + foreach (const QItemSelectionRange& range, selection) { QModelIndex topLeft = toModel->indexForCamItemInfo(fromModel->camItemInfo(range.topLeft())); QModelIndex bottomRight = toModel->indexForCamItemInfo(fromModel->camItemInfo(range.bottomRight())); newSelection.select(topLeft, bottomRight); } d->syncingSelection = true; if (currentIndex.isValid()) { // set current info to->setCurrentIndex(currentIndex); } to->selectionModel()->select(newSelection, QItemSelectionModel::ClearAndSelect); d->syncingSelection = false; } void ImportStackedView::slotThumbBarSelectionChanged() { if (currentIndex() != PreviewImageMode && currentIndex() != MediaPlayerMode) { return; } if (d->syncingSelection) { return; } syncSelection(d->thumbBar, d->importIconView); } void ImportStackedView::slotIconViewSelectionChanged() { if (currentIndex() != PreviewCameraMode) { return; } if (d->syncingSelection) { return; } syncSelection(d->importIconView, d->thumbBar); } void ImportStackedView::previewLoaded() { emit signalViewModeChanged(); } void ImportStackedView::slotZoomFactorChanged(double z) { if (viewMode() == PreviewImageMode) { emit signalZoomFactorChanged(z); } } void ImportStackedView::increaseZoom() { d->importPreviewView->layout()->increaseZoom(); } void ImportStackedView::decreaseZoom() { d->importPreviewView->layout()->decreaseZoom(); } void ImportStackedView::zoomTo100Percents() { d->importPreviewView->layout()->setZoomFactor(1.0); } void ImportStackedView::fitToWindow() { d->importPreviewView->layout()->fitToWindow(); } void ImportStackedView::toggleFitToWindowOr100() { d->importPreviewView->layout()->toggleFitToWindowOr100(); } bool ImportStackedView::maxZoom() const { return d->importPreviewView->layout()->atMaxZoom(); } bool ImportStackedView::minZoom() const { return d->importPreviewView->layout()->atMinZoom(); } void ImportStackedView::setZoomFactor(double z) { // Giving a null anchor means to use the current view center d->importPreviewView->layout()->setZoomFactor(z, QPoint()); } void ImportStackedView::setZoomFactorSnapped(double z) { d->importPreviewView->layout()->setZoomFactor(z, QPoint(), SinglePhotoPreviewLayout::SnapZoomFactor); } double ImportStackedView::zoomFactor() const { return d->importPreviewView->layout()->zoomFactor(); } double ImportStackedView::zoomMin() const { return d->importPreviewView->layout()->minZoomFactor(); } double ImportStackedView::zoomMax() const { return d->importPreviewView->layout()->maxZoomFactor(); } void ImportStackedView::slotPreviewLoaded(bool) { setViewMode(ImportStackedView::PreviewImageMode); previewLoaded(); } } // namespace Digikam diff --git a/core/utilities/import/views/importthumbnailbar.cpp b/core/utilities/import/views/importthumbnailbar.cpp index 7b10971e92..0a9caec5b9 100644 --- a/core/utilities/import/views/importthumbnailbar.cpp +++ b/core/utilities/import/views/importthumbnailbar.cpp @@ -1,225 +1,225 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2012-20-07 * Description : Thumbnail bar for import tool * * Copyright (C) 2012 by Islam Wazery * Copyright (C) 2012-2019 by Gilles Caulier * * This program is free software you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #include "importthumbnailbar.h" // Local includes #include "digikam_debug.h" #include "applicationsettings.h" #include "importsettings.h" #include "importdelegate.h" #include "importfiltermodel.h" #include "importoverlays.h" namespace Digikam { class Q_DECL_HIDDEN ImportThumbnailBar::Private { public: explicit Private() { scrollPolicy = Qt::ScrollBarAlwaysOn; duplicatesFilter = nullptr; } Qt::ScrollBarPolicy scrollPolicy; NoDuplicatesImportFilterModel* duplicatesFilter; }; ImportThumbnailBar::ImportThumbnailBar(QWidget* const parent) : ImportCategorizedView(parent), d(new Private()) { setItemDelegate(new ImportThumbnailDelegate(this)); setSpacing(3); setUsePointingHandCursor(false); setScrollStepGranularity(5); setScrollBarPolicy(Qt::ScrollBarAlwaysOn); setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(false); setScrollCurrentToCenter(ApplicationSettings::instance()->getScrollItemToCenter()); setToolTipEnabled(ImportSettings::instance()->showToolTipsIsValid()); connect(ImportSettings::instance(), SIGNAL(setupChanged()), this, SLOT(slotSetupChanged())); slotSetupChanged(); setFlow(LeftToRight); } ImportThumbnailBar::~ImportThumbnailBar() { delete d; } void ImportThumbnailBar::setModelsFiltered(ImportItemModel* model, ImportSortFilterModel* filterModel) { if (!d->duplicatesFilter) { d->duplicatesFilter = new NoDuplicatesImportFilterModel(this); } d->duplicatesFilter->setSourceFilterModel(filterModel); ImportCategorizedView::setModels(model, d->duplicatesFilter); } void ImportThumbnailBar::installOverlays() { ImportRatingOverlay* const ratingOverlay = new ImportRatingOverlay(this); addOverlay(ratingOverlay); connect(ratingOverlay, SIGNAL(ratingEdited(QList,int)), this, SLOT(assignRating(QList,int))); addOverlay(new ImportLockOverlay(this)); addOverlay(new ImportDownloadOverlay(this)); addOverlay(new ImportCoordinatesOverlay(this)); } void ImportThumbnailBar::slotDockLocationChanged(Qt::DockWidgetArea area) { if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea) { setFlow(TopToBottom); } else { setFlow(LeftToRight); } scrollTo(currentIndex()); } void ImportThumbnailBar::setScrollBarPolicy(Qt::ScrollBarPolicy policy) { if (policy == Qt::ScrollBarAsNeeded) { // Delegate resizing will cause endless relayouting, see bug #228807 qCDebug(DIGIKAM_IMPORTUI_LOG) << "The Qt::ScrollBarAsNeeded policy is not supported by ImportThumbnailBar"; } d->scrollPolicy = policy; if (flow() == TopToBottom) { setVerticalScrollBarPolicy(d->scrollPolicy); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } else { setHorizontalScrollBarPolicy(d->scrollPolicy); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } } void ImportThumbnailBar::setFlow(QListView::Flow flow) { setWrapping(false); ImportCategorizedView::setFlow(flow); ImportThumbnailDelegate* del = static_cast(delegate()); del->setFlow(flow); // Reset the minimum and maximum sizes. setMinimumSize(QSize(0, 0)); setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); // Adjust minimum and maximum width to thumbnail sizes. if (flow == TopToBottom) { int viewportFullWidgetOffset = size().width() - viewport()->size().width(); setMinimumWidth(del->minimumSize() + viewportFullWidgetOffset); setMaximumWidth(del->maximumSize() + viewportFullWidgetOffset); } else { int viewportFullWidgetOffset = size().height() - viewport()->size().height(); setMinimumHeight(del->minimumSize() + viewportFullWidgetOffset); setMaximumHeight(del->maximumSize() + viewportFullWidgetOffset); } setScrollBarPolicy(d->scrollPolicy); } void ImportThumbnailBar::slotSetupChanged() { setScrollCurrentToCenter(ApplicationSettings::instance()->getScrollItemToCenter()); setToolTipEnabled(ImportSettings::instance()->showToolTipsIsValid()); setFont(ImportSettings::instance()->getIconViewFont()); ImportCategorizedView::slotSetupChanged(); } void ImportThumbnailBar::assignRating(const QList& indexes, int rating) { QList mappedIndexes = importSortFilterModel()->mapListToSource(indexes); - foreach(const QModelIndex& index, mappedIndexes) + foreach (const QModelIndex& index, mappedIndexes) { if (index.isValid()) { importItemModel()->camItemInfoRef(index).rating = rating; } } } bool ImportThumbnailBar::event(QEvent* e) { // reset widget max/min sizes if (e->type() == QEvent::StyleChange || e->type() == QEvent::Show) { setFlow(flow()); } return ImportCategorizedView::event(e); } QModelIndex ImportThumbnailBar::nextIndex(const QModelIndex& index) const { return importFilterModel()->index(index.row() + 1, 0); } QModelIndex ImportThumbnailBar::previousIndex(const QModelIndex& index) const { return importFilterModel()->index(index.row() - 1, 0); } QModelIndex ImportThumbnailBar::firstIndex() const { return importFilterModel()->index(0, 0); } QModelIndex ImportThumbnailBar::lastIndex() const { return importFilterModel()->index(importFilterModel()->rowCount() - 1, 0); } } // namespace Digikam