File indexing completed on 2025-01-19 03:50:43
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-12-05 0007 * Description : Side Bar Widget for the date folder view. 0008 * 0009 * SPDX-FileCopyrightText: 2009-2010 by Johannes Wienke <languitar at semipol dot de> 0010 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2012 by Andi Clemens <andi dot clemens at gmail dot com> 0012 * SPDX-FileCopyrightText: 2014 by Mohamed_Anwer <m_dot_anwer at gmx dot com> 0013 * SPDX-FileCopyrightText: 2010 by Aditya Bhatt <adityabhatt1991 at gmail dot com> 0014 * 0015 * SPDX-License-Identifier: GPL-2.0-or-later 0016 * 0017 * ============================================================ */ 0018 0019 #include "datefolderviewsidebarwidget.h" 0020 0021 // Qt includes 0022 0023 #include <QApplication> 0024 #include <QStyle> 0025 #include <QIcon> 0026 0027 // KDE includes 0028 0029 #include <kconfiggroup.h> 0030 #include <klocalizedstring.h> 0031 0032 // Local includes 0033 0034 #include "digikam_debug.h" 0035 #include "albumpointer.h" 0036 #include "applicationsettings.h" 0037 #include "datefolderview.h" 0038 0039 namespace Digikam 0040 { 0041 0042 class Q_DECL_HIDDEN DateFolderViewSideBarWidget::Private 0043 { 0044 public: 0045 0046 explicit Private() 0047 : dateFolderView(nullptr) 0048 { 0049 } 0050 0051 DateFolderView* dateFolderView; 0052 }; 0053 0054 DateFolderViewSideBarWidget::DateFolderViewSideBarWidget(QWidget* const parent, 0055 DateAlbumModel* const model, 0056 ItemAlbumFilterModel* const imageFilterModel) 0057 : SidebarWidget(parent), 0058 d (new Private) 0059 { 0060 setObjectName(QLatin1String("DateFolderView Sidebar")); 0061 setProperty("Shortcut", QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_F4)); 0062 0063 const int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0064 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0065 0066 QVBoxLayout* const layout = new QVBoxLayout(this); 0067 0068 d->dateFolderView = new DateFolderView(this, model); 0069 d->dateFolderView->setConfigGroup(getConfigGroup()); 0070 d->dateFolderView->setItemModel(imageFilterModel); 0071 0072 layout->addWidget(d->dateFolderView); 0073 layout->setContentsMargins(0, 0, spacing, 0); 0074 } 0075 0076 DateFolderViewSideBarWidget::~DateFolderViewSideBarWidget() 0077 { 0078 delete d; 0079 } 0080 0081 void DateFolderViewSideBarWidget::setActive(bool active) 0082 { 0083 d->dateFolderView->setActive(active); 0084 } 0085 0086 void DateFolderViewSideBarWidget::doLoadState() 0087 { 0088 d->dateFolderView->loadState(); 0089 } 0090 0091 void DateFolderViewSideBarWidget::doSaveState() 0092 { 0093 d->dateFolderView->saveState(); 0094 } 0095 0096 void DateFolderViewSideBarWidget::applySettings() 0097 { 0098 } 0099 0100 void DateFolderViewSideBarWidget::changeAlbumFromHistory(const QList<Album*>& album) 0101 { 0102 d->dateFolderView->changeAlbumFromHistory(dynamic_cast<DAlbum*>(album.first())); 0103 } 0104 0105 AlbumPointer<DAlbum> DateFolderViewSideBarWidget::currentAlbum() const 0106 { 0107 return d->dateFolderView->currentAlbum(); 0108 } 0109 0110 void DateFolderViewSideBarWidget::gotoDate(const QDate& date) 0111 { 0112 d->dateFolderView->gotoDate(date); 0113 } 0114 0115 const QIcon DateFolderViewSideBarWidget::getIcon() 0116 { 0117 return QIcon::fromTheme(QLatin1String("view-calendar-list")); 0118 } 0119 0120 const QString DateFolderViewSideBarWidget::getCaption() 0121 { 0122 return i18n("Dates"); 0123 } 0124 0125 } // namespace Digikam 0126 0127 #include "moc_datefolderviewsidebarwidget.cpp"