File indexing completed on 2025-01-19 03:56:15
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-07-12 0007 * Description : tab for displaying item versions 0008 * 0009 * SPDX-FileCopyrightText: 2010 by Martin Klapetek <martin dot klapetek at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "itempropertiesversionstab.h" 0016 0017 // Qt includes 0018 0019 #include <QListView> 0020 #include <QGridLayout> 0021 #include <QLabel> 0022 #include <QIcon> 0023 #include <QString> 0024 0025 // KDE includes 0026 0027 #include <kconfiggroup.h> 0028 #include <klocalizedstring.h> 0029 0030 // Local includes 0031 0032 #include "digikam_debug.h" 0033 #include "itemversionsmodel.h" 0034 #include "dmetadata.h" 0035 #include "iteminfo.h" 0036 #include "iteminfolist.h" 0037 #include "versionswidget.h" 0038 #include "filtershistorywidget.h" 0039 #include "applicationsettings.h" 0040 #include "versionsoverlays.h" 0041 0042 namespace Digikam 0043 { 0044 0045 class Q_DECL_HIDDEN ItemPropertiesVersionsTab::Private 0046 { 0047 public: 0048 0049 explicit Private() 0050 : versionsWidget (nullptr), 0051 filtersHistoryWidget(nullptr) 0052 { 0053 } 0054 0055 VersionsWidget* versionsWidget; 0056 FiltersHistoryWidget* filtersHistoryWidget; 0057 DImageHistory history; 0058 ItemInfo info; 0059 0060 static const QString configActiveTab; 0061 }; 0062 0063 const QString ItemPropertiesVersionsTab::Private::configActiveTab(QLatin1String("Version Properties Tab")); 0064 0065 ItemPropertiesVersionsTab::ItemPropertiesVersionsTab(QWidget* const parent) 0066 : QTabWidget(parent), 0067 d (new Private) 0068 { 0069 d->versionsWidget = new VersionsWidget(this); 0070 insertTab(0, d->versionsWidget, i18nc("@title", "Versions")); 0071 0072 d->filtersHistoryWidget = new FiltersHistoryWidget(this); 0073 insertTab(1, d->filtersHistoryWidget, i18nc("@title", "Used Filters")); 0074 0075 connect(d->versionsWidget, SIGNAL(imageSelected(ItemInfo)), 0076 this, SIGNAL(imageSelected(ItemInfo))); 0077 } 0078 0079 ItemPropertiesVersionsTab::~ItemPropertiesVersionsTab() 0080 { 0081 delete d; 0082 } 0083 0084 void ItemPropertiesVersionsTab::readSettings(KConfigGroup& group) 0085 { 0086 QString tab = group.readEntry(d->configActiveTab, "versions"); 0087 0088 if (tab == QLatin1String("versions")) 0089 { 0090 setCurrentWidget(d->versionsWidget); 0091 } 0092 else 0093 { 0094 setCurrentWidget(d->filtersHistoryWidget); 0095 } 0096 0097 d->versionsWidget->readSettings(group); 0098 } 0099 0100 void ItemPropertiesVersionsTab::writeSettings(KConfigGroup& group) 0101 { 0102 group.writeEntry(d->configActiveTab, (currentWidget() == d->versionsWidget ? "versions" : "filters")); 0103 0104 d->versionsWidget->writeSettings(group); 0105 } 0106 0107 VersionsWidget* ItemPropertiesVersionsTab::versionsWidget() const 0108 { 0109 return d->versionsWidget; 0110 } 0111 0112 FiltersHistoryWidget* ItemPropertiesVersionsTab::filtersHistoryWidget() const 0113 { 0114 return d->filtersHistoryWidget; 0115 } 0116 0117 void ItemPropertiesVersionsTab::clear() 0118 { 0119 d->filtersHistoryWidget->clearData(); 0120 d->versionsWidget->setCurrentItem(ItemInfo()); 0121 } 0122 0123 void ItemPropertiesVersionsTab::setItem(const ItemInfo& info, const DImageHistory& history) 0124 { 0125 clear(); 0126 0127 if (info.isNull()) 0128 { 0129 return; 0130 } 0131 0132 d->history = history; 0133 0134 if (d->history.isNull()) 0135 { 0136 d->history = info.imageHistory(); 0137 } 0138 0139 d->info = info; 0140 0141 d->versionsWidget->setCurrentItem(info); 0142 d->filtersHistoryWidget->setHistory(d->history); 0143 } 0144 0145 void ItemPropertiesVersionsTab::addShowHideOverlay() 0146 { 0147 d->versionsWidget->addShowHideOverlay(); 0148 } 0149 0150 void ItemPropertiesVersionsTab::addOpenImageAction() 0151 { 0152 ActionVersionsOverlay* const overlay = d->versionsWidget->addActionOverlay(QIcon::fromTheme(QLatin1String("document-open")), 0153 i18nc("@action: open image", "Open"), 0154 i18nc("@info:tooltip", "Open file")); 0155 0156 connect(overlay, SIGNAL(activated(ItemInfo)), 0157 this, SIGNAL(actionTriggered(ItemInfo))); 0158 } 0159 0160 void ItemPropertiesVersionsTab::addOpenAlbumAction(const ItemModel* referenceModel) 0161 { 0162 ActionVersionsOverlay* const overlay = d->versionsWidget->addActionOverlay(QIcon::fromTheme(QLatin1String("folder-pictures")), 0163 i18nc("@action: go to album", "Go To Albums"), 0164 i18nc("@info:tooltip", "Go to the album of this image")); 0165 overlay->setReferenceModel(referenceModel); 0166 0167 connect(overlay, SIGNAL(activated(ItemInfo)), 0168 this, SIGNAL(actionTriggered(ItemInfo))); 0169 } 0170 0171 void ItemPropertiesVersionsTab::setEnabledHistorySteps(int count) 0172 { 0173 d->filtersHistoryWidget->setEnabledEntries(count); 0174 } 0175 0176 } // namespace Digikam 0177 0178 #include "moc_itempropertiesversionstab.cpp"