File indexing completed on 2025-01-19 03:53:22
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-03-25 0007 * Description : Tree View for album models 0008 * 0009 * SPDX-FileCopyrightText: 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2010-2011 by Andi Clemens <andi dot clemens at gmail dot com> 0011 * SPDX-FileCopyrightText: 2014 by Mohamed_Anwer <m_dot_anwer at gmx dot com> 0012 * SPDX-FileCopyrightText: 2014 by Michael G. Hansen <mike at mghansen dot de> 0013 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0014 * 0015 * SPDX-License-Identifier: GPL-2.0-or-later 0016 * 0017 * ============================================================ */ 0018 0019 #include "searchtreeview.h" 0020 0021 // Local includes 0022 0023 #include "abstractalbumtreeview_p.h" 0024 0025 namespace Digikam 0026 { 0027 0028 SearchTreeView::SearchTreeView(QWidget* const parent, Flags flags) 0029 : AbstractCheckableAlbumTreeView(parent, flags), 0030 m_filteredModel (nullptr) 0031 { 0032 setRootIsDecorated(false); 0033 0034 if (flags & CreateDefaultModel) 0035 { 0036 setAlbumModel(new SearchModel(this)); 0037 } 0038 0039 if (flags & CreateDefaultFilterModel) // must set again! 0040 { 0041 setAlbumFilterModel(new SearchFilterModel(this), albumFilterModel()); 0042 } 0043 } 0044 0045 SearchTreeView::~SearchTreeView() 0046 { 0047 } 0048 0049 void SearchTreeView::setAlbumModel(SearchModel* const model) 0050 { 0051 AbstractCheckableAlbumTreeView::setAlbumModel(model); 0052 0053 if (m_filteredModel) 0054 { 0055 m_filteredModel->setSourceSearchModel(model); 0056 } 0057 } 0058 0059 SearchModel* SearchTreeView::albumModel() const 0060 { 0061 return static_cast<SearchModel*>(m_albumModel); 0062 } 0063 0064 void SearchTreeView::setAlbumFilterModel(SearchFilterModel* const filteredModel, CheckableAlbumFilterModel* const filterModel) 0065 { 0066 m_filteredModel = filteredModel; 0067 AbstractCheckableAlbumTreeView::setAlbumFilterModel(filterModel); 0068 0069 // hook in: source album model -> filtered model -> album filter model 0070 0071 albumFilterModel()->setSourceFilterModel(m_filteredModel); 0072 } 0073 0074 SearchFilterModel* SearchTreeView::filteredModel() const 0075 { 0076 return m_filteredModel; 0077 } 0078 0079 SAlbum* SearchTreeView::currentAlbum() const 0080 { 0081 return dynamic_cast<SAlbum*> (m_albumFilterModel->albumForIndex(currentIndex())); 0082 } 0083 0084 void SearchTreeView::setCurrentAlbums(const QList<Album*>& albums, bool selectInAlbumManager) 0085 { 0086 AbstractCheckableAlbumTreeView::setCurrentAlbums(albums, selectInAlbumManager); 0087 } 0088 0089 void SearchTreeView::setCurrentAlbum(int albumId, bool selectInAlbumManager) 0090 { 0091 SAlbum* const album = AlbumManager::instance()->findSAlbum(albumId); 0092 setCurrentAlbums(QList<Album*>() << album, selectInAlbumManager); 0093 } 0094 0095 } // namespace Digikam 0096 0097 #include "moc_searchtreeview.cpp"