File indexing completed on 2025-01-19 03:51:28
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-09-24 0007 * Description : file list view and items. 0008 * 0009 * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2011 by Veaceslav Munteanu <slavuttici at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "dngconverterlist.h" 0017 0018 // Qt includes 0019 0020 #include <QFileInfo> 0021 #include <QDir> 0022 0023 // KDE includes 0024 0025 #include <klocalizedstring.h> 0026 0027 // LibKDcraw includes 0028 0029 #include "drawdecoder.h" 0030 0031 namespace DigikamGenericDNGConverterPlugin 0032 { 0033 0034 DNGConverterList::DNGConverterList(QWidget* const parent) 0035 : DItemsList(parent) 0036 { 0037 listView()->setColumnLabel(DItemsListView::Filename, i18n("Raw File")); 0038 listView()->setColumn(static_cast<DItemsListView::ColumnType>(TARGETFILENAME), i18n("Target File"), true); 0039 listView()->setColumn(static_cast<DItemsListView::ColumnType>(IDENTIFICATION), i18n("Camera"), true); 0040 listView()->setColumn(static_cast<DItemsListView::ColumnType>(STATUS), i18n("Status"), true); 0041 } 0042 0043 DNGConverterList::~DNGConverterList() 0044 { 0045 } 0046 0047 void DNGConverterList::slotAddImages(const QList<QUrl>& list) 0048 { 0049 /** 0050 * Replaces the DItemsList::slotAddImages method, so that 0051 * DNGConverterListViewItems can be added instead of ImagesListViewItems 0052 */ 0053 0054 // Figure out which of the supplied Url's should actually be added and which 0055 // of them already exist. 0056 0057 bool found = false; 0058 0059 for (QList<QUrl>::const_iterator it = list.constBegin() ; it != list.constEnd() ; ++it) 0060 { 0061 QUrl imageUrl = *it; 0062 found = false; 0063 0064 for (int i = 0 ; i < listView()->topLevelItemCount() ; ++i) 0065 { 0066 DNGConverterListViewItem* const currItem = dynamic_cast<DNGConverterListViewItem*>(listView()->topLevelItem(i)); 0067 0068 if (currItem && (currItem->url() == imageUrl)) 0069 { 0070 found = true; 0071 break; 0072 } 0073 } 0074 0075 if (!found && 0076 (DRawDecoder::isRawFile(imageUrl)) && 0077 (QFileInfo(imageUrl.toLocalFile()).suffix().toUpper() != QLatin1String("DNG"))) 0078 { 0079 new DNGConverterListViewItem(listView(), imageUrl); 0080 } 0081 } 0082 0083 // Duplicate the signalImageListChanged of the ImageWindow, to enable the upload button again. 0084 0085 Q_EMIT signalImageListChanged(); 0086 } 0087 0088 void DNGConverterList::slotRemoveItems() 0089 { 0090 bool find = false; 0091 0092 do 0093 { 0094 find = false; 0095 QTreeWidgetItemIterator it(listView()); 0096 0097 while (*it) 0098 { 0099 DNGConverterListViewItem* const item = dynamic_cast<DNGConverterListViewItem*>(*it); 0100 0101 if (item && item->isSelected()) 0102 { 0103 delete item; 0104 find = true; 0105 break; 0106 } 0107 0108 ++it; 0109 } 0110 } 0111 while(find); 0112 } 0113 0114 // ------------------------------------------------------------------------------------------------ 0115 0116 class DNGConverterListViewItem::Private 0117 { 0118 public: 0119 0120 Private() 0121 { 0122 } 0123 0124 QString destFileName; 0125 QString identity; 0126 QString status; 0127 }; 0128 0129 DNGConverterListViewItem::DNGConverterListViewItem(DItemsListView* const view, const QUrl& url) 0130 : DItemsListViewItem(view, url), 0131 d (new Private) 0132 { 0133 } 0134 0135 DNGConverterListViewItem::~DNGConverterListViewItem() 0136 { 0137 delete d; 0138 } 0139 0140 void DNGConverterListViewItem::setDestFileName(const QString& str) 0141 { 0142 d->destFileName = str; 0143 setText(DNGConverterList::TARGETFILENAME, d->destFileName); 0144 } 0145 0146 QString DNGConverterListViewItem::destFileName() const 0147 { 0148 return d->destFileName; 0149 } 0150 0151 void DNGConverterListViewItem::setIdentity(const QString& str) 0152 { 0153 d->identity = str; 0154 setText(DNGConverterList::IDENTIFICATION, d->identity); 0155 } 0156 0157 QString DNGConverterListViewItem::identity() const 0158 { 0159 return d->identity; 0160 } 0161 0162 void DNGConverterListViewItem::setStatus(const QString& str) 0163 { 0164 d->status = str; 0165 setText(DNGConverterList::STATUS, d->status); 0166 } 0167 0168 QString DNGConverterListViewItem::destPath() const 0169 { 0170 return (QDir::fromNativeSeparators(QFileInfo(url().toLocalFile()).path() + QLatin1String("/") + destFileName())); 0171 } 0172 0173 } // namespace DigikamGenericDNGConverterPlugin 0174 0175 #include "moc_dngconverterlist.cpp"