File indexing completed on 2025-01-19 03:50:50
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-12-05 0007 * Description : factory of basic models used for views in digikam 0008 * 0009 * SPDX-FileCopyrightText: 2009-2010 by Johannes Wienke <languitar at semipol dot de> 0010 * SPDX-FileCopyrightText: 2010 by Andi Clemens <andi dot clemens at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "dmodelfactory.h" 0017 0018 // Qt includes 0019 0020 #include <QIcon> 0021 0022 // Local settings 0023 0024 #include "applicationsettings.h" 0025 0026 namespace Digikam 0027 { 0028 0029 class Q_DECL_HIDDEN DModelFactory::Private 0030 { 0031 0032 public: 0033 0034 explicit Private() 0035 : tagModel (nullptr), 0036 tagFaceModel (nullptr), 0037 tagFilterModel (nullptr), 0038 albumModel (nullptr), 0039 searchModel (nullptr), 0040 dateAlbumModel (nullptr), 0041 imageVersionModel(nullptr) 0042 { 0043 } 0044 0045 TagModel* tagModel; 0046 TagModel* tagFaceModel; 0047 TagModel* tagFilterModel; 0048 AlbumModel* albumModel; 0049 SearchModel* searchModel; 0050 DateAlbumModel* dateAlbumModel; 0051 ItemVersionsModel* imageVersionModel; 0052 }; 0053 0054 DModelFactory::DModelFactory() 0055 : d(new Private) 0056 { 0057 d->tagModel = new TagModel(AbstractAlbumModel::IncludeRootAlbum); 0058 d->tagFaceModel = new TagModel(AbstractAlbumModel::IgnoreRootAlbum); 0059 d->tagFaceModel->activateFaceTagModel(); 0060 d->tagFilterModel = new TagModel(AbstractAlbumModel::IgnoreRootAlbum); 0061 d->tagFilterModel->setAddExcludeTristate(true); 0062 0063 d->albumModel = new AlbumModel(AlbumModel::IncludeRootAlbum); 0064 d->searchModel = new SearchModel(); 0065 d->dateAlbumModel = new DateAlbumModel(); 0066 d->imageVersionModel = new ItemVersionsModel(); 0067 0068 // set icons initially 0069 0070 slotApplicationSettingsChanged(); 0071 0072 connect(ApplicationSettings::instance(), SIGNAL(setupChanged()), 0073 this, SLOT(slotApplicationSettingsChanged())); 0074 } 0075 0076 DModelFactory::~DModelFactory() 0077 { 0078 delete d->tagModel; 0079 delete d->tagFaceModel; 0080 delete d->tagFilterModel; 0081 0082 delete d->albumModel; 0083 delete d->searchModel; 0084 delete d->dateAlbumModel; 0085 delete d->imageVersionModel; 0086 0087 delete d; 0088 } 0089 0090 TagModel* DModelFactory::getTagModel() const 0091 { 0092 return d->tagModel; 0093 } 0094 0095 TagModel* DModelFactory::getTagFaceModel() const 0096 { 0097 return d->tagFaceModel; 0098 } 0099 0100 TagModel* DModelFactory::getTagFilterModel() const 0101 { 0102 return d->tagFilterModel; 0103 } 0104 0105 AlbumModel* DModelFactory::getAlbumModel() const 0106 { 0107 return d->albumModel; 0108 } 0109 0110 SearchModel* DModelFactory::getSearchModel() const 0111 { 0112 return d->searchModel; 0113 } 0114 0115 DateAlbumModel* DModelFactory::getDateAlbumModel() const 0116 { 0117 return d->dateAlbumModel; 0118 } 0119 0120 ItemVersionsModel* DModelFactory::getItemVersionsModel() const 0121 { 0122 return d->imageVersionModel; 0123 } 0124 0125 void DModelFactory::slotApplicationSettingsChanged() 0126 { 0127 int size = ApplicationSettings::instance()->getTreeViewIconSize(); 0128 d->dateAlbumModel->setPixmaps(QIcon::fromTheme(QLatin1String("view-calendar-list")).pixmap(size), 0129 QIcon::fromTheme(QLatin1String("view-calendar")).pixmap(size)); 0130 } 0131 0132 } // namespace Digikam 0133 0134 #include "moc_dmodelfactory.cpp"