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 : Labels sidebar widgets 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 "labelssidebarwidget.h" 0020 0021 // Qt includes 0022 0023 #include <QVBoxLayout> 0024 #include <QApplication> 0025 #include <QStyle> 0026 #include <QIcon> 0027 0028 // KDE includes 0029 0030 #include <kconfiggroup.h> 0031 #include <klocalizedstring.h> 0032 0033 // Local includes 0034 0035 #include "digikam_debug.h" 0036 #include "albummanager.h" 0037 #include "applicationsettings.h" 0038 0039 namespace Digikam 0040 { 0041 0042 class Q_DECL_HIDDEN LabelsSideBarWidget::Private 0043 { 0044 0045 public: 0046 0047 explicit Private() 0048 : labelsTree(nullptr) 0049 { 0050 } 0051 0052 LabelsTreeView* labelsTree; 0053 }; 0054 0055 LabelsSideBarWidget::LabelsSideBarWidget(QWidget* const parent) 0056 : SidebarWidget(parent), 0057 d (new Private) 0058 { 0059 setObjectName(QLatin1String("Labels Sidebar")); 0060 setProperty("Shortcut", QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_F3)); 0061 0062 const int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0063 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0064 0065 QVBoxLayout* const layout = new QVBoxLayout(this); 0066 0067 d->labelsTree = new LabelsTreeView(this); 0068 d->labelsTree->setConfigGroup(getConfigGroup()); 0069 0070 layout->addWidget(d->labelsTree); 0071 layout->setContentsMargins(0, 0, spacing, 0); 0072 } 0073 0074 LabelsSideBarWidget::~LabelsSideBarWidget() 0075 { 0076 delete d; 0077 } 0078 0079 LabelsTreeView *LabelsSideBarWidget::labelsTree() 0080 { 0081 return d->labelsTree; 0082 } 0083 0084 void LabelsSideBarWidget::setActive(bool active) 0085 { 0086 if (active) 0087 { 0088 d->labelsTree->setCurrentAlbum(); 0089 } 0090 } 0091 0092 void LabelsSideBarWidget::applySettings() 0093 { 0094 } 0095 0096 void LabelsSideBarWidget::changeAlbumFromHistory(const QList<Album*>& album) 0097 { 0098 Q_UNUSED(album); 0099 } 0100 0101 void LabelsSideBarWidget::doLoadState() 0102 { 0103 d->labelsTree->doLoadState(); 0104 } 0105 0106 void LabelsSideBarWidget::doSaveState() 0107 { 0108 d->labelsTree->doSaveState(); 0109 } 0110 0111 const QIcon LabelsSideBarWidget::getIcon() 0112 { 0113 return QIcon::fromTheme(QLatin1String("folder-favorites")); 0114 } 0115 0116 const QString LabelsSideBarWidget::getCaption() 0117 { 0118 return i18n("Labels"); 0119 } 0120 0121 QHash<LabelsTreeView::Labels, QList<int> > LabelsSideBarWidget::selectedLabels() 0122 { 0123 return d->labelsTree->selectedLabels(); 0124 } 0125 0126 } // namespace Digikam 0127 0128 #include "moc_labelssidebarwidget.cpp"