diff --git a/core/dplugins/editor/enhance/hotpixels/blackframelistview.cpp b/core/dplugins/editor/enhance/hotpixels/blackframelistview.cpp index 66a94d264f..0f3d7d2971 100644 --- a/core/dplugins/editor/enhance/hotpixels/blackframelistview.cpp +++ b/core/dplugins/editor/enhance/hotpixels/blackframelistview.cpp @@ -1,155 +1,171 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2005-07-05 * Description : a ListView to display black frames * * Copyright (C) 2005-2019 by Gilles Caulier * Copyright (C) 2005-2006 by Unai Garro * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #define THUMB_WIDTH 150 #include "blackframelistview.h" // Qt includes #include #include #include // KDE includes #include namespace DigikamEditorHotPixelsToolPlugin { BlackFrameListViewItem::BlackFrameListViewItem(QTreeWidget* const parent, const QUrl& url) : QObject(parent), QTreeWidgetItem(parent), m_blackFrameURL(url) { m_parser = new BlackFrameParser(parent); m_parser->parseBlackFrame(url); connect(m_parser, SIGNAL(signalParsed(QList)), this, SLOT(slotParsed(QList))); connect(this, SIGNAL(signalParsed(QList,QUrl)), parent, SLOT(slotParsed(QList,QUrl))); connect(m_parser, SIGNAL(signalLoadingProgress(float)), this, SIGNAL(signalLoadingProgress(float))); connect(m_parser, SIGNAL(signalLoadingComplete()), this, SIGNAL(signalLoadingComplete())); } +BlackFrameListViewItem::~BlackFrameListViewItem() +{ +} + void BlackFrameListViewItem::activate() { static_cast(this)->treeWidget()->setToolTip(m_blackFrameDesc); emit signalParsed(m_hotPixels, m_blackFrameURL); } void BlackFrameListViewItem::slotParsed(const QList& hotPixels) { m_hotPixels = hotPixels; m_image = m_parser->image(); m_imageSize = m_image.size(); m_thumb = thumb(QSize(THUMB_WIDTH, THUMB_WIDTH/3*2)).toImage(); setIcon(0, QPixmap::fromImage(m_thumb)); if (!m_imageSize.isEmpty()) { setText(1, QString::fromUtf8("%1x%2").arg(m_imageSize.width()).arg(m_imageSize.height())); } setText(2, QString::number(m_hotPixels.count())); m_blackFrameDesc = QString::fromUtf8("

%1:

").arg(m_blackFrameURL.fileName()); for (QList ::const_iterator it = m_hotPixels.constBegin() ; it != m_hotPixels.constEnd() ; ++it) { m_blackFrameDesc.append( QString::fromUtf8("[%1,%2] ").arg((*it).x()).arg((*it).y()) ); } emit signalParsed(m_hotPixels, m_blackFrameURL); } QPixmap BlackFrameListViewItem::thumb(const QSize& size) { - //First scale it down to the size + // First scale it down to the size + QPixmap thumb = QPixmap::fromImage(m_image.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - //And draw the hot pixel positions on the thumb + // And draw the hot pixel positions on the thumb + QPainter p(&thumb); - //Take scaling into account + // Take scaling into account + float xRatio, yRatio; float hpThumbX, hpThumbY; QRect hpRect; xRatio = (float)size.width() / (float)m_image.width(); yRatio = (float)size.height() / (float)m_image.height(); - //Draw hot pixels one by one + // Draw hot pixels one by one + QList::const_iterator it; for (it = m_hotPixels.constBegin() ; it != m_hotPixels.constEnd() ; ++it) { hpRect = (*it).rect; hpThumbX = (hpRect.x() + hpRect.width() / 2) * xRatio; hpThumbY = (hpRect.y() + hpRect.height() / 2) * yRatio; p.setPen(QPen(Qt::black)); p.drawLine((int) hpThumbX, (int) hpThumbY - 1, (int) hpThumbX, (int) hpThumbY + 1); p.drawLine((int) hpThumbX - 1, (int) hpThumbY, (int) hpThumbX + 1, (int) hpThumbY); p.setPen(QPen(Qt::white)); p.drawPoint((int) hpThumbX - 1, (int) hpThumbY - 1); p.drawPoint((int) hpThumbX + 1, (int) hpThumbY + 1); p.drawPoint((int) hpThumbX - 1, (int) hpThumbY + 1); p.drawPoint((int) hpThumbX + 1, (int) hpThumbY - 1); } return thumb; } // ---------------------------------------------------------------------------- BlackFrameListView::BlackFrameListView(QWidget* const parent) : QTreeWidget(parent) { setColumnCount(3); setRootIsDecorated(false); setSelectionMode(QAbstractItemView::SingleSelection); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setAllColumnsShowFocus(true); setIconSize(QSize(THUMB_WIDTH, THUMB_WIDTH)); QStringList labels; labels.append( i18n("Preview") ); labels.append( i18n("Size") ); labels.append( i18nc("This is a column which will contain the amount of HotPixels " "found in the black frame file", "HP") ); setHeaderLabels(labels); } +BlackFrameListView::~BlackFrameListView() +{ +} + +void BlackFrameListView::slotParsed(const QList& hotPixels, const QUrl& blackFrameURL) +{ + emit signalBlackFrameSelected(hotPixels, blackFrameURL); +} } // namespace DigikamEditorHotPixelsToolPlugin diff --git a/core/dplugins/editor/enhance/hotpixels/blackframelistview.h b/core/dplugins/editor/enhance/hotpixels/blackframelistview.h index 41a5c72272..f9ff05b849 100644 --- a/core/dplugins/editor/enhance/hotpixels/blackframelistview.h +++ b/core/dplugins/editor/enhance/hotpixels/blackframelistview.h @@ -1,116 +1,114 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2005-07-05 * Description : a ListView to display black frames * * Copyright (C) 2005-2019 by Gilles Caulier * Copyright (C) 2005-2006 by Unai Garro * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #ifndef DIGIKAM_EDITOR_BLACK_FRAME_LIST_VIEW_H #define DIGIKAM_EDITOR_BLACK_FRAME_LIST_VIEW_H // Qt includes #include #include #include #include #include #include #include #include // Local includes #include "blackframeparser.h" #include "hotpixel.h" namespace DigikamEditorHotPixelsToolPlugin { class BlackFrameListViewItem : public QObject, QTreeWidgetItem { Q_OBJECT public: explicit BlackFrameListViewItem(QTreeWidget* const parent, const QUrl& url); - ~BlackFrameListViewItem() {}; + ~BlackFrameListViewItem(); Q_SIGNALS: void signalParsed(const QList&, const QUrl&); void signalLoadingProgress(float); void signalLoadingComplete(); protected: void activate(); private: QPixmap thumb(const QSize& size); private Q_SLOTS: void slotParsed(const QList&); private: // Data contained within each listview item + QImage m_thumb; QImage m_image; QSize m_imageSize; QList m_hotPixels; QString m_blackFrameDesc; QUrl m_blackFrameURL; BlackFrameParser* m_parser; }; //----------------------------------------------------------------------------------- class BlackFrameListView : public QTreeWidget { Q_OBJECT public: explicit BlackFrameListView(QWidget* const parent=nullptr); - ~BlackFrameListView() {}; + ~BlackFrameListView(); Q_SIGNALS: void signalBlackFrameSelected(const QList&, const QUrl&); private Q_SLOTS: - void slotParsed(const QList& hotPixels, const QUrl& blackFrameURL) - { - emit signalBlackFrameSelected(hotPixels, blackFrameURL); - }; + void slotParsed(const QList&, const QUrl&); }; } // namespace DigikamEditorHotPixelsToolPlugin #endif // DIGIKAM_EDITOR_BLACK_FRAME_LIST_VIEW_H