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 "datetreeview.h"
0020 
0021 // Local includes
0022 
0023 #include "abstractalbumtreeview_p.h"
0024 
0025 namespace Digikam
0026 {
0027 
0028 DateTreeView::DateTreeView(QWidget* const parent, Flags flags)
0029     : AbstractCountingAlbumTreeView(parent, flags | AlwaysShowInclusiveCounts)
0030 {
0031     if (flags & CreateDefaultModel)
0032     {
0033         setAlbumModel(new DateAlbumModel(this));
0034     }
0035 }
0036 
0037 void DateTreeView::setAlbumModel(DateAlbumModel* const model)
0038 {
0039     AbstractCountingAlbumTreeView::setAlbumModel(model);
0040 }
0041 
0042 DateAlbumModel* DateTreeView::albumModel() const
0043 {
0044     return static_cast<DateAlbumModel*>(m_albumModel);
0045 }
0046 
0047 void DateTreeView::setAlbumFilterModel(AlbumFilterModel* const filterModel)
0048 {
0049     AbstractCountingAlbumTreeView::setAlbumFilterModel(filterModel);
0050 }
0051 
0052 DAlbum* DateTreeView::currentAlbum() const
0053 {
0054     return dynamic_cast<DAlbum*> (m_albumFilterModel->albumForIndex(currentIndex()));
0055 }
0056 
0057 DAlbum* DateTreeView::albumForIndex(const QModelIndex& index) const
0058 {
0059     return dynamic_cast<DAlbum*> (m_albumFilterModel->albumForIndex(index));
0060 }
0061 
0062 void DateTreeView::setCurrentAlbums(const QList<Album*>& albums, bool selectInAlbumManager)
0063 {
0064     AbstractCountingAlbumTreeView::setCurrentAlbums(albums, selectInAlbumManager);
0065 }
0066 
0067 void DateTreeView::setCurrentAlbum(int albumId, bool selectInAlbumManager)
0068 {
0069     DAlbum* const album = AlbumManager::instance()->findDAlbum(albumId);
0070     setCurrentAlbums(QList<Album*>() << album, selectInAlbumManager);
0071 }
0072 
0073 } // namespace Digikam
0074 
0075 #include "moc_datetreeview.cpp"