File indexing completed on 2025-01-19 03:50:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2002-16-10
0007  * Description : Item icon view interface.
0008  *
0009  * SPDX-FileCopyrightText: 2002-2005 by Renchi Raju <renchi dot raju at gmail dot com>
0010  * SPDX-FileCopyrightText: 2002-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2009-2011 by Johannes Wienke <languitar at semipol dot de>
0012  * SPDX-FileCopyrightText: 2010-2011 by Andi Clemens <andi dot clemens at gmail dot com>
0013  * SPDX-FileCopyrightText: 2011-2013 by Michael G. Hansen <mike at mghansen dot de>
0014  * SPDX-FileCopyrightText: 2014-2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0015  * SPDX-FileCopyrightText: 2017      by Simon Frei <freisim93 at gmail dot com>
0016  *
0017  * SPDX-License-Identifier: GPL-2.0-or-later
0018  *
0019  * ============================================================ */
0020 
0021 #include "itemiconview_p.h"
0022 
0023 namespace Digikam
0024 {
0025 
0026 ItemIconView::ItemIconView(QWidget* const parent, DModelFactory* const modelCollection)
0027     : DHBox(parent),
0028       d    (new Private)
0029 {
0030     d->parent                   = static_cast<DigikamApp*>(parent);
0031     d->modelCollection          = modelCollection;
0032     d->albumManager             = AlbumManager::instance();
0033 
0034     d->albumModificationHelper  = new AlbumModificationHelper(this, this);
0035     d->tagModificationHelper    = new TagModificationHelper(this, this);
0036     d->searchModificationHelper = new SearchModificationHelper(this, this);
0037 
0038     const int spacing           = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0039                                        QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0040 
0041     d->splitter    = new SidebarSplitter;
0042     d->splitter->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
0043     d->splitter->setOpaqueResize(false);
0044 
0045     d->leftSideBar = new Sidebar(this, d->splitter, Qt::LeftEdge);
0046     d->leftSideBar->setObjectName(QLatin1String("Digikam Left Sidebar"));
0047     d->leftSideBar->setContentsMargins(0, 0, spacing, 0);
0048 
0049     d->splitter->setParent(this);
0050 
0051     // The dock area where the thumbnail bar is allowed to go.
0052 
0053     d->dockArea    = new QMainWindow(this, Qt::Widget);
0054     d->dockArea->setContentsMargins(QMargins());
0055     d->splitter->addWidget(d->dockArea);
0056     d->splitter->setStretchFactor(d->splitter->indexOf(d->dockArea), 10);
0057 
0058     DVBox* const vbox = new DVBox(d->dockArea);
0059     d->errorWidget    = new DNotificationWidget(vbox);
0060     d->errorWidget->setCloseButtonVisible(true);
0061     d->errorWidget->setWordWrap(true);
0062     d->errorWidget->hide();
0063 
0064     connect(d->leftSideBar, SIGNAL(signalChangedTab(QWidget*)),
0065             d->errorWidget, SLOT(animatedHide()));
0066 
0067     d->stackedView = new StackedView(vbox);
0068 
0069     d->dockArea->setCentralWidget(vbox);
0070     d->stackedView->setDockArea(d->dockArea);
0071 
0072     d->iconView  = d->stackedView->imageIconView();
0073 
0074 #ifdef HAVE_GEOLOCATION
0075 
0076     d->mapView   = d->stackedView->mapWidgetView();
0077 
0078 #endif // HAVE_GEOLOCATION
0079 
0080     d->tableView = d->stackedView->tableView();
0081     d->trashView = d->stackedView->trashView();
0082 
0083     d->utilities = d->iconView->utilities();
0084 
0085     d->addPageUpDownActions(this, d->stackedView->imagePreviewView());
0086     d->addPageUpDownActions(this, d->stackedView->thumbBar());
0087 
0088 #ifdef HAVE_MEDIAPLAYER
0089 
0090     d->addPageUpDownActions(this, d->stackedView->mediaPlayerView());
0091 
0092 #endif // HAVE_MEDIAPLAYER
0093 
0094     d->rightSideBar        = new ItemPropertiesSideBarDB(this, d->splitter, Qt::RightEdge, true);
0095     d->rightSideBar->setObjectName(QLatin1String("Digikam Right Sidebar"));
0096 
0097     // album folder view
0098 
0099     d->albumFolderSideBar  = new AlbumFolderViewSideBarWidget(d->leftSideBar,
0100                                                               d->modelCollection->getAlbumModel(),
0101                                                               d->albumModificationHelper);
0102     d->leftSideBarWidgets << d->albumFolderSideBar;
0103 
0104     connect(d->albumFolderSideBar, SIGNAL(signalFindDuplicates(QList<PAlbum*>)),
0105             this, SLOT(slotNewDuplicatesSearch(QList<PAlbum*>)));
0106 
0107     // Tags sidebar tab contents.
0108 
0109     d->tagViewSideBar      = new TagViewSideBarWidget(d->leftSideBar, d->modelCollection->getTagModel());
0110     d->leftSideBarWidgets << d->tagViewSideBar;
0111 
0112     connect(d->tagViewSideBar, SIGNAL(signalFindDuplicates(QList<TAlbum*>)),
0113             this, SLOT(slotNewDuplicatesSearch(QList<TAlbum*>)));
0114 
0115     // Labels sidebar
0116 
0117     d->labelsSideBar       = new LabelsSideBarWidget(d->leftSideBar);
0118     d->leftSideBarWidgets << d->labelsSideBar;
0119     d->labelsSearchHandler = new AlbumLabelsSearchHandler(d->labelsSideBar->labelsTree());
0120 
0121     // date view
0122 
0123     d->dateViewSideBar     = new DateFolderViewSideBarWidget(d->leftSideBar,
0124                                                              d->modelCollection->getDateAlbumModel(),
0125                                                              d->iconView->imageAlbumFilterModel());
0126     d->leftSideBarWidgets << d->dateViewSideBar;
0127 
0128     // timeline side bar
0129 
0130     d->timelineSideBar     = new TimelineSideBarWidget(d->leftSideBar,
0131                                                        d->modelCollection->getSearchModel(),
0132                                                        d->searchModificationHelper);
0133     d->leftSideBarWidgets << d->timelineSideBar;
0134 
0135     // Search sidebar tab contents.
0136 
0137     d->searchSideBar       = new SearchSideBarWidget(d->leftSideBar,
0138                                                      d->modelCollection->getSearchModel(),
0139                                                      d->searchModificationHelper);
0140     d->leftSideBarWidgets << d->searchSideBar;
0141 
0142     // Fuzzy search
0143 
0144     d->fuzzySearchSideBar  = new FuzzySearchSideBarWidget(d->leftSideBar,
0145                                                           d->modelCollection->getSearchModel(),
0146                                                           d->searchModificationHelper);
0147     d->leftSideBarWidgets << d->fuzzySearchSideBar;
0148 
0149     connect(d->fuzzySearchSideBar,SIGNAL(signalActive(bool)),
0150             this, SIGNAL(signalFuzzySidebarActive(bool)));
0151 
0152     connect(d->fuzzySearchSideBar, SIGNAL(signalNotificationError(QString,int)),
0153             this, SLOT(slotNotificationError(QString,int)));
0154 
0155 #ifdef HAVE_GEOLOCATION
0156 
0157     d->gpsSearchSideBar    = new GPSSearchSideBarWidget(d->leftSideBar,
0158                                                         d->modelCollection->getSearchModel(),
0159                                                         d->searchModificationHelper,
0160                                                         d->iconView->imageFilterModel(),
0161                                                         d->iconView->getSelectionModel());
0162 
0163     d->leftSideBarWidgets << d->gpsSearchSideBar;
0164 
0165 #endif // HAVE_GEOLOCATION
0166 
0167     // People Sidebar
0168 
0169     d->peopleSideBar       = new PeopleSideBarWidget(d->leftSideBar,
0170                                                      d->modelCollection->getTagFaceModel(),
0171                                                      d->searchModificationHelper);
0172 
0173     connect(d->peopleSideBar, SIGNAL(requestFaceMode(bool)),
0174             d->iconView, SLOT(setFaceMode(bool)));
0175 
0176     connect(d->peopleSideBar, SIGNAL(signalFindDuplicates(QList<TAlbum*>)),
0177             this, SLOT(slotNewDuplicatesSearch(QList<TAlbum*>)));
0178 
0179     connect(d->peopleSideBar, SIGNAL(signalNotificationError(QString,int)),
0180             this, SLOT(slotNotificationError(QString,int)));
0181 
0182     d->leftSideBarWidgets << d->peopleSideBar;
0183 
0184     Q_FOREACH (SidebarWidget* const leftWidget, d->leftSideBarWidgets)
0185     {
0186         d->leftSideBar->appendTab(leftWidget, leftWidget->getIcon(), leftWidget->getCaption());
0187 
0188         connect(leftWidget, SIGNAL(requestActiveTab(SidebarWidget*)),
0189                 this, SLOT(slotLeftSideBarActivate(SidebarWidget*)));
0190     }
0191 
0192     // add only page up and down to work correctly with QCompleter
0193 
0194     defineShortcut(d->rightSideBar->imageDescEditTab(), Qt::Key_PageDown, this, SLOT(slotNextItem()));
0195     defineShortcut(d->rightSideBar->imageDescEditTab(), Qt::Key_PageUp,   this, SLOT(slotPrevItem()));
0196 
0197     // Tags Filter sidebar tab contents.
0198 
0199     d->filterWidget   = new FilterSideBarWidget(d->rightSideBar, d->modelCollection->getTagFilterModel());
0200     d->rightSideBar->appendTab(d->filterWidget, QIcon::fromTheme(QLatin1String("view-filter")),
0201                                i18nc("Filters as in Search type Filters", "Filters"));
0202 
0203     // Versions sidebar overlays
0204     d->rightSideBar->getFiltersHistoryTab()->addOpenAlbumAction(d->iconView->imageModel());
0205     d->rightSideBar->getFiltersHistoryTab()->addShowHideOverlay();
0206 
0207     d->selectionTimer = new QTimer(this);
0208     d->selectionTimer->setSingleShot(true);
0209     d->selectionTimer->setInterval(75);
0210 
0211     d->thumbSizeTimer = new QTimer(this);
0212     d->thumbSizeTimer->setSingleShot(true);
0213     d->thumbSizeTimer->setInterval(300);
0214 
0215     d->msgNotifyTimer = new QTimer(this);
0216     d->msgNotifyTimer->setSingleShot(true);
0217     d->msgNotifyTimer->setInterval(250);
0218 
0219     d->albumHistory = new AlbumHistory();
0220 
0221     slotSidebarTabTitleStyleChanged();
0222     setupConnections();
0223 
0224     connect(d->rightSideBar->imageDescEditTab()->getNewTagEdit(), SIGNAL(taggingActionFinished()),
0225             this, SLOT(slotFocusAndNextImage()));
0226 
0227     connect(d->rightSideBar, SIGNAL(signalSetupMetadataFilters(int)),
0228             this, SLOT(slotSetupMetadataFilters(int)));
0229 
0230     connect(d->rightSideBar, SIGNAL(signalSetupExifTool()),
0231             this, SLOT(slotSetupExifTool()));
0232 
0233     connect(d->iconView, SIGNAL(signalSeparationModeChanged(int)),
0234             this, SIGNAL(signalSeparationModeChanged(int)));
0235 }
0236 
0237 ItemIconView::~ItemIconView()
0238 {
0239     saveViewState();
0240 
0241     delete d->labelsSearchHandler;
0242     delete d->albumHistory;
0243     delete d;
0244 }
0245 
0246 void ItemIconView::applySettings()
0247 {
0248     Q_FOREACH (SidebarWidget* const sidebarWidget, d->leftSideBarWidgets)
0249     {
0250         sidebarWidget->applySettings();
0251     }
0252 
0253     d->iconView->imageFilterModel()->setVersionItemFilterSettings(VersionItemFilterSettings(ApplicationSettings::instance()->getVersionManagerSettings()));
0254 
0255     refreshView();
0256 }
0257 
0258 void ItemIconView::setupConnections()
0259 {
0260     // -- DigikamApp connections ----------------------------------
0261 
0262     connect(d->parent, SIGNAL(signalEscapePressed()),
0263             this, SLOT(slotEscapePreview()));
0264 
0265     connect(d->parent, SIGNAL(signalNextItem()),
0266             this, SLOT(slotNextItem()));
0267 
0268     connect(d->parent, SIGNAL(signalPrevItem()),
0269             this, SLOT(slotPrevItem()));
0270 
0271     connect(d->parent, SIGNAL(signalFirstItem()),
0272             this, SLOT(slotFirstItem()));
0273 
0274     connect(d->parent, SIGNAL(signalLastItem()),
0275             this, SLOT(slotLastItem()));
0276 
0277     connect(d->parent, SIGNAL(signalCutAlbumItemsSelection()),
0278             d->iconView, SLOT(cut()));
0279 
0280     connect(d->parent, SIGNAL(signalCopyAlbumItemsSelection()),
0281             d->iconView, SLOT(copy()));
0282 
0283     connect(d->parent, SIGNAL(signalPasteAlbumItemsSelection()),
0284             this, SLOT(slotImagePaste()));
0285 
0286     // -- AlbumManager connections --------------------------------
0287 
0288     connect(d->albumManager, SIGNAL(signalAlbumCurrentChanged(QList<Album*>)),
0289             this, SLOT(slotAlbumSelected(QList<Album*>)));
0290 
0291     connect(d->albumManager, SIGNAL(signalAllAlbumsLoaded()),
0292             this, SLOT(slotAllAlbumsLoaded()));
0293 
0294     connect(d->albumManager, SIGNAL(signalAlbumsCleared()),
0295             this, SLOT(slotAlbumsCleared()));
0296 
0297     connect(d->albumManager, SIGNAL(signalEmptyTrash()),
0298             d->trashView, SIGNAL(signalEmptytrash()));
0299 
0300     // -- IconView Connections -------------------------------------
0301 
0302     connect(d->iconView->model(), SIGNAL(rowsInserted(QModelIndex,int,int)),
0303             this, SLOT(slotImageSelected()));
0304 
0305     connect(d->iconView->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
0306             this, SLOT(slotImageSelected()));
0307 
0308     connect(d->iconView->model(), SIGNAL(layoutChanged()),
0309             this, SLOT(slotImageSelected()));
0310 
0311     connect(d->iconView->imageModel(), SIGNAL(allRefreshingFinished()),
0312             d->msgNotifyTimer, SLOT(start()));
0313 
0314     connect(d->iconView, SIGNAL(selectionChanged()),
0315             this, SLOT(slotImageSelected()));
0316 
0317     connect(d->iconView, SIGNAL(previewRequested(ItemInfo)),
0318             this, SLOT(slotTogglePreviewMode(ItemInfo)));
0319 
0320     connect(d->iconView, SIGNAL(zoomOutStep()),
0321             this, SLOT(slotZoomOut()));
0322 
0323     connect(d->iconView, SIGNAL(zoomInStep()),
0324             this, SLOT(slotZoomIn()));
0325 
0326     connect(d->iconView, SIGNAL(signalShowContextMenu(QContextMenuEvent*,QList<QAction*>)),
0327             this, SLOT(slotShowContextMenu(QContextMenuEvent*,QList<QAction*>)));
0328 
0329     connect(d->iconView, SIGNAL(signalShowContextMenuOnInfo(QContextMenuEvent*,ItemInfo,QList<QAction*>,ItemFilterModel*)),
0330             this, SLOT(slotShowContextMenuOnInfo(QContextMenuEvent*,ItemInfo,QList<QAction*>,ItemFilterModel*)));
0331 
0332     connect(d->iconView, SIGNAL(signalShowGroupContextMenu(QContextMenuEvent*,QList<ItemInfo>,ItemFilterModel*)),
0333             this, SLOT(slotShowGroupContextMenu(QContextMenuEvent*,QList<ItemInfo>,ItemFilterModel*)));
0334 
0335     // -- TableView Connections -----------------------------------
0336 
0337     connect(d->tableView, SIGNAL(signalPreviewRequested(ItemInfo)),
0338             this, SLOT(slotTogglePreviewMode(ItemInfo)));
0339 
0340     connect(d->tableView, SIGNAL(signalZoomOutStep()),
0341             this, SLOT(slotZoomOut()));
0342 
0343     connect(d->tableView, SIGNAL(signalZoomInStep()),
0344             this, SLOT(slotZoomIn()));
0345 
0346     connect(d->tableView, SIGNAL(signalShowContextMenu(QContextMenuEvent*,QList<QAction*>)),
0347             this, SLOT(slotShowContextMenu(QContextMenuEvent*,QList<QAction*>)));
0348 
0349     connect(d->tableView, SIGNAL(signalShowContextMenuOnInfo(QContextMenuEvent*,ItemInfo,QList<QAction*>,ItemFilterModel*)),
0350             this, SLOT(slotShowContextMenuOnInfo(QContextMenuEvent*,ItemInfo,QList<QAction*>,ItemFilterModel*)));
0351 
0352     // TableView::signalItemsChanged is emitted when something changes in the model that
0353     // ItemIconView should care about, not only the selection.
0354 
0355     connect(d->tableView, SIGNAL(signalItemsChanged()),
0356             this, SLOT(slotImageSelected()));
0357 
0358     // -- Trash View Connections ----------------------------------
0359 
0360     connect(d->trashView, SIGNAL(selectionChanged()),
0361             this, SLOT(slotImageSelected()));
0362 
0363     // -- Sidebar Connections -------------------------------------
0364 
0365     connect(d->leftSideBar, SIGNAL(signalChangedTab(QWidget*)),
0366             this, SLOT(slotLeftSidebarChangedTab(QWidget*)));
0367 
0368     connect(d->rightSideBar, SIGNAL(signalFirstItem()),
0369             this, SLOT(slotFirstItem()));
0370 
0371     connect(d->rightSideBar, SIGNAL(signalNextItem()),
0372             this, SLOT(slotNextItem()));
0373 
0374     connect(d->rightSideBar, SIGNAL(signalPrevItem()),
0375             this, SLOT(slotPrevItem()));
0376 
0377     connect(d->rightSideBar, SIGNAL(signalLastItem()),
0378             this, SLOT(slotLastItem()));
0379 
0380     connect(this, SIGNAL(signalNoCurrentItem()),
0381             d->rightSideBar, SLOT(slotNoCurrentItem()));
0382 
0383 #ifdef HAVE_GEOLOCATION
0384 
0385     connect(d->gpsSearchSideBar, SIGNAL(signalMapSoloItems(QList<qlonglong>,QString)),
0386             d->iconView->imageFilterModel(), SLOT(setIdWhitelist(QList<qlonglong>,QString)));
0387 
0388 #endif // HAVE_GEOLOCATION
0389 
0390     // -- Filter Bars Connections ---------------------------------
0391 
0392     ItemAlbumFilterModel* const model = d->iconView->imageAlbumFilterModel();
0393 
0394     connect(d->filterWidget,
0395             SIGNAL(signalTagFilterChanged(QList<int>,QList<int>,ItemFilterSettings::MatchingCondition,bool,QList<int>,QList<int>)),
0396             d->iconView->imageFilterModel(), SLOT(setTagFilter(QList<int>,QList<int>,ItemFilterSettings::MatchingCondition,bool,QList<int>,QList<int>)));
0397 
0398     connect(d->filterWidget, SIGNAL(signalRatingFilterChanged(int,ItemFilterSettings::RatingCondition,bool)),
0399             model, SLOT(setRatingFilter(int,ItemFilterSettings::RatingCondition,bool)));
0400 
0401     connect(d->filterWidget, SIGNAL(signalSearchTextFilterChanged(SearchTextFilterSettings)),
0402             model, SLOT(setTextFilter(SearchTextFilterSettings)));
0403 
0404     connect(model, SIGNAL(filterMatchesForText(bool)),
0405             d->filterWidget, SLOT(slotFilterMatchesForText(bool)));
0406 
0407     connect(d->filterWidget, SIGNAL(signalMimeTypeFilterChanged(int)),
0408             model, SLOT(setMimeTypeFilter(int)));
0409 
0410     connect(d->filterWidget, SIGNAL(signalGeolocationFilterChanged(ItemFilterSettings::GeolocationCondition)),
0411             model, SLOT(setGeolocationFilter(ItemFilterSettings::GeolocationCondition)));
0412 
0413     // -- Preview image widget Connections ------------------------
0414 
0415     connect(d->stackedView, SIGNAL(signalNextItem()),
0416             this, SLOT(slotNextItem()));
0417 
0418     connect(d->stackedView, SIGNAL(signalPrevItem()),
0419             this, SLOT(slotPrevItem()));
0420 
0421     connect(d->stackedView, SIGNAL(signalDeleteItem()),
0422             this, SLOT(slotImageDelete()));
0423 
0424     connect(d->stackedView, SIGNAL(signalViewModeChanged()),
0425             this, SLOT(slotViewModeChanged()));
0426 
0427     connect(d->stackedView, SIGNAL(signalEscapePreview()),
0428             this, SLOT(slotEscapePreview()));
0429 
0430     connect(d->stackedView, SIGNAL(signalZoomFactorChanged(double)),
0431             this, SLOT(slotZoomFactorChanged(double)));
0432 
0433     connect(d->stackedView, SIGNAL(signalAddToExistingQueue(int)),
0434             this, SLOT(slotImageAddToExistingQueue(int)));
0435 
0436     connect(d->stackedView, SIGNAL(signalGotoAlbumAndItem(ItemInfo)),
0437             this, SLOT(slotGotoAlbumAndItem(ItemInfo)));
0438 
0439     connect(d->stackedView, SIGNAL(signalGotoDateAndItem(ItemInfo)),
0440             this, SLOT(slotGotoDateAndItem(ItemInfo)));
0441 
0442     connect(d->stackedView, SIGNAL(signalGotoTagAndItem(int)),
0443             this, SLOT(slotGotoTagAndItem(int)));
0444 
0445     connect(d->stackedView, SIGNAL(signalPopupTagsView()),
0446             d->rightSideBar, SLOT(slotPopupTagsView()));
0447 
0448     // -- FileActionMngr progress ---------------
0449 
0450     connect(FileActionMngr::instance(), SIGNAL(signalImageChangeFailed(QString,QStringList)),
0451             this, SLOT(slotImageChangeFailed(QString,QStringList)));
0452 
0453     // -- timers ---------------
0454 
0455     connect(d->selectionTimer, SIGNAL(timeout()),
0456             this, SLOT(slotDispatchImageSelected()));
0457 
0458     connect(d->thumbSizeTimer, SIGNAL(timeout()),
0459             this, SLOT(slotThumbSizeEffect()));
0460 
0461     connect(d->msgNotifyTimer, SIGNAL(timeout()),
0462             this, SLOT(slotEmptyMessageTimer()));
0463 
0464     // -- Album Settings ----------------
0465 
0466     connect(ApplicationSettings::instance(), SIGNAL(setupChanged()),
0467             this, SLOT(slotSidebarTabTitleStyleChanged()));
0468 
0469     // -- Album History -----------------
0470 
0471     connect(this, SIGNAL(signalAlbumSelected(Album*)),
0472             d->albumHistory, SLOT(slotAlbumSelected()));
0473 
0474     connect(this, SIGNAL(signalImageSelected(ItemInfoList,ItemInfoList)),
0475             d->albumHistory, SLOT(slotImageSelected(ItemInfoList)));
0476 
0477     connect(d->iconView, SIGNAL(currentChanged(ItemInfo)),
0478             d->albumHistory, SLOT(slotCurrentChange(ItemInfo)));
0479 
0480     connect(d->iconView->imageModel(), SIGNAL(imageInfosAdded(QList<ItemInfo>)),
0481             d->albumHistory, SLOT(slotAlbumCurrentChanged()));
0482 
0483     connect(d->albumHistory, SIGNAL(signalSetCurrent(qlonglong)),
0484             this, SLOT(slotSetCurrentWhenAvailable(qlonglong)));
0485 
0486     connect(d->albumHistory, SIGNAL(signalSetSelectedInfos(QList<ItemInfo>)),
0487             d->iconView, SLOT(setSelectedItemInfos(QList<ItemInfo>)));
0488 
0489     connect(d->albumManager, SIGNAL(signalAlbumDeleted(Album*)),
0490             d->albumHistory, SLOT(slotAlbumDeleted(Album*)));
0491 
0492     connect(d->albumManager, SIGNAL(signalAlbumsCleared()),
0493             d->albumHistory, SLOT(slotAlbumsCleared()));
0494 
0495     // -- Image versions ----------------
0496 
0497     connect(d->rightSideBar->getFiltersHistoryTab(), SIGNAL(imageSelected(ItemInfo)),
0498             d->iconView, SLOT(hintAt(ItemInfo)));
0499 
0500     connect(d->rightSideBar->getFiltersHistoryTab(), SIGNAL(actionTriggered(ItemInfo)),
0501             this, SLOT(slotGotoAlbumAndItem(ItemInfo)));
0502 }
0503 
0504 void ItemIconView::loadViewState()
0505 {
0506     Q_FOREACH (SidebarWidget* const widget, d->leftSideBarWidgets)
0507     {
0508         widget->loadState();
0509     }
0510 
0511     d->filterWidget->loadState();
0512 
0513     KSharedConfig::Ptr config = KSharedConfig::openConfig();
0514     KConfigGroup group        = config->group(QLatin1String("MainWindow"));
0515 
0516     // Restore the splitter
0517 
0518     d->splitter->restoreState(group);
0519 
0520     // Restore the thumbnail bar dock.
0521 
0522     QByteArray thumbbarState;
0523     thumbbarState     = group.readEntry(QLatin1String("ThumbbarState"), thumbbarState);
0524     d->dockArea->restoreState(QByteArray::fromBase64(thumbbarState));
0525 
0526     d->initialAlbumID = group.readEntry(QLatin1String("InitialAlbumID"), 0);
0527 
0528 #ifdef HAVE_GEOLOCATION
0529 
0530     d->mapView->loadState();
0531 
0532 #endif // HAVE_GEOLOCATION
0533 
0534     d->tableView->loadState();
0535     d->rightSideBar->loadState();
0536 }
0537 
0538 void ItemIconView::saveViewState()
0539 {
0540     KSharedConfig::Ptr config = KSharedConfig::openConfig();
0541     KConfigGroup group        = config->group(QLatin1String("MainWindow"));
0542 
0543     Q_FOREACH (SidebarWidget* const widget, d->leftSideBarWidgets)
0544     {
0545         widget->saveState();
0546     }
0547 
0548     d->filterWidget->saveState();
0549 
0550     // Save the splitter states.
0551 
0552     d->splitter->saveState(group);
0553 
0554     // Save the position and size of the thumbnail bar. The thumbnail bar dock
0555     // needs to be closed explicitly, because when it is floating and visible
0556     // (when the user is in image preview mode) when the layout is saved, it
0557     // also reappears when restoring the view, while it should always be hidden.
0558 
0559     d->stackedView->thumbBarDock()->close();
0560     group.writeEntry(QLatin1String("ThumbbarState"), d->dockArea->saveState().toBase64());
0561 
0562     QList<Album*> albumList = AlbumManager::instance()->currentAlbums();
0563     Album* album            = nullptr;
0564 
0565     if (!albumList.isEmpty())
0566     {
0567         album = albumList.first();
0568     }
0569 
0570     if (album)
0571     {
0572         group.writeEntry(QLatin1String("InitialAlbumID"), album->globalID());
0573     }
0574     else
0575     {
0576         group.writeEntry(QLatin1String("InitialAlbumID"), 0);
0577     }
0578 
0579 #ifdef HAVE_GEOLOCATION
0580 
0581     d->mapView->saveState();
0582 
0583 #endif // HAVE_GEOLOCATION
0584 
0585     d->tableView->saveState();
0586     d->rightSideBar->saveState();
0587 }
0588 
0589 } // namespace Digikam
0590 
0591 #include "moc_itemiconview.cpp"