diff --git a/.arcconfig b/.arcconfig new file mode 100644 --- /dev/null +++ b/.arcconfig @@ -0,0 +1,4 @@ +{ + "phabricator.uri" : "https://phabricator.kde.org/", + "project.name" : "digiKam" +} diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ HTML Gallery : New Vanilla theme to emulate export to HTML from Adobe LightRoom. HTML Gallery : New Blue Frame theme. +HTML Gallery : New Kiosk-Mode theme. ***************************************************************************************************** BUGFIXES: @@ -225,4 +226,7 @@ 196 ==> 394168 - OSM Search Yields No Results. 197 ==> 377719 - Cannot rename file with overwrite [patch]. 198 ==> 388002 - remove kio related legacy [patch] -199 ==> +199 ==> 394242 - Import settings unneccesarily asks to overwrite image database, and crashes when I decline. +200 ==> 394278 - A slideshow theme for kiosk mode. +201 ==> 340389 - digiKam crashes while editing pictures for color balancing on OSX [patch]. +202 ==> diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![Coverity Scan Build Status](https://scan.coverity.com/projects/285/badge.svg)](https://scan.coverity.com/projects/digikam) [![Phabricator Build Status](https://build.kde.org/job/Extragear%20digikam%20kf5-qt5%20SUSEQt5.9/badge/icon)](https://build.kde.org/job/Extragear%20digikam%20kf5-qt5%20SUSEQt5.9/) +If you are reading this on Github, be aware that this is just a mirror. Our real code repository [is located here](https://phabricator.kde.org/source/digikam/) + # About digiKam is an advanced open-source digital photo management application that runs on Linux, Windows, and MacOS. diff --git a/core/app/CMakeLists.txt b/core/app/CMakeLists.txt --- a/core/app/CMakeLists.txt +++ b/core/app/CMakeLists.txt @@ -350,6 +350,7 @@ utils/contextmenuhelper.cpp utils/digikam_debug.cpp utils/componentsinfo.cpp + utils/groupingviewimplementation.cpp views/tableview/tableview.cpp views/tableview/tableview_treeview.cpp diff --git a/core/app/date/datefolderview.h b/core/app/date/datefolderview.h --- a/core/app/date/datefolderview.h +++ b/core/app/date/datefolderview.h @@ -48,7 +48,7 @@ template class AlbumPointer; -class DateFolderView: public DVBox, public StateSavingObject +class DateFolderView : public DVBox, public StateSavingObject { Q_OBJECT diff --git a/core/app/date/ddateedit.h b/core/app/date/ddateedit.h --- a/core/app/date/ddateedit.h +++ b/core/app/date/ddateedit.h @@ -38,20 +38,20 @@ { /** - A date editing widget that consists of an editable combo box. - The combo box contains the date in text form, and clicking the combo - box arrow will display a 'popup' style date picker. - - This widget also supports advanced features like allowing the user - to type in the day name to get the date. The following keywords - are supported (in the native language): tomorrow, yesterday, today, - Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. - - @author Cornelius Schumacher - @author Mike Pilone - @author David Jarvie - @author Tobias Koenig -*/ + * A date editing widget that consists of an editable combo box. + * The combo box contains the date in text form, and clicking the combo + * box arrow will display a 'popup' style date picker. + * + * This widget also supports advanced features like allowing the user + * to type in the day name to get the date. The following keywords + * are supported (in the native language): tomorrow, yesterday, today, + * Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. + * + * @author Cornelius Schumacher + * @author Mike Pilone + * @author David Jarvie + * @author Tobias Koenig + */ class DDateEdit : public QComboBox { Q_OBJECT @@ -62,41 +62,41 @@ virtual ~DDateEdit(); /** - @return The date entered. This date could be invalid, - you have to check validity yourself. + * @return The date entered. This date could be invalid, + * you have to check validity yourself. */ QDate date() const; /** - Sets whether the widget is read-only for the user. If read-only, - the date picker pop-up is inactive, and the displayed date cannot be edited. - - @param readOnly True to set the widget read-only, false to set it read-write. + * Sets whether the widget is read-only for the user. If read-only, + * the date picker pop-up is inactive, and the displayed date cannot be edited. + * + * @param readOnly True to set the widget read-only, false to set it read-write. */ void setReadOnly(bool readOnly); /** - @return True if the widget is read-only, false if read-write. + * @return True if the widget is read-only, false if read-write. */ bool isReadOnly() const; virtual void showPopup(); Q_SIGNALS: /** - This signal is emitted whenever the user modifies the date. - The passed date can be invalid. + * This signal is emitted whenever the user modifies the date. + * The passed date can be invalid. */ void dateChanged(const QDate& date); public Q_SLOTS: /** - Sets the date. - - @param date The new date to display. This date must be valid or - it will not be set + * Sets the date. + * + * @param date The new date to display. This date must be valid or + * it will not be set */ void setDate(const QDate& date); @@ -113,21 +113,21 @@ virtual void mousePressEvent(QMouseEvent*); /** - Sets the date, without altering the display. - This method is used internally to set the widget's date value. - As a virtual method, it allows derived classes to perform additional validation - on the date value before it is set. Derived classes should return true if - QDate::isValid(@p date) returns false. - - @param date The new date to set. - @return True if the date was set, false if it was considered invalid and - remains unchanged. + * Sets the date, without altering the display. + * This method is used internally to set the widget's date value. + * As a virtual method, it allows derived classes to perform additional validation + * on the date value before it is set. Derived classes should return true if + * QDate::isValid(@p date) returns false. + * + * @param date The new date to set. + * @return True if the date was set, false if it was considered invalid and + * remains unchanged. */ virtual bool assignDate(const QDate& date); /** - Fills the keyword map. Re-implement it if you want additional - keywords. + * Fills the keyword map. Re-implement it if you want additional + * keywords. */ void setupKeywords(); diff --git a/core/app/date/ddatepicker.h b/core/app/date/ddatepicker.h --- a/core/app/date/ddatepicker.h +++ b/core/app/date/ddatepicker.h @@ -45,9 +45,8 @@ /** * Provides a widget for calendar date input. - * */ -class DIGIKAM_EXPORT DDatePicker: public QFrame +class DIGIKAM_EXPORT DDatePicker : public QFrame { Q_OBJECT Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true) @@ -71,18 +70,19 @@ */ virtual ~DDatePicker(); - /** The size hint for date pickers. The size hint recommends the - * minimum size of the widget so that all elements may be placed - * without clipping. This sometimes looks ugly, so when using the - * size hint, try adding 28 to each of the reported numbers of - * pixels. + /** + * The size hint for date pickers. The size hint recommends the + * minimum size of the widget so that all elements may be placed + * without clipping. This sometimes looks ugly, so when using the + * size hint, try adding 28 to each of the reported numbers of + * pixels. */ QSize sizeHint() const Q_DECL_OVERRIDE; /** * Sets the date. * - * @returns @p false and does not change anything if the date given is invalid. + * @returns @p false and does not change anything if the date given is invalid. */ bool setDate(const QDate& date); @@ -99,7 +99,7 @@ /** * Sets the font size of the widgets elements. - **/ + */ void setFontSize(int); /** @@ -149,30 +149,34 @@ Q_SIGNALS: - /** This signal is emitted each time the selected date is changed. - * Usually, this does not mean that the date has been entered, - * since the date also changes, for example, when another month is - * selected. - * @see dateSelected + /** + * This signal is emitted each time the selected date is changed. + * Usually, this does not mean that the date has been entered, + * since the date also changes, for example, when another month is + * selected. + * @see dateSelected */ void dateChanged(const QDate& date); - /** This signal is emitted each time a day has been selected by - * clicking on the table (hitting a day in the current month). It - * has the same meaning as dateSelected() in older versions of - * DDatePicker. + /** + * This signal is emitted each time a day has been selected by + * clicking on the table (hitting a day in the current month). It + * has the same meaning as dateSelected() in older versions of + * DDatePicker. */ void dateSelected(const QDate& date); - /** This signal is emitted when enter is pressed and a VALID date - * has been entered before into the line edit. Connect to both - * dateEntered() and dateSelected() to receive all events where the - * user really enters a date. + /** + * This signal is emitted when enter is pressed and a VALID date + * has been entered before into the line edit. Connect to both + * dateEntered() and dateSelected() to receive all events where the + * user really enters a date. */ void dateEntered(const QDate& date); - /** This signal is emitted when the day has been selected by - * clicking on it in the table. + /** + * This signal is emitted when the day has been selected by + * clicking on it in the table. */ void tableClicked(); diff --git a/core/app/date/ddatepickerpopup.h b/core/app/date/ddatepickerpopup.h --- a/core/app/date/ddatepickerpopup.h +++ b/core/app/date/ddatepickerpopup.h @@ -39,19 +39,19 @@ { /** - @short This menu helps the user to select a date quickly. - - This menu helps the user to select a date quickly. It offers various ways of selecting, e.g. with a DDatePicker or with words like "Tomorrow". - - The available items are: - - @li NoDate: A menu-item with "No Date". If chosen, the datepicker will emit a null QDate. - @li DatePicker: Show a DDatePicker-widget. - @li Words: Show items like "Today", "Tomorrow" or "Next Week". - - When supplying multiple items, separate each item with a bitwise OR. -*/ -class DDatePickerPopup: public QMenu + * @short This menu helps the user to select a date quickly. + * + * This menu helps the user to select a date quickly. It offers various ways of selecting, e.g. with a DDatePicker or with words like "Tomorrow". + * + * The available items are: + * + * @li NoDate: A menu-item with "No Date". If chosen, the datepicker will emit a null QDate. + * @li DatePicker: Show a DDatePicker-widget. + * @li Words: Show items like "Today", "Tomorrow" or "Next Week". + * + * When supplying multiple items, separate each item with a bitwise OR. + */ +class DDatePickerPopup : public QMenu { Q_OBJECT @@ -69,40 +69,44 @@ public: /** - A constructor for the DDatePickerPopup. - - @param items List of all desirable items, separated with a bitwise OR. - @param date Initial date of datepicker-widget. - @param parent The object's parent. - */ - explicit DDatePickerPopup(Items items = DatePicker, const QDate& date = QDate::currentDate(), - QWidget* const parent = 0); - virtual ~DDatePickerPopup(); + * A constructor for the DDatePickerPopup. + * + * @param items List of all desirable items, separated with a bitwise OR. + * @param date Initial date of datepicker-widget. + * @param parent The object's parent. + */ + DDatePickerPopup(Items items = DatePicker, + const QDate& date = QDate::currentDate(), + QWidget* const parent = 0); + ~DDatePickerPopup(); /** - @return A pointer to the private variable mDatePicker, an instance of - DDatePicker. - */ + * @return A pointer to the private variable mDatePicker, an instance of + * DDatePicker. + */ DDatePicker* datePicker() const; void setDate(const QDate& date); #if 0 - /** Set items which should be shown and rebuilds the menu afterwards. Only if the menu is not visible. - @param items List of all desirable items, separated with a bitwise OR. - */ + /** + * Set items which should be shown and rebuilds the menu afterwards. Only if the menu is not visible. + * @param items List of all desirable items, separated with a bitwise OR. + */ void setItems(int items = 1); #endif - /** @return Returns the bitwise result of the active items in the popup. */ + /** + * @return Returns the bitwise result of the active items in the popup. + */ int items() const; Q_SIGNALS: /** - This signal emits the new date (selected with datepicker or other - menu-items). - */ + * This signal emits the new date (selected with datepicker or other + * menu-items). + */ void dateChanged(const QDate&); protected Q_SLOTS: diff --git a/core/app/date/ddatetimeedit.h b/core/app/date/ddatetimeedit.h --- a/core/app/date/ddatetimeedit.h +++ b/core/app/date/ddatetimeedit.h @@ -53,7 +53,7 @@ * @param parent the parent widget * @param name the name of the widget */ - DDateTimeEdit(QWidget* const parent, const QString& name); + explicit DDateTimeEdit(QWidget* const parent, const QString& name); /** * destructor @@ -74,8 +74,8 @@ Q_SIGNALS: /** - * This signal is emitted whenever the user modifies the date or time. - * The passed date and time can be invalid. + * This signal is emitted whenever the user modifies the date or time. + * The passed date and time can be invalid. */ void dateTimeChanged(const QDateTime& dateTime); diff --git a/core/app/date/timelinewidget.h b/core/app/date/timelinewidget.h --- a/core/app/date/timelinewidget.h +++ b/core/app/date/timelinewidget.h @@ -83,7 +83,9 @@ QDateTime cursorDateTime() const; int cursorInfo(QString& infoDate) const; - /** Return a list of Date-Range based on selection performed on days-map */ + /** + * Return a list of Date-Range based on selection performed on days-map + */ DateRangeList selectedDateRange(int& totalCount) const; void setSelectedDateRange(const DateRangeList& list); diff --git a/core/app/items/digikamimageview.h b/core/app/items/digikamimageview.h --- a/core/app/items/digikamimageview.h +++ b/core/app/items/digikamimageview.h @@ -27,15 +27,18 @@ // Local includes +#include "applicationsettings.h" #include "imagecategorizedview.h" #include "imageviewutilities.h" +#include "groupingviewimplementation.h" namespace Digikam { class ImageViewUtilities; +class ImageInfoList; -class DigikamImageView : public ImageCategorizedView +class DigikamImageView : public ImageCategorizedView, public GroupingViewImplementation { Q_OBJECT @@ -50,6 +53,12 @@ virtual void setThumbnailSize(const ThumbnailSize& size); + ImageInfoList allImageInfos(bool grouping = false) const; + ImageInfoList selectedImageInfos(bool grouping = false) const; + ImageInfoList selectedImageInfosCurrentFirst(bool grouping = false) const; + bool allNeedGroupResolving(const ApplicationSettings::OperationType type) const; + bool selectedNeedGroupResolving(const ApplicationSettings::OperationType type) const; + public Q_SLOTS: void openFile(const ImageInfo& info); @@ -95,6 +104,12 @@ virtual void showContextMenu(QContextMenuEvent* event); virtual void slotSetupChanged(); + virtual bool hasHiddenGroupedImages(const ImageInfo& info) const; + + ImageInfoList imageInfos(const QList& indexes, + ApplicationSettings::OperationType type + = ApplicationSettings::Unspecified) const; + private Q_SLOTS: void slotRotateLeft(const QList&); diff --git a/core/app/items/digikamimageview.cpp b/core/app/items/digikamimageview.cpp --- a/core/app/items/digikamimageview.cpp +++ b/core/app/items/digikamimageview.cpp @@ -179,6 +179,46 @@ ImageCategorizedView::setThumbnailSize(size); } +ImageInfoList DigikamImageView::allImageInfos(bool grouping) const +{ + if (grouping) + { + return resolveGrouping(ImageCategorizedView::allImageInfos()); + } + + return ImageCategorizedView::allImageInfos(); +} + +ImageInfoList DigikamImageView::selectedImageInfos(bool grouping) const +{ + if (grouping) + { + return resolveGrouping(ImageCategorizedView::selectedImageInfos()); + } + + return ImageCategorizedView::selectedImageInfos(); +} + +ImageInfoList DigikamImageView::selectedImageInfosCurrentFirst(bool grouping) const +{ + if (grouping) + { + return resolveGrouping(ImageCategorizedView::selectedImageInfosCurrentFirst()); + } + + return ImageCategorizedView::selectedImageInfosCurrentFirst(); +} + +bool DigikamImageView::allNeedGroupResolving(const ApplicationSettings::OperationType type) const +{ + return needGroupResolving(type, allImageInfos()); +} + +bool DigikamImageView::selectedNeedGroupResolving(const ApplicationSettings::OperationType type) const +{ + return needGroupResolving(type, selectedImageInfos()); +} + int DigikamImageView::fitToWidthIcons() { return delegate()->calculatethumbSizeToFit(viewport()->size().width()); @@ -195,6 +235,24 @@ ImageCategorizedView::slotSetupChanged(); } +bool DigikamImageView::hasHiddenGroupedImages(const ImageInfo& info) const +{ + return info.hasGroupedImages() && !imageFilterModel()->isGroupOpen(info.id()); +} + +ImageInfoList DigikamImageView::imageInfos(const QList& indexes, + ApplicationSettings::OperationType type) const +{ + ImageInfoList infos = ImageCategorizedView::imageInfos(indexes); + + if (needGroupResolving(type, infos)) + { + return resolveGrouping(infos); + } + + return infos; +} + void DigikamImageView::setFaceMode(bool on) { d->faceMode = on; @@ -389,8 +447,12 @@ void DigikamImageView::rename() { - bool grouping = needGroupResolving(ApplicationSettings::Rename); - QList urls = selectedUrls(grouping); + ImageInfoList infos = selectedImageInfos(); + if (needGroupResolving(ApplicationSettings::Rename, infos)) + { + infos = resolveGrouping(infos); + } + QList urls = infos.toImageUrlList(); bool loop = false; NewNamesList newNamesList; @@ -409,7 +471,7 @@ if (!loop) { - QUrl nextUrl = nextInOrder(selectedImageInfos(grouping).last(), 1).fileUrl(); + QUrl nextUrl = nextInOrder(infos.last(),1).fileUrl(); setCurrentUrl(nextUrl); loop = true; } diff --git a/core/app/items/digikamimageview_p.h b/core/app/items/digikamimageview_p.h --- a/core/app/items/digikamimageview_p.h +++ b/core/app/items/digikamimageview_p.h @@ -54,7 +54,7 @@ public: explicit Private(DigikamImageView* const qq); - virtual ~Private(); + ~Private(); void updateOverlays(); void triggerRotateAction(const char* actionName); @@ -80,6 +80,10 @@ private: DigikamImageView* q_ptr; + +private: + + Private() {}; // disable default constuctor. }; } // namespace Digikam diff --git a/core/app/items/imagecategorizedview.h b/core/app/items/imagecategorizedview.h --- a/core/app/items/imagecategorizedview.h +++ b/core/app/items/imagecategorizedview.h @@ -27,7 +27,6 @@ // Local includes -#include "applicationsettings.h" #include "imageinfo.h" #include "itemviewcategorized.h" #include "thumbnailsize.h" @@ -78,23 +77,10 @@ ImageInfo currentInfo() const; QUrl currentUrl() const; - ImageInfo imageInfo(const QModelIndex& index) const; - ImageInfoList imageInfos(const QList& indexes, - bool grouping = false) const; - ImageInfoList imageInfos(const QList& indexes, - ApplicationSettings::OperationType type) const; - - ImageInfoList selectedImageInfos(bool grouping = false) const; - ImageInfoList selectedImageInfos(ApplicationSettings::OperationType type) const; - ImageInfoList selectedImageInfosCurrentFirst(bool grouping = false) const; - QList selectedUrls(bool grouping = false) const; - QList selectedUrls(ApplicationSettings::OperationType type) const; - - ImageInfoList allImageInfos(bool grouping = false) const; - QList allUrls(bool grouping = false) const; - - bool needGroupResolving(ApplicationSettings::OperationType type, - bool all = false) const; + ImageInfoList allImageInfos() const; + QList allUrls() const; + ImageInfoList selectedImageInfos() const; + ImageInfoList selectedImageInfosCurrentFirst() const; /** Selects the index as current and scrolls to it. */ @@ -218,13 +204,8 @@ virtual void showContextMenuOnInfo(QContextMenuEvent* event, const ImageInfo& info); virtual void showContextMenuOnIndex(QContextMenuEvent* event, const QModelIndex& index); - // Adds group members when appropriate - ImageInfoList resolveGrouping(const QModelIndexList& indexes) const; - ImageInfoList resolveGrouping(const ImageInfoList& infos) const; - bool needGroupResolving(ApplicationSettings::OperationType type, - const QList& indexes) const; - bool needGroupResolving(ApplicationSettings::OperationType type, - const ImageInfoList& infos) const; + ImageInfo imageInfo(const QModelIndex& index) const; + ImageInfoList imageInfos(const QList& indexes) const; private Q_SLOTS: diff --git a/core/app/items/imagecategorizedview.cpp b/core/app/items/imagecategorizedview.cpp --- a/core/app/items/imagecategorizedview.cpp +++ b/core/app/items/imagecategorizedview.cpp @@ -303,32 +303,27 @@ return d->filterModel->imageInfo(index); } -ImageInfoList ImageCategorizedView::imageInfos(const QList& indexes, - ApplicationSettings::OperationType type) const +ImageInfoList ImageCategorizedView::imageInfos(const QList& indexes) const { - return imageInfos(indexes, needGroupResolving(type, indexes)); + return d->filterModel->imageInfos(indexes); } -ImageInfoList ImageCategorizedView::imageInfos(const QList& indexes, bool grouping) const +ImageInfoList ImageCategorizedView::allImageInfos() const { - if (grouping) { - return resolveGrouping(indexes); - } - return d->filterModel->imageInfos(indexes); + return d->filterModel->imageInfosSorted(); } -ImageInfoList ImageCategorizedView::selectedImageInfos(bool grouping) const +QList ImageCategorizedView::allUrls() const { - return imageInfos(selectedIndexes(), grouping); + return allImageInfos().toImageUrlList(); } -ImageInfoList ImageCategorizedView::selectedImageInfos( - ApplicationSettings::OperationType type) const +ImageInfoList ImageCategorizedView::selectedImageInfos() const { - return selectedImageInfos(needGroupResolving(type)); + return imageInfos(selectedIndexes()); } -ImageInfoList ImageCategorizedView::selectedImageInfosCurrentFirst(bool grouping) const +ImageInfoList ImageCategorizedView::selectedImageInfosCurrentFirst() const { QModelIndexList indexes = selectedIndexes(); const QModelIndex current = currentIndex(); @@ -344,61 +339,9 @@ } } - if (grouping) { - return resolveGrouping(indexes); - } return imageInfos(indexes); } -ImageInfoList ImageCategorizedView::allImageInfos(bool grouping) const -{ - if (grouping) { - return resolveGrouping(d->filterModel->imageInfosSorted()); - } - return d->filterModel->imageInfosSorted(); -} - -QList ImageCategorizedView::allUrls(bool grouping) const -{ - ImageInfoList infos = allImageInfos(grouping); - QList urls; - - foreach(const ImageInfo& info, infos) - { - urls << info.fileUrl(); - } - - return urls; -} - -bool ImageCategorizedView::needGroupResolving(ApplicationSettings::OperationType type, bool all) const -{ - if (all) - { - return needGroupResolving(type, allImageInfos()); - } - - return needGroupResolving(type, selectedIndexes()); -} - -QList ImageCategorizedView::selectedUrls(bool grouping) const -{ - ImageInfoList infos = selectedImageInfos(grouping); - QList urls; - - foreach(const ImageInfo& info, infos) - { - urls << info.fileUrl(); - } - - return urls; -} - -QList ImageCategorizedView::selectedUrls(ApplicationSettings::OperationType type) const -{ - return selectedUrls(needGroupResolving(type)); -} - void ImageCategorizedView::toIndex(const QUrl& url) { ItemViewCategorized::toIndex(d->filterModel->indexForPath(url.toLocalFile())); @@ -765,61 +708,6 @@ // implemented in subclass } -ImageInfoList ImageCategorizedView::resolveGrouping(const QModelIndexList& indexes) const -{ - return resolveGrouping(imageInfos(indexes)); -} - -ImageInfoList ImageCategorizedView::resolveGrouping(const ImageInfoList& infos) const -{ - ImageInfoList outInfos; - - foreach(const ImageInfo& info, infos) - { - outInfos << info; - - if (info.hasGroupedImages() && !imageFilterModel()->isGroupOpen(info.id())) - { - outInfos << info.groupedImages(); - } - } - - return outInfos; -} - -bool ImageCategorizedView::needGroupResolving(ApplicationSettings::OperationType type, - const QList& indexes) const -{ - return needGroupResolving(type, imageInfos(indexes)); -} - -bool ImageCategorizedView::needGroupResolving(ApplicationSettings::OperationType type, - const ImageInfoList& infos) const -{ - ApplicationSettings::ApplyToEntireGroup applyAll = - ApplicationSettings::instance()->getGroupingOperateOnAll(type); - - if (applyAll == ApplicationSettings::No) - { - return false; - } - else if (applyAll == ApplicationSettings::Yes) - { - return true; - } - - foreach(const ImageInfo& info, infos) - { - if (info.hasGroupedImages() && !imageFilterModel()->isGroupOpen(info.id())) - { - // Ask whether should be performed on all and return info if no - return ApplicationSettings::instance()->askGroupingOperateOnAll(type); - } - } - - return false; -} - void ImageCategorizedView::paintEvent(QPaintEvent* e) { // We want the thumbnails to be loaded in order. diff --git a/core/app/items/overlays/assignnameoverlay.h b/core/app/items/overlays/assignnameoverlay.h --- a/core/app/items/overlays/assignnameoverlay.h +++ b/core/app/items/overlays/assignnameoverlay.h @@ -81,7 +81,11 @@ void updatePosition(); void updateFace(); +/* +private: + AssignNameOverlay() {}; // Disable default constructor. +*/ private: class Private; diff --git a/core/app/utils/groupingviewimplementation.h b/core/app/utils/groupingviewimplementation.h new file mode 100644 --- /dev/null +++ b/core/app/utils/groupingviewimplementation.h @@ -0,0 +1,55 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2017-11-02 + * Description : Implementation of grouping specific functions for views + * + * Copyright (C) 2017 by Simon Frei + * + * 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 VIEWGROUPINGIMPLEMENTATION_H +#define VIEWGROUPINGIMPLEMENTATION_H + +// Local includes + +#include "applicationsettings.h" +#include "digikam_export.h" + +namespace Digikam +{ + +class ImageInfo; +class ImageInfoList; + +class DIGIKAM_EXPORT GroupingViewImplementation +{ +public: + + virtual ~GroupingViewImplementation() {} + + // must be implemented by parent view + virtual bool hasHiddenGroupedImages(const ImageInfo&) const {return false;} + + bool needGroupResolving(ApplicationSettings::OperationType type, + const ImageInfoList& infos) const; + ImageInfoList resolveGrouping(const ImageInfoList& infos) const; + ImageInfoList getHiddenGroupedInfos(const ImageInfoList& infos) const; +}; + +} // namespace Digikam + +#endif /* VIEWGROUPINGIMPLEMENTATION_H */ diff --git a/core/app/utils/groupingviewimplementation.cpp b/core/app/utils/groupingviewimplementation.cpp new file mode 100644 --- /dev/null +++ b/core/app/utils/groupingviewimplementation.cpp @@ -0,0 +1,94 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2017-11-02 + * Description : Implementation of grouping specific functions for views + * + * Copyright (C) 2017 by Simon Frei + * + * 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. + * + * ============================================================ */ + +#include "groupingviewimplementation.h" + +// Local includes + +#include "imageinfolist.h" + +// Qt includes + +#include + +namespace Digikam +{ + +bool GroupingViewImplementation::needGroupResolving(ApplicationSettings::OperationType type, const ImageInfoList& infos) const +{ + ApplicationSettings::ApplyToEntireGroup applyAll = + ApplicationSettings::instance()->getGroupingOperateOnAll(type); + + if (applyAll == ApplicationSettings::No) + { + return false; + } + + foreach(const ImageInfo& info, infos) + { + if (hasHiddenGroupedImages(info)) + { + if (applyAll == ApplicationSettings::Yes) + { + return true; + } + return ApplicationSettings::instance()->askGroupingOperateOnAll(type); + } + } + + return false; +} + +ImageInfoList GroupingViewImplementation::resolveGrouping(const ImageInfoList& infos) const +{ + ImageInfoList outInfos; + + foreach(const ImageInfo& info, infos) + { + outInfos << info; + + if (hasHiddenGroupedImages(info)) + { + outInfos << info.groupedImages(); + } + } + + return outInfos; +} + +ImageInfoList GroupingViewImplementation::getHiddenGroupedInfos(const ImageInfoList& infos) const +{ + ImageInfoList outInfos; + + foreach(const ImageInfo& info, infos) + { + if (hasHiddenGroupedImages(info)) + { + outInfos << info.groupedImages(); + } + } + + return outInfos; +} + +} // namespace Digikam diff --git a/core/app/views/digikamview.h b/core/app/views/digikamview.h --- a/core/app/views/digikamview.h +++ b/core/app/views/digikamview.h @@ -119,17 +119,12 @@ ImageInfoList allInfo(const ApplicationSettings::OperationType type) const; /** - * Query whether the operation to be performed on currently selected items - * (all=false, default) or all items in the currently active view (all=true) - * should be performed on all grouped items or just the first. - * - * @brief needGroupResolving - * @param type Type of operation to be performed. - * @param all Whether to apply to all items in the current view or just selected - * @return Whether to perform operation on all grouped items or just the first + * Query whether the operation to be performed on currently selected or all + * all items in the currently active view should be performed on all + * grouped items or just the first. */ - bool needGroupResolving(const ApplicationSettings::OperationType type, - const bool all = false) const; + bool allNeedGroupResolving(const ApplicationSettings::OperationType type) const; + bool selectedNeedGroupResolving(const ApplicationSettings::OperationType type) const; double zoomMin() const; double zoomMax() const; diff --git a/core/app/views/digikamview.cpp b/core/app/views/digikamview.cpp --- a/core/app/views/digikamview.cpp +++ b/core/app/views/digikamview.cpp @@ -803,31 +803,17 @@ { /// @todo This functions seems not to be used anywhere right now - switch (viewMode()) - { - case StackedView::TableViewMode: - return d->tableView->allUrls(grouping); - - default: - return d->iconView->allUrls(grouping); - } + return allInfo(grouping).toImageUrlList(); } QList DigikamView::selectedUrls(bool grouping) const { - switch (viewMode()) - { - case StackedView::TableViewMode: - return d->tableView->selectedUrls(grouping); - - default: - return d->iconView->selectedUrls(grouping); - } + return selectedInfoList(grouping).toImageUrlList(); } QList DigikamView::selectedUrls(const ApplicationSettings::OperationType type) const { - return selectedUrls(needGroupResolving(type)); + return selectedInfoList(type).toImageUrlList(); } void DigikamView::showSideBars() @@ -1794,12 +1780,12 @@ void DigikamView::slotLightTable() { - bool grouping = needGroupResolving(ApplicationSettings::LightTable); + bool grouping = selectedNeedGroupResolving(ApplicationSettings::LightTable); const ImageInfoList selectedList = selectedInfoList(false, grouping); if (selectedList.isEmpty()) { - grouping = needGroupResolving(ApplicationSettings::LightTable, true); + grouping = allNeedGroupResolving(ApplicationSettings::LightTable); } const ImageInfoList allInfoList = allInfo(grouping); @@ -1810,7 +1796,7 @@ void DigikamView::slotQueueMgr() { - bool grouping = needGroupResolving(ApplicationSettings::BQM); + bool grouping = selectedNeedGroupResolving(ApplicationSettings::BQM); ImageInfoList imageInfoList = selectedInfoList(false, grouping); ImageInfo singleInfo = currentInfo(); @@ -1821,7 +1807,7 @@ if (singleInfo.isNull()) { - grouping = needGroupResolving(ApplicationSettings::BQM, true); + grouping = allNeedGroupResolving(ApplicationSettings::BQM); const ImageInfoList allItems = allInfo(grouping); if (!allItems.isEmpty()) @@ -2444,15 +2430,15 @@ ImageInfoList DigikamView::selectedInfoList(const ApplicationSettings::OperationType type, const bool currentFirst) const { - return selectedInfoList(currentFirst, needGroupResolving(type)); + return selectedInfoList(currentFirst, selectedNeedGroupResolving(type)); } ImageInfoList DigikamView::allInfo(const bool grouping) const { switch (viewMode()) { case StackedView::TableViewMode: - return d->tableView->allInfo(grouping); + return d->tableView->allImageInfos(grouping); case StackedView::MapWidgetMode: case StackedView::PreviewImageMode: @@ -2468,23 +2454,38 @@ ImageInfoList DigikamView::allInfo(const ApplicationSettings::OperationType type) const { - return allInfo(needGroupResolving(type, true)); + return allInfo(allNeedGroupResolving(type)); } -bool DigikamView::needGroupResolving(const ApplicationSettings::OperationType type, - const bool all) const +bool DigikamView::allNeedGroupResolving(const ApplicationSettings::OperationType type) const { switch (viewMode()) { case StackedView::TableViewMode: - return d->tableView->needGroupResolving(type, all); + return d->tableView->allNeedGroupResolving(type); case StackedView::MapWidgetMode: case StackedView::PreviewImageMode: case StackedView::MediaPlayerMode: case StackedView::IconViewMode: // all of these modes use the same selection model and data as the IconViewMode - return d->iconView->needGroupResolving(type, all); + return d->iconView->allNeedGroupResolving(type); + default: + return false; + } +} +bool DigikamView::selectedNeedGroupResolving(const ApplicationSettings::OperationType type) const +{ + switch (viewMode()) + { + case StackedView::TableViewMode: + return d->tableView->selectedNeedGroupResolving(type); + case StackedView::MapWidgetMode: + case StackedView::PreviewImageMode: + case StackedView::MediaPlayerMode: + case StackedView::IconViewMode: + // all of these modes use the same selection model and data as the IconViewMode + return d->iconView->selectedNeedGroupResolving(type); default: return false; } diff --git a/core/app/views/tableview/tableview.h b/core/app/views/tableview/tableview.h --- a/core/app/views/tableview/tableview.h +++ b/core/app/views/tableview/tableview.h @@ -67,8 +67,6 @@ ThumbnailSize getThumbnailSize() const; ImageInfo currentInfo() const; Album* currentAlbum() const; - ImageInfoList allInfo(bool grouping = false) const; - QList allUrls(bool grouping = false) const; int numberOfSelectedItems() const; ImageInfo nextInfo() const; ImageInfo previousInfo() const; @@ -78,15 +76,11 @@ void clearSelection(); void invertSelection(); - QModelIndexList selectedIndexesCurrentFirst() const; - ImageInfoList selectedImageInfos(bool grouping = false) const; - ImageInfoList selectedImageInfos(ApplicationSettings::OperationType type) const; - ImageInfoList selectedImageInfosCurrentFirst(bool grouping = false) const; - QList selectedImageIdsCurrentFirst(bool grouping = false) const; - QList selectedUrls(bool grouping = false) const; - - bool needGroupResolving(ApplicationSettings::OperationType type, - bool all = false) const; + ImageInfoList allImageInfos(bool grouping = false) const; + ImageInfoList selectedImageInfos(bool grouping = false) const; + ImageInfoList selectedImageInfosCurrentFirst(bool grouping = false) const; + bool allNeedGroupResolving(const ApplicationSettings::OperationType type) const; + bool selectedNeedGroupResolving(const ApplicationSettings::OperationType type) const; protected: @@ -96,10 +90,6 @@ virtual bool eventFilter(QObject* watched, QEvent* event); QList getExtraGroupingActions(); - // Adds group members when appropriate - ImageInfoList resolveGrouping(const QList& indexes) const; - ImageInfoList resolveGrouping(const ImageInfoList& infos) const; - public Q_SLOTS: void slotGoToRow(const int rowNumber, const bool relativeMove); diff --git a/core/app/views/tableview/tableview.cpp b/core/app/views/tableview/tableview.cpp --- a/core/app/views/tableview/tableview.cpp +++ b/core/app/views/tableview/tableview.cpp @@ -39,6 +39,7 @@ #include "advancedrenamedialog.h" #include "advancedrenameprocessdialog.h" +#include "applicationsettings.h" #include "contextmenuhelper.h" #include "digikam_debug.h" #include "fileactionmngr.h" @@ -183,7 +184,7 @@ } else { - d->imageViewUtilities->openInfos(info, allInfo(), currentAlbum()); + d->imageViewUtilities->openInfos(info, allImageInfos(), currentAlbum()); } } else @@ -264,16 +265,26 @@ return s->tableViewModel->imageInfo(s->tableViewSelectionModel->currentIndex()); } -ImageInfoList TableView::allInfo(bool grouping) const +ImageInfoList TableView::allImageInfos(bool grouping) const { if (grouping) { - return resolveGrouping(s->tableViewModel->allImageInfo()); + return s->treeView->resolveGrouping(s->tableViewModel->allImageInfo()); } return s->tableViewModel->allImageInfo(); } +bool TableView::allNeedGroupResolving(const ApplicationSettings::OperationType type) const +{ + return s->treeView->needGroupResolving(type, allImageInfos()); +} + +bool TableView::selectedNeedGroupResolving(const ApplicationSettings::OperationType type) const +{ + return s->treeView->needGroupResolving(type, selectedImageInfos()); +} + void TableView::slotDeleteSelected(const ImageViewUtilities::DeleteMode deleteMode) { const ImageInfoList infoList = selectedImageInfos(true); @@ -345,19 +356,6 @@ s->tableViewModel->setGroupingMode(newGroupingMode); } -QList TableView::allUrls(bool grouping) const -{ - const ImageInfoList infos = allInfo(grouping); - QList resultList; - - foreach(const ImageInfo& info, infos) - { - resultList << info.fileUrl(); - } - - return resultList; -} - int TableView::numberOfSelectedItems() const { return s->tableViewSelectionModel->selectedRows().count(); @@ -569,18 +567,14 @@ ImageInfoList TableView::selectedImageInfos(bool grouping) const { + ImageInfoList infos = s->tableViewModel->imageInfos(s->tableViewSelectionModel->selectedRows()); if (grouping) { - return resolveGrouping(s->tableViewSelectionModel->selectedRows()); + return s->treeView->resolveGrouping(infos); } - return s->tableViewModel->imageInfos(s->tableViewSelectionModel->selectedRows()); -} - -ImageInfoList TableView::selectedImageInfos(ApplicationSettings::OperationType type) const -{ - return selectedImageInfos(needGroupResolving(type)); + return infos; } -QModelIndexList TableView::selectedIndexesCurrentFirst() const +ImageInfoList TableView::selectedImageInfosCurrentFirst(bool grouping) const { QModelIndexList indexes = s->tableViewSelectionModel->selectedRows(); const QModelIndex current = s->tableViewModel->toCol0(s->tableViewSelectionModel->currentIndex()); @@ -596,100 +590,22 @@ } } - return indexes; -} - -ImageInfoList TableView::selectedImageInfosCurrentFirst(bool grouping) const -{ if (grouping) { - return resolveGrouping(selectedIndexesCurrentFirst()); - } - return s->tableViewModel->imageInfos(selectedIndexesCurrentFirst()); -} - -QList TableView::selectedImageIdsCurrentFirst(bool grouping) const -{ - return selectedImageInfosCurrentFirst(grouping).toImageIdList(); -} - -QList TableView::selectedUrls(bool grouping) const -{ - return selectedImageInfos(grouping).toImageUrlList(); -} - -ImageInfoList TableView::resolveGrouping(const QList& indexes) const -{ - return resolveGrouping(s->tableViewModel->imageInfos(indexes)); -} - -ImageInfoList TableView::resolveGrouping(const ImageInfoList& infos) const -{ - ImageInfoList out; - - foreach(const ImageInfo& info, infos) - { - QModelIndex index = s->tableViewModel->indexFromImageId(info.id(), 0); - - out << info; - - if (info.hasGroupedImages() - && (s->tableViewModel->groupingMode() == s->tableViewModel->GroupingMode::GroupingHideGrouped - || (s->tableViewModel->groupingMode() == s->tableViewModel->GroupingMode::GroupingShowSubItems - && !s->treeView->isExpanded(index)))) - { - out << info.groupedImages(); - } + return s->treeView->resolveGrouping(s->tableViewModel->imageInfos(indexes)); } - - return out; + return s->tableViewModel->imageInfos(indexes); } -bool TableView::needGroupResolving(ApplicationSettings::OperationType type, bool all) const +void TableView::rename() { - ApplicationSettings::ApplyToEntireGroup applyAll = - ApplicationSettings::instance()->getGroupingOperateOnAll(type); - - if (applyAll == ApplicationSettings::No) + ImageInfoList infos = selectedImageInfos(); + if (s->treeView->needGroupResolving(ApplicationSettings::Rename, infos)) { - return false; - } - else if (applyAll == ApplicationSettings::Yes) - { - return true; + infos = s->treeView->resolveGrouping(infos); } - ImageInfoList infos; + QList urls = infos.toImageUrlList(); - if (all) - { - infos = s->tableViewModel->allImageInfo(); - } - else - { - infos = s->tableViewModel->imageInfos(s->tableViewSelectionModel->selectedRows()); - } - - foreach(const ImageInfo& info, infos) - { - QModelIndex index = s->tableViewModel->indexFromImageId(info.id(), 0); - - if (info.hasGroupedImages() - && (s->tableViewModel->groupingMode() == s->tableViewModel->GroupingMode::GroupingHideGrouped - || (s->tableViewModel->groupingMode() == s->tableViewModel->GroupingMode::GroupingShowSubItems - && !s->treeView->isExpanded(index)))) - { - // Ask whether should be performed on all and return info if no - return ApplicationSettings::instance()->askGroupingOperateOnAll(type); - } - } - - return false; -} - -void TableView::rename() -{ - bool grouping = needGroupResolving(ApplicationSettings::Rename); - QList urls = selectedUrls(grouping); bool loop = false; NewNamesList newNamesList; diff --git a/core/app/views/tableview/tableview_treeview.h b/core/app/views/tableview/tableview_treeview.h --- a/core/app/views/tableview/tableview_treeview.h +++ b/core/app/views/tableview/tableview_treeview.h @@ -38,6 +38,7 @@ #include "tableview_columnfactory.h" #include "tableview_shared.h" #include "thumbnailloadthread.h" +#include "groupingviewimplementation.h" class QMenu; class QContextMenuEvent; @@ -49,7 +50,7 @@ /// of DragDropModelImplementation's functions in the TableViewModel or /// in the sort model. Subclassing DragDropModelImplementation would not /// work there, because we want to re-use ImageDragDropHandler... -class TableViewTreeView : public QTreeView, public DragDropViewImplementation +class TableViewTreeView : public QTreeView, public DragDropViewImplementation, public GroupingViewImplementation { Q_OBJECT @@ -71,6 +72,8 @@ virtual QPixmap pixmapForDrag(const QList& indexes) const; virtual void wheelEvent(QWheelEvent* event); + virtual bool hasHiddenGroupedImages(const ImageInfo& info) const; + private: void addColumnDescriptionsToMenu(const QList& columnDescriptions, QMenu* const menu); diff --git a/core/app/views/tableview/tableview_treeview.cpp b/core/app/views/tableview/tableview_treeview.cpp --- a/core/app/views/tableview/tableview_treeview.cpp +++ b/core/app/views/tableview/tableview_treeview.cpp @@ -330,6 +330,14 @@ QTreeView::wheelEvent(event); } +bool TableViewTreeView::hasHiddenGroupedImages(const ImageInfo& info) const +{ + return (info.hasGroupedImages() + && (s->tableViewModel->groupingMode() == s->tableViewModel->GroupingMode::GroupingHideGrouped + || (s->tableViewModel->groupingMode() == s->tableViewModel->GroupingMode::GroupingShowSubItems + && !s->treeView->isExpanded(s->tableViewModel->indexFromImageId(info.id(), 0))))); +} + void TableViewTreeView::slotModelGroupingModeChanged() { setRootIsDecorated(s->tableViewModel->groupingMode()==TableViewModel::GroupingShowSubItems); diff --git a/core/data/htmlgallery/themes/bluecurved/template.xsl b/core/data/htmlgallery/themes/bluecurved/template.xsl --- a/core/data/htmlgallery/themes/bluecurved/template.xsl +++ b/core/data/htmlgallery/themes/bluecurved/template.xsl @@ -1,3 +1,30 @@ + + + + ]> diff --git a/core/data/htmlgallery/themes/blueframes/blueframes.desktop b/core/data/htmlgallery/themes/blueframes/blueframes.desktop --- a/core/data/htmlgallery/themes/blueframes/blueframes.desktop +++ b/core/data/htmlgallery/themes/blueframes/blueframes.desktop @@ -4,6 +4,7 @@ Name[ca]=Marcs blaus Name[ca@valencia]=Marcs blaus Name[en_GB]=Blue Frames +Name[es]=Marcos azules Name[nl]=Blauwe frames Name[nn]=Blå rammer Name[pl]=Niebieskie ramki @@ -15,6 +16,7 @@ Comment[ca]=Una variació del tema basat en el tema Marcs Comment[ca@valencia]=Una variació del tema basat en el tema Marcs Comment[en_GB]=A theme variation based Frames theme +Comment[es]=Un tema basado en una variación del tema Marcos Comment[nl]=Een themavariatie gebaseerd op Frames-thema Comment[nn]=Temavariasjon av «Rammer»-temaet Comment[pl]=Wariacja wyglądu oparta na wyglądzie ramek @@ -52,6 +54,7 @@ Name[ca]=Marcs blaus Name[ca@valencia]=Marcs blaus Name[en_GB]=Blue Frames +Name[es]=Marcos azules Name[nl]=Blauwe frames Name[nn]=Blå rammer Name[pl]=Niebieskie ramki diff --git a/core/data/htmlgallery/themes/blueframes/template.xsl b/core/data/htmlgallery/themes/blueframes/template.xsl --- a/core/data/htmlgallery/themes/blueframes/template.xsl +++ b/core/data/htmlgallery/themes/blueframes/template.xsl @@ -1,4 +1,30 @@ + + + diff --git a/core/data/htmlgallery/themes/classic/classic.desktop b/core/data/htmlgallery/themes/classic/classic.desktop --- a/core/data/htmlgallery/themes/classic/classic.desktop +++ b/core/data/htmlgallery/themes/classic/classic.desktop @@ -146,7 +146,7 @@ Name[tr]=Artalan Rengi Name[uk]=Колір тла Name[x-test]=xxBackground Colorxx -Name[zh_CN]=背景颜色 +Name[zh_CN]=背景色 Type=color Default=#333333 diff --git a/core/data/htmlgallery/themes/classic/template.xsl b/core/data/htmlgallery/themes/classic/template.xsl --- a/core/data/htmlgallery/themes/classic/template.xsl +++ b/core/data/htmlgallery/themes/classic/template.xsl @@ -1,4 +1,30 @@ + + + ]> diff --git a/core/data/htmlgallery/themes/cleanframes/cleanframes.desktop b/core/data/htmlgallery/themes/cleanframes/cleanframes.desktop --- a/core/data/htmlgallery/themes/cleanframes/cleanframes.desktop +++ b/core/data/htmlgallery/themes/cleanframes/cleanframes.desktop @@ -118,7 +118,7 @@ Name[tr]=Stil Name[uk]=Стиль Name[x-test]=xxStylexx -Name[zh_CN]=样式 +Name[zh_CN]=风格 Type=list Default=pink.css Value-0=pink.css diff --git a/core/data/htmlgallery/themes/cleanframes/template.xsl b/core/data/htmlgallery/themes/cleanframes/template.xsl --- a/core/data/htmlgallery/themes/cleanframes/template.xsl +++ b/core/data/htmlgallery/themes/cleanframes/template.xsl @@ -1,4 +1,30 @@ + + + diff --git a/core/data/htmlgallery/themes/dateframes/template.xsl b/core/data/htmlgallery/themes/dateframes/template.xsl --- a/core/data/htmlgallery/themes/dateframes/template.xsl +++ b/core/data/htmlgallery/themes/dateframes/template.xsl @@ -1,4 +1,30 @@ + + + diff --git a/core/data/htmlgallery/themes/details/details.desktop b/core/data/htmlgallery/themes/details/details.desktop --- a/core/data/htmlgallery/themes/details/details.desktop +++ b/core/data/htmlgallery/themes/details/details.desktop @@ -46,7 +46,7 @@ Name[tr]=Ayrıntılar Name[uk]=Подробиці Name[x-test]=xxDetailsxx -Name[zh_CN]=细节 +Name[zh_CN]=详细信息 [X-HTMLGallery Author] Name=Gianluca Urgese diff --git a/core/data/htmlgallery/themes/details/template.xsl b/core/data/htmlgallery/themes/details/template.xsl --- a/core/data/htmlgallery/themes/details/template.xsl +++ b/core/data/htmlgallery/themes/details/template.xsl @@ -1,4 +1,30 @@ + + + ]> - + + + diff --git a/core/data/htmlgallery/themes/frames/frames.desktop b/core/data/htmlgallery/themes/frames/frames.desktop --- a/core/data/htmlgallery/themes/frames/frames.desktop +++ b/core/data/htmlgallery/themes/frames/frames.desktop @@ -21,7 +21,7 @@ Name[tr]=Çerçeveler Name[uk]=Рамки Name[x-test]=xxFramesxx -Name[zh_CN]=框架 +Name[zh_CN]=帧数 Comment=A frame theme Comment[ca]=Un tema de marcs Comment[ca@valencia]=Un tema de marcs @@ -91,5 +91,5 @@ Name[tr]=Çerçeveler Name[uk]=Рамки Name[x-test]=xxFramesxx -Name[zh_CN]=框架 +Name[zh_CN]=帧数 Url=preview.png diff --git a/core/data/htmlgallery/themes/frames/template.xsl b/core/data/htmlgallery/themes/frames/template.xsl --- a/core/data/htmlgallery/themes/frames/template.xsl +++ b/core/data/htmlgallery/themes/frames/template.xsl @@ -1,4 +1,30 @@ + + + diff --git a/core/data/htmlgallery/themes/matrix/template.xsl b/core/data/htmlgallery/themes/matrix/template.xsl --- a/core/data/htmlgallery/themes/matrix/template.xsl +++ b/core/data/htmlgallery/themes/matrix/template.xsl @@ -1,4 +1,30 @@ + + + ]> diff --git a/core/data/htmlgallery/themes/s0/template.xsl b/core/data/htmlgallery/themes/s0/template.xsl --- a/core/data/htmlgallery/themes/s0/template.xsl +++ b/core/data/htmlgallery/themes/s0/template.xsl @@ -1,4 +1,31 @@ + + + ]> + + + ]> diff --git a/core/data/htmlgallery/themes/simplerounded/template.xsl b/core/data/htmlgallery/themes/simplerounded/template.xsl --- a/core/data/htmlgallery/themes/simplerounded/template.xsl +++ b/core/data/htmlgallery/themes/simplerounded/template.xsl @@ -1,23 +1,29 @@ - + + + + + + + + + +<!DOCTYPE html> + + + + Slideshow + + + +
+ + + + +
+
+ diff --git a/core/data/htmlgallery/themes/snow/template.xsl b/core/data/htmlgallery/themes/snow/template.xsl --- a/core/data/htmlgallery/themes/snow/template.xsl +++ b/core/data/htmlgallery/themes/snow/template.xsl @@ -1,4 +1,30 @@ + + + ]> diff --git a/core/data/htmlgallery/themes/vanilla/template.xsl b/core/data/htmlgallery/themes/vanilla/template.xsl --- a/core/data/htmlgallery/themes/vanilla/template.xsl +++ b/core/data/htmlgallery/themes/vanilla/template.xsl @@ -1,11 +1,29 @@ + const albums, QWidget* const widget = 0); diff --git a/core/libs/album/albumhistory.cpp b/core/libs/album/albumhistory.cpp --- a/core/libs/album/albumhistory.cpp +++ b/core/libs/album/albumhistory.cpp @@ -41,19 +41,19 @@ uint qHash(QList key) { - if(key.isEmpty()) + if (key.isEmpty()) return 0; uint value; - Digikam::Album* temp = key.first(); - quint64 myint = (unsigned long long)temp; - value = qHash(myint); + Digikam::Album* const temp = key.first(); + quint64 myint = (unsigned long long)temp; + value = qHash(myint); - for(int it = 1; it < key.size(); ++it) + for (int it = 1 ; it < key.size() ; ++it) { - Digikam::Album* al = key.at(it); - quint64 myint = (unsigned long long)al; - value ^= qHash(myint); + Digikam::Album* const al = key.at(it); + quint64 myint = (unsigned long long)al; + value ^= qHash(myint); } return value; @@ -90,7 +90,7 @@ bool operator==(const HistoryItem& item) { - if(widget != item.widget) + if (widget != item.widget) { return false; } @@ -111,13 +111,12 @@ HistoryPosition() { - }; HistoryPosition(const ImageInfo& c, const QList& s) + : current(c), + select(s) { - current = c; - select = s; }; bool operator==(const HistoryPosition& item) @@ -135,9 +134,9 @@ { public: - explicit Private() : - moving(false), - blockSelection(false) + explicit Private() + : moving(false), + blockSelection(false) { } @@ -221,7 +220,8 @@ */ void AlbumHistory::addAlbums(QList const albums, QWidget* const widget, - QHash > selectedLabels) + QHash > selectedLabels) { if (albums.isEmpty() || !widget || d->moving) @@ -353,7 +353,7 @@ QList::const_iterator it = d->backwardStack.constBegin(); - for (; it != (d->backwardStack.isEmpty() ? d->backwardStack.constEnd() : --d->backwardStack.constEnd()); ++it) + for ( ; it != (d->backwardStack.isEmpty() ? d->backwardStack.constEnd() : --d->backwardStack.constEnd()) ; ++it) { if (!(it->albums.isEmpty())) { @@ -383,13 +383,13 @@ QList::const_iterator it; - for (it = d->forwardStack.constBegin(); it != d->forwardStack.constEnd(); ++it) + for (it = d->forwardStack.constBegin() ; it != d->forwardStack.constEnd() ; ++it) { if (!(it->albums.isEmpty())) { QString name; - for (int iter = 0; iter < it->albums.size(); ++iter) + for (int iter = 0 ; iter < it->albums.size() ; ++iter) { name.append(it->albums.at(iter)->title()); @@ -462,7 +462,7 @@ return; } - if(!(d->backwardStack.last().albums.isEmpty())) + if (!(d->backwardStack.last().albums.isEmpty())) { *album = d->backwardStack.last().albums.first(); } @@ -518,7 +518,9 @@ QList albumList = AlbumManager::instance()->currentAlbums(); if (albumList.isEmpty()) + { return; + } d->historyPos[albumList].current = info; } diff --git a/core/libs/album/albumtreeview.h b/core/libs/album/albumtreeview.h --- a/core/libs/album/albumtreeview.h +++ b/core/libs/album/albumtreeview.h @@ -89,7 +89,7 @@ * If you give 0 for model, call setAlbumModel afterwards. * If you supply 0 for filterModel, call setAlbumFilterModel afterwards. */ - explicit AbstractAlbumTreeView(QWidget* const parent, Flags flags); + AbstractAlbumTreeView(QWidget* const parent, Flags flags); ~AbstractAlbumTreeView(); AbstractSpecificAlbumModel* albumModel() const; diff --git a/core/libs/database/coredb/coredbschemaupdater.h b/core/libs/database/coredb/coredbschemaupdater.h --- a/core/libs/database/coredb/coredbschemaupdater.h +++ b/core/libs/database/coredb/coredbschemaupdater.h @@ -91,11 +91,17 @@ private: + // cppcheck-suppress unusedPrivateFunction bool createTablesV3(); + // cppcheck-suppress unusedPrivateFunction void preAlpha010Update1(); + // cppcheck-suppress unusedPrivateFunction void preAlpha010Update2(); + // cppcheck-suppress unusedPrivateFunction void preAlpha010Update3(); + // cppcheck-suppress unusedPrivateFunction void beta010Update1(); + // cppcheck-suppress unusedPrivateFunction void beta010Update2(); private: diff --git a/core/libs/database/dbjobs/dbjob.cpp b/core/libs/database/dbjobs/dbjob.cpp --- a/core/libs/database/dbjobs/dbjob.cpp +++ b/core/libs/database/dbjobs/dbjob.cpp @@ -49,9 +49,9 @@ // ---------------------------------------------- AlbumsJob::AlbumsJob(const AlbumsDBJobInfo& jobInfo) - : DBJob() + : DBJob(), + m_jobInfo(jobInfo) { - m_jobInfo = jobInfo; } AlbumsJob::~AlbumsJob() @@ -83,9 +83,9 @@ // ---------------------------------------------- DatesJob::DatesJob(const DatesDBJobInfo& jobInfo) - : DBJob() + : DBJob(), + m_jobInfo(jobInfo) { - m_jobInfo = jobInfo; } DatesJob::~DatesJob() @@ -118,9 +118,9 @@ // ---------------------------------------------- GPSJob::GPSJob(const GPSDBJobInfo& jobInfo) - : DBJob() + : DBJob(), + m_jobInfo(jobInfo) { - m_jobInfo = jobInfo; } GPSJob::~GPSJob() @@ -164,9 +164,9 @@ // ---------------------------------------------- TagsJob::TagsJob(const TagsDBJobInfo& jobInfo) - : DBJob() + : DBJob(), + m_jobInfo(jobInfo) { - m_jobInfo = jobInfo; } TagsJob::~TagsJob() @@ -229,9 +229,9 @@ // ---------------------------------------------- SearchesJob::SearchesJob(const SearchesDBJobInfo& jobInfo) - : DBJob() + : DBJob(), + m_jobInfo(jobInfo) { - m_jobInfo = jobInfo; } SearchesJob::~SearchesJob() diff --git a/core/libs/database/item/imagecomments.cpp b/core/libs/database/item/imagecomments.cpp --- a/core/libs/database/item/imagecomments.cpp +++ b/core/libs/database/item/imagecomments.cpp @@ -39,18 +39,18 @@ { public: - explicit Private() : - id(-1), + explicit Private() + : id(-1), unique(ImageComments::UniquePerLanguage) { } void init(CoreDbAccess& access, qlonglong imageId) { - id = imageId; + id = imageId; infos = access.db()->getImageComments(id); - for (int i=0; iunique = behavior; } -void ImageComments::addComment(const QString& comment, const QString& lang, const QString& author_, - const QDateTime& date, DatabaseComment::Type type) +void ImageComments::addComment(const QString& comment, + const QString& lang, + const QString& author_, + const QDateTime& date, + DatabaseComment::Type type) { if (!d) { @@ -383,14 +391,14 @@ author = QString(); } - for (int i=0; i < d->infos.size(); ++i) + for (int i = 0 ; i < d->infos.size() ; ++i) { CommentInfo& info = d->infos[i]; // some extra considerations on replacing if (info.type == type && info.type == DatabaseComment::Comment && info.language == language) { - if ( !multipleCommentsPerLanguage || (multipleCommentsPerLanguage && info.author == author) ) + if (!multipleCommentsPerLanguage || (info.author == author)) { info.comment = comment; info.date = date; @@ -402,8 +410,9 @@ // simulate unique restrictions of db. // There is a problem that a NULL value is never unique, see #189080 - if (info.type == type && info.language == language && - (info.author == author || (info.author.isEmpty() && author.isEmpty())) ) + if ((info.type == type) && + (info.language == language) && + ((info.author == author) || (info.author.isEmpty() && author.isEmpty()))) { info.comment = comment; info.date = date; @@ -443,7 +452,7 @@ } // remove all comments of this type that have not been touched above - for (int i = 0 ; i < d->infos.size() /* changing! */; ) + for (int i = 0 ; i < d->infos.size() /* changing! */ ; ) { if (!d->dirtyIndices.contains(i) && !d->newIndices.contains(i) && d->infos[i].type == type) { @@ -475,7 +484,7 @@ } // remove all that have not been touched above - for (int i=0; iinfos.size() /* changing! */; ) + for (int i = 0 ; i < d->infos.size() /* changing! */ ; ) { if (!d->dirtyIndices.contains(i) && !d->newIndices.contains(i)) { @@ -488,8 +497,11 @@ } } -void ImageComments::addCommentDirectly(const QString& comment, const QString& language, const QString& author, - DatabaseComment::Type type, const QDateTime& date) +void ImageComments::addCommentDirectly(const QString& comment, + const QString& language, + const QString& author, + DatabaseComment::Type type, + const QDateTime& date) { CommentInfo info; info.comment = comment; @@ -521,7 +533,7 @@ return; } - for (int i = 0 ; i < d->infos.size() /* changing! */; ) + for (int i = 0 ; i < d->infos.size() /* changing! */ ; ) { if (d->infos.at(i).type == type) { diff --git a/core/libs/database/server/databaseserver.h b/core/libs/database/server/databaseserver.h --- a/core/libs/database/server/databaseserver.h +++ b/core/libs/database/server/databaseserver.h @@ -60,7 +60,8 @@ public: - explicit DatabaseServer(const DbEngineParameters& params, DatabaseServerStarter* const parent = DatabaseServerStarter::instance()); + explicit DatabaseServer(const DbEngineParameters& params, + DatabaseServerStarter* const parent = DatabaseServerStarter::instance()); virtual ~DatabaseServer(); /** diff --git a/core/libs/database/server/databaseserver.cpp b/core/libs/database/server/databaseserver.cpp --- a/core/libs/database/server/databaseserver.cpp +++ b/core/libs/database/server/databaseserver.cpp @@ -73,6 +73,7 @@ QString miscDir; QString fileDataDir; QString actualConfig; + QString globalConfig; }; DatabaseServer::DatabaseServer(const DbEngineParameters& params, DatabaseServerStarter* const parent) @@ -106,6 +107,8 @@ d->miscDir = QDir(defaultAkDir).absoluteFilePath(QLatin1String("db_misc")); d->fileDataDir = QDir(defaultAkDir).absoluteFilePath(QLatin1String("file_db_data")); d->actualConfig = QDir(defaultAkDir).absoluteFilePath(QLatin1String("mysql.conf")); + d->globalConfig = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QLatin1String("digikam/database/mysql-global.conf")); databaseServerStateEnum = started; } @@ -309,37 +312,35 @@ { DatabaseServerError result; - QString globalConfig = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QLatin1String("digikam/database/mysql-global.conf")); QString localConfig = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("digikam/database/mysql-local.conf")); - if (!globalConfig.isEmpty()) + if (!d->globalConfig.isEmpty()) { - bool confUpdate = false; + bool confUpdate = false; bool confShouldUpdate = false; QFile actualFile(d->actualConfig); // Update actualconf only if either global or local is newer than actual // If actual does not yet exist it was initialised with datetime 0 // so it will get updated too - if ((QFileInfo(globalConfig).lastModified() > QFileInfo(actualFile).lastModified()) || + if ((QFileInfo(d->globalConfig).lastModified() > QFileInfo(actualFile).lastModified()) || (QFileInfo(localConfig).lastModified() > QFileInfo(actualFile).lastModified())) { confShouldUpdate = true; qCDebug(DIGIKAM_DATABASESERVER_LOG) << "The mysql configuration is outdated," << d->actualConfig << "will be updated."; - QFile globalFile(globalConfig); - QFile localFile (localConfig); + QFile globalFile(d->globalConfig); + QFile localFile(localConfig); if (globalFile.open(QFile::ReadOnly) && actualFile.open(QFile::WriteOnly)) { actualFile.write(globalFile.readAll()); - qCDebug(DIGIKAM_DATABASESERVER_LOG) << "Updated mysql configuration with" << globalConfig; + qCDebug(DIGIKAM_DATABASESERVER_LOG) << "Updated mysql configuration with" << d->globalConfig; if (!localConfig.isEmpty() && localFile.open(QFile::ReadOnly)) { @@ -376,7 +377,7 @@ { qCDebug(DIGIKAM_DATABASESERVER_LOG) << "Unable to create MySQL server configuration file." << "This means that either the default configuration file" - << globalConfig + << d->globalConfig << "was not readable or the target file" << d->actualConfig << "could not be written."; @@ -387,7 +388,7 @@ "

was not readable or the target file

" "

%2

" "

could not be written.

", - globalConfig, d->actualConfig); + d->globalConfig, d->actualConfig); return DatabaseServerError(DatabaseServerError::StartError, errorMsg); } @@ -454,7 +455,7 @@ mysqlInitCmdArgs << QDir::toNativeSeparators(QString::fromLatin1("--datadir=%1").arg(d->dataDir)); #ifndef Q_OS_WIN - mysqlInitCmdArgs << QDir::toNativeSeparators(QString::fromLatin1("--defaults-file=%1").arg(d->actualConfig)); + mysqlInitCmdArgs << QDir::toNativeSeparators(QString::fromLatin1("--defaults-file=%1").arg(d->globalConfig)); #endif QProcess initProcess; @@ -550,7 +551,7 @@ bool opened = false; bool exited = false; - for (int i = 0; i < 120; ++i) + for (int i = 0 ; i < 120 ; ++i) { opened = db.open(); @@ -589,7 +590,7 @@ QSqlQuery query(db); - if (!query.exec(QString::fromLatin1("USE %1").arg(d->internalDBName))) + if (!query.exec(QString::fromLatin1("USE %1;").arg(d->internalDBName))) { qCDebug(DIGIKAM_DATABASESERVER_LOG) << "Failed to use database" << d->internalDBName; @@ -599,7 +600,7 @@ << db.lastError().text(); qCDebug(DIGIKAM_DATABASESERVER_LOG) << "Trying to create database now"; - if (query.exec(QLatin1String("CREATE DATABASE digikam"))) + if (query.exec(QString::fromLatin1("CREATE DATABASE %1;").arg(d->internalDBName))) { qCDebug(DIGIKAM_DATABASESERVER_LOG) << "Database was successfully created"; } diff --git a/core/libs/database/server/databaseservererror.h b/core/libs/database/server/databaseservererror.h --- a/core/libs/database/server/databaseservererror.h +++ b/core/libs/database/server/databaseservererror.h @@ -61,7 +61,8 @@ public: - explicit DatabaseServerError(DatabaseServerErrorEnum errorType = NoErrors, const QString& errorText = QString()); + explicit DatabaseServerError(DatabaseServerErrorEnum errorType = NoErrors, + const QString& errorText = QString()); DatabaseServerError(const DatabaseServerError& dbServerError); ~DatabaseServerError(); diff --git a/core/libs/database/utils/dbinfoiface.cpp b/core/libs/database/utils/dbinfoiface.cpp --- a/core/libs/database/utils/dbinfoiface.cpp +++ b/core/libs/database/utils/dbinfoiface.cpp @@ -256,7 +256,7 @@ } withGroupedIsSet = true; - withGrouped = DigikamApp::instance()->view()->needGroupResolving(operationType, true); + withGrouped = DigikamApp::instance()->view()->allNeedGroupResolving(operationType); return withGrouped; } diff --git a/core/libs/database/utils/dbsettingswidget.cpp b/core/libs/database/utils/dbsettingswidget.cpp --- a/core/libs/database/utils/dbsettingswidget.cpp +++ b/core/libs/database/utils/dbsettingswidget.cpp @@ -248,12 +248,12 @@ // Std Macports install d->dbBinariesWidget->addDirectory(QLatin1String("/opt/local/bin")); d->dbBinariesWidget->addDirectory(QLatin1String("/opt/local/sbin")); - d->dbBinariesWidget->addDirectory(QLatin1String("/opt/local/lib/mysql56/bin")); + d->dbBinariesWidget->addDirectory(QLatin1String("/opt/local/lib/mariadb/bin")); // digiKam Bundle PKG install d->dbBinariesWidget->addDirectory(QLatin1String("/opt/digikam/bin")); d->dbBinariesWidget->addDirectory(QLatin1String("/opt/digikam/sbin")); - d->dbBinariesWidget->addDirectory(QLatin1String("/opt/digikam/lib/mysql56/bin")); + d->dbBinariesWidget->addDirectory(QLatin1String("/opt/digikam/lib/mariadb/bin")); #endif #ifdef Q_OS_WIN diff --git a/core/libs/database/utils/dio.h b/core/libs/database/utils/dio.h --- a/core/libs/database/utils/dio.h +++ b/core/libs/database/utils/dio.h @@ -92,8 +92,8 @@ Q_SIGNALS: - void signalRenameSucceeded(const QUrl&); - void signalRenameFailed(const QUrl&); + void signalRenameSucceeded(const QUrl& url); + void signalRenameFailed(const QUrl& url); private: @@ -103,8 +103,8 @@ void processJob(IOJobData* const data); void createJob(IOJobData* const data); - ProgressItem* getProgressItem(int operation) const; - QPair getItemStrings(int operation) const; + QString getItemString(IOJobData* const data) const; + ProgressItem* getProgressItem(IOJobData* const data) const; void addAlbumChildrenToList(QList& list, Album* const album); private Q_SLOTS: diff --git a/core/libs/database/utils/dio.cpp b/core/libs/database/utils/dio.cpp --- a/core/libs/database/utils/dio.cpp +++ b/core/libs/database/utils/dio.cpp @@ -333,43 +333,34 @@ return; } - ProgressItem* item = 0; - IOJobsThread* jobThread = 0; - const int operation = data->operation(); - - item = getProgressItem(operation); + ProgressItem* item = 0; + QString itemString = getItemString(data); - if (!item || item->totalCompleted()) + if (!itemString.isEmpty()) { - QPair itemStrings = getItemStrings(operation); - - if (!itemStrings.first.isEmpty()) - { - item = ProgressManager::instance()->createProgressItem(itemStrings.first, - itemStrings.second, - QString(), true, false); - } + item = ProgressManager::instance()->createProgressItem(itemString, + QString(), true, false); + item->setTotalItems(data->sourceUrls().count()); + data->setProgressId(item->id()); } - jobThread = IOJobsManager::instance()->startIOJobs(data); + IOJobsThread* const jobThread = IOJobsManager::instance()->startIOJobs(data); connect(jobThread, SIGNAL(signalOneProccessed(QUrl)), this, SLOT(slotOneProccessed(QUrl)), Qt::QueuedConnection); connect(jobThread, SIGNAL(finished()), this, SLOT(slotResult())); - if (operation == IOJobData::Rename) + if (data->operation() == IOJobData::Rename) { connect(jobThread, SIGNAL(signalRenameFailed(QUrl)), this, SIGNAL(signalRenameFailed(QUrl))); } if (item) { - item->setTotalItems(item->totalItems() + data->sourceUrls().count()); - connect(item, SIGNAL(progressItemCanceled(ProgressItem*)), jobThread, SLOT(slotCancel())); @@ -387,17 +378,17 @@ return; } - const int operation = jobThread->jobData()->operation(); + IOJobData* const data = jobThread->jobData(); - if (jobThread->hasErrors() && operation != IOJobData::Rename) + if (jobThread->hasErrors() && data->operation() != IOJobData::Rename) { // Pop-up a message about the error. QString errors = jobThread->errorsList().join(QLatin1String("\n")); DNotificationWrapper(QString(), errors, DigikamApp::instance(), DigikamApp::instance()->windowTitle()); } - slotCancel(getProgressItem(operation)); + slotCancel(getProgressItem(data)); } void DIO::slotOneProccessed(const QUrl& url) @@ -444,7 +435,8 @@ foreach(const qlonglong& imageId, imagesToRemove) { - access.db()->removeAllImageRelationsFrom(imageId, DatabaseRelation::Grouped); + access.db()->removeAllImageRelationsFrom(imageId, + DatabaseRelation::Grouped); } access.db()->removeItemsPermanently(imagesToRemove, albumsToDelete); @@ -456,11 +448,24 @@ if (!info.isNull()) { CoreDbAccess access; - access.db()->removeAllImageRelationsFrom(info.id(), DatabaseRelation::Grouped); - access.db()->removeItemsPermanently(QList() << info.id(), QList() << info.albumId()); + access.db()->removeAllImageRelationsFrom(info.id(), + DatabaseRelation::Grouped); + + access.db()->removeItemsPermanently(QList() << info.id(), + QList() << info.albumId()); } } } + else if (operation == IOJobData::Trash) + { + ImageInfo info = data->findImageInfo(url); + + if (!info.isNull()) + { + CoreDbAccess().db()->removeItems(QList() << info.id(), + QList() << info.albumId()); + } + } else if (operation == IOJobData::Rename) { // If we rename a file, the name changes. This is equivalent to a move. @@ -522,48 +527,59 @@ ScanController::instance()->scheduleCollectionScanRelaxed(scanPath); } - ProgressItem* const item = getProgressItem(operation); + ProgressItem* const item = getProgressItem(data); if (item) { item->advance(1); } } -ProgressItem* DIO::getProgressItem(int operation) const +QString DIO::getItemString(IOJobData* const data) const { - ProgressItem* item = 0; - QString itemString = getItemStrings(operation).first; - - if (!itemString.isEmpty()) - { - item = ProgressManager::instance()->findItembyId(itemString); - } - - return item; -} - -QPair DIO::getItemStrings(int operation) const -{ - switch (operation) + switch (data->operation()) { case IOJobData::CopyAlbum: + return i18n("Copy Album"); + case IOJobData::CopyImage: + return i18n("Copy Images"); + case IOJobData::CopyFiles: - return qMakePair(QLatin1String("DIOCopy"), i18n("Copy")); + return i18n("Copy Files"); + case IOJobData::MoveAlbum: + return i18n("Move Album"); + case IOJobData::MoveImage: + return i18n("Move Images"); + case IOJobData::MoveFiles: - return qMakePair(QLatin1String("DIOMove"), i18n("Move")); + return i18n("Move Files"); + case IOJobData::Trash: - return qMakePair(QLatin1String("DIOTrash"), i18n("Trash")); + return i18n("Trash"); + case IOJobData::Delete: - return qMakePair(QLatin1String("DIODelete"), i18n("Delete")); + return i18n("Delete"); + default: break; } - return qMakePair(QString(), QString()); + return QString(); +} + +ProgressItem* DIO::getProgressItem(IOJobData* const data) const +{ + QString itemId = data->getProgressId(); + + if (itemId.isEmpty()) + { + return 0; + } + + return ProgressManager::instance()->findItembyId(itemId); } void DIO::slotCancel(ProgressItem* item) diff --git a/core/libs/dialogs/dconfigdlgview_p.h b/core/libs/dialogs/dconfigdlgview_p.h --- a/core/libs/dialogs/dconfigdlgview_p.h +++ b/core/libs/dialogs/dconfigdlgview_p.h @@ -110,6 +110,7 @@ private: + // cppcheck-suppress unusedPrivateFunction void init(); }; diff --git a/core/libs/dialogs/dsplashscreen.cpp b/core/libs/dialogs/dsplashscreen.cpp --- a/core/libs/dialogs/dsplashscreen.cpp +++ b/core/libs/dialogs/dsplashscreen.cpp @@ -91,6 +91,8 @@ } // Under Linux, only test versions has Beta stage. + + // cppcheck-suppress redundantAssignment bool isBeta = !QString::fromUtf8(digikam_version_suffix).isEmpty(); #if defined Q_OS_WIN diff --git a/core/libs/dimg/dimg.cpp b/core/libs/dimg/dimg.cpp --- a/core/libs/dimg/dimg.cpp +++ b/core/libs/dimg/dimg.cpp @@ -313,7 +313,9 @@ if (!m_priv->data) { - m_priv->null = true; + m_priv->null = true; + m_priv->width = 0; + m_priv->height = 0; return 0; } diff --git a/core/libs/dimg/filters/auto/autolevelsfilter.cpp b/core/libs/dimg/filters/auto/autolevelsfilter.cpp --- a/core/libs/dimg/filters/auto/autolevelsfilter.cpp +++ b/core/libs/dimg/filters/auto/autolevelsfilter.cpp @@ -67,12 +67,13 @@ m_destImage = m_orgImage; } -/** Performs histogram auto correction of levels. - This method maximizes the tonal range in the Red, - Green, and Blue channels. It search the image shadow and highlight - limit values and adjust the Red, Green, and Blue channels - to a full histogram range. -*/ +/** + * Performs histogram auto correction of levels. + * This method maximizes the tonal range in the Red, + * Green, and Blue channels. It search the image shadow and highlight + * limit values and adjust the Red, Green, and Blue channels + * to a full histogram range. + */ void AutoLevelsFilter::autoLevelsCorrectionImage() { if (m_orgImage.sixteenBit() != m_refImage.sixteenBit()) diff --git a/core/libs/dimg/filters/auto/equalizefilter.h b/core/libs/dimg/filters/auto/equalizefilter.h --- a/core/libs/dimg/filters/auto/equalizefilter.h +++ b/core/libs/dimg/filters/auto/equalizefilter.h @@ -82,14 +82,30 @@ struct double_packet { + double_packet() + : red(0.0), + green(0.0), + blue(0.0), + alpha(0.0) + { + } + double red; double green; double blue; double alpha; }; struct int_packet { + int_packet() + : red(0), + green(0), + blue(0), + alpha(0) + { + } + unsigned int red; unsigned int green; unsigned int blue; diff --git a/core/libs/dimg/filters/auto/equalizefilter.cpp b/core/libs/dimg/filters/auto/equalizefilter.cpp --- a/core/libs/dimg/filters/auto/equalizefilter.cpp +++ b/core/libs/dimg/filters/auto/equalizefilter.cpp @@ -66,16 +66,17 @@ m_destImage = m_orgImage; } -/** Performs an histogram equalization of the image. - this method adjusts the brightness of colors across the - active image so that the histogram for the value channel - is as nearly as possible flat, that is, so that each possible - brightness value appears at about the same number of pixels - as each other value. Sometimes Equalize works wonderfully at - enhancing the contrasts in an image. Other times it gives - garbage. It is a very powerful operation, which can either work - miracles on an image or destroy it. -*/ +/** + * Performs an histogram equalization of the image. + * this method adjusts the brightness of colors across the + * active image so that the histogram for the value channel + * is as nearly as possible flat, that is, so that each possible + * brightness value appears at about the same number of pixels + * as each other value. Sometimes Equalize works wonderfully at + * enhancing the contrasts in an image. Other times it gives + * garbage. It is a very powerful operation, which can either work + * miracles on an image or destroy it. + */ void EqualizeFilter::equalizeImage() { if (m_orgImage.sixteenBit() != m_refImage.sixteenBit()) @@ -85,7 +86,7 @@ } struct double_packet high, low, intensity; - int i; + int i; int progress; // Create an histogram of the reference image. @@ -104,24 +105,19 @@ // Integrate the histogram to get the equalization map. - memset(&intensity, 0, sizeof(struct double_packet)); - memset(&high, 0, sizeof(struct double_packet)); - memset(&low, 0, sizeof(struct double_packet)); - for (i = 0 ; runningFlag() && (i < histogram->getHistogramSegments()) ; ++i) { - intensity.red += histogram->getValue(RedChannel, i); + intensity.red += histogram->getValue(RedChannel, i); intensity.green += histogram->getValue(GreenChannel, i); - intensity.blue += histogram->getValue(BlueChannel, i); + intensity.blue += histogram->getValue(BlueChannel, i); intensity.alpha += histogram->getValue(AlphaChannel, i); map[i] = intensity; } // Stretch the histogram. low = map[0]; high = map[histogram->getHistogramSegments() - 1]; - memset(equalize_map.data(), 0, histogram->getHistogramSegments()*sizeof(int_packet)); // TODO magic number 256 for (i = 0 ; runningFlag() && (i < histogram->getHistogramSegments()) ; ++i) diff --git a/core/libs/dimg/filters/auto/normalizefilter.cpp b/core/libs/dimg/filters/auto/normalizefilter.cpp --- a/core/libs/dimg/filters/auto/normalizefilter.cpp +++ b/core/libs/dimg/filters/auto/normalizefilter.cpp @@ -65,12 +65,13 @@ m_destImage = m_orgImage; } -/** This method scales brightness values across the active - image so that the darkest point becomes black, and the - brightest point becomes as bright as possible without - altering its hue. This is often a magic fix for - images that are dim or washed out. -*/ +/** + * This method scales brightness values across the active + * image so that the darkest point becomes black, and the + * brightest point becomes as bright as possible without + * altering its hue. This is often a magic fix for + * images that are dim or washed out. + */ void NormalizeFilter::normalizeImage() { if (m_orgImage.sixteenBit() != m_refImage.sixteenBit()) diff --git a/core/libs/dimg/filters/auto/stretchfilter.h b/core/libs/dimg/filters/auto/stretchfilter.h --- a/core/libs/dimg/filters/auto/stretchfilter.h +++ b/core/libs/dimg/filters/auto/stretchfilter.h @@ -82,14 +82,30 @@ struct double_packet { + double_packet() + : red(0.0), + green(0.0), + blue(0.0), + alpha(0.0) + { + } + double red; double green; double blue; double alpha; }; struct int_packet { + int_packet() + : red(0), + green(0), + blue(0), + alpha(0) + { + } + unsigned int red; unsigned int green; unsigned int blue; diff --git a/core/libs/dimg/filters/auto/stretchfilter.cpp b/core/libs/dimg/filters/auto/stretchfilter.cpp --- a/core/libs/dimg/filters/auto/stretchfilter.cpp +++ b/core/libs/dimg/filters/auto/stretchfilter.cpp @@ -65,10 +65,11 @@ m_destImage = m_orgImage; } -/** Performs histogram normalization of the image. The algorithm normalizes - the pixel values from an image for to span the full range - of color values. This is a contrast enhancement technique. -*/ +/** + * Performs histogram normalization of the image. The algorithm normalizes + * the pixel values from an image for to span the full range + * of color values. This is a contrast enhancement technique. + */ void StretchFilter::stretchContrastImage() { if (m_orgImage.sixteenBit() != m_refImage.sixteenBit()) @@ -79,17 +80,19 @@ struct double_packet high, low, intensity; long long number_pixels; - long i; + long i; int progress; unsigned long threshold_intensity; // Create an histogram of the reference image. QScopedPointer histogram(new ImageHistogram(m_refImage)); + if (histogram.isNull()) { qCWarning(DIGIKAM_DIMG_LOG) << ("Unable to allocate memory!"); return; } + histogram->calculate(); // Memory allocation. @@ -106,12 +109,9 @@ number_pixels = (long long)m_refImage.width() * (long long)m_refImage.height(); threshold_intensity = number_pixels / 1000; - memset(&high, 0, sizeof(struct double_packet)); - memset(&low, 0, sizeof(struct double_packet)); - // Red. - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.red = histogram->getMaxSegmentIndex() ; high.red != 0 ; --high.red) { @@ -126,7 +126,7 @@ if (low.red == high.red) { threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (low.red = 0 ; low.red < histogram->getMaxSegmentIndex() ; ++low.red) { @@ -138,7 +138,7 @@ } } - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.red = histogram->getMaxSegmentIndex() ; high.red != 0 ; --high.red) { @@ -153,7 +153,7 @@ // Green. - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.green = histogram->getMaxSegmentIndex() ; high.green != 0 ; --high.green) { @@ -168,7 +168,7 @@ if (low.green == high.green) { threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (low.green = 0 ; low.green < histogram->getMaxSegmentIndex() ; ++low.green) { @@ -180,7 +180,7 @@ } } - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.green = histogram->getMaxSegmentIndex() ; high.green != 0 ; --high.green) { @@ -195,7 +195,7 @@ // Blue. - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.blue = histogram->getMaxSegmentIndex() ; high.blue != 0 ; --high.blue) { @@ -210,7 +210,7 @@ if (low.blue == high.blue) { threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (low.blue = 0 ; low.blue < histogram->getMaxSegmentIndex() ; ++low.blue) { @@ -222,7 +222,7 @@ } } - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.blue = histogram->getMaxSegmentIndex() ; high.blue != 0 ; --high.blue) { @@ -237,7 +237,7 @@ // Alpha. - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.alpha = histogram->getMaxSegmentIndex() ; high.alpha != 0 ; --high.alpha) { @@ -252,7 +252,7 @@ if (low.alpha == high.alpha) { threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (low.alpha = 0 ; low.alpha < histogram->getMaxSegmentIndex() ; ++low.alpha) { @@ -264,7 +264,7 @@ } } - memset(&intensity, 0, sizeof(struct double_packet)); + intensity = double_packet(); for (high.alpha = histogram->getMaxSegmentIndex() ; high.alpha != 0 ; --high.alpha) { @@ -279,8 +279,6 @@ // Stretch the histogram to create the normalized image mapping. - memset(normalize_map.data(), 0, histogram->getHistogramSegments()*sizeof(struct int_packet)); - // TODO magic number 256 for (i = 0 ; runningFlag() && (i <= (long)histogram->getMaxSegmentIndex()) ; ++i) { diff --git a/core/libs/dimg/filters/bw/infraredfilter.h b/core/libs/dimg/filters/bw/infraredfilter.h --- a/core/libs/dimg/filters/bw/infraredfilter.h +++ b/core/libs/dimg/filters/bw/infraredfilter.h @@ -39,15 +39,17 @@ public: - InfraredContainer() + explicit InfraredContainer() { + sensibility = 200; redGain = 0.4; greenGain = 2.1; blueGain = -0.8; - sensibility = 200; }; - ~InfraredContainer() {}; + ~InfraredContainer() + { + }; public: @@ -66,8 +68,10 @@ public: - explicit InfraredFilter(QObject* parent = 0); - explicit InfraredFilter(DImg* orgImage, QObject* parent=0, const InfraredContainer& settings=InfraredContainer()); + explicit InfraredFilter(QObject* const parent = 0); + explicit InfraredFilter(DImg* const orgImage, + QObject* const parent=0, + const InfraredContainer& settings=InfraredContainer()); ~InfraredFilter(); static QString FilterIdentifier() diff --git a/core/libs/dimg/filters/bw/infraredfilter.cpp b/core/libs/dimg/filters/bw/infraredfilter.cpp --- a/core/libs/dimg/filters/bw/infraredfilter.cpp +++ b/core/libs/dimg/filters/bw/infraredfilter.cpp @@ -8,7 +8,7 @@ * * Copyright (C) 2005-2018 by Gilles Caulier * Copyright (C) 2006-2010 by Marcel Wiesweg - * Copyright (C) 2010 by Martin Klapetek + * Copyright (C) 2010 by Martin Klapetek * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -44,16 +44,16 @@ namespace Digikam { -InfraredFilter::InfraredFilter(QObject* parent) +InfraredFilter::InfraredFilter(QObject* const parent) : DImgThreadedFilter(parent) { initFilter(); } -InfraredFilter::InfraredFilter(DImg* orgImage, QObject* parent, const InfraredContainer& settings) - : DImgThreadedFilter(orgImage, parent, QLatin1String("Infrared")) +InfraredFilter::InfraredFilter(DImg* const orgImage, QObject* const parent, const InfraredContainer& settings) + : DImgThreadedFilter(orgImage, parent, QLatin1String("Infrared")), + m_settings(settings) { - m_settings = settings; initFilter(); } @@ -93,7 +93,7 @@ // This film have a sensibility escursion from 200 to 800 ISO. // Over 800 ISO, we reproduce The Kodak HIE high speed infrared film. - int blurRadius = (int)((m_settings.sensibility / 200.0) + 1.0); // Gaussian blur infrared highlight effect [2 to 5]. + int blurRadius = (int)((m_settings.sensibility / 200.0) + 1.0); // Gaussian blur infrared highlight effect [2 to 5]. int offset, progress; uchar* pOverlayBits = 0; // Overlay to merge with original converted in gray scale. @@ -159,26 +159,26 @@ outData.setSixteenBit(sixteenBit); - for (int x = 0; runningFlag() && x < Width; ++x) + for (int x = 0 ; runningFlag() && x < Width ; ++x) { - for (int y = 0; runningFlag() && y < Height; ++y) + for (int y = 0 ; runningFlag() && y < Height ; ++y) { offset = x * bytesDepth + (y * Width * bytesDepth); bwData.setColor(BWImage.bits() + offset, sixteenBit); overData.setColor(pOverlayBits + offset, sixteenBit); if (sixteenBit) { - outData.setRed(intMult16(bwData.red(), bwData.red() + intMult16(2 * overData.red(), 65535 - bwData.red()))); + outData.setRed(intMult16(bwData.red(), bwData.red() + intMult16(2 * overData.red(), 65535 - bwData.red()))); outData.setGreen(intMult16(bwData.green(), bwData.green() + intMult16(2 * overData.green(), 65535 - bwData.green()))); - outData.setBlue(intMult16(bwData.blue(), bwData.blue() + intMult16(2 * overData.blue(), 65535 - bwData.blue()))); + outData.setBlue(intMult16(bwData.blue(), bwData.blue() + intMult16(2 * overData.blue(), 65535 - bwData.blue()))); } else { - outData.setRed(intMult8(bwData.red(), bwData.red() + intMult8(2 * overData.red(), 255 - bwData.red()))); + outData.setRed(intMult8(bwData.red(), bwData.red() + intMult8(2 * overData.red(), 255 - bwData.red()))); outData.setGreen(intMult8(bwData.green(), bwData.green() + intMult8(2 * overData.green(), 255 - bwData.green()))); - outData.setBlue(intMult8(bwData.blue(), bwData.blue() + intMult8(2 * overData.blue(), 255 - bwData.blue()))); + outData.setBlue(intMult8(bwData.blue(), bwData.blue() + intMult8(2 * overData.blue(), 255 - bwData.blue()))); } outData.setAlpha(bwData.alpha()); @@ -222,11 +222,10 @@ void InfraredFilter::readParameters(const FilterAction& action) { - m_settings.blueGain = action.parameter(QLatin1String("blueGain")).toDouble(); - m_settings.greenGain = action.parameter(QLatin1String("greenGain")).toDouble(); - m_settings.redGain = action.parameter(QLatin1String("redGain")).toDouble(); + m_settings.blueGain = action.parameter(QLatin1String("blueGain")).toDouble(); + m_settings.greenGain = action.parameter(QLatin1String("greenGain")).toDouble(); + m_settings.redGain = action.parameter(QLatin1String("redGain")).toDouble(); m_settings.sensibility = action.parameter(QLatin1String("sensibility")).toInt(); } - } // namespace Digikam diff --git a/core/libs/dimg/filters/bw/mixerfilter.h b/core/libs/dimg/filters/bw/mixerfilter.h --- a/core/libs/dimg/filters/bw/mixerfilter.h +++ b/core/libs/dimg/filters/bw/mixerfilter.h @@ -93,7 +93,9 @@ public: explicit MixerFilter(QObject* const parent = 0); - explicit MixerFilter(DImg* const orgImage, QObject* const parent=0, const MixerContainer& settings=MixerContainer()); + explicit MixerFilter(DImg* const orgImage, + QObject* const parent=0, + const MixerContainer& settings=MixerContainer()); virtual ~MixerFilter(); static QString FilterIdentifier() diff --git a/core/libs/dimg/filters/bw/mixerfilter.cpp b/core/libs/dimg/filters/bw/mixerfilter.cpp --- a/core/libs/dimg/filters/bw/mixerfilter.cpp +++ b/core/libs/dimg/filters/bw/mixerfilter.cpp @@ -44,9 +44,9 @@ } MixerFilter::MixerFilter(DImg* const orgImage, QObject* const parent, const MixerContainer& settings) - : DImgThreadedFilter(orgImage, parent, QLatin1String("MixerFilter")) + : DImgThreadedFilter(orgImage, parent, QLatin1String("MixerFilter")), + m_settings(settings) { - m_settings = settings; initFilter(); } @@ -64,12 +64,12 @@ uint height = m_destImage.height(); bool sixteenBit = m_destImage.sixteenBit(); - uint size = width * height; + uint size = width * height; int progress; uint i; - double rnorm = 1; // red channel normalizer use in RGB mode. - double mnorm = 1; // monochrome normalizer used in Monochrome mode. + double rnorm = 1; // red channel normalizer use in RGB mode. + double mnorm = 1; // monochrome normalizer used in Monochrome mode. if (m_settings.bMonochrome) { @@ -100,9 +100,9 @@ if (m_settings.bMonochrome) { - nGray = MixPixel(m_settings.blackRedGain, m_settings.blackGreenGain, m_settings.blackBlueGain, - (unsigned short)red, (unsigned short)green, (unsigned short)blue, - sixteenBit, mnorm); + nGray = MixPixel(m_settings.blackRedGain, m_settings.blackGreenGain, m_settings.blackBlueGain, + (unsigned short)red, (unsigned short)green, (unsigned short)blue, + sixteenBit, mnorm); ptr[0] = ptr[1] = ptr[2] = nGray; } else @@ -118,7 +118,7 @@ sixteenBit, rnorm); } - ptr += 4; + ptr += 4; progress = (int)(((double)i * 100.0) / size); @@ -141,8 +141,8 @@ if (m_settings.bMonochrome) { - nGray = MixPixel(m_settings.blackRedGain, m_settings.blackGreenGain, m_settings.blackBlueGain, - red, green, blue, sixteenBit, mnorm); + nGray = MixPixel(m_settings.blackRedGain, m_settings.blackGreenGain, m_settings.blackBlueGain, + red, green, blue, sixteenBit, mnorm); ptr[0] = ptr[1] = ptr[2] = nGray; } else @@ -155,7 +155,7 @@ red, green, blue, sixteenBit, rnorm); } - ptr += 4; + ptr += 4; progress = (int)(((double)i * 100.0) / size); @@ -176,15 +176,15 @@ return (1.0); } - return(fabs(1.0 / lfSum)); + return (fabs(1.0 / lfSum)); } unsigned short MixerFilter::MixPixel(double RedGain, double GreenGain, double BlueGain, unsigned short R, unsigned short G, unsigned short B, bool sixteenBit, double Norm) { double lfMix = Norm * (RedGain * (double)R + GreenGain * (double)G + BlueGain * (double)B); - return((unsigned short)CLAMP((int)lfMix, 0, sixteenBit ? 65535 : 255)); + return ((unsigned short)CLAMP((int)lfMix, 0, sixteenBit ? 65535 : 255)); } FilterAction MixerFilter::filterAction() @@ -212,20 +212,20 @@ void MixerFilter::readParameters(const Digikam::FilterAction& action) { - m_settings.blackBlueGain = action.parameter(QLatin1String("blackBlueGain")).toDouble(); + m_settings.blackBlueGain = action.parameter(QLatin1String("blackBlueGain")).toDouble(); m_settings.blackGreenGain = action.parameter(QLatin1String("blackGreenGain")).toDouble(); - m_settings.blackRedGain = action.parameter(QLatin1String("blackRedGain")).toDouble(); - m_settings.blueBlueGain = action.parameter(QLatin1String("blueBlueGain")).toDouble(); - m_settings.blueGreenGain = action.parameter(QLatin1String("blueGreenGain")).toDouble(); - m_settings.blueRedGain = action.parameter(QLatin1String("blueRedGain")).toDouble(); - m_settings.bMonochrome = action.parameter(QLatin1String("bMonochrome")).toBool(); - m_settings.bPreserveLum = action.parameter(QLatin1String("bPreserveLum")).toBool(); - m_settings.greenBlueGain = action.parameter(QLatin1String("greenBlueGain")).toDouble(); + m_settings.blackRedGain = action.parameter(QLatin1String("blackRedGain")).toDouble(); + m_settings.blueBlueGain = action.parameter(QLatin1String("blueBlueGain")).toDouble(); + m_settings.blueGreenGain = action.parameter(QLatin1String("blueGreenGain")).toDouble(); + m_settings.blueRedGain = action.parameter(QLatin1String("blueRedGain")).toDouble(); + m_settings.bMonochrome = action.parameter(QLatin1String("bMonochrome")).toBool(); + m_settings.bPreserveLum = action.parameter(QLatin1String("bPreserveLum")).toBool(); + m_settings.greenBlueGain = action.parameter(QLatin1String("greenBlueGain")).toDouble(); m_settings.greenGreenGain = action.parameter(QLatin1String("greenGreenGain")).toDouble(); - m_settings.greenRedGain = action.parameter(QLatin1String("greenRedGain")).toDouble(); - m_settings.redBlueGain = action.parameter(QLatin1String("redBlueGain")).toDouble(); - m_settings.redGreenGain = action.parameter(QLatin1String("redGreenGain")).toDouble(); - m_settings.redRedGain = action.parameter(QLatin1String("redRedGain")).toDouble(); + m_settings.greenRedGain = action.parameter(QLatin1String("greenRedGain")).toDouble(); + m_settings.redBlueGain = action.parameter(QLatin1String("redBlueGain")).toDouble(); + m_settings.redGreenGain = action.parameter(QLatin1String("redGreenGain")).toDouble(); + m_settings.redRedGain = action.parameter(QLatin1String("redRedGain")).toDouble(); } } // namespace Digikam diff --git a/core/libs/dimg/filters/bw/tonalityfilter.h b/core/libs/dimg/filters/bw/tonalityfilter.h --- a/core/libs/dimg/filters/bw/tonalityfilter.h +++ b/core/libs/dimg/filters/bw/tonalityfilter.h @@ -67,7 +67,9 @@ public: explicit TonalityFilter(QObject* const parent = 0); - explicit TonalityFilter(DImg* const orgImage, QObject* const parent=0, const TonalityContainer& settings=TonalityContainer()); + explicit TonalityFilter(DImg* const orgImage, + QObject* const parent=0, + const TonalityContainer& settings=TonalityContainer()); virtual ~TonalityFilter(); static QString FilterIdentifier() diff --git a/core/libs/dimg/filters/bw/tonalityfilter.cpp b/core/libs/dimg/filters/bw/tonalityfilter.cpp --- a/core/libs/dimg/filters/bw/tonalityfilter.cpp +++ b/core/libs/dimg/filters/bw/tonalityfilter.cpp @@ -43,10 +43,12 @@ initFilter(); } -TonalityFilter::TonalityFilter(DImg* const orgImage, QObject* const parent, const TonalityContainer& settings) - : DImgThreadedFilter(orgImage, parent, QLatin1String("TonalityFilter")) +TonalityFilter::TonalityFilter(DImg* const orgImage, + QObject* const parent, + const TonalityContainer& settings) + : DImgThreadedFilter(orgImage, parent, QLatin1String("TonalityFilter")), + m_settings(settings) { - m_settings = settings; initFilter(); } @@ -79,14 +81,14 @@ { // Convert to grayscale using tonal mask - lig = lround(0.3 * ptr[2] + 0.59 * ptr[1] + 0.11 * ptr[0]); + lig = lround(0.3 * ptr[2] + 0.59 * ptr[1] + 0.11 * ptr[0]); mask.setHSL(hue, sat, lig, sixteenBit); ptr[0] = (uchar)mask.blue(); ptr[1] = (uchar)mask.green(); ptr[2] = (uchar)mask.red(); - ptr += 4; + ptr += 4; progress = (int)(((double)i * 100.0) / size); @@ -104,14 +106,14 @@ { // Convert to grayscale using tonal mask - lig = lround(0.3 * ptr[2] + 0.59 * ptr[1] + 0.11 * ptr[0]); + lig = lround(0.3 * ptr[2] + 0.59 * ptr[1] + 0.11 * ptr[0]); mask.setHSL(hue, sat, lig, sixteenBit); ptr[0] = (unsigned short)mask.blue(); ptr[1] = (unsigned short)mask.green(); ptr[2] = (unsigned short)mask.red(); - ptr += 4; + ptr += 4; progress = (int)(((double)i * 100.0) / size); diff --git a/core/libs/dimg/filters/cb/cbfilter.cpp b/core/libs/dimg/filters/cb/cbfilter.cpp --- a/core/libs/dimg/filters/cb/cbfilter.cpp +++ b/core/libs/dimg/filters/cb/cbfilter.cpp @@ -323,11 +323,11 @@ void CBFilter::adjustRGB(double r, double g, double b, double a, bool sixteenBit) { - int r_table[65536]; - int g_table[65536]; - int b_table[65536]; - int a_table[65536]; - int dummy_table[65536]; + int* r_table = new int[65536]; + int* g_table = new int[65536]; + int* b_table = new int[65536]; + int* a_table = new int[65536]; + int* dummy_table = new int[65536]; if (r == 1.0 && g == 1.0 && b == 1.0 && a == 1.0) { @@ -372,6 +372,12 @@ setTables(r_table, g_table, b_table, a_table, sixteenBit); } + + delete [] r_table; + delete [] g_table; + delete [] b_table; + delete [] a_table; + delete [] dummy_table; } FilterAction CBFilter::filterAction() diff --git a/core/libs/dimg/filters/curves/curvesfilter.h b/core/libs/dimg/filters/curves/curvesfilter.h --- a/core/libs/dimg/filters/curves/curvesfilter.h +++ b/core/libs/dimg/filters/curves/curvesfilter.h @@ -47,9 +47,15 @@ public: explicit CurvesFilter(QObject* const parent = 0); - explicit CurvesFilter(DImg* const orgImage, QObject* const parent=0, const CurvesContainer& settings=CurvesContainer()); - explicit CurvesFilter(const CurvesContainer& settings, DImgThreadedFilter* const master, - const DImg& orgImage, DImg& destImage, int progressBegin=0, int progressEnd=100); + explicit CurvesFilter(DImg* const orgImage, + QObject* const parent=0, + const CurvesContainer& settings=CurvesContainer()); + explicit CurvesFilter(const CurvesContainer& settings, + DImgThreadedFilter* const master, + const DImg& orgImage, + DImg& destImage, + int progressBegin=0, + int progressEnd=100); virtual ~CurvesFilter(); static QString FilterIdentifier() diff --git a/core/libs/dimg/filters/curves/curvesfilter.cpp b/core/libs/dimg/filters/curves/curvesfilter.cpp --- a/core/libs/dimg/filters/curves/curvesfilter.cpp +++ b/core/libs/dimg/filters/curves/curvesfilter.cpp @@ -38,19 +38,31 @@ initFilter(); } -CurvesFilter::CurvesFilter(DImg* const orgImage, QObject* const parent, const CurvesContainer& settings) - : DImgThreadedFilter(orgImage, parent, QLatin1String("CurvesFilter")) +CurvesFilter::CurvesFilter(DImg* const orgImage, + QObject* const parent, + const CurvesContainer& settings) + : DImgThreadedFilter(orgImage, + parent, + QLatin1String("CurvesFilter")), + m_settings(settings) { - m_settings = settings; initFilter(); } -CurvesFilter::CurvesFilter(const CurvesContainer& settings, DImgThreadedFilter* const master, - const DImg& orgImage, DImg& destImage, int progressBegin, int progressEnd) - : DImgThreadedFilter(master, orgImage, destImage, progressBegin, progressEnd, QLatin1String("CurvesFilter")) +CurvesFilter::CurvesFilter(const CurvesContainer& settings, + DImgThreadedFilter* const master, + const DImg& orgImage, + DImg& destImage, + int progressBegin, + int progressEnd) + : DImgThreadedFilter(master, + orgImage, + destImage, + progressBegin, + progressEnd, + QLatin1String("CurvesFilter")), + m_settings(settings) { - m_settings = settings; - // cannot operate in-place, so allocate dest image initFilter(); destImage = m_destImage; diff --git a/core/libs/dimg/filters/filteractionfilter.cpp b/core/libs/dimg/filters/filteractionfilter.cpp --- a/core/libs/dimg/filters/filteractionfilter.cpp +++ b/core/libs/dimg/filters/filteractionfilter.cpp @@ -112,6 +112,7 @@ return false; } } + return true; } diff --git a/core/libs/dimg/filters/fx/blurfilter.cpp b/core/libs/dimg/filters/fx/blurfilter.cpp --- a/core/libs/dimg/filters/fx/blurfilter.cpp +++ b/core/libs/dimg/filters/fx/blurfilter.cpp @@ -113,7 +113,7 @@ if (my < 0) { mh += my; - my = 0; + my = 0; } if ((my + mh) > height) @@ -169,7 +169,7 @@ if (mx < 0) { mw += mx; - mx = 0; + mx = 0; } if ((mx + mw) > width) diff --git a/core/libs/dimg/filters/fx/blurfxfilter.h b/core/libs/dimg/filters/fx/blurfxfilter.h --- a/core/libs/dimg/filters/fx/blurfxfilter.h +++ b/core/libs/dimg/filters/fx/blurfxfilter.h @@ -99,6 +99,35 @@ struct Args { + explicit Args() + { + start = 0; + stop = 0; + h = 0; + w = 0; + orgImage = 0; + destImage = 0; + X = 0; + Y = 0; + Distance = 0; + nCount = 0; + lpXArray = 0; + lpYArray = 0; + BlendRadius = 0; + bInversed = 0; + layer1 = 0; + layer2 = 0; + layer3 = 0; + layer4 = 0; + SizeW = 0; + SizeH = 0; + StrengthRange = 0; + Radius = 0; + Kernel = 0; + arrMult = 0; + pBlur = 0; + } + uint start; uint stop; uint h; @@ -201,13 +230,11 @@ // function to allocate a 2d array inline int** Alloc2DArray (int Columns, int Rows) { - // First, we declare our future 2d array to be returned - int** lpcArray = NULL; - - // Now, we alloc the main pointer with Columns - lpcArray = new int*[Columns]; + // We declare our future 2d array to be returned + // and we alloc the main pointer with Columns + int** lpcArray = new int*[Columns]; - for (int i = 0; i < Columns; ++i) + for (int i = 0 ; i < Columns ; ++i) { lpcArray[i] = new int[Rows]; } @@ -219,7 +246,7 @@ inline void Free2DArray (int** lpcArray, int Columns) { // loop to deallocate the columns - for (int i = 0; i < Columns; ++i) + for (int i = 0 ; i < Columns ; ++i) { delete [] lpcArray[i]; } diff --git a/core/libs/dimg/filters/fx/blurfxfilter.cpp b/core/libs/dimg/filters/fx/blurfxfilter.cpp --- a/core/libs/dimg/filters/fx/blurfxfilter.cpp +++ b/core/libs/dimg/filters/fx/blurfxfilter.cpp @@ -1062,6 +1062,7 @@ int yMaxBlur = yMax + BlurRadius; DImg areaImage = orgImage->copy(xMinBlur, yMaxBlur, xMaxBlur - xMinBlur, yMaxBlur - yMinBlur); + // cppcheck-suppress unusedScopedObject BlurFilter(this, *orgImage, *destImage, 10, 75, BlurRadius); // I am unsure about differences of 1 pixel @@ -1097,7 +1098,7 @@ // we have reached the main loop - for (int h = yMin; runningFlag() && (h < yMax); ++h) + for (int h = yMin ; runningFlag() && (h < yMax) ; ++h) { for (int j = 0 ; runningFlag() && (j < vals.count()-1) ; ++j) { @@ -1135,7 +1136,7 @@ DColor color, radiusColor, radiusColorBlur; int offset, loopOffset; - for (uint w = prm.start; runningFlag() && (w < prm.stop); ++w) + for (uint w = prm.start ; runningFlag() && (w < prm.stop) ; ++w) { // we initialize the variables sumR = sumG = sumB = nCount = 0; @@ -1145,7 +1146,7 @@ color.setColor(data + offset, sixteenBit); // ...we enter this loop to sum the bits - for (int a = -prm.Radius; runningFlag() && (a <= prm.Radius); ++a) + for (int a = -prm.Radius ; runningFlag() && (a <= prm.Radius) ; ++a) { // verify if is inside the rect if (IsInside(Width, Height, w + a, prm.h)) @@ -1205,7 +1206,7 @@ DColor color, radiusColor, radiusColorBlur; int offset, loopOffset; - for (uint h = prm.start; runningFlag() && (h < prm.stop); ++h) + for (uint h = prm.start ; runningFlag() && (h < prm.stop) ; ++h) { // we initialize the variables sumR = sumG = sumB = nCount = 0; @@ -1215,7 +1216,7 @@ color.setColor(data + offset, sixteenBit); // ...we enter this loop to sum the bits - for (int a = -prm.Radius; runningFlag() && (a <= prm.Radius); ++a) + for (int a = -prm.Radius ; runningFlag() && (a <= prm.Radius) ; ++a) { // verify if is inside the rect if (IsInside(Width, Height, prm.w, h + a)) @@ -1312,7 +1313,7 @@ // we have reached the main loop - for (uint h = 0; runningFlag() && (h < orgImage->height()); ++h) + for (uint h = 0 ; runningFlag() && (h < orgImage->height()) ; ++h) { for (int j = 0 ; runningFlag() && (j < valsw.count()-1) ; ++j) { @@ -1341,7 +1342,7 @@ tasks.clear(); - for (uint w = 0; runningFlag() && (w < orgImage->width()); ++w) + for (uint w = 0 ; runningFlag() && (w < orgImage->width()) ; ++w) { for (int j = 0 ; runningFlag() && (j < valsh.count()-1) ; ++j) { diff --git a/core/libs/dimg/filters/fx/charcoalfilter.cpp b/core/libs/dimg/filters/fx/charcoalfilter.cpp --- a/core/libs/dimg/filters/fx/charcoalfilter.cpp +++ b/core/libs/dimg/filters/fx/charcoalfilter.cpp @@ -73,7 +73,10 @@ initFilter(); } -CharcoalFilter::CharcoalFilter(DImg* const orgImage, QObject* const parent, double pencil, double smooth) +CharcoalFilter::CharcoalFilter(DImg* const orgImage, + QObject* const parent, + double pencil, + double smooth) : DImgThreadedFilter(orgImage, parent, QLatin1String("Charcoal")), d(new Private) { @@ -105,7 +108,7 @@ // -- Applying Edge effect ----------------------------------------------- - long i = 0; + long i = 0; int kernelWidth = getOptimalKernelWidth(d->pencil, d->smooth); if ((int)m_orgImage.width() < kernelWidth) @@ -132,6 +135,7 @@ // -- Applying Gaussian blur effect --------------------------------------- + // cppcheck-suppress unusedScopedObject BlurFilter(this, m_destImage, m_destImage, 80, 85, (int)(d->smooth / 10.0)); if (!runningFlag()) @@ -203,24 +207,24 @@ { sy = y - (kernelWidth / 2); - for (uint x = 0; runningFlag() && (x < width); ++x) + for (uint x = 0 ; runningFlag() && (x < width) ; ++x) { k = normal_kernel; red = green = blue = alpha = 0; sy = y - (kernelWidth / 2); - for (mcy = 0; runningFlag() && (mcy < kernelWidth); ++mcy, ++sy) + for (mcy = 0 ; runningFlag() && (mcy < kernelWidth) ; ++mcy, ++sy) { my = sy < 0 ? 0 : sy > (int) height - 1 ? height - 1 : sy; sx = x + (-kernelWidth / 2); - for (mcx = 0; runningFlag() && (mcx < kernelWidth); ++mcx, ++sx) + for (mcx = 0 ; runningFlag() && (mcx < kernelWidth) ; ++mcx, ++sx) { - mx = sx < 0 ? 0 : sx > (int) width - 1 ? width - 1 : sx; + mx = sx < 0 ? 0 : sx > (int) width - 1 ? width - 1 : sx; DColor color(sdata + mx * sdepth + (width * my * sdepth), sixteenBit); - red += (*k) * (color.red() * 257.0); + red += (*k) * (color.red() * 257.0); green += (*k) * (color.green() * 257.0); - blue += (*k) * (color.blue() * 257.0); + blue += (*k) * (color.blue() * 257.0); alpha += (*k) * (color.alpha() * 257.0); ++k; } @@ -231,7 +235,7 @@ blue = blue < 0.0 ? 0.0 : blue > maxClamp ? maxClamp : blue + 0.5; alpha = alpha < 0.0 ? 0.0 : alpha > maxClamp ? maxClamp : alpha + 0.5; - DColor color((int)(red / 257UL), (int)(green / 257UL), + DColor color((int)(red / 257UL), (int)(green / 257UL), (int)(blue / 257UL), (int)(alpha / 257UL), sixteenBit); color.setPixel((ddata + x * ddepth + (width * y * ddepth))); } @@ -312,9 +316,9 @@ int CharcoalFilter::getOptimalKernelWidth(double radius, double sigma) { - double normalize, value; - long kernelWidth; - long u; + double normalize, value; + long kernelWidth; + long u; if (radius > 0.0) { @@ -341,7 +345,7 @@ kernelWidth += 2; } - return((int)kernelWidth - 2); + return ((int)kernelWidth - 2); } FilterAction CharcoalFilter::filterAction() diff --git a/core/libs/dimg/filters/fx/colorfxfilter.h b/core/libs/dimg/filters/fx/colorfxfilter.h --- a/core/libs/dimg/filters/fx/colorfxfilter.h +++ b/core/libs/dimg/filters/fx/colorfxfilter.h @@ -85,7 +85,9 @@ public: explicit ColorFXFilter(QObject* const parent = 0); - explicit ColorFXFilter(DImg* const orgImage, QObject* const parent, const ColorFXContainer& settings=ColorFXContainer()); + explicit ColorFXFilter(DImg* const orgImage, + QObject* const parent, + const ColorFXContainer& settings=ColorFXContainer()); ~ColorFXFilter(); static QString FilterIdentifier() diff --git a/core/libs/dimg/filters/fx/colorfxfilter.cpp b/core/libs/dimg/filters/fx/colorfxfilter.cpp --- a/core/libs/dimg/filters/fx/colorfxfilter.cpp +++ b/core/libs/dimg/filters/fx/colorfxfilter.cpp @@ -59,11 +59,10 @@ QObject* const parent, const ColorFXContainer& settings) : DImgThreadedFilter(orgImage, parent, QLatin1String("ColorFX")), + m_settings(settings), m_lutTable(0), m_lutTableSize(0) { - m_settings = settings; - loadLut3D(m_settings.path); initFilter(); @@ -324,7 +323,7 @@ Intensity = (Intensity < 0) ? 0 : (Intensity > 5) ? 5 : Intensity; BW = (BW < 1) ? 1 : (BW > 5) ? 5 : BW; - uchar* ptr, *ptr1, *ptr2; + uchar* ptr=0, *ptr1=0, *ptr2=0; // these must be uint, we need full 2^32 range for 16 bit uint color_1, color_2, colorPoint, colorOther1, colorOther2; @@ -334,17 +333,17 @@ double intensityFactor = qSqrt(1 << Intensity); - for (int h = 0; h < Height; ++h) + for (int h = 0 ; h < Height ; ++h) { - for (int w = 0; w < Width; ++w) + for (int w = 0 ; w < Width ; ++w) { ptr = pResBits + getOffset(Width, w, h, bytesDepth); ptr1 = pResBits + getOffset(Width, w + Lim_Max(w, BW, Width), h, bytesDepth); ptr2 = pResBits + getOffset(Width, w, h + Lim_Max(h, BW, Height), bytesDepth); if (sixteenBit) { - for (int k = 0; k <= 2; ++k) + for (int k = 0 ; k <= 2 ; ++k) { colorPoint = reinterpret_cast(ptr)[k]; colorOther1 = reinterpret_cast(ptr1)[k]; @@ -368,7 +367,7 @@ } else { - for (int k = 0; k <= 2; ++k) + for (int k = 0 ; k <= 2 ; ++k) { colorPoint = ptr[k]; colorOther1 = ptr1[k]; @@ -390,7 +389,7 @@ } } -#define Lut3DSetPixel(table, w, x, y, p) \ +#define Lut3DSetPixel(table, w, x, y, p) \ table[((y) * (w) + (x)) * 4 + 0] = qRed(p) * 65535 / 255; \ table[((y) * (w) + (x)) * 4 + 1] = qGreen(p) * 65535 / 255; \ table[((y) * (w) + (x)) * 4 + 2] = qBlue(p) * 65535 / 255; @@ -419,7 +418,7 @@ if (img.width() == img.height()) { // HALD LUT (Like imagemagick creates) - int w = img.width(); + int w = img.width(); m_lutTableSize = int(pow(pow(w, 1 / 3.0), 2) + 0.1); diff --git a/core/libs/dimg/filters/fx/pixelsaliasfilter.h b/core/libs/dimg/filters/fx/pixelsaliasfilter.h --- a/core/libs/dimg/filters/fx/pixelsaliasfilter.h +++ b/core/libs/dimg/filters/fx/pixelsaliasfilter.h @@ -41,8 +41,8 @@ { public: - PixelsAliasFilter() {}; - ~PixelsAliasFilter() {}; + explicit PixelsAliasFilter(); + ~PixelsAliasFilter(); public: // Public methods. diff --git a/core/libs/dimg/filters/fx/pixelsaliasfilter.cpp b/core/libs/dimg/filters/fx/pixelsaliasfilter.cpp --- a/core/libs/dimg/filters/fx/pixelsaliasfilter.cpp +++ b/core/libs/dimg/filters/fx/pixelsaliasfilter.cpp @@ -40,8 +40,18 @@ namespace Digikam { -/** Function to perform pixel antialiasing with 8 bits/color/pixel images. This method is used to smooth target - image in transformation method like free rotation or shear tool. */ +PixelsAliasFilter::PixelsAliasFilter() +{ +} + +PixelsAliasFilter::~PixelsAliasFilter() +{ +} + +/** + * Function to perform pixel antialiasing with 8 bits/color/pixel images. This method is used to smooth target + * image in transformation method like free rotation or shear tool. + */ void PixelsAliasFilter::pixelAntiAliasing(uchar* data, int Width, int Height, double X, double Y, uchar* A, uchar* R, uchar* G, uchar* B) { @@ -70,9 +80,9 @@ lfWeightX[1] = 1.0 - (lfWeightX[0] = -(X - (double)nX)); } - for (int loopx = 0; loopx <= 1; ++loopx) + for (int loopx = 0 ; loopx <= 1 ; ++loopx) { - for (int loopy = 0; loopy <= 1; ++loopy) + for (int loopy = 0 ; loopy <= 1 ; ++loopy) { lfWeight = lfWeightX[loopx] * lfWeightY[loopy]; j = setPositionAdjusted(Width, Height, nX + loopx, nY + loopy); @@ -94,8 +104,10 @@ *A = CLAMP0255((int)lfTotalA); } -/** Function to perform pixel antialiasing with 16 bits/color/pixel images. This method is used to smooth target - image in transformation method like free rotation or shear tool. */ +/** + * Function to perform pixel antialiasing with 16 bits/color/pixel images. This method is used to smooth target + * image in transformation method like free rotation or shear tool. + */ void PixelsAliasFilter::pixelAntiAliasing16(unsigned short* data, int Width, int Height, double X, double Y, unsigned short* A, unsigned short* R, unsigned short* G, unsigned short* B) @@ -125,12 +137,12 @@ lfWeightX[1] = 1.0 - (lfWeightX[0] = -(X - (double)nX)); } - for (int loopx = 0; loopx <= 1; ++loopx) + for (int loopx = 0 ; loopx <= 1 ; ++loopx) { - for (int loopy = 0; loopy <= 1; ++loopy) + for (int loopy = 0 ; loopy <= 1 ; ++loopy) { lfWeight = lfWeightX[loopx] * lfWeightY[loopy]; - j = setPositionAdjusted(Width, Height, nX + loopx, nY + loopy); + j = setPositionAdjusted(Width, Height, nX + loopx, nY + loopy); lfTotalB += ((double)data[j] * lfWeight); ++j; diff --git a/core/libs/dimg/filters/fx/raindropfilter.h b/core/libs/dimg/filters/fx/raindropfilter.h --- a/core/libs/dimg/filters/fx/raindropfilter.h +++ b/core/libs/dimg/filters/fx/raindropfilter.h @@ -44,8 +44,12 @@ public: explicit RainDropFilter(QObject* const parent = 0); - explicit RainDropFilter(DImg* const orgImage, QObject* const parent=0, int drop=80, - int amount=150, int coeff=30, const QRect& selection=QRect(0, 0, 0, 0)); + explicit RainDropFilter(DImg* const orgImage, + QObject* const parent=0, + int drop=80, + int amount=150, + int coeff=30, + const QRect& selection=QRect(0, 0, 0, 0)); ~RainDropFilter(); static QString FilterIdentifier() diff --git a/core/libs/dimg/filters/fx/raindropfilter.cpp b/core/libs/dimg/filters/fx/raindropfilter.cpp --- a/core/libs/dimg/filters/fx/raindropfilter.cpp +++ b/core/libs/dimg/filters/fx/raindropfilter.cpp @@ -263,7 +263,7 @@ int nBlurPixels, nBlurRadius; Coeff *= 0.01; int nHalfSize = DropSize / 2; - double lfDiv = (double)nHalfSize / log(Coeff * (double)nHalfSize + 1.0); + double lfDiv = (double)nHalfSize / log1p(Coeff * (double)nHalfSize); for (h = -nHalfSize ; runningFlag() && (h <= nHalfSize) ; ++h) { @@ -608,6 +608,7 @@ { bool bIsWOk = ((X < 0) ? false : (X >= Width ) ? false : true); bool bIsHOk = ((Y < 0) ? false : (Y >= Height) ? false : true); + return (bIsWOk && bIsHOk); } diff --git a/core/libs/dimg/filters/greycstoration/greycstorationfilter.cpp b/core/libs/dimg/filters/greycstoration/greycstorationfilter.cpp --- a/core/libs/dimg/filters/greycstoration/greycstorationfilter.cpp +++ b/core/libs/dimg/filters/greycstoration/greycstorationfilter.cpp @@ -22,10 +22,9 @@ * * ============================================================ */ - -/** Don't use CImg interface (keyboard/mouse interaction) */ +// Don't use CImg interface (keyboard/mouse interaction). #define cimg_display 0 -/** Only print debug information on the console */ +// Only print debug information on the console. #define cimg_debug 1 #include "greycstorationfilter.h" @@ -47,36 +46,35 @@ #define cimg_plugin "cimg/greycstoration.h" -/** Uncomment this line if you use future GreycStoration implementation with GFact parameter - */ +// Uncomment this line if you use future GreycStoration implementation with GFact parameter. #define GREYSTORATION_USING_GFACT 1 // Pragma directives to reduce warnings from CImg header files. #if !defined(Q_OS_DARWIN) && defined(Q_CC_GNU) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-local-typedefs" +# pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #if defined(Q_OS_DARWIN) && defined(Q_CC_CLANG) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-parameter" -#pragma clang diagnostic ignored "-Wcast-align" -#pragma clang diagnostic ignored "-Wshift-negative-value" -#pragma clang diagnostic ignored "-Wunused-local-typedef" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunused-parameter" +# pragma clang diagnostic ignored "-Wcast-align" +# pragma clang diagnostic ignored "-Wshift-negative-value" +# pragma clang diagnostic ignored "-Wunused-local-typedef" #endif // CImg includes #include "cimg/CImg.h" // Restore warnings #if !defined(Q_OS_DARWIN) && defined(Q_CC_GNU) -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif #if defined(Q_OS_DARWIN) && defined(Q_CC_CLANG) -#pragma clang diagnostic pop +# pragma clang diagnostic pop #endif extern "C" @@ -238,7 +236,7 @@ void GreycstorationFilter::filterImage() { - int x, y; + int x, y; qCDebug(DIGIKAM_DIMG_LOG) << "Initialization..."; @@ -308,9 +306,9 @@ { uchar* ptr = newData; - for (y = 0; y < newHeight; ++y) + for (y = 0 ; y < newHeight ; ++y) { - for (x = 0; x < newWidth; ++x) + for (x = 0 ; x < newWidth ; ++x) { // Overwrite RGB values to destination. ptr[0] = static_cast(d->img(x, y, 0)); // Blue @@ -325,9 +323,9 @@ { unsigned short* ptr = reinterpret_cast(newData); - for (y = 0; y < newHeight; ++y) + for (y = 0 ; y < newHeight ; ++y) { - for (x = 0; x < newWidth; ++x) + for (x = 0 ; x < newWidth ; ++x) { // Overwrite RGB values to destination. ptr[0] = static_cast(d->img(x, y, 0)); // Blue @@ -379,9 +377,9 @@ d->mask = CImg(d->inPaintingMask.width(), d->inPaintingMask.height(), 1, 3); uchar* ptr = d->inPaintingMask.bits(); - for (y = 0; y < d->inPaintingMask.height(); ++y) + for (y = 0 ; y < d->inPaintingMask.height() ; ++y) { - for (x = 0; x < d->inPaintingMask.width(); ++x) + for (x = 0 ; x < d->inPaintingMask.width() ; ++x) { d->mask(x, y, 0) = ptr[2]; // blue. d->mask(x, y, 1) = ptr[1]; // green. @@ -433,6 +431,7 @@ d->mask.assign(d->img.dimx(), d->img.dimy(), 1, 1, 255); + // cppcheck-suppress knownConditionTrueFalse if (!anchor) { d->mask.resize(w, h, 1, 1, 1); @@ -477,7 +476,7 @@ int w = m_destImage.width(); int h = m_destImage.height(); - while (d->img.dimx() > 2 * w && d->img.dimy() > 2 * h) + while ((d->img.dimx() > 2 * w) && (d->img.dimy() > 2 * h)) { d->img.resize_halfXY(); } diff --git a/core/libs/dimg/filters/greycstoration/greycstorationsettings.h b/core/libs/dimg/filters/greycstoration/greycstorationsettings.h --- a/core/libs/dimg/filters/greycstoration/greycstorationsettings.h +++ b/core/libs/dimg/filters/greycstoration/greycstorationsettings.h @@ -45,7 +45,7 @@ public: - explicit GreycstorationSettings(QTabWidget* parent); + explicit GreycstorationSettings(QTabWidget* const parent); ~GreycstorationSettings(); void setSettings(const GreycstorationContainer& settings); diff --git a/core/libs/dimg/filters/greycstoration/greycstorationsettings.cpp b/core/libs/dimg/filters/greycstoration/greycstorationsettings.cpp --- a/core/libs/dimg/filters/greycstoration/greycstorationsettings.cpp +++ b/core/libs/dimg/filters/greycstoration/greycstorationsettings.cpp @@ -119,12 +119,11 @@ DIntNumInput* tileInput; }; -GreycstorationSettings::GreycstorationSettings(QTabWidget* parent) +GreycstorationSettings::GreycstorationSettings(QTabWidget* const parent) : QObject(static_cast(parent)), d(new Private) { - d->parent = parent; - + d->parent = parent; const int spacing = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); // ------------------------------------------------------------- diff --git a/core/libs/dimg/filters/icc/iccmanager.cpp b/core/libs/dimg/filters/icc/iccmanager.cpp --- a/core/libs/dimg/filters/icc/iccmanager.cpp +++ b/core/libs/dimg/filters/icc/iccmanager.cpp @@ -43,9 +43,10 @@ public: explicit Private() + : profileMismatch(false), + settings(ICCSettingsContainer()), + observer(0) { - profileMismatch = false; - observer = 0; } DImg image; diff --git a/core/libs/dimg/filters/icc/iccsettings.h b/core/libs/dimg/filters/icc/iccsettings.h --- a/core/libs/dimg/filters/icc/iccsettings.h +++ b/core/libs/dimg/filters/icc/iccsettings.h @@ -116,7 +116,7 @@ private: - IccSettings(); + explicit IccSettings(); ~IccSettings(); void readFromConfig(); diff --git a/core/libs/dimg/filters/icc/iccsettings.cpp b/core/libs/dimg/filters/icc/iccsettings.cpp --- a/core/libs/dimg/filters/icc/iccsettings.cpp +++ b/core/libs/dimg/filters/icc/iccsettings.cpp @@ -54,7 +54,7 @@ # include # include # include -#endif /* HAVE_X11 */ +#endif // HAVE_X11 namespace Digikam { @@ -64,7 +64,8 @@ public: explicit Private() - : configGroup(QLatin1String("Color Management")) + : settings(ICCSettingsContainer()), + configGroup(QLatin1String("Color Management")) { } diff --git a/core/libs/dimg/filters/levels/histogrambox.h b/core/libs/dimg/filters/levels/histogrambox.h --- a/core/libs/dimg/filters/levels/histogrambox.h +++ b/core/libs/dimg/filters/levels/histogrambox.h @@ -48,7 +48,9 @@ public: - explicit HistogramBox(QWidget* const parent = 0, HistogramBoxType type = Digikam::LRGB, bool selectMode = false); + explicit HistogramBox(QWidget* const parent = 0, + HistogramBoxType type = Digikam::LRGB, + bool selectMode = false); ~HistogramBox(); void setHistogramType(HistogramBoxType type); diff --git a/core/libs/dimg/filters/levels/histogrambox.cpp b/core/libs/dimg/filters/levels/histogrambox.cpp --- a/core/libs/dimg/filters/levels/histogrambox.cpp +++ b/core/libs/dimg/filters/levels/histogrambox.cpp @@ -83,7 +83,8 @@ }; HistogramBox::HistogramBox(QWidget* const parent, HistogramBoxType type, bool selectMode) - : QWidget(parent), d(new Private) + : QWidget(parent), + d(new Private) { d->channelCB = new QComboBox(this); QLabel* const channelLabel = new QLabel(i18n("Channel:"), this); @@ -272,24 +273,24 @@ typedef QPair ChannelPair; ChannelPair luminosityPair(i18nc("The luminosity channel", "Luminosity"), i18n( - "Luminosity: display the image's luminosity values.")); + "Luminosity: display the image's luminosity values.")); ChannelPair redPair(i18nc("The red channel", "Red"), i18n( - "Red: display the red image-channel values.")); + "Red: display the red image-channel values.")); ChannelPair greenPair(i18nc("The green channel", "Green"), i18n( - "Green: display the green image-channel values.")); + "Green: display the green image-channel values.")); ChannelPair bluePair(i18nc("The blue channel", "Blue"), i18n( - "Blue: display the blue image-channel values.")); + "Blue: display the blue image-channel values.")); ChannelPair colorsPair(i18nc("The colors channel", "Colors"), i18n( - "Colors: Display all color channel values at the same time.")); + "Colors: Display all color channel values at the same time.")); ChannelPair alphaPair(i18nc("The alpha channel", "Alpha"), i18n( - "Alpha: display the alpha image-channel values. " - "This channel corresponds to the transparency value and " - "is supported by some image formats, such as PNG or TIF.")); + "Alpha: display the alpha image-channel values. " + "This channel corresponds to the transparency value and " + "is supported by some image formats, such as PNG or TIF.")); channelDescMap.insert(LuminosityChannel, luminosityPair); channelDescMap.insert(RedChannel, redPair); diff --git a/core/libs/dimg/filters/levels/histogrampainter.cpp b/core/libs/dimg/filters/levels/histogrampainter.cpp --- a/core/libs/dimg/filters/levels/histogrampainter.cpp +++ b/core/libs/dimg/filters/levels/histogrampainter.cpp @@ -51,8 +51,8 @@ public: - explicit Private() : - histogram(0), + explicit Private() + : histogram(0), widgetToInitFrom(0), scale(LogScaleHistogram), channelType(LuminosityChannel), @@ -514,7 +514,8 @@ }; HistogramPainter::HistogramPainter(QObject* const parent) - : QObject(parent), d(new Private()) + : QObject(parent), + d(new Private()) { } diff --git a/core/libs/dimg/filters/levels/histogramwidget.h b/core/libs/dimg/filters/levels/histogramwidget.h --- a/core/libs/dimg/filters/levels/histogramwidget.h +++ b/core/libs/dimg/filters/levels/histogramwidget.h @@ -54,7 +54,8 @@ /** Standard constructor. Needed to use updateData() methods after to create valid instance. */ HistogramWidget(int w, int h, // Widget size. - QWidget* const parent=0, bool selectMode=true, + QWidget* const parent=0, + bool selectMode=true, bool showProgress=true, bool statisticsVisible=false); diff --git a/core/libs/dimg/filters/levels/histogramwidget.cpp b/core/libs/dimg/filters/levels/histogramwidget.cpp --- a/core/libs/dimg/filters/levels/histogramwidget.cpp +++ b/core/libs/dimg/filters/levels/histogramwidget.cpp @@ -123,7 +123,7 @@ int animationState; QPropertyAnimation* animation; - DWorkingPixmap progressPix; + DWorkingPixmap progressPix; DColor colorGuide; @@ -133,7 +133,8 @@ HistogramWidget::HistogramWidget(int w, int h, QWidget* const parent, bool selectMode, bool showProgress, bool statisticsVisible) - : QWidget(parent), d(new Private) + : QWidget(parent), + d(new Private) { setup(w, h, selectMode, statisticsVisible); d->showProgress = showProgress; @@ -187,7 +188,7 @@ emit signalMaximumValueChanged(d->range); - if (!img.isNull() || (img.isNull() && sel.isNull())) + if (!img.isNull() || sel.isNull()) { // do not delete main histogram if only the selection is reset delete d->imageHistogram; @@ -253,7 +254,7 @@ { d->renderingType = type; - ImageHistogram* nowUsedHistogram = currentHistogram(); + ImageHistogram* const nowUsedHistogram = currentHistogram(); if (!nowUsedHistogram) { diff --git a/core/libs/dimg/filters/levels/imagehistogram.h b/core/libs/dimg/filters/levels/imagehistogram.h --- a/core/libs/dimg/filters/levels/imagehistogram.h +++ b/core/libs/dimg/filters/levels/imagehistogram.h @@ -49,15 +49,21 @@ explicit ImageHistogram(const DImg& img, QObject* const parent = 0); ~ImageHistogram(); - /** Started computation: synchronous or threaded */ + /** + * Started computation: synchronous or threaded. + */ void calculate(); void calculateInThread(); - /** Stop threaded computation. */ + /** + * Stop threaded computation. + */ void stopCalculation(); bool isCalculating() const; - /** Methods to access the histogram data.*/ + /** + * Methods to access the histogram data. + */ bool isSixteenBit() const; bool isValid() const; diff --git a/core/libs/dimg/filters/levels/imagehistogram.cpp b/core/libs/dimg/filters/levels/imagehistogram.cpp --- a/core/libs/dimg/filters/levels/imagehistogram.cpp +++ b/core/libs/dimg/filters/levels/imagehistogram.cpp @@ -81,7 +81,8 @@ }; ImageHistogram::ImageHistogram(const DImg& img, QObject* const parent) - : DynamicThread(parent), d(new Private) + : DynamicThread(parent), + d(new Private) { // A simple copy of reference must be enough instead a deep copy. See this BKO comment for details: // https://bugs.kde.org/show_bug.cgi?id=274555#c40 @@ -197,6 +198,7 @@ // count here instead of inside the loop, because d is not optimized because it's not defined in the header const uint count = d->img.width() * d->img.height() * 4; + for (i = 0 ; runningFlag() && (i < count) ; i += 4) { blue = data[i ]; @@ -228,6 +230,7 @@ // count here instead of inside the loop, because d is not optimized because it's not defined in the header const uint count = d->img.width() * d->img.height() * 4; + for (i = 0 ; runningFlag() && (i < count) ; i += 4) { blue = data[i ]; diff --git a/core/libs/dimg/filters/levels/levelsfilter.h b/core/libs/dimg/filters/levels/levelsfilter.h --- a/core/libs/dimg/filters/levels/levelsfilter.h +++ b/core/libs/dimg/filters/levels/levelsfilter.h @@ -53,7 +53,9 @@ } }; - ~LevelsContainer() {}; + ~LevelsContainer() + { + }; public: @@ -73,9 +75,15 @@ public: explicit LevelsFilter(QObject* const parent = 0); - explicit LevelsFilter(DImg* const orgImage, QObject* const parent=0, const LevelsContainer& settings=LevelsContainer()); - explicit LevelsFilter(const LevelsContainer& settings, DImgThreadedFilter* const master, - const DImg& orgImage, DImg& destImage, int progressBegin=0, int progressEnd=100); + explicit LevelsFilter(DImg* const orgImage, + QObject* const parent=0, + const LevelsContainer& settings=LevelsContainer()); + explicit LevelsFilter(const LevelsContainer& settings, + DImgThreadedFilter* const master, + const DImg& orgImage, + DImg& destImage, + int progressBegin=0, + int progressEnd=100); virtual ~LevelsFilter(); static QString FilterIdentifier() diff --git a/core/libs/dimg/filters/levels/levelsfilter.cpp b/core/libs/dimg/filters/levels/levelsfilter.cpp --- a/core/libs/dimg/filters/levels/levelsfilter.cpp +++ b/core/libs/dimg/filters/levels/levelsfilter.cpp @@ -38,18 +38,27 @@ initFilter(); } -LevelsFilter::LevelsFilter(DImg* const orgImage, QObject* const parent, const LevelsContainer& settings) - : DImgThreadedFilter(orgImage, parent, QLatin1String("LevelsFilter")) +LevelsFilter::LevelsFilter(DImg* const orgImage, + QObject* const parent, + const LevelsContainer& settings) + : DImgThreadedFilter(orgImage, parent, + QLatin1String("LevelsFilter")), + m_settings(settings) { - m_settings = settings; initFilter(); } -LevelsFilter::LevelsFilter(const LevelsContainer& settings, DImgThreadedFilter* const master, - const DImg& orgImage, DImg& destImage, int progressBegin, int progressEnd) - : DImgThreadedFilter(master, orgImage, destImage, progressBegin, progressEnd, QLatin1String("LevelsFilter")) +LevelsFilter::LevelsFilter(const LevelsContainer& settings, + DImgThreadedFilter* const master, + const DImg& orgImage, + DImg& destImage, + int progressBegin, + int progressEnd) + : DImgThreadedFilter(master, orgImage, destImage, + progressBegin, progressEnd, + QLatin1String("LevelsFilter")), + m_settings(settings) { - m_settings = settings; initFilter(); destImage = m_destImage; } @@ -75,7 +84,8 @@ postProgress(50); - m_destImage = DImg(m_orgImage.width(), m_orgImage.height(), m_orgImage.sixteenBit(), m_orgImage.hasAlpha()); + m_destImage = DImg(m_orgImage.width(), m_orgImage.height(), + m_orgImage.sixteenBit(), m_orgImage.hasAlpha()); postProgress(60); levels.levelsCalculateTransfers(); @@ -85,16 +95,17 @@ levels.levelsLutSetup(AlphaChannel); postProgress(80); - levels.levelsLutProcess(m_orgImage.bits(), m_destImage.bits(), m_orgImage.width(), m_orgImage.height()); + levels.levelsLutProcess(m_orgImage.bits(), m_destImage.bits(), + m_orgImage.width(), m_orgImage.height()); postProgress(90); } FilterAction LevelsFilter::filterAction() { FilterAction action(FilterIdentifier(), CurrentVersion()); action.setDisplayableName(DisplayableName()); - for (int i = 0; i < 5; ++i) + for (int i = 0 ; i < 5 ; ++i) { action.addParameter(QString::fromLatin1("gamma[%1]").arg(i), m_settings.gamma[i]); action.addParameter(QString::fromLatin1("hInput[%1]").arg(i), m_settings.hInput[i]); @@ -108,7 +119,7 @@ void LevelsFilter::readParameters(const Digikam::FilterAction& action) { - for (int i = 0; i < 5; ++i) + for (int i = 0 ; i < 5 ; ++i) { m_settings.gamma[i] = action.parameter(QString::fromLatin1("gamma[%1]").arg(i)).toDouble(); m_settings.hInput[i] = action.parameter(QString::fromLatin1("hInput[%1]").arg(i)).toInt(); diff --git a/core/libs/dimg/filters/randomnumbergenerator.cpp b/core/libs/dimg/filters/randomnumbergenerator.cpp --- a/core/libs/dimg/filters/randomnumbergenerator.cpp +++ b/core/libs/dimg/filters/randomnumbergenerator.cpp @@ -84,7 +84,8 @@ } #endif - /* Fallback, mostly for Windows, where UUID generation + /* + * Fallback, mostly for Windows, where UUID generation * is supposed to be very good. */ if (isEmpty()) @@ -125,7 +126,7 @@ boost::random_device device; boost::random_device::result_type* ptr = reinterpret_cast(data()); - for (int i = 0; i < stepSize; ++i) + for (int i = 0 ; i < stepSize ; ++i) { *ptr++ = device(); } @@ -215,20 +216,23 @@ { boost::uniform_smallint<> distribution(min, max); boost::variate_generator > generator(d->engine, distribution); + return generator(); } double RandomNumberGenerator::number(double min, double max) { boost::uniform_real<> distribution(min, max); boost::variate_generator > generator(d->engine, distribution); + return generator(); } bool RandomNumberGenerator::yesOrNo(double p) { boost::bernoulli_distribution<> distribution(p); boost::variate_generator > generator(d->engine, distribution); + return generator(); } diff --git a/core/libs/dimg/filters/wb/wbfilter.cpp b/core/libs/dimg/filters/wb/wbfilter.cpp --- a/core/libs/dimg/filters/wb/wbfilter.cpp +++ b/core/libs/dimg/filters/wb/wbfilter.cpp @@ -58,7 +58,7 @@ WP = 0; rgbMax = 0; - for (int i = 0; i < 65536; ++i) + for (int i = 0 ; i < 65536 ; ++i) { curve[i] = 0.0; } @@ -88,18 +88,18 @@ WBFilter::WBFilter(DImg* const orgImage, QObject* const parent, const WBContainer& settings) : DImgThreadedFilter(orgImage, parent, QLatin1String("WBFilter")), + m_settings(settings), d(new Private) { - m_settings = settings; initFilter(); } WBFilter::WBFilter(const WBContainer& settings, DImgThreadedFilter* const master, const DImg& orgImage, const DImg& destImage, int progressBegin, int progressEnd) : DImgThreadedFilter(master, orgImage, destImage, progressBegin, progressEnd, QLatin1String("WBFilter")), + m_settings(settings), d(new Private) { - m_settings = settings; filterImage(); } @@ -116,7 +116,8 @@ // Set final lut. setRGBmult(); - d->mr = d->mb = 1.0; + d->mr = 1.0; + d->mb = 1.0; if (d->clipSat) { @@ -127,7 +128,7 @@ setRGBmult(); // See bug #259223 : scaling down the rgb multipliers just enough to prevent clipping - if (m_settings.maxr == -1 && m_settings.maxg == -1 && m_settings.maxb == -1) + if ((m_settings.maxr == -1) && (m_settings.maxg == -1) && (m_settings.maxb == -1)) { findChanelsMax((const DImg*) &m_orgImage, m_settings.maxr, @@ -146,7 +147,9 @@ { // Calculate Temperature and Green component from color picked. - float mr=0.0, mg=0.0, mb=0.0; + float mr = 0.0; + float mg = 0.0; + float mb = 0.0; qCDebug(DIGIKAM_DIMG_LOG) << "Sums: R:" << tc.red() << " G:" << tc.green() << " B:" << tc.blue(); @@ -159,7 +162,7 @@ double mBR = (double)tc.blue() / (double)tc.red(); green = 1.0; - for (temperature = (tmin + tmax) / 2; tmax - tmin > 10; temperature = (tmin + tmax) / 2) + for (temperature = (tmin + tmax) / 2 ; tmax - tmin > 10 ; temperature = (tmin + tmax) / 2) { qCDebug(DIGIKAM_DIMG_LOG) << "Intermediate Temperature (K):" << temperature; setRGBmult(temperature, green, mr, mg, mb); @@ -198,20 +201,20 @@ stop = img->width() * img->height() / 200; - for (i = rgbMax, sum = 0; (i >= 0) && (sum < stop); --i) + for (i = rgbMax, sum = 0 ; (i >= 0) && (sum < stop) ; --i) { sum += histogram->getValue(LuminosityChannel, i); } expo = -log((float)(i + 1) / rgbMax) / log(2); qCDebug(DIGIKAM_DIMG_LOG) << "White level at:" << i; - for (i = 1, sum = 0; (i < (int)rgbMax) && (sum < stop); ++i) + for (i = 1, sum = 0 ; (i < (int)rgbMax) && (sum < stop) ; ++i) { sum += histogram->getValue(LuminosityChannel, i); } - black = (double)i / rgbMax; + black = (double)i / rgbMax; black /= 2; qCDebug(DIGIKAM_DIMG_LOG) << "Black:" << black << " Exposition:" << expo; @@ -312,7 +315,7 @@ if (!sixteenBit) // 8 bits image. { - for (uint j = 0 ; j < size; ++j) + for (uint j = 0 ; j < size ; ++j) { if (maxb < data[0]) { @@ -336,7 +339,7 @@ { const unsigned short* ptr = reinterpret_cast(data); - for (uint j = 0 ; j < size; ++j) + for (uint j = 0 ; j < size ; ++j) { if (maxb < ptr[0]) { @@ -408,7 +411,7 @@ gamma = 1.8 * (2.0 - m_settings.gamma) - 0.8; } - for (int i = 1; i < (int)d->rgbMax; ++i) + for (int i = 1 ; i < (int)d->rgbMax ; ++i) { float x = (float)(i - d->BP) / (d->WP - d->BP); d->curve[i] = (i < d->BP) ? 0 : (d->rgbMax - 1) * pow((double)x, gamma); @@ -452,7 +455,7 @@ ptr[0] = (uchar)pixelColor(rv[0], i, v); ptr[1] = (uchar)pixelColor(rv[1], i, v); ptr[2] = (uchar)pixelColor(rv[2], i, v); - ptr += 4; + ptr += 4; progress = (int)(((double)j * 100.0) / size); @@ -491,7 +494,7 @@ ptr[0] = pixelColor(rv[0], i, v); ptr[1] = pixelColor(rv[1], i, v); ptr[2] = pixelColor(rv[2], i, v); - ptr += 4; + ptr += 4; progress = (int)(((double)j * 100.0) / size); diff --git a/core/libs/dimg/loaders/tiffloader.h b/core/libs/dimg/loaders/tiffloader.h --- a/core/libs/dimg/loaders/tiffloader.h +++ b/core/libs/dimg/loaders/tiffloader.h @@ -60,6 +60,8 @@ private: void tiffSetExifAsciiTag(TIFF* const tif, ttag_t tiffTag, const DMetadata& metaData, const char* const exifTagName); + + // cppcheck-suppress unusedPrivateFunction void tiffSetExifDataTag(TIFF* const tif, ttag_t tiffTag, const DMetadata& metaData, const char* const exifTagName); static void dimg_tiff_warning(const char* module, const char* format, va_list warnings); diff --git a/core/libs/dimg/loaders/tiffloader.cpp b/core/libs/dimg/loaders/tiffloader.cpp --- a/core/libs/dimg/loaders/tiffloader.cpp +++ b/core/libs/dimg/loaders/tiffloader.cpp @@ -70,16 +70,18 @@ void TIFFLoader::dimg_tiff_warning(const char* module, const char* format, va_list warnings) { - if(DIGIKAM_DIMG_LOG_TIFF().isDebugEnabled()) { + if(DIGIKAM_DIMG_LOG_TIFF().isDebugEnabled()) + { char message[4096]; vsnprintf(message, 4096, format, warnings); qCDebug(DIGIKAM_DIMG_LOG_TIFF) << module << "::" << message; } } void TIFFLoader::dimg_tiff_error(const char* module, const char* format, va_list errors) { - if(DIGIKAM_DIMG_LOG_TIFF().isDebugEnabled()) { + if(DIGIKAM_DIMG_LOG_TIFF().isDebugEnabled()) + { char message[4096]; vsnprintf(message, 4096, format, errors); qCDebug(DIGIKAM_DIMG_LOG_TIFF) << module << "::" << message; @@ -107,16 +109,17 @@ // ------------------------------------------------------------------- // Open the file - TIFF* tif = TIFFOpen(QFile::encodeName(filePath).constData(), "r"); + TIFF* const tif = TIFFOpen(QFile::encodeName(filePath).constData(), "r"); if (!tif) { qCWarning(DIGIKAM_DIMG_LOG_TIFF) << "Cannot open image file."; loadingFailed(); return false; } - if(DIGIKAM_DIMG_LOG_TIFF().isDebugEnabled()) { + if (DIGIKAM_DIMG_LOG_TIFF().isDebugEnabled()) + { TIFFPrintDirectory(tif, stdout, 0); } @@ -160,11 +163,11 @@ ) { qCWarning(DIGIKAM_DIMG_LOG_TIFF) << "TIFF loader: Encountered invalid value in image." << endl - << " bits_per_sample : " << bits_per_sample << endl - << " samples_per_pixel : " << samples_per_pixel << endl - << " rows_per_strip : " << rows_per_strip << endl - << " h : " << h << endl - << " Loading file : " << filePath; + << " bits_per_sample : " << bits_per_sample << endl + << " samples_per_pixel : " << samples_per_pixel << endl + << " rows_per_strip : " << rows_per_strip << endl + << " h : " << h << endl + << " Loading file : " << filePath; TIFFClose(tif); loadingFailed(); return false; @@ -177,16 +180,16 @@ TIFFGetFieldDefaulted(tif, TIFFTAG_PHOTOMETRIC, &photometric); - if (photometric != PHOTOMETRIC_RGB && - photometric != PHOTOMETRIC_PALETTE && - photometric != PHOTOMETRIC_MINISWHITE && - photometric != PHOTOMETRIC_MINISBLACK && - ((photometric != PHOTOMETRIC_YCBCR) | (bits_per_sample != 8)) && + if (photometric != PHOTOMETRIC_RGB && + photometric != PHOTOMETRIC_PALETTE && + photometric != PHOTOMETRIC_MINISWHITE && + photometric != PHOTOMETRIC_MINISBLACK && + ((photometric != PHOTOMETRIC_YCBCR) | (bits_per_sample != 8)) && ((photometric != PHOTOMETRIC_SEPARATED) | (bits_per_sample != 8)) && (m_loadFlags & LoadImageData)) { qCWarning(DIGIKAM_DIMG_LOG_TIFF) << "Can not handle image without RGB color-space: " - << photometric; + << photometric; TIFFClose(tif); loadingFailed(); return false; @@ -301,12 +304,11 @@ return false; } - long offset = 0; - long bytesRead = 0; - + long offset = 0; + long bytesRead = 0; uint checkpoint = 0; - for (tstrip_t st = 0; st < num_of_strips; ++st) + for (tstrip_t st = 0 ; st < num_of_strips ; ++st) { if (observer && st == checkpoint) { @@ -346,7 +348,7 @@ if (samples_per_pixel == 1) // See bug #148400: Greyscale pictures only have _one_ sample per pixel { - for (int i = 0; i < bytesRead / 2; ++i) + for (int i = 0 ; i < bytesRead / 2 ; ++i) { // We have to read two bytes for one pixel p = dataPtr; @@ -363,7 +365,7 @@ } else if ((samples_per_pixel == 3) && (planar_config == PLANARCONFIG_CONTIG)) { - for (int i = 0; i < bytesRead / 6; ++i) + for (int i = 0 ; i < bytesRead / 6 ; ++i) { p = dataPtr; @@ -379,7 +381,7 @@ } else if ((samples_per_pixel == 3) && (planar_config == PLANARCONFIG_SEPARATE)) { - for (int i = 0; i < bytesRead / 2; ++i) + for (int i = 0 ; i < bytesRead / 2 ; ++i) { p = dataPtr; @@ -406,7 +408,7 @@ } else if ((samples_per_pixel == 4) && (planar_config == PLANARCONFIG_CONTIG)) { - for (int i = 0; i < bytesRead / 8; ++i) + for (int i = 0 ; i < bytesRead / 8 ; ++i) { p = dataPtr; @@ -422,7 +424,7 @@ } else if ((samples_per_pixel == 4) && (planar_config == PLANARCONFIG_SEPARATE)) { - for (int i = 0; i < bytesRead / 2; ++i) + for (int i = 0 ; i < bytesRead / 2 ; ++i) { p = dataPtr; @@ -467,11 +469,10 @@ long offset = 0; long bytesRead = 0; - uint checkpoint = 0; float maxValue = 0.0; - for (tstrip_t st = 0; st < num_of_strips; ++st) + for (tstrip_t st = 0 ; st < num_of_strips ; ++st) { if (observer && !observer->continueQuery(m_image)) { @@ -492,21 +493,21 @@ float* stripPtr = reinterpret_cast(strip.data()); - for (int i = 0; i < bytesRead / 4; ++i) + for (int i = 0 ; i < bytesRead / 4 ; ++i) { maxValue = qMax(maxValue, *stripPtr++); } } double factor = (maxValue > 10.0) ? log10(maxValue) * 1.5 : 1.0; - double scale = (factor > 1.0) ? 0.75 : 1.0; + double scale = (factor > 1.0) ? 0.75 : 1.0; if (factor > 1.0) { qCWarning(DIGIKAM_DIMG_LOG_TIFF) << "TIFF image cannot be converted lossless from 32 to 16 bits" << filePath; } - for (tstrip_t st = 0; st < num_of_strips; ++st) + for (tstrip_t st = 0 ; st < num_of_strips ; ++st) { if (observer && st == checkpoint) { @@ -544,7 +545,7 @@ if ((samples_per_pixel == 3) && (planar_config == PLANARCONFIG_CONTIG)) { - for (int i = 0; i < bytesRead / 12; ++i) + for (int i = 0 ; i < bytesRead / 12 ; ++i) { p = dataPtr; @@ -560,7 +561,7 @@ } else if ((samples_per_pixel == 3) && (planar_config == PLANARCONFIG_SEPARATE)) { - for (int i = 0; i < bytesRead / 4; ++i) + for (int i = 0 ; i < bytesRead / 4 ; ++i) { p = dataPtr; @@ -587,7 +588,7 @@ } else if ((samples_per_pixel == 4) && (planar_config == PLANARCONFIG_CONTIG)) { - for (int i = 0; i < bytesRead / 16; ++i) + for (int i = 0 ; i < bytesRead / 16 ; ++i) { p = dataPtr; @@ -603,7 +604,7 @@ } else if ((samples_per_pixel == 4) && (planar_config == PLANARCONFIG_SEPARATE)) { - for (int i = 0; i < bytesRead / 4; ++i) + for (int i = 0 ; i < bytesRead / 4 ; ++i) { p = dataPtr; @@ -646,22 +647,22 @@ return false; } - long offset = 0; - long pixelsRead = 0; + long offset = 0; + long pixelsRead = 0; // this is inspired by TIFFReadRGBAStrip, tif_getimage.c char emsg[1024] = ""; TIFFRGBAImage img; uint32 rows_to_read; - uint checkpoint = 0; + uint checkpoint = 0; // test whether libtiff can read format and initiate reading if (!TIFFRGBAImageOK(tif, emsg) || !TIFFRGBAImageBegin(&img, tif, 0, emsg)) { qCWarning(DIGIKAM_DIMG_LOG_TIFF) << "Failed to set up RGBA reading of image, filename " - << TIFFFileName(tif) << " error message from Libtiff: " << emsg; + << TIFFFileName(tif) << " error message from Libtiff: " << emsg; TIFFClose(tif); loadingFailed(); return false; @@ -672,7 +673,7 @@ img.req_orientation = img.orientation; // read strips from image: read rows_per_strip, so always start at beginning of a strip - for (uint row = 0; row < h; row += rows_per_strip) + for (uint row = 0 ; row < h ; row += rows_per_strip) { if (observer && row >= checkpoint) { @@ -718,7 +719,7 @@ // Reverse red and blue - for (int i = 0; i < pixelsRead; ++i) + for (int i = 0 ; i < pixelsRead ; ++i) { p = dataPtr; @@ -759,9 +760,9 @@ bool TIFFLoader::save(const QString& filePath, DImgLoaderObserver* const observer) { - uint32 w = imageWidth(); - uint32 h = imageHeight(); - uchar* data = imageData(); + uint32 w = imageWidth(); + uint32 h = imageHeight(); + uchar* data = imageData(); // ------------------------------------------------------------------- // TIFF error handling. If an errors/warnings occurs during reading, @@ -773,7 +774,7 @@ // ------------------------------------------------------------------- // Open the file - TIFF* tif = TIFFOpen(QFile::encodeName(filePath).constData(), "w"); + TIFF* const tif = TIFFOpen(QFile::encodeName(filePath).constData(), "w"); if (!tif) { @@ -793,7 +794,7 @@ // Image must be compressed using deflate algorithm ? QVariant compressAttr = imageGetAttribute(QLatin1String("compress")); - bool compress = compressAttr.isValid() ? compressAttr.toBool() : false; + bool compress = compressAttr.isValid() ? compressAttr.toBool() : false; if (compress) { @@ -892,12 +893,12 @@ observer->progressInfo(m_image, 0.1F); } - uchar* pixel; - uint16* pixel16; - double alpha_factor; - uint32 x, y; - uint8 r8, g8, b8, a8 = 0; - uint16 r16, g16, b16, a16 = 0; + uchar* pixel = 0; + uint16* pixel16 = 0; + double alpha_factor = 0; + uint32 x = 0, y = 0; + uint8 r8 = 0, g8 = 0, b8 = 0, a8 = 0; + uint16 r16 = 0, g16 = 0, b16 = 0, a16 = 0; int i = 0; uint8* buf = (uint8*)_TIFFmalloc(TIFFScanlineSize(tif)); @@ -912,7 +913,7 @@ uint checkpoint = 0; - for (y = 0; y < h; ++y) + for (y = 0 ; y < h ; ++y) { if (observer && y == checkpoint) @@ -931,7 +932,7 @@ i = 0; - for (x = 0; x < w; ++x) + for (x = 0 ; x < w ; ++x) { pixel = &data[((y * w) + x) * imageBytesDepth()]; @@ -959,12 +960,12 @@ *buf16++ = r16; *buf16++ = g16; *buf16++ = b16; - i+= 6; + i += 6; if (imageHasAlpha()) { *buf16++ = a16; - i += 2; + i += 2; } } else // 8 bits image. @@ -1042,7 +1043,7 @@ for (x = 0 ; x < uint32(thumb.width()) ; ++x) { - pixelThumb = &dataThumb[((y * thumb.width()) + x) * 4]; + pixelThumb = &dataThumb[((y * thumb.width()) + x) * 4]; // This might be endian dependent bufThumb[i++] = (uint8)pixelThumb[2]; diff --git a/core/libs/dmetadata/captionvalues.h b/core/libs/dmetadata/captionvalues.h --- a/core/libs/dmetadata/captionvalues.h +++ b/core/libs/dmetadata/captionvalues.h @@ -58,9 +58,10 @@ // -------------------------------------------------------------------- -/** A map used to store a list of Alternative Language values + author and date properties - The map key is the language code following RFC3066 notation - (like "fr-FR" for French), and the CaptionsMap value all caption properties. +/** + * A map used to store a list of Alternative Language values + author and date properties + * The map key is the language code following RFC3066 notation + * (like "fr-FR" for French), and the CaptionsMap value all caption properties. */ class DIGIKAM_EXPORT CaptionsMap : public QMap { @@ -79,7 +80,8 @@ /** Sets the author for the comments in the specified languages. * If commonAuthor is not null, it will be used to set the author of all comments - * for which the author is not specified in the map. */ + * for which the author is not specified in the map. + */ void setAuthorsList(const MetaEngine::AltLangMap& map, const QString& commonAuthor = QString()); MetaEngine::AltLangMap authorsList() const; diff --git a/core/libs/dmetadata/dmetadata.h b/core/libs/dmetadata/dmetadata.h --- a/core/libs/dmetadata/dmetadata.h +++ b/core/libs/dmetadata/dmetadata.h @@ -52,8 +52,9 @@ public: - /** Video color model reported by FFMPEG following XMP DM Spec from Adobe. - * These value are stored in DB as Image color model properties (extension of DImg::ColorModel) + /** + * Video color model reported by FFMPEG following XMP DM Spec from Adobe. + * These values are stored in DB as Image color model properties (extension of DImg::ColorModel) */ enum VIDEOCOLORMODEL { @@ -74,22 +75,27 @@ void registerMetadataSettings(); void setSettings(const MetadataSettingsContainer& settings); - /** Re-implemented from libMetaEngine to use libraw identify and - * ffmpeg probe methods if Exiv2 failed. + /** + * Re-implemented from libMetaEngine to use libraw identify and + * ffmpeg probe methods if Exiv2 failed. */ bool load(const QString& filePath); bool save(const QString& filePath, bool setVersion = true) const; bool applyChanges() const; - /** Try to extract metadata using Raw Engine identify method (libraw) + /** + * Try to extract metadata using Raw Engine identify method (libraw). */ bool loadUsingRawEngine(const QString& filePath); - /** Try to extract metadata using FFMpeg probe method (libav) + /** + * Try to extract metadata using FFMpeg probe method (libav). */ bool loadUsingFFmpeg(const QString& filePath); - /** Metadata manipulation methods */ + /** + * Metadata manipulation methods. + */ CaptionsMap getImageComments(const DMetadataSettingsContainer& settings = DMetadataSettings::instance()->settings()) const; bool setImageComments(const CaptionsMap& comments, @@ -117,15 +123,17 @@ bool setACDSeeTagsPath(const QStringList& tagsPath) const; - /** Get Images Face Map based on tags stored in Picassa/Metadatagroup + /** + * Get Images Face Map based on tags stored in Picassa/Metadatagroup * format. Use $ exiv2 -pa image to see the tag structure */ bool getImageFacesMap(QMultiMap& facesPath) const; - /** Set Images Face Map tags in Picassa/Metadatagroup format - * Use exiv2 -pa image to check for face tags, - * @param write - if true all faces will be written, else update mode: - * search if at least a face tag exist and write if true + /** + * Set Images Face Map tags in Picassa/Metadatagroup format + * Use exiv2 -pa image to check for face tags, + * @param write - if true all faces will be written, else update mode: + * search if at least a face tag exist and write if true */ bool setImageFacesMap(QMultiMap& facesPath, bool write) const; @@ -152,56 +160,68 @@ QStringList getIptcCoreSubjects() const; - /** Return a string with Lens mounted on the front of camera. - There no standard Exif tag for Lens information. - Camera makernotes and Xmp tags are parsed. - Take a care : lens information are not standardized and string content is not homogeneous between - camera model/maker. + /** + * Return a string with Lens mounted on the front of camera. + * There no standard Exif tag for Lens information. + * Camera makernotes and Xmp tags are parsed. + * Take a care : lens information are not standardized and string content is not homogeneous between + * camera model/maker. */ QString getLensDescription() const; - /** Reads an IccProfile that is described or embedded in the metadata. - This method does not retrieve profiles embedded in the image but not the metadata, - e.g. embedded profiles in JPEG images. - Returns a null profile if no profile is found. + /** + * Reads an IccProfile that is described or embedded in the metadata. + * This method does not retrieve profiles embedded in the image but not the metadata, + * e.g. embedded profiles in JPEG images. + * Returns a null profile if no profile is found. */ IccProfile getIccProfile() const; - /** Sets the IccProfile embedded in the Exif metadata. */ + /** + * Sets the IccProfile embedded in the Exif metadata. + */ bool setIccProfile(const IccProfile& profile); - /** Remove the Exif color space identification from the image */ + /** + * Remove the Exif color space identification from the image. + */ bool removeExifColorSpace() const; PhotoInfoContainer getPhotographInformation() const; - /** Returns video metadata from Xmp tags. + /** + * Returns video metadata from Xmp tags. */ VideoInfoContainer getVideoInformation() const; - /** Returns millisecond time-stamp from Exif tags or 0 if not found. + /** + * Returns millisecond time-stamp from Exif tags or 0 if not found. */ int getMSecsInfo() const; - /** Extract milliseconds time-stamp of photo from an Exif tag and store it to 'ms'. - * Returns true if data are extracted. + /** + * Extract milliseconds time-stamp of photo from an Exif tag and store it to 'ms'. + * Returns true if data are extracted. */ bool mSecTimeStamp(const char* const exifTagName, int& ms) const; - /** Returns the requested metadata field as a QVariant. See metadatainfo.h for a specification - of the format of the QVariant. + /** + * Returns the requested metadata field as a QVariant. See metadatainfo.h for a specification + * of the format of the QVariant. */ QVariant getMetadataField(MetadataInfo::Field field) const; QVariantList getMetadataFields(const MetadataFields& fields) const; - /** Convert a QVariant value of the specified field to a user-presentable, i18n'ed string. - The QVariant must be of the type as specified in metadatainfo.h and as obtained by getMetadataField. + /** + * Convert a QVariant value of the specified field to a user-presentable, i18n'ed string. + * The QVariant must be of the type as specified in metadatainfo.h and as obtained by getMetadataField. */ static QString valueToString (const QVariant& value, MetadataInfo::Field field); static QStringList valuesToString(const QVariantList& list, const MetadataFields& fields); - /** Returns a map of possible enum values and their user-presentable, i18n'ed representation. - Valid fields are those which are described as "enum from" or "bit mask from" in metadatainfo.h. + /** + * Returns a map of possible enum values and their user-presentable, i18n'ed representation. + * Valid fields are those which are described as "enum from" or "bit mask from" in metadatainfo.h. */ static QMap possibleValuesForEnumField(MetadataInfo::Field field); @@ -212,65 +232,76 @@ // These methods have been factored to libMetaEngine 2.3.0. Remove it after KDE 4.8.2 - /** Set an Xmp tag content using a list of strings defined by the 'entriesToAdd' parameter. - The existing entries are preserved. The method will compare - all new with all already existing entries to prevent duplicates in the image. - Return true if the entries have been added to metadata. + /** + * Set an Xmp tag content using a list of strings defined by the 'entriesToAdd' parameter. + * The existing entries are preserved. The method will compare + * all new with all already existing entries to prevent duplicates in the image. + * Return true if the entries have been added to metadata. */ bool addToXmpTagStringBag(const char* const xmpTagName, const QStringList& entriesToAdd) const; - /** Remove those Xmp tag entries that are listed in entriesToRemove from the entries in metadata. - Return true if tag entries are no longer contained in metadata. - All other entries are preserved. + /** + * Remove those Xmp tag entries that are listed in entriesToRemove from the entries in metadata. + * Return true if tag entries are no longer contained in metadata. + * All other entries are preserved. */ bool removeFromXmpTagStringBag(const char* const xmpTagName, const QStringList& entriesToRemove) const; - /** Return a strings list of Xmp keywords from image. Return an empty list if no keyword are set. + /** + * Return a strings list of Xmp keywords from image. Return an empty list if no keyword are set. */ QStringList getXmpKeywords() const; - /** Set Xmp keywords using a list of strings defined by 'newKeywords' parameter. - The existing keywords from image are preserved. The method will compare - all new keywords with all already existing keywords to prevent duplicate entries in image. - Return true if keywords have been changed in metadata. + /** + * Set Xmp keywords using a list of strings defined by 'newKeywords' parameter. + * The existing keywords from image are preserved. The method will compare + * all new keywords with all already existing keywords to prevent duplicate entries in image. + * Return true if keywords have been changed in metadata. */ bool setXmpKeywords(const QStringList& newKeywords) const; - /** Remove those Xmp keywords that are listed in keywordsToRemove from the keywords in metadata. - Return true if keywords are no longer contained in metadata. + /** + * Remove those Xmp keywords that are listed in keywordsToRemove from the keywords in metadata. + * Return true if keywords are no longer contained in metadata. */ bool removeXmpKeywords(const QStringList& keywordsToRemove); - /** Return a strings list of Xmp subjects from image. Return an empty list if no subject are set. + /** + * Return a strings list of Xmp subjects from image. Return an empty list if no subject are set. */ QStringList getXmpSubjects() const; - /** Set Xmp subjects using a list of strings defined by 'newSubjects' parameter. - The existing subjects from image are preserved. The method will compare - all new subject with all already existing subject to prevent duplicate entries in image. - Return true if subjects have been changed in metadata. + /** + * Set Xmp subjects using a list of strings defined by 'newSubjects' parameter. + * The existing subjects from image are preserved. The method will compare + * all new subject with all already existing subject to prevent duplicate entries in image. + * Return true if subjects have been changed in metadata. */ bool setXmpSubjects(const QStringList& newSubjects) const; - /** Remove those Xmp subjects that are listed in subjectsToRemove from the subjects in metadata. - Return true if subjects are no longer contained in metadata. + /** + * Remove those Xmp subjects that are listed in subjectsToRemove from the subjects in metadata. + * Return true if subjects are no longer contained in metadata. */ bool removeXmpSubjects(const QStringList& subjectsToRemove); - /** Return a strings list of Xmp sub-categories from image. Return an empty list if no sub-category - are set. + /** + * Return a strings list of Xmp sub-categories from image. Return an empty list if no sub-category + * are set. */ QStringList getXmpSubCategories() const; - /** Set Xmp sub-categories using a list of strings defined by 'newSubCategories' parameter. - The existing sub-categories from image are preserved. The method will compare - all new sub-categories with all already existing sub-categories to prevent duplicate entries in image. - Return true if sub-categories have been changed in metadata. + /** + * Set Xmp sub-categories using a list of strings defined by 'newSubCategories' parameter. + * The existing sub-categories from image are preserved. The method will compare + * all new sub-categories with all already existing sub-categories to prevent duplicate entries in image. + * Return true if sub-categories have been changed in metadata. */ bool setXmpSubCategories(const QStringList& newSubCategories) const; - /** Remove those Xmp sub-categories that are listed in categoriesToRemove from the sub-categories in metadata. - Return true if subjects are no longer contained in metadata. + /** + * Remove those Xmp sub-categories that are listed in categoriesToRemove from the sub-categories in metadata. + * Return true if subjects are no longer contained in metadata. */ bool removeXmpSubCategories(const QStringList& categoriesToRemove); diff --git a/core/libs/dmetadata/dmetadatasettingscontainer.h b/core/libs/dmetadata/dmetadatasettingscontainer.h --- a/core/libs/dmetadata/dmetadatasettingscontainer.h +++ b/core/libs/dmetadata/dmetadatasettingscontainer.h @@ -151,8 +151,8 @@ }; /** - The class DMetadataSettingsContainer is designed to dynamically add namespaces. -*/ + * The class DMetadataSettingsContainer is designed to dynamically add namespaces. + */ class DIGIKAM_EXPORT DMetadataSettingsContainer { public: diff --git a/core/libs/dmetadata/dmetadatasettingscontainer.cpp b/core/libs/dmetadata/dmetadatasettingscontainer.cpp --- a/core/libs/dmetadata/dmetadatasettingscontainer.cpp +++ b/core/libs/dmetadata/dmetadatasettingscontainer.cpp @@ -290,9 +290,9 @@ QList microsoftMappings; QList iptcMappings; - defaultVal << 0 << 1 << 2 << 3 << 4 << 5; + defaultVal << 0 << 1 << 2 << 3 << 4 << 5; microsoftMappings << 0 << 1 << 25 << 50 << 75 << 99; - iptcMappings << 8 << 6 << 5 << 4 << 2 << 1; + iptcMappings << 8 << 6 << 5 << 4 << 2 << 1; NamespaceEntry ratingNs1; ratingNs1.namespaceName = QLatin1String("Xmp.xmp.Rating"); diff --git a/core/libs/dmetadata/geodetictools.h b/core/libs/dmetadata/geodetictools.h --- a/core/libs/dmetadata/geodetictools.h +++ b/core/libs/dmetadata/geodetictools.h @@ -69,172 +69,167 @@ // ------------------------------------------------------------------------------------------------ +/** + * Geometric figure that can be used to describe the approximate shape of the earth. + * In mathematical terms, it is a surface formed by the rotation of an ellipse about + * its minor axis. An ellipsoid requires two defining parameters: + * - semi-major axis and inverse flattening, or + * - semi-major axis and semi-minor axis. + */ class DIGIKAM_EXPORT Ellipsoid { - /** - * Geometric figure that can be used to describe the approximate shape of the earth. - * In mathematical terms, it is a surface formed by the rotation of an ellipse about - * its minor axis. An ellipsoid requires two defining parameters: - * - semi-major axis and inverse flattening, or - * - semi-major axis and semi-minor axis. - */ public: /** - * WGS 1984 ellipsoid with axis in metres. This ellipsoid is used - * in GPS systems and is the default for most org.geotools packages. - */ + * WGS 1984 ellipsoid with axis in metres. This ellipsoid is used + * in GPS systems and is the default for most org.geotools packages. + */ static Ellipsoid WGS84(); /** - * GRS 80 ellipsoid with axis in metres. - * - * @since 2.2 - */ + * GRS 80 ellipsoid with axis in metres. + */ static Ellipsoid GRS80(); /** - * International 1924 ellipsoid with axis in metres. - */ + * International 1924 ellipsoid with axis in metres. + */ static Ellipsoid INTERNATIONAL_1924(); /** - * Clarke 1866 ellipsoid with axis in metres. - * - * @since 2.2 - */ + * Clarke 1866 ellipsoid with axis in metres. + */ static Ellipsoid CLARKE_1866(); /** - * A sphere with a radius of 6371000 metres. Spheres use a simpler - * algorithm for orthodromic distance computation, which - * may be faster and more robust. - */ + * A sphere with a radius of 6371000 metres. Spheres use a simpler + * algorithm for orthodromic distance computation, which + * may be faster and more robust. + */ static Ellipsoid SPHERE(); - /** - * Constructs a new ellipsoid using the specified axis length. - * - * @param name The ellipsoid name. - * @param semiMajorAxis The equatorial radius. - * @param semiMinorAxis The polar radius. - */ + * Constructs a new ellipsoid using the specified axis length. + * + * @param name The ellipsoid name. + * @param semiMajorAxis The equatorial radius. + * @param semiMinorAxis The polar radius. + */ static Ellipsoid createEllipsoid(const QString& name, double semiMajorAxis, double semiMinorAxis); /** - * Constructs a new ellipsoid using the specified axis length and inverse flattening value. - * - * @param name The ellipsoid name. - * @param semiMajorAxis The equatorial radius. - * @param inverseFlattening The inverse flattening value. - * values. - */ + * Constructs a new ellipsoid using the specified axis length and inverse flattening value. + * + * @param name The ellipsoid name. + * @param semiMajorAxis The equatorial radius. + * @param inverseFlattening The inverse flattening value. + * values. + */ static Ellipsoid createFlattenedSphere(const QString& name, double semiMajorAxis, double inverseFlattening); /** - * Length of the semi-major axis of the ellipsoid. This is the - * equatorial radius in axis linear unit. - * - * @return Length of semi-major axis. - */ + * Length of the semi-major axis of the ellipsoid. This is the + * equatorial radius in axis linear unit. + * + * @return Length of semi-major axis. + */ double semiMajorAxis() const; /** - * Length of the semi-minor axis of the ellipsoid. This is the - * polar radius in axis linear unit. - * - * @return Length of semi-minor axis. - */ + * Length of the semi-minor axis of the ellipsoid. This is the + * polar radius in axis linear unit. + * + * @return Length of semi-minor axis. + */ double semiMinorAxis() const; /** - * The ratio of the distance between the center and a focus of the ellipse - * to the length of its semimajor axis. The eccentricity can alternately be - * computed from the equation: e=sqrt(2f-f^2). - */ + * The ratio of the distance between the center and a focus of the ellipse + * to the length of its semimajor axis. The eccentricity can alternately be + * computed from the equation: e=sqrt(2f-f^2). + */ double eccentricity() const; /** - * Returns the value of the inverse of the flattening constant. Flattening is a value - * used to indicate how closely an ellipsoid approaches a spherical shape. The inverse - * flattening is related to the equatorial/polar radius by the formula - * - * ivf=r_e/(r_e-r_p). - * - * For perfect spheres (i.e. if isSphere returns @c true), - * the DoublePOSITIVE_INFINITY value is used. - * - * @return The inverse flattening value. - */ + * Returns the value of the inverse of the flattening constant. Flattening is a value + * used to indicate how closely an ellipsoid approaches a spherical shape. The inverse + * flattening is related to the equatorial/polar radius by the formula + * + * ivf=r_e/(r_e-r_p). + * + * For perfect spheres (i.e. if isSphere returns @c true), + * the DoublePOSITIVE_INFINITY value is used. + * + * @return The inverse flattening value. + */ double inverseFlattening() const; /** - * Indicates if the inverse flattening is definitive for - * this ellipsoid. Some ellipsoids use the IVF as the defining value, and calculate the polar - * radius whenever asked. Other ellipsoids use the polar radius to calculate the IVF whenever - * asked. This distinction can be important to avoid floating-point rounding errors. - * - * @return @c true if the inverse flattening is - * definitive, or @c false if the polar radius - * is definitive. - */ + * Indicates if the inverse flattening is definitive for + * this ellipsoid. Some ellipsoids use the IVF as the defining value, and calculate the polar + * radius whenever asked. Other ellipsoids use the polar radius to calculate the IVF whenever + * asked. This distinction can be important to avoid floating-point rounding errors. + * + * @return @c true if the inverse flattening is + * definitive, or @c false if the polar radius + * is definitive. + */ bool isIvfDefinitive() const; /** - * @c true if the ellipsoid is degenerate and is actually a sphere. The sphere is - * completely defined by the semi-major axis, which is the - * radius of the sphere. - * - * @return @c true if the ellipsoid is degenerate and is actually a sphere. - */ + * @c true if the ellipsoid is degenerate and is actually a sphere. The sphere is + * completely defined by the semi-major axis, which is the + * radius of the sphere. + * + * @return @c true if the ellipsoid is degenerate and is actually a sphere. + */ bool isSphere() const; /** - * Returns the orthodromic distance between two geographic coordinates. - * The orthodromic distance is the shortest distance between two points - * on a sphere's surface. The orthodromic path is always on a great circle. - * This is different from the loxodromic distance, which is a - * longer distance on a path with a constant direction on the compass. - * - * @param x1 Longitude of first point (in decimal degrees). - * @param y1 Latitude of first point (in decimal degrees). - * @param x2 Longitude of second point (in decimal degrees). - * @param y2 Latitude of second point (in decimal degrees). - * @return The orthodromic distance (in the units of this ellipsoid's axis). - */ + * Returns the orthodromic distance between two geographic coordinates. + * The orthodromic distance is the shortest distance between two points + * on a sphere's surface. The orthodromic path is always on a great circle. + * This is different from the loxodromic distance, which is a + * longer distance on a path with a constant direction on the compass. + * + * @param x1 Longitude of first point (in decimal degrees). + * @param y1 Latitude of first point (in decimal degrees). + * @param x2 Longitude of second point (in decimal degrees). + * @param y2 Latitude of second point (in decimal degrees). + * @return The orthodromic distance (in the units of this ellipsoid's axis). + */ double orthodromicDistance(double x1, double y1, double x2, double y2); /** - * Returns the Radius Of Curvature for the given latitude, - * using the geometric mean of two radii of - * curvature for all azimuths. - * @param latitude in degrees - */ + * Returns the Radius Of Curvature for the given latitude, + * using the geometric mean of two radii of + * curvature for all azimuths. + * @param latitude in degrees + */ double radiusOfCurvature(double latitude); protected: /** - * Constructs a new ellipsoid using the specified axis length. The properties map is - * given unchanged to the AbstractIdentifiedObjectAbstractIdentifiedObject(Map) - * super-class constructor. - * - * @param semiMajorAxis The equatorial radius. - * @param semiMinorAxis The polar radius. - * @param inverseFlattening The inverse of the flattening value. - * @param ivfDefinitive @c true if the inverse flattening is definitive. - * - * @see createEllipsoid - * @see createFlattenedSphere - */ + * Constructs a new ellipsoid using the specified axis length. The properties map is + * given unchanged to the AbstractIdentifiedObjectAbstractIdentifiedObject(Map) + * super-class constructor. + * + * @param semiMajorAxis The equatorial radius. + * @param semiMinorAxis The polar radius. + * @param inverseFlattening The inverse of the flattening value. + * @param ivfDefinitive @c true if the inverse flattening is definitive. + * + * @see createEllipsoid + * @see createFlattenedSphere + */ Ellipsoid(const QString& name, double semiMajorAxis, - double semiMinorAxis, + double semiMinorAxis, double inverseFlattening, bool ivfDefinitive); Ellipsoid(const QString& name, @@ -246,30 +241,30 @@ QString name; /** - * The equatorial radius. - * @see getSemiMajorAxis - */ + * The equatorial radius. + * @see getSemiMajorAxis + */ double m_semiMajorAxis; /** - * The polar radius. - * @see getSemiMinorAxis - */ + * The polar radius. + * @see getSemiMinorAxis + */ double m_semiMinorAxis; /** - * The inverse of the flattening value, or DBL_MAX - * if the ellipsoid is a sphere. - * - * @see getInverseFlattening - */ + * The inverse of the flattening value, or DBL_MAX + * if the ellipsoid is a sphere. + * + * @see getInverseFlattening + */ double m_inverseFlattening; /** - * Tells if the Inverse Flattening definitive for this ellipsoid. - * - * @see isIvfDefinitive - */ + * Tells if the Inverse Flattening definitive for this ellipsoid. + * + * @see isIvfDefinitive + */ bool m_ivfDefinitive; bool m_isSphere; @@ -307,33 +302,32 @@ explicit GeodeticCalculator(const Ellipsoid& e = Ellipsoid::WGS84()); - /** - * Returns the referenced ellipsoid. - */ + * Returns the referenced ellipsoid. + */ Ellipsoid ellipsoid() const; /** - * Set the starting point in geographic coordinates. - * The azimuth, the orthodromic distance and the destination point - * are discarded. They will need to be specified again. - * Coordinates positive North and East. - * - * @param longitude The longitude in decimal degrees between -180 and +180° - * @param latitude The latitude in decimal degrees between -90 and +90° - */ + * Set the starting point in geographic coordinates. + * The azimuth, the orthodromic distance and the destination point + * are discarded. They will need to be specified again. + * Coordinates positive North and East. + * + * @param longitude The longitude in decimal degrees between -180 and +180° + * @param latitude The latitude in decimal degrees between -90 and +90° + */ void setStartingGeographicPoint(double longitude, double latitude); /** - * Set the destination point in geographic coordinates. The azimuth and distance values - * will be updated as a side effect of this call. They will be recomputed the next time - * getAzimuth() or getOrthodromicDistance() are invoked. - * Coordinates positive North and East. - * - * @param longitude The longitude in decimal degrees between -180 and +180° - * @param latitude The latitude in decimal degrees between -90 and +90° - * - */ + * Set the destination point in geographic coordinates. The azimuth and distance values + * will be updated as a side effect of this call. They will be recomputed the next time + * getAzimuth() or getOrthodromicDistance() are invoked. + * Coordinates positive North and East. + * + * @param longitude The longitude in decimal degrees between -180 and +180° + * @param latitude The latitude in decimal degrees between -90 and +90° + * + */ void setDestinationGeographicPoint(double longitude, double latitude); /** @@ -351,118 +345,118 @@ QPointF destinationGeographicPoint(); /** - * Set the azimuth and the distance from the startingGeographicPoint - * starting point. The destination point will be updated as a side effect of this call. - * It will be recomputed the next time destinationGeographicPoint() is invoked. - * Azimuth 0° North. - * - * @param azimuth The azimuth in decimal degrees from -180° to 180°. - * @param distance The orthodromic distance in the same units as the ellipsoid axis. - */ + * Set the azimuth and the distance from the startingGeographicPoint + * starting point. The destination point will be updated as a side effect of this call. + * It will be recomputed the next time destinationGeographicPoint() is invoked. + * Azimuth 0° North. + * + * @param azimuth The azimuth in decimal degrees from -180° to 180°. + * @param distance The orthodromic distance in the same units as the ellipsoid axis. + */ void setDirection(double azimuth, double distance); /** - * Returns the azimuth. This method returns the value set by the last call to - * setDirection(double,double) setDirection(azimuth,distance), - * except if setDestinationGeographicPoint(double,double) - * setDestinationGeographicPoint(...) has been invoked after. In this later case, the - * azimuth will be computed from the startingGeographicPoint starting point - * to the destination point. - * - * @return The azimuth, in decimal degrees from -180° to +180°. - */ + * Returns the azimuth. This method returns the value set by the last call to + * setDirection(double,double) setDirection(azimuth,distance), + * except if setDestinationGeographicPoint(double,double) + * setDestinationGeographicPoint(...) has been invoked after. In this later case, the + * azimuth will be computed from the startingGeographicPoint starting point + * to the destination point. + * + * @return The azimuth, in decimal degrees from -180° to +180°. + */ double azimuth(); /** - * Returns the orthodromic distance. This method returns the value set by the last call to - * setDirection(double,double) setDirection(azimuth,distance), - * except if setDestinationGeographicPoint(double,double) - * setDestinationGeographicPoint(...) has been invoked after. In this later case, the - * distance will be computed from the startingGeographicPoint starting point - * to the destination point. - * - * @return The orthodromic distance, in the same units as the - * getEllipsoid ellipsoid axis. - */ + * Returns the orthodromic distance. This method returns the value set by the last call to + * setDirection(double,double) setDirection(azimuth,distance), + * except if setDestinationGeographicPoint(double,double) + * setDestinationGeographicPoint(...) has been invoked after. In this later case, the + * distance will be computed from the startingGeographicPoint starting point + * to the destination point. + * + * @return The orthodromic distance, in the same units as the + * getEllipsoid ellipsoid axis. + */ double orthodromicDistance(); /** - * Computes the orthodromic distance using the algorithm implemented in the Geotools's - * ellipsoid class (if available), and check if the error is smaller than some tolerance - * error. - */ + * Computes the orthodromic distance using the algorithm implemented in the Geotools's + * ellipsoid class (if available), and check if the error is smaller than some tolerance + * error. + */ bool checkOrthodromicDistance(); /** - * Computes the destination point from the starting - * point, the azimuth and the orthodromic distance. - */ + * Computes the destination point from the starting + * point, the azimuth and the orthodromic distance. + */ bool computeDestinationPoint(); /** - * Calculates the meridian arc length between two points in the same meridian - * in the referenced ellipsoid. - * - * @param latitude1 The latitude of the first point (in decimal degrees). - * @param latitude2 The latitude of the second point (in decimal degrees). - * @return Returned the meridian arc length between latitude1 and latitude2 - */ + * Calculates the meridian arc length between two points in the same meridian + * in the referenced ellipsoid. + * + * @param latitude1 The latitude of the first point (in decimal degrees). + * @param latitude2 The latitude of the second point (in decimal degrees). + * @return Returned the meridian arc length between latitude1 and latitude2 + */ double meridianArcLength(double latitude1, double latitude2); /** - * Calculates the meridian arc length between two points in the same meridian - * in the referenced ellipsoid. - * - * @param P1 The latitude of the first point (in radians). - * @param P2 The latitude of the second point (in radians). - * @return Returned the meridian arc length between P1 and P2 - */ + * Calculates the meridian arc length between two points in the same meridian + * in the referenced ellipsoid. + * + * @param P1 The latitude of the first point (in radians). + * @param P2 The latitude of the second point (in radians). + * @return Returned the meridian arc length between P1 and P2 + */ double meridianArcLengthRadians(double P1, double P2); /** - * Computes the azimuth and orthodromic distance from the - * startingGeographicPoint starting point and the - * destinationGeographicPoint destination point. - */ + * Computes the azimuth and orthodromic distance from the + * startingGeographicPoint starting point and the + * destinationGeographicPoint destination point. + */ bool computeDirection(); protected: double castToAngleRange(const double alpha); /** - * Checks the latitude validity. The argument @c latitude should be - * greater or equal than -90 degrees and lower or equals than +90 degrees. As - * a convenience, this method converts the latitude to radians. - * - * @param latitude The latitude value in decimal degrees. - */ + * Checks the latitude validity. The argument @c latitude should be + * greater or equal than -90 degrees and lower or equals than +90 degrees. As + * a convenience, this method converts the latitude to radians. + * + * @param latitude The latitude value in decimal degrees. + */ bool checkLatitude(double* latitude); /** - * Checks the longitude validity. The argument @c longitude should be - * greater or equal than -180 degrees and lower or equals than +180 degrees. As - * a convenience, this method converts the longitude to radians. - * - * @param longitude The longitude value in decimal degrees. - */ + * Checks the longitude validity. The argument @c longitude should be + * greater or equal than -180 degrees and lower or equals than +180 degrees. As + * a convenience, this method converts the longitude to radians. + * + * @param longitude The longitude value in decimal degrees. + */ bool checkLongitude(double* longitude); /** - * Checks the azimuth validity. The argument @c azimuth should be - * greater or equal than -180 degrees and lower or equals than +180 degrees. - * As a convenience, this method converts the azimuth to radians. - * - * @param azimuth The azimuth value in decimal degrees. - */ + * Checks the azimuth validity. The argument @c azimuth should be + * greater or equal than -180 degrees and lower or equals than +180 degrees. + * As a convenience, this method converts the azimuth to radians. + * + * @param azimuth The azimuth value in decimal degrees. + */ bool checkAzimuth(double* azimuth); /** - * Checks the orthodromic distance validity. Arguments @c orthodromicDistance - * should be greater or equal than 0 and lower or equals than the maximum orthodromic distance. - * - * @param distance The orthodromic distance value. - */ + * Checks the orthodromic distance validity. Arguments @c orthodromicDistance + * should be greater or equal than 0 and lower or equals than the maximum orthodromic distance. + * + * @param distance The orthodromic distance value. + */ bool checkOrthodromicDistance(const double distance); /** @@ -482,23 +476,23 @@ Ellipsoid m_ellipsoid; /* - * The semi major axis of the referenced ellipsoid. - */ + * The semi major axis of the referenced ellipsoid. + */ double m_semiMajorAxis; /* - * The semi minor axis of the referenced ellipsoid. - */ + * The semi minor axis of the referenced ellipsoid. + */ double m_semiMinorAxis; /* - * The eccentricity squared of the referenced ellipsoid. - */ + * The eccentricity squared of the referenced ellipsoid. + */ double m_eccentricitySquared; /* - * The maximum orthodromic distance that could be calculated onto the referenced ellipsoid. - */ + * The maximum orthodromic distance that could be calculated onto the referenced ellipsoid. + */ double m_maxOrthodromicDistance; /** diff --git a/core/libs/dmetadata/metadatasettingscontainer.h b/core/libs/dmetadata/metadatasettingscontainer.h --- a/core/libs/dmetadata/metadatasettingscontainer.h +++ b/core/libs/dmetadata/metadatasettingscontainer.h @@ -41,9 +41,9 @@ { /** - The class MetadataSettingsContainer encapsulates all metadata related settings. - NOTE: this allows supply changed arguments to MetadataHub without changing the global settings. -*/ + * The class MetadataSettingsContainer encapsulates all metadata related settings. + * NOTE: this allows supply changed arguments to MetadataHub without changing the global settings. + */ class DIGIKAM_EXPORT MetadataSettingsContainer { public: diff --git a/core/libs/dmetadata/metadatasettingscontainer.cpp b/core/libs/dmetadata/metadatasettingscontainer.cpp --- a/core/libs/dmetadata/metadatasettingscontainer.cpp +++ b/core/libs/dmetadata/metadatasettingscontainer.cpp @@ -39,26 +39,26 @@ { MetadataSettingsContainer::MetadataSettingsContainer() + : exifRotate(true), + exifSetOrientation(true), + saveComments(false), + saveDateTime(false), + savePickLabel(false), + saveColorLabel(false), + saveRating(false), + saveTemplate(false), + saveTags(false), + saveFaceTags(false), + writeRawFiles(false), + updateFileTimeStamp(true), + rescanImageIfModified(false), + clearMetadataIfRescan(false), + useXMPSidecar4Reading(false), + useLazySync(false), + metadataWritingMode(MetaEngine::WRITETOIMAGEONLY), + rotationBehavior(RotatingFlags | RotateByLosslessRotation), + sidecarExtensions(QStringList()) { - exifRotate = true; - exifSetOrientation = true; - saveComments = false; - saveDateTime = false; - savePickLabel = false; - saveColorLabel = false; - saveRating = false; - saveTemplate = false; - saveFaceTags = false; - saveTags = false; - writeRawFiles = false; - useXMPSidecar4Reading = false; - metadataWritingMode = MetaEngine::WRITETOIMAGEONLY; - updateFileTimeStamp = true; - rescanImageIfModified = false; - clearMetadataIfRescan = false; - rotationBehavior = RotatingFlags | RotateByLosslessRotation; - useLazySync = false; - sidecarExtensions = QStringList(); } void MetadataSettingsContainer::readFromConfig(KConfigGroup& group) diff --git a/core/libs/dmetadata/metaengine.h b/core/libs/dmetadata/metaengine.h --- a/core/libs/dmetadata/metaengine.h +++ b/core/libs/dmetadata/metaengine.h @@ -57,7 +57,8 @@ public: - /** The image metadata writing mode, between image file metadata and XMP sidecar file, depending on the context. + /** + * The image metadata writing mode, between image file metadata and XMP sidecar file, depending on the context. * @sa MetadataWritingMode(), metadataWritingMode() */ enum MetadataWritingMode @@ -75,7 +76,8 @@ WRITETOSIDECARONLY4READONLYFILES = 3 }; - /** The image color workspace values given by Exif metadata. + /** + * The image color workspace values given by Exif metadata. */ enum ImageColorWorkSpace { @@ -85,7 +87,8 @@ WORKSPACE_UNCALIBRATED = 65535 }; - /** The image orientation values given by Exif metadata. + /** + * The image orientation values given by Exif metadata. */ enum ImageOrientation { @@ -112,46 +115,55 @@ ArraySeqTag = 4 }; - /** A map used to store Tags Key and Tags Value. + /** + * A map used to store Tags Key and Tags Value. */ typedef QMap MetaDataMap; - /** A map used to store a list of Alternative Language values. - The map key is the language code following RFC3066 notation - (like "fr-FR" for French), and the map value the text. + /** + * A map used to store a list of Alternative Language values. + * The map key is the language code following RFC3066 notation + * (like "fr-FR" for French), and the map value the text. */ typedef QMap AltLangMap; - /** A map used to store Tags Key and a list of Tags properties : - - name, - - title, - - description. + /** + * A map used to store Tags Key and a list of Tags properties : + * - name, + * - title, + * - description. */ typedef QMap TagsMap; public: - /** Standard constructor. + /** + * Standard constructor. */ MetaEngine(); - /** Copy constructor. + /** + * Copy constructor. */ MetaEngine(const MetaEngine& metadata); - /** Constructor to load from parsed data. + /** + * Constructor to load from parsed data. */ explicit MetaEngine(const MetaEngineData& data); - /** Contructor to Load Metadata from image file. + /** + * Contructor to Load Metadata from image file. */ explicit MetaEngine(const QString& filePath); - /** Standard destructor + /** + * Standard destructor */ virtual ~MetaEngine(); - /** Create a copy of container + /** + * Create a copy of container */ MetaEngine& operator=(const MetaEngine& metadata); diff --git a/core/libs/dmetadata/metaengine_gps.cpp b/core/libs/dmetadata/metaengine_gps.cpp --- a/core/libs/dmetadata/metaengine_gps.cpp +++ b/core/libs/dmetadata/metaengine_gps.cpp @@ -608,6 +608,7 @@ { // Divide both by Denominator. numTemp /= denTemp; + // cppcheck-suppress duplicateExpression denTemp /= denTemp; } diff --git a/core/libs/dmetadata/template.h b/core/libs/dmetadata/template.h --- a/core/libs/dmetadata/template.h +++ b/core/libs/dmetadata/template.h @@ -49,15 +49,18 @@ explicit Template(); ~Template(); - /** Return true is Template title is null + /** + * Return true if Template title is null */ bool isNull() const; - /** Return true is Template contents is empty + /** + * Return true if Template contents is empty */ bool isEmpty() const; - /** Compare for metadata equality, not including "templateTitle" value. + /** + * Compare for metadata equality, not including "templateTitle" value. */ bool operator==(const Template& t) const; @@ -93,47 +96,58 @@ protected: - /** Template title used internaly. This value always exist and cannot be empty. + /** + * Template title used internaly. This value always exist and cannot be empty. */ QString m_templateTitle; - /** List of author names. + /** + * List of author names. */ QStringList m_authors; - /** Description of authors position. + /** + * Description of authors position. */ QString m_authorsPosition; - /** Credit description. + /** + * Credit description. */ QString m_credit; - /** Language alternative copyright notices. + /** + * Language alternative copyright notices. */ MetaEngine::AltLangMap m_copyright; - /** Language alternative right term usages. + /** + * Language alternative right term usages. */ MetaEngine::AltLangMap m_rightUsageTerms; - /** Descriptions of contents source. + /** + * Descriptions of contents source. */ QString m_source; - /** Special instructions to process with contents. + /** + * Special instructions to process with contents. */ QString m_instructions; - /** IPTC Location Information. + /** + * IPTC Location Information. */ IptcCoreLocationInfo m_locationInfo; - /** IPTC Contact Information. + /** + * IPTC Contact Information. */ IptcCoreContactInfo m_contactInfo; - /** IPTC Subjects Information. + /** + * IPTC Subjects Information. */ QStringList m_subjects; }; diff --git a/core/libs/dtrash/dtrashiteminfo.cpp b/core/libs/dtrash/dtrashiteminfo.cpp --- a/core/libs/dtrash/dtrashiteminfo.cpp +++ b/core/libs/dtrash/dtrashiteminfo.cpp @@ -46,13 +46,13 @@ QDebug operator<<(QDebug dbg, const DTrashItemInfo& info) { - dbg.nospace() << "DTrashItemInfo:\n "; - dbg.nospace() << "trashPath: " << info.trashPath << "\n "; - dbg.nospace() << "jsonFilePath: " << info.jsonFilePath << "\n "; - dbg.nospace() << "CollectionPath: "<< info.collectionPath << "\n "; - dbg.nospace() << "RelativePath: " << info.collectionRelativePath << "\n "; - dbg.nospace() << "DeletionTimestamp: " << info.deletionTimestamp.toString() << "\n"; - dbg.nospace() << "Image id: " << QString::number(info.imageId) << "\n"; + dbg.nospace() << "DTrashItemInfo:"; + dbg.nospace() << "\ntrashPath: " << info.trashPath; + dbg.nospace() << "\njsonFilePath: " << info.jsonFilePath; + dbg.nospace() << "\nCollectionPath: " << info.collectionPath; + dbg.nospace() << "\nRelativePath: " << info.collectionRelativePath; + dbg.nospace() << "\nDeletionTimestamp: " << info.deletionTimestamp.toString(); + dbg.nospace() << "\nImage id: " << QString::number(info.imageId) << "\n"; return dbg.space(); } diff --git a/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.h b/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.h --- a/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.h +++ b/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.h @@ -41,14 +41,14 @@ { public: - // Initializes this DNNFace Model. + /// Initializes this DNNFace Model. explicit DNNFaceRecognizer(double threshold = DBL_MAX) : m_threshold(threshold) { } - // Initializes and computes this DNNFace Model. - DNNFaceRecognizer(std::vector> src, + /// Initializes and computes this DNNFace Model. + DNNFaceRecognizer(const std::vector>& src, cv::InputArray labels, double threshold = DBL_MAX) : m_threshold(threshold) @@ -87,9 +87,8 @@ void predict(cv::InputArray _src, int& label, double& dist) const; /** - * Getter functions. + * Getter and setter functions. */ - double getThreshold() const { return m_threshold; } void setThreshold(double _threshold) { m_threshold = _threshold; } @@ -101,15 +100,16 @@ private: - /** Computes a DNNFace model with images in src and - * corresponding labels in labels, possibly preserving - * old training data. + /** + * Computes a DNNFace model with images in src and + * corresponding labels in labels, possibly preserving + * old training data. */ void train(std::vector> src, cv::InputArray labels, bool preserveData); private: - // NOTE: Do not use a d private internal container, this will crash OpenCV in cv::Algorithm::set() + // NOTE: Do not use a d private internal container here, this will crash OpenCV in cv::Algorithm::set() double m_threshold; std::vector> m_src; diff --git a/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.cpp b/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.cpp --- a/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.cpp +++ b/core/libs/facesengine/recognition-dlib-dnn/facerec_dnnborrowed.cpp @@ -54,7 +54,9 @@ { // got no data, just return if (_in_src.size() == 0) + { return; + } this->train(_in_src, _inm_labels, true); } @@ -84,7 +86,7 @@ } // append labels to m_labels matrix - for (size_t labelIdx = 0; labelIdx < labels.total(); labelIdx++) + for (size_t labelIdx = 0 ; labelIdx < labels.total() ; labelIdx++) { m_labels.push_back(labels.at((int)labelIdx)); m_src.push_back(src[(int)labelIdx]); @@ -182,7 +184,7 @@ { qCWarning(DIGIKAM_FACESENGINE_LOG) << "Predicting face image"; - cv::Mat src = _src.getMat();//254*254 + cv::Mat src = _src.getMat();//254*254 std::vector vecdata; FaceDb *tmp_facedb = new FaceDb(); tmp_facedb->getFaceVector(src, vecdata); @@ -193,13 +195,15 @@ // find nearest neighbor - for (size_t sampleIdx = 0; sampleIdx < m_src.size(); sampleIdx++) + for (size_t sampleIdx = 0 ; sampleIdx < m_src.size() ; sampleIdx++) { double dist = 0; - for(size_t i = 0; i < m_src[sampleIdx].size(); i++) + + for(size_t i = 0 ; i < m_src[sampleIdx].size() ; i++) { dist += (vecdata[i]-m_src[sampleIdx][i])*(vecdata[i]-m_src[sampleIdx][i]); } + dist = std::sqrt(dist); if ((dist < minDist) && (dist < m_threshold)) diff --git a/core/libs/imageproperties/versionsdelegate.h b/core/libs/imageproperties/versionsdelegate.h --- a/core/libs/imageproperties/versionsdelegate.h +++ b/core/libs/imageproperties/versionsdelegate.h @@ -43,7 +43,7 @@ public: - explicit VersionsDelegate(QObject* const parent = 0); + VersionsDelegate(QObject* const parent = 0); ~VersionsDelegate(); QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; diff --git a/core/libs/iojobs/iojob.h b/core/libs/iojobs/iojob.h --- a/core/libs/iojobs/iojob.h +++ b/core/libs/iojobs/iojob.h @@ -105,8 +105,7 @@ Q_SIGNALS: - void signalRenamed(const QUrl& oldUrl); - void signalRenameFailed(const QUrl& oldUrl); + void signalRenameFailed(const QUrl& url); protected: diff --git a/core/libs/iojobs/iojob.cpp b/core/libs/iojobs/iojob.cpp --- a/core/libs/iojobs/iojob.cpp +++ b/core/libs/iojobs/iojob.cpp @@ -37,6 +37,7 @@ // Local includes #include "digikam_debug.h" +#include "imageinfo.h" #include "dtrash.h" #include "coredb.h" #include "coredbaccess.h" @@ -408,16 +409,22 @@ void DeleteDTrashItemsJob::run() { CoreDbAccess access; + QList albumsFromImages; + QList imagesToRemove; foreach (const DTrashItemInfo& item, m_dtrashItemInfoList) { QFile::remove(item.trashPath); QFile::remove(item.jsonFilePath); - // Set the status of the image id to obsolete, i.e. to remove. + + imagesToRemove << item.imageId; + albumsFromImages << ImageInfo(item.imageId).albumId(); + access.db()->removeAllImageRelationsFrom(item.imageId, DatabaseRelation::Grouped); - access.db()->setItemStatus(item.imageId, DatabaseItem::Status::Obsolete); } + access.db()->removeItemsPermanently(imagesToRemove, albumsFromImages); + emit signalDone(); } diff --git a/core/libs/iojobs/iojobdata.h b/core/libs/iojobs/iojobdata.h --- a/core/libs/iojobs/iojobdata.h +++ b/core/libs/iojobs/iojobdata.h @@ -89,6 +89,8 @@ void setDestUrl(const QUrl& srcUrl, const QUrl& destUrl); + void setProgressId(const QString& id); + int operation() const; bool overwrite() const; @@ -99,6 +101,8 @@ QUrl destUrl(const QUrl& srcUrl = QUrl()) const; QUrl getNextUrl() const; + QString getProgressId() const; + ImageInfo findImageInfo(const QUrl& url) const; QList sourceUrls() const; diff --git a/core/libs/iojobs/iojobdata.cpp b/core/libs/iojobs/iojobdata.cpp --- a/core/libs/iojobs/iojobdata.cpp +++ b/core/libs/iojobs/iojobdata.cpp @@ -61,7 +61,9 @@ QUrl destUrl; - QMutex lock; + QString progressId; + + QMutex mutex; }; IOJobData::IOJobData(int operation, @@ -168,6 +170,11 @@ d->changeDestMap.insert(srcUrl, destUrl); } +void IOJobData::setProgressId(const QString& id) +{ + d->progressId = id; +} + int IOJobData::operation() const { return d->operation; @@ -200,18 +207,23 @@ QUrl IOJobData::getNextUrl() const { - d->lock.lock(); + d->mutex.lock(); QUrl url; if (!d->sourceUrlList.isEmpty()) { url = d->sourceUrlList.takeFirst(); } - d->lock.unlock(); + d->mutex.unlock(); return url; } +QString IOJobData::getProgressId() const +{ + return d->progressId; +} + ImageInfo IOJobData::findImageInfo(const QUrl& url) const { foreach(const ImageInfo& info, d->imageInfoList) diff --git a/core/libs/iojobs/iojobsthread.h b/core/libs/iojobs/iojobsthread.h --- a/core/libs/iojobs/iojobsthread.h +++ b/core/libs/iojobs/iojobsthread.h @@ -118,7 +118,7 @@ void finished(); void signalOneProccessed(const QUrl& url); - void signalRenameFailed(const QUrl& oldUrl); + void signalRenameFailed(const QUrl& url); void collectionTrashItemInfo(const DTrashItemInfo& trashItemInfo); diff --git a/core/libs/jpegutils/iccjpeg.h b/core/libs/jpegutils/iccjpeg.h --- a/core/libs/jpegutils/iccjpeg.h +++ b/core/libs/jpegutils/iccjpeg.h @@ -21,9 +21,6 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * - * iccprofile.h - * * This file provides code to read and write International Color Consortium * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has * defined a standard format for including such data in JPEG "APP2" markers. @@ -35,7 +32,7 @@ * IJG release 6b; it will not compile or work with older IJG versions. * * NOTE: this code would need surgery to work on 16-bit-int machines - * with ICC profiles exceeding 64K bytes in size. See iccprofile.c + * with ICC profiles exceeding 64K bytes in size. See iccjpeg.c * for details. */ @@ -45,7 +42,6 @@ #include /* needed to define "FILE", "NULL" */ #include - /** * This routine writes the given ICC profile data into a JPEG file. * It *must* be called AFTER calling jpeg_start_compress() and BEFORE @@ -57,7 +53,6 @@ const JOCTET* icc_data_ptr, unsigned int icc_data_len)); - /** * Reading a JPEG file that may contain an ICC profile requires two steps: * @@ -69,13 +64,11 @@ * whether there was a profile and obtain it if so. */ - /** * Prepare for reading an ICC profile */ extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo)); - /** * See if there was an ICC profile in the JPEG file being read; * if so, reassemble and return the profile data. diff --git a/core/libs/jpegutils/iccjpeg.c b/core/libs/jpegutils/iccjpeg.c --- a/core/libs/jpegutils/iccjpeg.c +++ b/core/libs/jpegutils/iccjpeg.c @@ -21,8 +21,6 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * iccprofile.c - * * This file provides code to read and write International Color Consortium * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has * defined a standard format for including such data in JPEG "APP2" markers. @@ -34,14 +32,16 @@ * IJG release 6b; it will not compile or work with older IJG versions. * * NOTE: this code would need surgery to work on 16-bit-int machines - * with ICC profiles exceeding 64K bytes in size. If you need to do that, - * change all the "unsigned int" variables to "INT32". You'll also need + * with ICC profiles exceeding 64K bytes in size. If you need to do that, + * change all the "unsigned int" variables to "INT32". You'll also need * to find a malloc() replacement that can allocate more than 64K. */ #include "iccjpeg.h" -#include /* define malloc() */ +/* C includes */ + +#include /* define malloc() */ /** * Since an ICC profile can be larger than the maximum size of a JPEG marker @@ -60,16 +60,15 @@ #define MAX_BYTES_IN_MARKER 65533 /* maximum data len of a JPEG marker */ #define MAX_DATA_BYTES_IN_MARKER (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN) - /** * This routine writes the given ICC profile data into a JPEG file. * It *must* be called AFTER calling jpeg_start_compress() and BEFORE * the first call to jpeg_write_scanlines(). * (This ordering ensures that the APP2 marker(s) will appear after the * SOI and JFIF or Adobe markers, but before all else.) */ void write_icc_profile(j_compress_ptr cinfo, - const JOCTET *icc_data_ptr, + const JOCTET* icc_data_ptr, unsigned int icc_data_len) { unsigned int num_markers = 0; /* total number of markers we'll write */ @@ -127,7 +126,6 @@ } } - /** * Prepare for reading an ICC profile */ @@ -137,7 +135,6 @@ jpeg_save_markers(cinfo, ICC_MARKER, 0xFFFF); } - /** * Handy subroutine to test whether a saved marker is an ICC profile marker. */ @@ -160,7 +157,6 @@ GETJOCTET(marker->data[11]) == 0x0); } - /** * See if there was an ICC profile in the JPEG file being read; * if so, reassemble and return the profile data. @@ -180,8 +176,8 @@ * return FALSE. You might want to issue an error message instead. */ boolean read_icc_profile(j_decompress_ptr cinfo, - JOCTET **icc_data_ptr, - unsigned int *icc_data_len) + JOCTET** icc_data_ptr, + unsigned int* icc_data_len) { jpeg_saved_marker_ptr marker; int num_markers = 0; @@ -202,10 +198,10 @@ * any ICC markers and verifies the consistency of the marker numbering. */ - for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++) + for (seq_no = 1 ; seq_no <= MAX_SEQ_NO ; seq_no++) marker_present[seq_no] = 0; - for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) + for (marker = cinfo->marker_list ; marker != NULL ; marker = marker->next) { if (marker_is_icc(marker)) { @@ -236,37 +232,33 @@ total_length = 0; - for (seq_no = 1; seq_no <= num_markers; seq_no++) + for (seq_no = 1 ; seq_no <= num_markers ; seq_no++) { if (marker_present[seq_no] == 0) return FALSE; /* missing sequence number */ data_offset[seq_no] = total_length; - total_length += data_length[seq_no]; + total_length += data_length[seq_no]; } if (total_length == 0) return FALSE; /* found only empty markers? */ /* Allocate space for assembled data */ - icc_data = (JOCTET *) malloc(total_length * sizeof(JOCTET)); + icc_data = (JOCTET*) malloc(total_length * sizeof(JOCTET)); if (icc_data == NULL) return FALSE; /* oops, out of memory */ /* and fill it in */ - for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) + for (marker = cinfo->marker_list ; marker != NULL ; marker = marker->next) { if (marker_is_icc(marker)) { - JOCTET FAR *src_ptr = NULL; - JOCTET *dst_ptr = NULL; - unsigned int length = 0; - - seq_no = GETJOCTET(marker->data[12]); - dst_ptr = icc_data + data_offset[seq_no]; - src_ptr = marker->data + ICC_OVERHEAD_LEN; - length = data_length[seq_no]; + seq_no = GETJOCTET(marker->data[12]); + JOCTET* dst_ptr = icc_data + data_offset[seq_no]; + JOCTET FAR* src_ptr = marker->data + ICC_OVERHEAD_LEN; + unsigned int length = data_length[seq_no]; while (length--) { diff --git a/core/libs/progressmanager/progressmanager.cpp b/core/libs/progressmanager/progressmanager.cpp --- a/core/libs/progressmanager/progressmanager.cpp +++ b/core/libs/progressmanager/progressmanager.cpp @@ -119,14 +119,14 @@ void ProgressItem::setComplete() { - if ( d->children.isEmpty() ) + if (d->children.isEmpty()) { - if ( !d->canceled ) + if (!d->canceled) { - setProgress( 100 ); + setProgress(100); } - emit progressItemCompleted( this ); + emit progressItemCompleted(this); } else { @@ -152,38 +152,38 @@ void ProgressItem::cancel() { - if ( d->canceled || !d->canBeCanceled ) + if (d->canceled || !d->canBeCanceled) { return; } d->canceled = true; // Cancel all children. QList kids = d->children.keys(); - QList::Iterator it( kids.begin() ); - QList::Iterator end( kids.end() ); + QList::Iterator it(kids.begin()); + QList::Iterator end(kids.end()); - for ( ; it != end; it++ ) + for ( ; it != end ; ++it) { ProgressItem* const kid = *it; - if ( kid->canBeCanceled() ) + if (kid->canBeCanceled()) { kid->cancel(); } } - setStatus( i18n( "Aborting..." ) ); + setStatus(i18n("Aborting...")); - emit progressItemCanceled( this ); - emit progressItemCanceled( this->id() ); + emit progressItemCanceled(this); + emit progressItemCanceled(this->id()); } void ProgressItem::setLabel(const QString& v) { d->label = v; - emit progressItemLabel( this, d->label ); + emit progressItemLabel(this, d->label); } void ProgressItem::setStatus(const QString& v) @@ -200,7 +200,10 @@ void ProgressItem::setThumbnail(const QIcon& icon) { - if (!hasThumbnail()) return; + if (!hasThumbnail()) + { + return; + } int iconSize = qApp->style()->pixelMetric(QStyle::PM_SmallIconSize); @@ -418,15 +421,17 @@ ProgressItem* ProgressManager::findItembyId(const QString& id) const { if (id.isEmpty()) + { return 0; + } QMutexLocker lock(&d->mutex); return d->transactions.value(id); } QString ProgressManager::getUniqueID() { - return QString::number( d->uID.fetchAndAddOrdered(1) ); + return QString::number(d->uID.fetchAndAddOrdered(1)); } ProgressManager* ProgressManager::instance() @@ -439,8 +444,7 @@ const QString& label, const QString& status, bool cancellable, - bool hasThumb - ) + bool hasThumb) { ProgressItem* t = findItembyId(id); @@ -458,8 +462,7 @@ const QString& label, const QString& status, bool canBeCanceled, - bool hasThumb - ) + bool hasThumb) { ProgressItem* const p = findItembyId(parent); return createProgressItemImpl(p, id, label, status, canBeCanceled, hasThumb); @@ -554,24 +557,28 @@ ProgressItem* ProgressManager::singleItem() const { - QHash hash; + QHash hash; + { QMutexLocker lock(&d->mutex); hash = d->transactions; } ProgressItem* item = 0; QHash::const_iterator it = hash.constBegin(); - while ( it != hash.constEnd() ) + while (it != hash.constEnd()) { // No single item for progress possible, as one of them is a busy indicator one. - if ( (*it)->usesBusyIndicator() ) + if ((*it)->usesBusyIndicator()) + { return 0; + } - if ( !(*it)->parent() ) - { // if it's a top level one, only those count - if ( item ) + // If it's a top level one, only those count. + if (!(*it)->parent()) + { + if (item) { return 0; // we found more than one } @@ -589,7 +596,8 @@ void ProgressManager::slotAbortAll() { - QHash hash; + QHash hash; + { QMutexLocker lock(&d->mutex); diff --git a/core/libs/progressmanager/workingwidget.cpp b/core/libs/progressmanager/workingwidget.cpp --- a/core/libs/progressmanager/workingwidget.cpp +++ b/core/libs/progressmanager/workingwidget.cpp @@ -46,9 +46,9 @@ public: explicit Private() + : pixmaps(DWorkingPixmap()), + currentPixmap(0) { - currentPixmap = 0; - pixmaps = DWorkingPixmap(); } DWorkingPixmap pixmaps; diff --git a/core/libs/settings/applicationsettings_p.h b/core/libs/settings/applicationsettings_p.h --- a/core/libs/settings/applicationsettings_p.h +++ b/core/libs/settings/applicationsettings_p.h @@ -308,6 +308,7 @@ private: + // cppcheck-suppress unusedPrivateFunction static ApplicationSettings::OperationStrings createConfigGroupingOperateOnAll(); }; diff --git a/core/libs/threadimageio/ffmpegthumbnailer/moviedecoder_p.h b/core/libs/threadimageio/ffmpegthumbnailer/moviedecoder_p.h --- a/core/libs/threadimageio/ffmpegthumbnailer/moviedecoder_p.h +++ b/core/libs/threadimageio/ffmpegthumbnailer/moviedecoder_p.h @@ -106,6 +106,7 @@ int height, AVPixelFormat format); + // cppcheck-suppress unusedPrivateFunction int decodeVideoNew(AVCodecContext* const avContext, AVFrame* const avFrame, int* gotFrame, diff --git a/core/libs/threadimageio/loadingdescription.h b/core/libs/threadimageio/loadingdescription.h --- a/core/libs/threadimageio/loadingdescription.h +++ b/core/libs/threadimageio/loadingdescription.h @@ -7,6 +7,7 @@ * Description : image file IO threaded interface. * * Copyright (C) 2006-2011 by Marcel Wiesweg + * Copyright (C) 2012-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -143,15 +144,13 @@ /** * An invalid LoadingDescription */ - LoadingDescription() - { - rawDecodingHint = RawDecodingDefaultSettings; - } + LoadingDescription(); /** * Use this for full loading of non-raw files */ - explicit LoadingDescription(const QString& filePath, ColorManagementSettings = NoColorConversion); + explicit LoadingDescription(const QString& filePath, + ColorManagementSettings = NoColorConversion); /** * Use this for full loading of raw files diff --git a/core/libs/threadimageio/loadingdescription.cpp b/core/libs/threadimageio/loadingdescription.cpp --- a/core/libs/threadimageio/loadingdescription.cpp +++ b/core/libs/threadimageio/loadingdescription.cpp @@ -7,6 +7,7 @@ * Description : Loading parameters for multithreaded loading * * Copyright (C) 2006-2011 by Marcel Wiesweg + * Copyright (C) 2012-2018 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -89,21 +90,35 @@ return iccData.value(); } -LoadingDescription::LoadingDescription(const QString& filePath, ColorManagementSettings cm) - : filePath(filePath) +// ---------------------------------------------------------------------------- + +LoadingDescription::LoadingDescription() + : filePath(QString()), + rawDecodingSettings(DRawDecoding()), + rawDecodingHint(RawDecodingDefaultSettings), + previewParameters(PreviewParameters()), + postProcessingParameters(PostProcessingParameters()) { - rawDecodingSettings = DRawDecoding(); - rawDecodingHint = RawDecodingDefaultSettings; - postProcessingParameters.colorManagement = cm; +} + +LoadingDescription::LoadingDescription(const QString& filePath, + ColorManagementSettings cm) + : filePath(filePath), + rawDecodingSettings(DRawDecoding()), + rawDecodingHint(RawDecodingDefaultSettings), + previewParameters(PreviewParameters()) +{ + postProcessingParameters.colorManagement = cm; } LoadingDescription::LoadingDescription(const QString& filePath, const DRawDecoding& settings, RawDecodingHint hint, ColorManagementSettings cm) : filePath(filePath), rawDecodingSettings(settings), - rawDecodingHint(hint) + rawDecodingHint(hint), + previewParameters(PreviewParameters()) { postProcessingParameters.colorManagement = cm; } @@ -113,10 +128,10 @@ int size, ColorManagementSettings cm, LoadingDescription::PreviewParameters::PreviewType type) - : filePath(filePath) + : filePath(filePath), + rawDecodingSettings(DRawDecoding()), + rawDecodingHint(RawDecodingDefaultSettings) { - rawDecodingSettings = DRawDecoding(); - rawDecodingHint = RawDecodingDefaultSettings; previewParameters.type = type; previewParameters.size = size; previewParameters.previewSettings = previewSettings; diff --git a/core/libs/widgets/graphicsview/itemvisibilitycontroller.cpp b/core/libs/widgets/graphicsview/itemvisibilitycontroller.cpp --- a/core/libs/widgets/graphicsview/itemvisibilitycontroller.cpp +++ b/core/libs/widgets/graphicsview/itemvisibilitycontroller.cpp @@ -506,17 +506,16 @@ public: explicit Private(ItemVisibilityController* const qq) - : q(qq) + : visible(false), + shallBeShown(true), + itemShallBeShown(0), + animationDuration(75), + easingCurve(QEasingCurve::InOutQuad), + control(0), + q(qq) { - visible = false; - shallBeShown = true; - itemShallBeShown = 0; - animationDuration= 75; - easingCurve = QEasingCurve::InOutQuad; - control = 0; } - public: void setVisible(bool v, bool immediately); diff --git a/core/utilities/advancedrename/advancedrenameprocessdialog.h b/core/utilities/advancedrename/advancedrenameprocessdialog.h --- a/core/utilities/advancedrename/advancedrenameprocessdialog.h +++ b/core/utilities/advancedrename/advancedrenameprocessdialog.h @@ -67,13 +67,13 @@ protected Q_SLOTS: void slotCancel(); - void slotRenameSuccessded(const QUrl&); - void slotRenameFailed(const QUrl&); + void slotRenameSuccessded(const QUrl& url); + void slotRenameFailed(const QUrl& url); private Q_SLOTS: void slotRenameImages(); - void slotGotThumbnail(const LoadingDescription&, const QPixmap&); + void slotGotThumbnail(const LoadingDescription& desc, const QPixmap& pix); private: diff --git a/core/utilities/advancedrename/advancedrenameprocessdialog.cpp b/core/utilities/advancedrename/advancedrenameprocessdialog.cpp --- a/core/utilities/advancedrename/advancedrenameprocessdialog.cpp +++ b/core/utilities/advancedrename/advancedrenameprocessdialog.cpp @@ -155,9 +155,9 @@ done(QDialogButtonBox::Cancel); } -void AdvancedRenameProcessDialog::slotRenameSuccessded(const QUrl& src) +void AdvancedRenameProcessDialog::slotRenameSuccessded(const QUrl& url) { - if (d->cancel || d->currentInfo.first != src) + if (d->cancel || d->currentInfo.first != url) { return; } @@ -219,23 +219,23 @@ } } -void AdvancedRenameProcessDialog::slotRenameFailed(const QUrl& src) +void AdvancedRenameProcessDialog::slotRenameFailed(const QUrl& url) { - if (d->cancel || d->currentInfo.first != src) + if (d->cancel || d->currentInfo.first != url) { return; } QPixmap pix = QIcon::fromTheme(QLatin1String("emblem-error")).pixmap(32, 32); - addedAction(pix, QDir::toNativeSeparators(src.toLocalFile())); + addedAction(pix, QDir::toNativeSeparators(url.toLocalFile())); setLabel(i18n("Renaming images has failed...")); qApp->processEvents(); d->failedList << d->currentInfo; QThread::msleep(250); - slotRenameSuccessded(src); + slotRenameSuccessded(url); } void AdvancedRenameProcessDialog::closeEvent(QCloseEvent* e) diff --git a/core/utilities/assistants/expoblending/blendingdlg/bracketstack.h b/core/utilities/assistants/expoblending/blendingdlg/bracketstack.h --- a/core/utilities/assistants/expoblending/blendingdlg/bracketstack.h +++ b/core/utilities/assistants/expoblending/blendingdlg/bracketstack.h @@ -22,8 +22,8 @@ * * ============================================================ */ -#ifndef BRACKETSTACK_H -#define BRACKETSTACK_H +#ifndef DIGIKAM_BRACKET_STACK_H +#define DIGIKAM_BRACKET_STACK_H // Qt includes @@ -91,4 +91,4 @@ } // namespace Digikam -#endif /* BRACKETSTACK_H */ +#endif // DIGIKAM_BRACKET_STACK_H diff --git a/core/utilities/assistants/expoblending/blendingdlg/enfusesettings.h b/core/utilities/assistants/expoblending/blendingdlg/enfusesettings.h --- a/core/utilities/assistants/expoblending/blendingdlg/enfusesettings.h +++ b/core/utilities/assistants/expoblending/blendingdlg/enfusesettings.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef ENFUSE_SETTINGS_H -#define ENFUSE_SETTINGS_H +#ifndef DIGIKAM_ENFUSE_SETTINGS_H +#define DIGIKAM_ENFUSE_SETTINGS_H // Qt includes @@ -110,4 +110,4 @@ } // namespace Digikam -#endif // ENFUSE_SETTINGS_H +#endif // DIGIKAM_ENFUSE_SETTINGS_H diff --git a/core/utilities/assistants/expoblending/blendingdlg/enfusestack.h b/core/utilities/assistants/expoblending/blendingdlg/enfusestack.h --- a/core/utilities/assistants/expoblending/blendingdlg/enfusestack.h +++ b/core/utilities/assistants/expoblending/blendingdlg/enfusestack.h @@ -22,8 +22,8 @@ * * ============================================================ */ -#ifndef ENFUSE_STACK_H -#define ENFUSE_STACK_H +#ifndef DIGIKAM_ENFUSE_STACK_H +#define DIGIKAM_ENFUSE_STACK_H // Qt includes @@ -115,4 +115,4 @@ } // namespace Digikam -#endif // ENFUSE_STACK_H +#endif // DIGIKAM_ENFUSE_STACK_H diff --git a/core/utilities/assistants/expoblending/blendingdlg/expoblendingdlg.h b/core/utilities/assistants/expoblending/blendingdlg/expoblendingdlg.h --- a/core/utilities/assistants/expoblending/blendingdlg/expoblendingdlg.h +++ b/core/utilities/assistants/expoblending/blendingdlg/expoblendingdlg.h @@ -22,8 +22,8 @@ * * ============================================================ */ -#ifndef EXPOBLENDINGDLG_H -#define EXPOBLENDINGDLG_H +#ifndef DIGIKAM_EXPO_BLENDING_DLG_H +#define DIGIKAM_EXPO_BLENDING_DLG_H // Qt includes @@ -97,4 +97,4 @@ } // namespace Digikam -#endif // EXPOBLENDINGDLG_H +#endif // DIGIKAM_EXPO_BLENDING_DLG_H diff --git a/core/utilities/assistants/expoblending/manager/alignbinary.h b/core/utilities/assistants/expoblending/manager/alignbinary.h --- a/core/utilities/assistants/expoblending/manager/alignbinary.h +++ b/core/utilities/assistants/expoblending/manager/alignbinary.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef ALIGN_BINARY_H -#define ALIGN_BINARY_H +#ifndef DIGIKAM_ALIGN_BINARY_H +#define DIGIKAM_ALIGN_BINARY_H // Local includes @@ -35,7 +35,7 @@ { public: - AlignBinary() + explicit AlignBinary() : DBinaryIface(QLatin1String("align_image_stack"), QLatin1String("0.8"), QLatin1String("align_image_stack version "), @@ -56,4 +56,4 @@ } // namespace Digikam -#endif // ALIGN_BINARY_H +#endif // DIGIKAM_ALIGN_BINARY_H diff --git a/core/utilities/assistants/expoblending/manager/enfusebinary.h b/core/utilities/assistants/expoblending/manager/enfusebinary.h --- a/core/utilities/assistants/expoblending/manager/enfusebinary.h +++ b/core/utilities/assistants/expoblending/manager/enfusebinary.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef ENFUSE_BINARY_H -#define ENFUSE_BINARY_H +#ifndef DIGIKAM_ENFUSE_BINARY_H +#define DIGIKAM_ENFUSE_BINARY_H // Local includes @@ -37,16 +37,16 @@ public: - EnfuseBinary() - : DBinaryIface(QLatin1String("enfuse"), - QLatin1String("3.2"), - QLatin1String("enfuse "), - 0, - QLatin1String("Enblend"), - QLatin1String("http://enblend.sourceforge.net/download/"), - QLatin1String("ExpoBlending"), - QStringList(QLatin1String("-V"))), - versionDouble(0) + explicit EnfuseBinary() + : DBinaryIface(QLatin1String("enfuse"), + QLatin1String("3.2"), + QLatin1String("enfuse "), + 0, + QLatin1String("Enblend"), + QLatin1String("http://enblend.sourceforge.net/download/"), + QLatin1String("ExpoBlending"), + QStringList(QLatin1String("-V"))), + versionDouble(0) { setup(); } @@ -72,4 +72,4 @@ } // namespace Digikam -#endif // ENFUSE_BINARY_H +#endif // DIGIKAM_ENFUSE_BINARY_H diff --git a/core/utilities/assistants/expoblending/manager/expoblendingactions.h b/core/utilities/assistants/expoblending/manager/expoblendingactions.h --- a/core/utilities/assistants/expoblending/manager/expoblendingactions.h +++ b/core/utilities/assistants/expoblending/manager/expoblendingactions.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef EXPO_BLENDING_ACTIONS_H -#define EXPO_BLENDING_ACTIONS_H +#ifndef DIGIKAM_EXPO_BLENDING_ACTIONS_H +#define DIGIKAM_EXPO_BLENDING_ACTIONS_H // Qt includes @@ -77,7 +77,7 @@ public: - ExpoBlendingActionData() + explicit ExpoBlendingActionData() : starting(false), success(false), action(EXPOBLENDING_NONE) @@ -106,4 +106,4 @@ Q_DECLARE_METATYPE(Digikam::ExpoBlendingActionData) Q_DECLARE_METATYPE(Digikam::ExpoBlendingItemPreprocessedUrls) -#endif // EXPO_BLENDING_ACTIONS_H +#endif // DIGIKAM_EXPO_BLENDING_ACTIONS_H diff --git a/core/utilities/assistants/expoblending/manager/expoblendingmanager.h b/core/utilities/assistants/expoblending/manager/expoblendingmanager.h --- a/core/utilities/assistants/expoblending/manager/expoblendingmanager.h +++ b/core/utilities/assistants/expoblending/manager/expoblendingmanager.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef EXPO_BLENDING_MANAGER_H -#define EXPO_BLENDING_MANAGER_H +#ifndef DIGIKAM_EXPO_BLENDING_MANAGER_H +#define DIGIKAM_EXPO_BLENDING_MANAGER_H // Qt includes @@ -91,4 +91,4 @@ } // namespace Digikam -#endif // EXPO_BLENDING_MANAGER_H +#endif // DIGIKAM_EXPO_BLENDING_MANAGER_H diff --git a/core/utilities/assistants/expoblending/manager/expoblendingthread.h b/core/utilities/assistants/expoblending/manager/expoblendingthread.h --- a/core/utilities/assistants/expoblending/manager/expoblendingthread.h +++ b/core/utilities/assistants/expoblending/manager/expoblendingthread.h @@ -22,8 +22,8 @@ * * ============================================================ */ -#ifndef EXPO_BLENDING_THREAD_H -#define EXPO_BLENDING_THREAD_H +#ifndef DIGIKAM_EXPO_BLENDING_THREAD_H +#define DIGIKAM_EXPO_BLENDING_THREAD_H // Qt includes @@ -103,4 +103,4 @@ } // namespace Digikam -#endif // EXPO_BLENDING_THREAD_H +#endif // DIGIKAM_EXPO_BLENDING_THREAD_H diff --git a/core/utilities/assistants/expoblending/manager/expoblendingthread.cpp b/core/utilities/assistants/expoblending/manager/expoblendingthread.cpp --- a/core/utilities/assistants/expoblending/manager/expoblendingthread.cpp +++ b/core/utilities/assistants/expoblending/manager/expoblendingthread.cpp @@ -436,11 +436,9 @@ ad1.enfuseSettings = t->enfuseSettings; emit starting(ad1); - QUrl destUrl = t->outputUrl; - bool result = false; QString errors; - - result = startEnfuse(t->urls, destUrl, t->enfuseSettings, t->binaryPath, errors); + QUrl destUrl = t->outputUrl; + bool result = startEnfuse(t->urls, destUrl, t->enfuseSettings, t->binaryPath, errors); // We will take first image metadata from stack to restore Exif, Iptc, and Xmp. @@ -484,7 +482,7 @@ default: { - qCritical() << "Unknown action specified" << endl; + qCritical(DIGIKAM_GENERAL_LOG) << "Unknown action specified" << endl; break; } } @@ -563,7 +561,7 @@ QList > tasks; - for (int i = 0; i < inUrls.size(); ++i) + for (int i = 0 ; i < inUrls.size() ; ++i) { QUrl url = inUrls.at(i); @@ -597,6 +595,7 @@ args << QLatin1String("-v"); args << QLatin1String("-a"); args << QLatin1String("aligned"); + foreach(const QUrl& url, d->mixedUrls) { args << url.toLocalFile(); @@ -616,19 +615,18 @@ return false; } - uint i=0; + uint i = 0; QString temp; d->preProcessedUrlsMap.clear(); - foreach(const QUrl& url, inUrls) + foreach (const QUrl& url, inUrls) { QUrl previewUrl; - QUrl alignedUrl = QUrl::fromLocalFile( - d->preprocessingTmpDir->path() - + QChar::fromLatin1('/') - + QLatin1String("aligned") - + QString::number(i).rightJustified(4, QChar::fromLatin1('0')) - + QLatin1String(".tif")); + QUrl alignedUrl = QUrl::fromLocalFile(d->preprocessingTmpDir->path() + + QChar::fromLatin1('/') + + QLatin1String("aligned") + + QString::number(i).rightJustified(4, QChar::fromLatin1('0')) + + QLatin1String(".tif")); if (!computePreview(alignedUrl, previewUrl)) { @@ -681,12 +679,11 @@ bool ExpoBlendingThread::computePreview(const QUrl& inUrl, QUrl& outUrl) { - outUrl = QUrl::fromLocalFile( - d->preprocessingTmpDir->path() - + QChar::fromLatin1('/') - + QChar::fromLatin1('.') - + inUrl.fileName().replace(QChar::fromLatin1('.'), QChar::fromLatin1('_')) - + QLatin1String("-preview.jpg")); + outUrl = QUrl::fromLocalFile(d->preprocessingTmpDir->path() + + QChar::fromLatin1('/') + + QChar::fromLatin1('.') + + inUrl.fileName().replace(QChar::fromLatin1('.'), QChar::fromLatin1('_')) + + QLatin1String("-preview.jpg")); DImg img; @@ -741,12 +738,11 @@ d->meta.setImageOrientation(MetaEngine::ORIENTATION_NORMAL); QFileInfo fi(inUrl.toLocalFile()); - outUrl = QUrl::fromLocalFile( - d->preprocessingTmpDir->path() - + QChar::fromLatin1('/') - + QChar::fromLatin1('.') - + fi.completeBaseName().replace(QChar::fromLatin1('.'), QChar::fromLatin1('_')) - + QLatin1String(".tif")); + outUrl = QUrl::fromLocalFile(d->preprocessingTmpDir->path() + + QChar::fromLatin1('/') + + QChar::fromLatin1('.') + + fi.completeBaseName().replace(QChar::fromLatin1('.'), QChar::fromLatin1('_')) + + QLatin1String(".tif")); if (!img.save(outUrl.toLocalFile(), QLatin1String("TIF"))) { @@ -767,8 +763,8 @@ } bool ExpoBlendingThread::startEnfuse(const QList& inUrls, QUrl& outUrl, - const EnfuseSettings& settings, - const QString& enfusePath, QString& errors) + const EnfuseSettings& settings, + const QString& enfusePath, QString& errors) { QString comp; QString ext = DSaveSettingsWidget::extensionForFormat(settings.outputFormat); @@ -829,7 +825,7 @@ args << QLatin1String("-o"); args << outUrl.toLocalFile(); - foreach(const QUrl& url, inUrls) + foreach (const QUrl& url, inUrls) { args << url.toLocalFile(); } diff --git a/core/utilities/assistants/expoblending/wizard/expoblendingintropage.h b/core/utilities/assistants/expoblending/wizard/expoblendingintropage.h --- a/core/utilities/assistants/expoblending/wizard/expoblendingintropage.h +++ b/core/utilities/assistants/expoblending/wizard/expoblendingintropage.h @@ -20,8 +20,8 @@ * * ============================================================ */ -#ifndef EXPO_BLENDING_INTRO_PAGE_H -#define EXPO_BLENDING_INTRO_PAGE_H +#ifndef DIGIKAM_EXPO_BLENDING_INTRO_PAGE_H +#define DIGIKAM_EXPO_BLENDING_INTRO_PAGE_H // Local includes @@ -54,4 +54,4 @@ } // namespace Digikam -#endif // EXPO_BLENDING_INTRO_PAGE_H +#endif // DIGIKAM_EXPO_BLENDING_INTRO_PAGE_H diff --git a/core/utilities/assistants/expoblending/wizard/expoblendingitemspage.h b/core/utilities/assistants/expoblending/wizard/expoblendingitemspage.h --- a/core/utilities/assistants/expoblending/wizard/expoblendingitemspage.h +++ b/core/utilities/assistants/expoblending/wizard/expoblendingitemspage.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef EXPO_BLENDING_ITEMS_PAGE_H -#define EXPO_BLENDING_ITEMS_PAGE_H +#ifndef DIGIKAM_EXPO_BLENDING_ITEMS_PAGE_H +#define DIGIKAM_EXPO_BLENDING_ITEMS_PAGE_H // Local includes @@ -68,4 +68,4 @@ } // namespace Digikam -#endif // EXPO_BLENDING_ITEMS_PAGE_H +#endif // DIGIKAM_EXPO_BLENDING_ITEMS_PAGE_H diff --git a/core/utilities/assistants/expoblending/wizard/expoblendinglastpage.h b/core/utilities/assistants/expoblending/wizard/expoblendinglastpage.h --- a/core/utilities/assistants/expoblending/wizard/expoblendinglastpage.h +++ b/core/utilities/assistants/expoblending/wizard/expoblendinglastpage.h @@ -20,8 +20,8 @@ * * ============================================================ */ -#ifndef EXPOBLENDINGLAST_PAGE_H -#define EXPOBLENDINGLAST_PAGE_H +#ifndef DIGIKAM_EXPO_BLENDING_LAST_PAGE_H +#define DIGIKAM_EXPO_BLENDING_LAST_PAGE_H // Local includes @@ -35,7 +35,7 @@ { public: - ExpoBlendingLastPage(ExpoBlendingManager* const mngr, QWizard* const dlg); + explicit ExpoBlendingLastPage(ExpoBlendingManager* const mngr, QWizard* const dlg); ~ExpoBlendingLastPage(); private: @@ -46,4 +46,4 @@ } // namespace Digikam -#endif /* EXPOBLENDINGLAST_PAGE_H */ +#endif // DIGIKAM_EXPO_BLENDING_LAST_PAGE_H diff --git a/core/utilities/assistants/expoblending/wizard/expoblendingpreprocesspage.h b/core/utilities/assistants/expoblending/wizard/expoblendingpreprocesspage.h --- a/core/utilities/assistants/expoblending/wizard/expoblendingpreprocesspage.h +++ b/core/utilities/assistants/expoblending/wizard/expoblendingpreprocesspage.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef EXPOBLENDINGPREPROCESS_PAGE_H -#define EXPOBLENDINGPREPROCESS_PAGE_H +#ifndef DIGIKAM_EXPO_BLENDING_PREPROCESS_PAGE_H +#define DIGIKAM_EXPO_BLENDING_PREPROCESS_PAGE_H // Local includes @@ -40,7 +40,7 @@ public: - ExpoBlendingPreProcessPage(ExpoBlendingManager* const mngr, QWizard* const dlg); + explicit ExpoBlendingPreProcessPage(ExpoBlendingManager* const mngr, QWizard* const dlg); ~ExpoBlendingPreProcessPage(); void process(); @@ -67,4 +67,4 @@ } // namespace Digikam -#endif /* EXPOBLENDINGPREPROCESS_PAGE_H */ +#endif // DIGIKAM_EXPO_BLENDING_PREPROCESS_PAGE_H diff --git a/core/utilities/assistants/expoblending/wizard/expoblendingwizard.h b/core/utilities/assistants/expoblending/wizard/expoblendingwizard.h --- a/core/utilities/assistants/expoblending/wizard/expoblendingwizard.h +++ b/core/utilities/assistants/expoblending/wizard/expoblendingwizard.h @@ -21,8 +21,8 @@ * * ============================================================ */ -#ifndef EXPOBLENDINGWIZARD_H -#define EXPOBLENDINGWIZARD_H +#ifndef DIGIKAM_EXPO_BLENDING_WIZARD_H +#define DIGIKAM_EXPO_BLENDING_WIZARD_H // Qt includes @@ -68,4 +68,4 @@ } // namespace Digikam -#endif /* EXPOBLENDINGWIZARD_H */ +#endif // DIGIKAM_EXPO_BLENDING_WIZARD_H diff --git a/core/utilities/assistants/panorama/ptoparser/tparsergetters.c b/core/utilities/assistants/panorama/ptoparser/tparsergetters.c --- a/core/utilities/assistants/panorama/ptoparser/tparsergetters.c +++ b/core/utilities/assistants/panorama/ptoparser/tparsergetters.c @@ -514,11 +514,9 @@ int panoScriptGetPanoOutputFormat(pt_script* script) { - char* str = NULL; - assert(script != NULL); - str = script->pano.outputFormat; + char* str = script->pano.outputFormat; if (str == 0) { @@ -528,12 +526,14 @@ switch (str[0]) { case 'P': + if (strncmp("NG", str + 1, 2) == 0) return 0; break; case 'T': + if (strncmp("IFF", str + 1, 3) == 0) { if (strncmp("_m", str + 4, 2) == 0) @@ -550,6 +550,7 @@ break; case 'J': + if (strncmp("PEG", str + 1, 3) == 0) return 4; @@ -564,11 +565,9 @@ int panoScriptGetPanoOutputCompression(pt_script* script) { - char* str = NULL; - assert(script != NULL && panoScriptGetPanoOutputFormat(script) > 0 && panoScriptGetPanoOutputFormat(script) < 4); - str = script->pano.outputFormat; + char* str = script->pano.outputFormat; while (str != NULL) { @@ -583,18 +582,21 @@ switch (str[0]) { case 'N': + if (strncmp("ONE", str + 1, 3) == 0) return 0; break; case 'L': + if (strncmp("ZW", str + 1, 2) == 0) return 1; break; case 'D': + if (strncmp("EFLATE", str + 1, 6) == 0) return 2; @@ -616,11 +618,10 @@ int panoScriptGetPanoOutputSaveCoordinates(pt_script* script) { - char* str = NULL; - assert(script != NULL && panoScriptGetPanoOutputFormat(script) > 1 && panoScriptGetPanoOutputFormat(script) < 4); - str = script->pano.outputFormat; + char* str = script->pano.outputFormat; + while (str != NULL) { str = strchr(str, ' '); @@ -644,11 +645,9 @@ int panoScriptGetPanoOutputCropped(pt_script* script) { - char* str = NULL; - assert(script != NULL && panoScriptGetPanoOutputFormat(script) > 1 && panoScriptGetPanoOutputFormat(script) < 4); - str = script->pano.outputFormat; + char* str = script->pano.outputFormat; while (str != NULL) { @@ -673,11 +672,9 @@ int panoScriptGetPanoOutputQuality(pt_script* script) { - char* str = NULL; - assert(script != NULL && panoScriptGetPanoOutputFormat(script) == 4); - str = script->pano.outputFormat; + char* str = script->pano.outputFormat; while (str != NULL) { @@ -795,11 +792,9 @@ int panoScriptGetVarsToOptimizeName(pt_script* script, int v) { - char* var = NULL; - assert(script != NULL && v >= 0 && v < script->iVarsToOptimizeCount); - var = script->varsToOptimize[v].varName; + char* var = script->varsToOptimize[v].varName; switch (var[0]) { diff --git a/core/utilities/assistants/webservices/common/wssettingswidget.cpp b/core/utilities/assistants/webservices/common/wssettingswidget.cpp --- a/core/utilities/assistants/webservices/common/wssettingswidget.cpp +++ b/core/utilities/assistants/webservices/common/wssettingswidget.cpp @@ -51,42 +51,40 @@ { public: - explicit Private(QWidget* const widget, - DInfoInterface* const interface, - const QString& name) - { - iface = interface; - toolName = name; - mainLayout = new QHBoxLayout(widget); - imgList = new DImagesList(widget); - settingsScrollArea = new QScrollArea(widget); - settingsBox = new QWidget(settingsScrollArea); - settingsBoxLayout = new QVBoxLayout(settingsBox); - headerLbl = new QLabel(widget); - accountBox = new QGroupBox(i18n("Account"), settingsBox); - accountBoxLayout = new QGridLayout(accountBox); - userNameDisplayLbl = new QLabel(accountBox); - changeUserBtn = new QPushButton(accountBox); - albBox = new QGroupBox(i18n("Album"), settingsBox); - albumsBoxLayout = new QGridLayout(albBox); - albumsCoB = new QComboBox(albBox); - newAlbumBtn = new QPushButton(accountBox); - reloadAlbumsBtn = new QPushButton(accountBox); - sizeBox = new QGroupBox(i18n("Max Dimension"), settingsBox); - sizeBoxLayout = new QVBoxLayout(sizeBox); - dlDimensionCoB = new QComboBox(sizeBox); - uploadBox = new QGroupBox(i18n("Destination"), settingsBox); - uploadWidget = iface->uploadWidget(uploadBox); - uploadBoxLayout = new QVBoxLayout(uploadBox); - optionsBox = new QGroupBox(i18n("Options"), settingsBox); - optionsBoxLayout = new QGridLayout(optionsBox); - originalChB = new QCheckBox(optionsBox); - resizeChB = new QCheckBox(optionsBox); - dimensionSpB = new QSpinBox(optionsBox); - imageQualitySpB = new QSpinBox(optionsBox); - progressBar = new DProgressWdg(settingsBox); + explicit Private(DInfoInterface* const interface, const QString& name) + : imgList(0), + uploadWidget(0), + toolName(name), + headerLbl(0), + userNameDisplayLbl(0), + changeUserBtn(0), + dlDimensionCoB(0), + settingsScrollArea(0), + albumsCoB(0), + newAlbumBtn(0), + reloadAlbumsBtn(0), + originalChB(0), + resizeChB(0), + dimensionSpB(0), + imageQualitySpB(0), + mainLayout(0), + settingsBox(0), + settingsBoxLayout(0), + albBox(0), + albumsBoxLayout(0), + optionsBox(0), + optionsBoxLayout(0), + uploadBox(0), + uploadBoxLayout(0), + sizeBox(0), + sizeBoxLayout(0), + accountBox(0), + accountBoxLayout(0), + iface(interface), + progressBar(0) + { } - + DImagesList* imgList; QWidget* uploadWidget; QString toolName; @@ -134,10 +132,39 @@ DInfoInterface* const iface, const QString& toolName) : QWidget(parent), - d(new Private(this, iface, toolName)) + d(new Private(iface, toolName)) { setObjectName(d->toolName + QString::fromLatin1(" Widget")); + d->mainLayout = new QHBoxLayout(this); + d->imgList = new DImagesList(this); + d->settingsScrollArea = new QScrollArea(this); + d->settingsBox = new QWidget(d->settingsScrollArea); + d->settingsBoxLayout = new QVBoxLayout(d->settingsBox); + d->headerLbl = new QLabel(this); + d->accountBox = new QGroupBox(i18n("Account"), d->settingsBox); + d->accountBoxLayout = new QGridLayout(d->accountBox); + d->userNameDisplayLbl = new QLabel(d->accountBox); + d->changeUserBtn = new QPushButton(d->accountBox); + d->albBox = new QGroupBox(i18n("Album"), d->settingsBox); + d->albumsBoxLayout = new QGridLayout(d->albBox); + d->albumsCoB = new QComboBox(d->albBox); + d->newAlbumBtn = new QPushButton(d->accountBox); + d->reloadAlbumsBtn = new QPushButton(d->accountBox); + d->sizeBox = new QGroupBox(i18n("Max Dimension"), d->settingsBox); + d->sizeBoxLayout = new QVBoxLayout(d->sizeBox); + d->dlDimensionCoB = new QComboBox(d->sizeBox); + d->uploadBox = new QGroupBox(i18n("Destination"), d->settingsBox); + d->uploadWidget = iface->uploadWidget(d->uploadBox); + d->uploadBoxLayout = new QVBoxLayout(d->uploadBox); + d->optionsBox = new QGroupBox(i18n("Options"), d->settingsBox); + d->optionsBoxLayout = new QGridLayout(d->optionsBox); + d->originalChB = new QCheckBox(d->optionsBox); + d->resizeChB = new QCheckBox(d->optionsBox); + d->dimensionSpB = new QSpinBox(d->optionsBox); + d->imageQualitySpB = new QSpinBox(d->optionsBox); + d->progressBar = new DProgressWdg(d->settingsBox); + //---------------------------------------------------------- const int spacing = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); diff --git a/core/utilities/assistants/webservices/yandexfotki/yfrsa.cpp b/core/utilities/assistants/webservices/yandexfotki/yfrsa.cpp --- a/core/utilities/assistants/webservices/yandexfotki/yfrsa.cpp +++ b/core/utilities/assistants/webservices/yandexfotki/yfrsa.cpp @@ -701,21 +701,28 @@ class monty // class for montgomery modular exponentiation { - vlong R,R1,m,n1; - vlong T,k; // work registers - unsigned N; // bits for R - void mul( vlong& x, const vlong& y ); + public: + + explicit monty( const vlong& M ); vlong exp( const vlong& x, const vlong& e ); - monty( const vlong& M ); + +private: + + vlong R, R1, m, n1; + vlong T, k; // work registers + unsigned N; // bits for R + +private: + + void mul( vlong& x, const vlong& y ); }; monty::monty( const vlong& M ) + : R(1), + m(M), + N(0) { - m = M; - N = 0; - R = 1; - while ( R < M ) { R += R; diff --git a/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.h b/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.h --- a/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.h +++ b/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.h @@ -66,13 +66,14 @@ class GPSLinkItemSelectionModelPrivate; /** - Makes it possible to share a selection in multiple views which do not have the same source model - - Although multiple views can share the same QItemSelectionModel, the views then need to have the same source model. - - If there is a proxy model between the model and one of the views, or different proxy models in each, this class makes - it possible to share the selection between the views. -*/ + * Makes it possible to share a selection in multiple views which do not have the same source model + * + * Although multiple views can share the same QItemSelectionModel, + * the views then need to have the same source model. + * + * If there is a proxy model between the model and one of the views, or different proxy models in each, this class makes + * it possible to share the selection between the views. + */ class GPSLinkItemSelectionModel : public QItemSelectionModel { Q_OBJECT diff --git a/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.cpp b/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.cpp --- a/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.cpp +++ b/core/utilities/geolocation/editor/items/gpsimagesortproxymodel.cpp @@ -51,7 +51,8 @@ GPSLinkItemSelectionModel* linkItemSelectionModel; }; -GPSImageSortProxyModel::GPSImageSortProxyModel(GPSImageModel* const imageModel, QItemSelectionModel* const sourceSelectionModel) +GPSImageSortProxyModel::GPSImageSortProxyModel(GPSImageModel* const imageModel, + QItemSelectionModel* const sourceSelectionModel) : QSortFilterProxyModel(imageModel), d(new Private()) { @@ -74,7 +75,7 @@ return false; } - const int column = left.column(); + const int column = left.column(); const GPSImageItem* const itemLeft = d->imageModel->itemFromIndex(left); const GPSImageItem* const itemRight = d->imageModel->itemFromIndex(right); @@ -108,12 +109,16 @@ #endif } +public: + Q_DECLARE_PUBLIC(GPSLinkItemSelectionModel) GPSLinkItemSelectionModel* const q_ptr; +public: + bool assertSelectionValid(const QItemSelection& selection) const { - foreach(const QItemSelectionRange& range, selection) + foreach (const QItemSelectionRange& range, selection) { if (!range.isValid()) { @@ -145,6 +150,8 @@ void sourceCurrentChanged(const QModelIndex& current); void slotCurrentChanged(const QModelIndex& current); +public: + QItemSelectionModel* m_linkedItemSelectionModel; bool m_ignoreCurrentChanged; GPSModelIndexProxyMapper* m_indexMapper; @@ -173,6 +180,7 @@ QItemSelectionModel* GPSLinkItemSelectionModel::linkedItemSelectionModel() const { Q_D(const GPSLinkItemSelectionModel); + return d->m_linkedItemSelectionModel; } @@ -211,11 +219,14 @@ void GPSLinkItemSelectionModel::select(const QModelIndex& index, QItemSelectionModel::SelectionFlags command) { Q_D(GPSLinkItemSelectionModel); + // When an item is removed, the current index is set to the top index in the model. // That causes a selectionChanged signal with a selection which we do not want. - if (d->m_ignoreCurrentChanged) { + if (d->m_ignoreCurrentChanged) + { return; } + // Do *not* replace next line with: QItemSelectionModel::select(index, command) // // Doing so would end up calling GPSLinkItemSelectionModel::select(QItemSelection, QItemSelectionModel::SelectionFlags) @@ -246,14 +257,14 @@ void GPSLinkItemSelectionModel::select(const QItemSelection& selection, QItemSelectionModel::SelectionFlags command) { Q_D(GPSLinkItemSelectionModel); - d->m_ignoreCurrentChanged = true; - QItemSelection _selection = selection; + d->m_ignoreCurrentChanged = true; + QItemSelection _selection = selection; QItemSelectionModel::select(_selection, command); Q_ASSERT(d->assertSelectionValid(_selection)); QItemSelection mappedSelection = d->m_indexMapper->mapSelectionLeftToRight(_selection); Q_ASSERT(d->assertSelectionValid(mappedSelection)); d->m_linkedItemSelectionModel->select(mappedSelection, command); - d->m_ignoreCurrentChanged = false; + d->m_ignoreCurrentChanged = false; } void GPSLinkItemSelectionModelPrivate::slotCurrentChanged(const QModelIndex& current) @@ -271,8 +282,8 @@ void GPSLinkItemSelectionModelPrivate::sourceSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { Q_Q(GPSLinkItemSelectionModel); - QItemSelection _selected = selected; - QItemSelection _deselected = deselected; + QItemSelection _selected = selected; + QItemSelection _deselected = deselected; Q_ASSERT(assertSelectionValid(_selected)); Q_ASSERT(assertSelectionValid(_deselected)); const QItemSelection mappedDeselection = m_indexMapper->mapSelectionRightToLeft(_deselected); @@ -299,9 +310,11 @@ class GPSModelIndexProxyMapperPrivate { - GPSModelIndexProxyMapperPrivate(const QAbstractItemModel* const leftModel, - const QAbstractItemModel* const rightModel, - GPSModelIndexProxyMapper* const qq) +public: + + explicit GPSModelIndexProxyMapperPrivate(const QAbstractItemModel* const leftModel, + const QAbstractItemModel* const rightModel, + GPSModelIndexProxyMapper* const qq) : q_ptr(qq), m_leftModel(leftModel), m_rightModel(rightModel), @@ -314,6 +327,7 @@ void checkConnected(); void setConnected(bool connected); + // cppcheck-suppress unusedPrivateFunction bool assertSelectionValid(const QItemSelection& selection) const { foreach(const QItemSelectionRange& range, selection) @@ -329,6 +343,8 @@ return true; } +public: + Q_DECLARE_PUBLIC(GPSModelIndexProxyMapper) GPSModelIndexProxyMapper* const q_ptr; @@ -350,19 +366,19 @@ */ void GPSModelIndexProxyMapperPrivate::createProxyChain() { - foreach(auto p, m_proxyChainUp) + foreach (auto p, m_proxyChainUp) { p->disconnect(q_ptr); } - foreach(auto p, m_proxyChainDown) + foreach (auto p, m_proxyChainDown) { p->disconnect(q_ptr); } m_proxyChainUp.clear(); m_proxyChainDown.clear(); - QPointer targetModel = m_rightModel; + QPointer targetModel = m_rightModel; QList > proxyChainDown; QPointer selectionTargetProxyModel = qobject_cast(targetModel); @@ -372,7 +388,11 @@ proxyChainDown.prepend(selectionTargetProxyModel); QObject::connect(selectionTargetProxyModel.data(), &QAbstractProxyModel::sourceModelChanged, - q_ptr, [this]{ createProxyChain(); } ); + q_ptr, [this] + { + createProxyChain(); + } + ); selectionTargetProxyModel = qobject_cast(selectionTargetProxyModel->sourceModel()); @@ -390,8 +410,14 @@ while (sourceProxyModel) { m_proxyChainUp.append(sourceProxyModel); + QObject::connect(sourceProxyModel.data(), &QAbstractProxyModel::sourceModelChanged, - q_ptr, [this]{ createProxyChain(); } ); + q_ptr, [this] + { + createProxyChain(); + + } + ); sourceProxyModel = qobject_cast(sourceProxyModel->sourceModel()); const int targetIndex = proxyChainDown.indexOf(sourceProxyModel); diff --git a/core/utilities/geolocation/editor/kmlexport/geodatacontainer.h b/core/utilities/geolocation/editor/kmlexport/geodatacontainer.h --- a/core/utilities/geolocation/editor/kmlexport/geodatacontainer.h +++ b/core/utilities/geolocation/editor/kmlexport/geodatacontainer.h @@ -41,8 +41,10 @@ { }; - GeoDataContainer(double altitude, double latitude, - double longitude, bool interpolated) + GeoDataContainer(double altitude, + double latitude, + double longitude, + bool interpolated) : m_interpolated(interpolated), m_altitude(altitude), m_latitude(latitude), @@ -60,15 +62,16 @@ m_altitude = data.altitude(); m_latitude = data.latitude(); m_longitude = data.longitude(); + return *this; }; // use this instead of '==', because '==' implies having the // same value for m_interpolated bool sameCoordinatesAs(const GeoDataContainer& a) const { - return ( a.m_altitude == m_altitude ) && - ( a.m_latitude == m_latitude ) && + return ( a.m_altitude == m_altitude ) && + ( a.m_latitude == m_latitude ) && ( a.m_longitude == m_longitude); } @@ -116,9 +119,8 @@ { bool okay = true; double ptLongitude = 0.0; - double ptLatitude = 0.0; double ptAltitude = 0.0; - ptLatitude = parts[0].toDouble(&okay); + double ptLatitude = parts[0].toDouble(&okay); if (okay) ptLongitude = parts[1].toDouble(&okay); diff --git a/core/utilities/geolocation/editor/reversegeocoding/rgtagmodel.cpp b/core/utilities/geolocation/editor/reversegeocoding/rgtagmodel.cpp --- a/core/utilities/geolocation/editor/reversegeocoding/rgtagmodel.cpp +++ b/core/utilities/geolocation/editor/reversegeocoding/rgtagmodel.cpp @@ -173,14 +173,16 @@ void checkTree(TreeBranch* const checkBranch, int level) { if (!checkBranch->sourceIndex.isValid()) + { return; + } - for (int j = 0; j < checkBranch->oldChildren.count(); ++j) + for (int j = 0 ; j < checkBranch->oldChildren.count() ; ++j) { checkTree(checkBranch->oldChildren[j], level+1); } - for (int j = 0; j < checkBranch->spacerChildren.count(); ++j) + for (int j = 0 ; j < checkBranch->spacerChildren.count() ; ++j) { checkTree(checkBranch->spacerChildren[j], level+1); } @@ -193,7 +195,9 @@ QModelIndex RGTagModel::fromSourceIndex(const QModelIndex& externalTagModelIndex) const { if (!externalTagModelIndex.isValid()) + { return QModelIndex(); + } Q_ASSERT(externalTagModelIndex.model()==d->tagModel); @@ -219,7 +223,7 @@ int where = -1; - for (int i = 0; i < subModelBranch->oldChildren.count(); ++i) + for (int i = 0 ; i < subModelBranch->oldChildren.count() ; ++i) { if (subModelBranch->oldChildren[i]->sourceIndex == parents[level]) { @@ -235,7 +239,9 @@ else { if (level>=parents.count()) + { return QModelIndex(); + } //TODO: check when rows are different TreeBranch* const newTreeBranch = new TreeBranch(); @@ -262,14 +268,18 @@ QModelIndex RGTagModel::toSourceIndex(const QModelIndex& tagModelIndex) const { if (!tagModelIndex.isValid()) + { return QModelIndex(); + } - Q_ASSERT(tagModelIndex.model()==this); + Q_ASSERT(tagModelIndex.model() == this); TreeBranch* const treeBranch = branchFromIndex(tagModelIndex); //static_cast(tagModelIndex.internalPointer()); if (!treeBranch) + { return QModelIndex(); + } return treeBranch->sourceIndex; } @@ -288,7 +298,7 @@ if (!parentBranch->spacerChildren.isEmpty()) { - for ( int i = 0; i < parentBranch->spacerChildren.count(); ++i) + for ( int i = 0 ; i < parentBranch->spacerChildren.count() ; ++i) { if (parentBranch->spacerChildren[i]->data == spacerName) { @@ -324,7 +334,7 @@ if (!parentBranch->newChildren.isEmpty()) { - for ( int i = 0; i < parentBranch->newChildren.count(); ++i) + for ( int i = 0 ; i < parentBranch->newChildren.count() ; ++i) { if (parentBranch->newChildren[i]->data == newTagName) { @@ -359,7 +369,7 @@ { QList tagAddress; - for (int i = 0; i < d->auxTagList.count(); ++i) + for (int i = 0 ; i < d->auxTagList.count() ; ++i) { TagData tagData; tagData.tagName = d->auxTagList[i]; @@ -378,9 +388,12 @@ * @param addressElements A list containing address elements. Example: {Country}, {City}... * @param elementsData A list containing the name of each address element found in elements. Example: France, Paris... */ -void RGTagModel::addDataInTree(TreeBranch* currentBranch, int currentRow,const QStringList& addressElements,const QStringList& elementsData) +void RGTagModel::addDataInTree(TreeBranch* currentBranch, + int currentRow, + const QStringList& addressElements, + const QStringList& elementsData) { - for (int i=0; ispacerChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->spacerChildren.count() ; ++i) { bool newDataAdded = false; @@ -395,7 +408,7 @@ } else { - for (int j = 0; j < addressElements.count(); ++j) + for (int j = 0 ; j < addressElements.count() ; ++j) { if (currentBranch->spacerChildren[i]->data == addressElements[j]) { @@ -413,7 +426,7 @@ if ((currentBranch->type != TypeSpacer) || ((currentBranch->type == TypeSpacer) && (currentBranch->data.indexOf(QString::fromLatin1("{")) != 0)) || - (d->auxIndexList.isEmpty())) + (d->auxIndexList.isEmpty())) { auxIndex = addNewTag(currentIndex, elementsData[j]); } @@ -444,20 +457,23 @@ } } - for (int i = 0; i < currentBranch->newChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->newChildren.count() ; ++i) { d->auxTagList.append(currentBranch->newChildren[i]->data); d->auxTagTypeList.append(TypeNewChild); addDataInTree(currentBranch->newChildren.at(i),i+currentBranch->spacerChildren.count(), addressElements, elementsData); d->auxTagList.removeLast(); d->auxTagTypeList.removeLast(); } - for (int i = 0; i < currentBranch->oldChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->oldChildren.count() ; ++i) { d->auxTagList.append(currentBranch->oldChildren.at(i)->data); d->auxTagTypeList.append(TypeChild); - addDataInTree(currentBranch->oldChildren.at(i),i+currentBranch->spacerChildren.count()+currentBranch->newChildren.count(), addressElements, elementsData); + addDataInTree(currentBranch->oldChildren.at(i), + i + currentBranch->spacerChildren.count() + currentBranch->newChildren.count(), + addressElements, + elementsData); d->auxTagList.removeLast(); d->auxTagTypeList.removeLast(); } @@ -506,7 +522,9 @@ QVariant RGTagModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) + { return QVariant(); + } TreeBranch* const treeBranch = branchFromIndex(index); //static_cast(index.internalPointer()); @@ -536,16 +554,20 @@ QModelIndex RGTagModel::index(int row, int column, const QModelIndex& parent) const { - if ( (column!=0) || (row<0) ) + if ( (column != 0) || (row < 0) ) + { return QModelIndex(); + } TreeBranch* const parentBranch = branchFromIndex(parent);//d->rootTag; // if (parent.isValid()) // parentBranch = static_cast(parent.internalPointer()); // this should not happen! if (!parentBranch) + { return QModelIndex(); + } if (row < parentBranch->spacerChildren.count()) { @@ -564,23 +586,29 @@ TreeBranch* const currentBranch = branchFromIndex(index); // static_cast(index.internalPointer()); if (!currentBranch) + { return QModelIndex(); - + } + if (currentBranch->type == TypeSpacer || currentBranch->type == TypeNewChild) { TreeBranch* const parentBranch = currentBranch->parent; if (!parentBranch) + { return QModelIndex(); + } TreeBranch* const gParentBranch = parentBranch->parent; if (!gParentBranch) + { return QModelIndex(); + } - if (parentBranch->type==TypeSpacer) + if (parentBranch->type == TypeSpacer) { - for (int parentRow=0; parentRowspacerChildren.count(); ++parentRow) + for (int parentRow = 0 ; parentRow < gParentBranch->spacerChildren.count() ; ++parentRow) { if (gParentBranch->spacerChildren[parentRow] == parentBranch) { @@ -592,22 +620,23 @@ } else if (parentBranch->type == TypeNewChild) { - for (int parentRow=0; parentRownewChildren.count(); ++parentRow) + for (int parentRow = 0 ; parentRow < gParentBranch->newChildren.count() ; ++parentRow) { if (gParentBranch->newChildren[parentRow] == parentBranch) { return createIndex(parentRow+gParentBranch->spacerChildren.count(), 0, parentBranch); } } } - else if (parentBranch->type==TypeChild) + else if (parentBranch->type == TypeChild) { // TODO: don't we have a function for this? - for (int parentRow=0; parentRowoldChildren.count(); ++parentRow) + for (int parentRow = 0 ; parentRow < gParentBranch->oldChildren.count() ; ++parentRow) { if (gParentBranch->oldChildren[parentRow] == parentBranch) { - return createIndex(parentRow+gParentBranch->spacerChildren.count()+gParentBranch->newChildren.count(), 0, parentBranch); + return createIndex(parentRow + gParentBranch->spacerChildren.count() + gParentBranch->newChildren.count(), + 0, parentBranch); } } @@ -624,10 +653,10 @@ int myRowCount = parentBranch->spacerChildren.count() + parentBranch->newChildren.count(); // TODO: we don't know whether the oldChildren have been set up, therefore query the source model - if (parentBranch->type==TypeChild) + if (parentBranch->type == TypeChild) { const QModelIndex sourceIndex = toSourceIndex(parent); - myRowCount += d->tagModel->rowCount(sourceIndex); + myRowCount += d->tagModel->rowCount(sourceIndex); } return myRowCount; @@ -671,7 +700,11 @@ beginInsertColumns(fromSourceIndex(parent), start, end); } -void RGTagModel::slotColumnsAboutToBeMoved(const QModelIndex& sourceParent, int sourceStart, int sourceEnd, const QModelIndex& destinationParent, int destinationColumn) +void RGTagModel::slotColumnsAboutToBeMoved(const QModelIndex& sourceParent, + int sourceStart, + int sourceEnd, + const QModelIndex& destinationParent, + int destinationColumn) { beginMoveColumns(fromSourceIndex(sourceParent), sourceStart, sourceEnd, fromSourceIndex(destinationParent), destinationColumn ); } @@ -717,17 +750,20 @@ endResetModel(); } -void RGTagModel::slotRowsAboutToBeInserted(const QModelIndex& parent, int start, int end ) +void RGTagModel::slotRowsAboutToBeInserted(const QModelIndex& parent, int start, int end) { TreeBranch* const parentBranch = parent.isValid() ? static_cast(fromSourceIndex(parent).internalPointer()) : d->rootTag; d->parent = fromSourceIndex(parent); d->startInsert = start; d->endInsert = end; - beginInsertRows(d->parent, start+parentBranch->newChildren.count()+parentBranch->spacerChildren.count(), end+parentBranch->newChildren.count()+parentBranch->spacerChildren.count()); + beginInsertRows(d->parent, + start + parentBranch->newChildren.count() + parentBranch->spacerChildren.count(), + end + parentBranch->newChildren.count() + parentBranch->spacerChildren.count()); } -void RGTagModel::slotRowsAboutToBeMoved(const QModelIndex& sourceParent, int sourceStart, int sourceEnd, const QModelIndex& destinationParent, int destinationRow) +void RGTagModel::slotRowsAboutToBeMoved(const QModelIndex& sourceParent, int sourceStart, int sourceEnd, + const QModelIndex& destinationParent, int destinationRow) { beginMoveRows(fromSourceIndex(sourceParent), sourceStart, sourceEnd, fromSourceIndex(destinationParent), destinationRow ); } @@ -743,12 +779,12 @@ { TreeBranch* const parentBranch = d->parent.isValid() ? static_cast(d->parent.internalPointer()) : d->rootTag; - for (int i = d->startInsert; i < d->endInsert; ++i) + for (int i = d->startInsert ; i < d->endInsert ; ++i) { TreeBranch* const newBranch = new TreeBranch(); - newBranch->parent = parentBranch; - newBranch->sourceIndex = d->tagModel->index(i, 0, d->parent); - newBranch->type = TypeChild; + newBranch->parent = parentBranch; + newBranch->sourceIndex = d->tagModel->index(i, 0, d->parent); + newBranch->type = TypeChild; parentBranch->oldChildren.insert(i, newBranch); } @@ -776,21 +812,26 @@ void RGTagModel::deleteTag(const QModelIndex& currentIndex) { if (!currentIndex.isValid()) + { return; + } QModelIndex parentIndex = currentIndex.parent(); int currentRow = currentIndex.row(); TreeBranch* const parentBranch = branchFromIndex(parentIndex); TreeBranch* const currentChildBranch = branchFromIndex(currentIndex); if (currentChildBranch->type == TypeChild) + { return; + } if (currentChildBranch->spacerChildren.count() > 0 || currentChildBranch->newChildren.count() > 0) { - beginMoveRows(currentIndex,0,currentChildBranch->spacerChildren.count()-1,parentIndex, parentBranch->spacerChildren.count()); + beginMoveRows(currentIndex, 0, currentChildBranch->spacerChildren.count() - 1, + parentIndex, parentBranch->spacerChildren.count()); - for (int j = 0; j < currentChildBranch->spacerChildren.count(); ++j) + for (int j = 0 ; j < currentChildBranch->spacerChildren.count() ; ++j) { parentBranch->spacerChildren.append(currentChildBranch->spacerChildren[j]); parentBranch->spacerChildren.last()->parent = parentBranch; @@ -800,12 +841,13 @@ currentChildBranch->spacerChildren.clear(); endMoveRows(); - beginMoveRows(currentIndex, currentChildBranch->spacerChildren.count(), currentChildBranch->spacerChildren.count()+currentChildBranch->newChildren.count()-1, - parentIndex, parentBranch->spacerChildren.count()+parentBranch->newChildren.count()); + beginMoveRows(currentIndex, currentChildBranch->spacerChildren.count(), + currentChildBranch->spacerChildren.count() + currentChildBranch->newChildren.count() - 1, + parentIndex, parentBranch->spacerChildren.count() + parentBranch->newChildren.count()); for (int j = currentChildBranch->spacerChildren.count(); j < currentChildBranch->spacerChildren.count()+currentChildBranch->newChildren.count(); ++j) { - parentBranch->newChildren.append(currentChildBranch->newChildren[j-currentChildBranch->spacerChildren.count()]); + parentBranch->newChildren.append(currentChildBranch->newChildren[j - currentChildBranch->spacerChildren.count()]); parentBranch->newChildren.last()->parent = parentBranch; } @@ -820,7 +862,7 @@ { parentBranch->spacerChildren.removeAt(currentRow); } - else if (currentRow >= parentBranch->spacerChildren.count()) + else { parentBranch->newChildren.removeAt(currentRow - parentBranch->spacerChildren.count()); } @@ -838,7 +880,7 @@ { /*QModelIndex currentIndex = */createIndex(currentRow, 0, currentBranch); - for (int i = 0; i < currentBranch->spacerChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->spacerChildren.count() ; ++i) { findAndDeleteSpacersOrNewTags(currentBranch->spacerChildren[i], i, whatShouldRemove); @@ -850,7 +892,7 @@ } } - for (int i = 0; i < currentBranch->newChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->newChildren.count() ; ++i) { findAndDeleteSpacersOrNewTags(currentBranch->newChildren[i], i+currentBranch->spacerChildren.count(), whatShouldRemove); @@ -862,9 +904,11 @@ } } - for (int i = 0; i < currentBranch->oldChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->oldChildren.count() ; ++i) { - findAndDeleteSpacersOrNewTags(currentBranch->oldChildren[i], i+currentBranch->spacerChildren.count()+currentBranch->newChildren.count(), whatShouldRemove); + findAndDeleteSpacersOrNewTags(currentBranch->oldChildren[i], + i + currentBranch->spacerChildren.count() + currentBranch->newChildren.count(), + whatShouldRemove); } } @@ -882,7 +926,7 @@ } else if (whatShouldRemove == TypeNewChild) { - findAndDeleteSpacersOrNewTags(d->rootTag,0, whatShouldRemove); + findAndDeleteSpacersOrNewTags(d->rootTag, 0, whatShouldRemove); } } @@ -903,11 +947,13 @@ int foundIndex; if (currentAddressElementIndex >= tagAddressElements.count()) + { return; + } if (tagAddressElements[currentAddressElementIndex].tagType == TypeSpacer) { - for (int i = 0; i < currentBranch->spacerChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->spacerChildren.count() ; ++i) { if (currentBranch->spacerChildren[i]->data == tagAddressElements[currentAddressElementIndex].tagName) { @@ -947,19 +993,22 @@ } else if (tagAddressElements[currentAddressElementIndex].tagType == TypeNewChild) { - for (int i = 0; i < currentBranch->newChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->newChildren.count() ; ++i) { if (currentBranch->newChildren[i]->data == tagAddressElements[currentAddressElementIndex].tagName) { - found = true; + found = true; foundIndex = i; break; } } if (found) { - readdTag(currentBranch->newChildren[foundIndex], foundIndex+currentBranch->spacerChildren.count(),tagAddressElements, currentAddressElementIndex+1); + readdTag(currentBranch->newChildren[foundIndex], + foundIndex + currentBranch->spacerChildren.count(), + tagAddressElements, + currentAddressElementIndex + 1); return; } @@ -978,24 +1027,24 @@ addNewTag(currentIndex, tagAddressElements[currentAddressElementIndex].tagName); - if ( (tagAddressElements.count()-1) > currentAddressElementIndex) + if ((tagAddressElements.count() - 1) > currentAddressElementIndex) { - readdTag(currentBranch->newChildren[currentBranch->newChildren.count()-1], - currentBranch->spacerChildren.count()+currentBranch->newChildren.count()-1, + readdTag(currentBranch->newChildren[currentBranch->newChildren.count() - 1], + currentBranch->spacerChildren.count() + currentBranch->newChildren.count() - 1, tagAddressElements, - currentAddressElementIndex+1); + currentAddressElementIndex + 1); } } } else if (tagAddressElements[currentAddressElementIndex].tagType == TypeChild) { bool found = false; - for (int i = 0; i < currentBranch->oldChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->oldChildren.count() ; ++i) { if (currentBranch->oldChildren[i]->data == tagAddressElements[currentAddressElementIndex].tagName) { - found = true; + found = true; foundIndex = i; break; } @@ -1034,7 +1083,7 @@ */ void RGTagModel::readdNewTags(const QList >& tagAddressList) { - for (int i = 0; i < tagAddressList.count(); ++i) + for (int i = 0 ; i < tagAddressList.count() ; ++i) { QList currentAddressTag = tagAddressList[i]; readdTag(d->rootTag, 0, currentAddressTag, 0); @@ -1069,20 +1118,20 @@ */ void RGTagModel::climbTreeAndGetSpacers(const TreeBranch* currentBranch) { - for (int i = 0; i < currentBranch->spacerChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->spacerChildren.count() ; ++i) { QList currentSpacerAddress; currentSpacerAddress = getSpacerAddress(currentBranch->spacerChildren[i]); d->savedSpacerList.append(currentSpacerAddress); climbTreeAndGetSpacers(currentBranch->spacerChildren[i]); } - for (int i = 0; i < currentBranch->newChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->newChildren.count() ; ++i) { climbTreeAndGetSpacers(currentBranch->newChildren[i]); } - for (int i = 0; i < currentBranch->oldChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->oldChildren.count() ; ++i) { climbTreeAndGetSpacers(currentBranch->oldChildren[i]); } @@ -1110,7 +1159,7 @@ QModelIndex parentIndex = createIndex(currentRow, 0, parentBranch); const int howManyRows = rowCount(parentIndex); - for (int i = 0; i < howManyRows; ++i) + for (int i = 0 ; i < howManyRows ; ++i) { QModelIndex currentIndex = index(i,0,parentIndex); TreeBranch* const currentBranch = branchFromIndex(currentIndex); //currentIndex.isValid() ? static_cast(currentIndex.internalPointer()) : d->rootTag; @@ -1140,7 +1189,7 @@ TreeBranch* const currentBranch = branchFromIndex(currentIndex); //currentIndex.isValid() ? static_cast(currentIndex.internalPointer()) : d->rootTag; - for (int i = 0; i < currentBranch->spacerChildren.count(); ++i) + for (int i = 0 ; i < currentBranch->spacerChildren.count() ; ++i) { if (currentBranch->data == spacerList[spacerListIndex]) { @@ -1151,8 +1200,9 @@ } addSpacerTag(currentIndex, spacerList[spacerListIndex]); - QModelIndex newIndex = createIndex(currentBranch->spacerChildren.count()-1, 0, currentBranch->spacerChildren[currentBranch->spacerChildren.count()-1]); - addAllSpacersToTag(newIndex, spacerList, spacerListIndex+1); + QModelIndex newIndex = createIndex(currentBranch->spacerChildren.count() - 1, 0, + currentBranch->spacerChildren[currentBranch->spacerChildren.count() - 1]); + addAllSpacersToTag(newIndex, spacerList, spacerListIndex + 1); } /** diff --git a/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.h b/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.h --- a/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.h +++ b/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.h @@ -73,7 +73,7 @@ public: - BlackFrameListViewItem(BlackFrameListView* const parent, const QUrl& url); + explicit BlackFrameListViewItem(BlackFrameListView* const parent, const QUrl& url); ~BlackFrameListViewItem() {}; Q_SIGNALS: diff --git a/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.cpp b/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.cpp --- a/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.cpp +++ b/core/utilities/imageeditor/tools/enhance/hotpixels/blackframelistview.cpp @@ -83,7 +83,7 @@ void BlackFrameListViewItem::activate() { - m_parent->setToolTip( m_blackFrameDesc); + m_parent->setToolTip(m_blackFrameDesc); emit signalParsed(m_hotPixels, m_blackFrameURL); } @@ -131,7 +131,7 @@ //Draw hot pixels one by one QList::const_iterator it; - for (it = m_hotPixels.constBegin(); it != m_hotPixels.constEnd(); ++it) + for (it = m_hotPixels.constBegin() ; it != m_hotPixels.constEnd() ; ++it) { hpRect = (*it).rect; hpThumbX = (hpRect.x() + hpRect.width() / 2) * xRatio; diff --git a/core/utilities/imageeditor/tools/enhance/hotpixels/blackframeparser.cpp b/core/utilities/imageeditor/tools/enhance/hotpixels/blackframeparser.cpp --- a/core/utilities/imageeditor/tools/enhance/hotpixels/blackframeparser.cpp +++ b/core/utilities/imageeditor/tools/enhance/hotpixels/blackframeparser.cpp @@ -137,20 +137,20 @@ // Find maximum component value. int maxValue; - int threshold = DENOM/10; + int threshold = DENOM / 10; const int threshold_value = REL_TO_ABS(threshold,255); - maxValue = (color.red()>color.blue()) ? color.red() : color.blue(); + maxValue = (color.red()>color.blue()) ? color.red() : color.blue(); - if (color.green()>maxValue) + if (color.green() > maxValue) { maxValue = color.green(); } // If the component is bigger than the threshold, add the point if (maxValue > threshold_value) { HotPixel point; - point.rect = QRect (x, y, 1, 1); + point.rect = QRect (x, y, 1, 1); //TODO:check this point.luminosity = ((2 * DENOM) / 255 ) * maxValue / 2; @@ -192,7 +192,7 @@ HotPixel point; HotPixel point_below; - for (; it != list.end(); ++it ) + for ( ; it != list.end() ; ++it ) { while (1) { diff --git a/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.h b/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.h --- a/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.h +++ b/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.h @@ -42,7 +42,7 @@ namespace Digikam { -class HotPixelFixer : public Digikam::DImgThreadedFilter +class HotPixelFixer : public DImgThreadedFilter { public: @@ -65,7 +65,7 @@ public: explicit HotPixelFixer(QObject* const parent = 0); - explicit HotPixelFixer(Digikam::DImg* const orgImage, QObject* const parent, + explicit HotPixelFixer(DImg* const orgImage, QObject* const parent, const QList& hpList, int interpolationMethod); ~HotPixelFixer(); @@ -89,7 +89,7 @@ return 1; } - void readParameters(const Digikam::FilterAction& action); + void readParameters(const FilterAction& action); virtual QString filterIdentifier() const { @@ -102,13 +102,13 @@ virtual void filterImage(); - void interpolate(Digikam::DImg& img,HotPixel& hp, int method); - void weightPixels(Digikam::DImg& img, HotPixel& px, int method, + void interpolate(DImg& img,HotPixel& hp, int method); + void weightPixels(DImg& img, HotPixel& px, int method, Direction dir, int maxComponent); - inline bool validPoint(Digikam::DImg& img, const QPoint& p) + inline bool validPoint(DImg& img, const QPoint& p) { - return (p.x()>=0 && p.y()>=0 && p.x()<(long) img.width() && p.y()<(long) img.height()); + return (p.x() >= 0 && p.y() >= 0 && p.x() < (long) img.width() && p.y() < (long) img.height()); }; QList mWeightList; diff --git a/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.cpp b/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.cpp --- a/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.cpp +++ b/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelfixer.cpp @@ -41,16 +41,17 @@ #include "dimg.h" #ifdef HAVE_FLOAT_H -#if HAVE_FLOAT_H -# include -#endif +# if HAVE_FLOAT_H +# include +# endif #endif #ifndef DBL_MIN -# define DBL_MIN 1e-37 +# define DBL_MIN 1e-37 #endif + #ifndef DBL_MAX -# define DBL_MAX 1e37 +# define DBL_MAX 1e37 #endif namespace Digikam @@ -63,9 +64,9 @@ initFilter(); } -HotPixelFixer::HotPixelFixer(Digikam::DImg* const orgImage, QObject* const parent, const QList& hpList, +HotPixelFixer::HotPixelFixer(DImg* const orgImage, QObject* const parent, const QList& hpList, int interpolationMethod) - : Digikam::DImgThreadedFilter(orgImage, parent, QLatin1String("HotPixels")) + : DImgThreadedFilter(orgImage, parent, QLatin1String("HotPixels")) { m_hpList = hpList; m_interpolationMethod = interpolationMethod; @@ -94,7 +95,7 @@ return action; } -void HotPixelFixer::readParameters(const Digikam::FilterAction& action) +void HotPixelFixer::readParameters(const FilterAction& action) { m_interpolationMethod = action.parameter(QLatin1String("interpolationMethod")).toInt(); QRegExp exp(QLatin1String("(\\d+)-(\\d+)x(\\d+)-(\\d+)x(\\d+)")); @@ -127,7 +128,7 @@ } // Interpolates a pixel block -void HotPixelFixer::interpolate(Digikam::DImg& img, HotPixel& hp, int method) +void HotPixelFixer::interpolate(DImg& img, HotPixel& hp, int method) { const int xPos = hp.x(); const int yPos = hp.y(); @@ -146,43 +147,43 @@ int sum_weight = 0; double vr = 0.0, vg = 0.0, vb = 0.0; int x, y; - Digikam::DColor col; + DColor col; - for (x = xPos; x < xPos+hp.width(); ++x) + for (x = xPos ; x < xPos+hp.width() ; ++x) { - if (validPoint(img,QPoint(x,yPos-1))) + if (validPoint(img,QPoint(x, yPos - 1))) { - col=img.getPixelColor(x,yPos-1); + col = img.getPixelColor(x, yPos - 1); vr += col.red(); vg += col.green(); vb += col.blue(); ++sum_weight; } - if (validPoint(img,QPoint(x,yPos+hp.height()))) + if (validPoint(img,QPoint(x, yPos + hp.height()))) { - col=img.getPixelColor(x,yPos+hp.height()); + col = img.getPixelColor(x, yPos + hp.height()); vr += col.red(); vg += col.green(); vb += col.blue(); ++sum_weight; } } - for (y = yPos; y < hp.height(); ++y) + for (y = yPos ; y < hp.height() ; ++y) { - if (validPoint(img,QPoint(xPos-1,y))) + if (validPoint(img, QPoint(xPos - 1, y))) { - col=img.getPixelColor(xPos,y); + col = img.getPixelColor(xPos, y); vr += col.red(); vg += col.green(); vb += col.blue(); ++sum_weight; } - if (validPoint(img,QPoint(xPos+hp.width(),y))) + if (validPoint(img, QPoint(xPos + hp.width(), y))) { - col=img.getPixelColor(xPos+hp.width(),y); + col = img.getPixelColor(xPos + hp.width(), y); vr += col.red(); vg += col.green(); vb += col.blue(); @@ -196,15 +197,17 @@ vg /= (double)sum_weight; vb /= (double)sum_weight; - for (x = 0; x < hp.width(); ++x) + for (x = 0 ; x < hp.width() ; ++x) { - for (y = 0; y < hp.height(); ++y) + for (y = 0 ; y < hp.height() ; ++y) { - if (validPoint(img,QPoint(xPos+x,yPos+y))) + if (validPoint(img, QPoint(xPos + x, yPos + y))) { int alpha = sixtBits ? 65535 : 255; - int ir = (int )round(vr), ig = (int) round(vg), ib = (int) round(vb); - img.setPixelColor(xPos+x,yPos+y,Digikam::DColor(ir,ig,ib,alpha,sixtBits)); + int ir = (int)round(vr); + int ig = (int)round(vg); + int ib = (int)round(vb); + img.setPixelColor(xPos + x, yPos + y, DColor(ir, ig, ib, alpha, sixtBits)); } } } @@ -227,16 +230,16 @@ } } -void HotPixelFixer::weightPixels(Digikam::DImg& img, HotPixel& px, int method, Direction dir, int maxComponent) +void HotPixelFixer::weightPixels(DImg& img, HotPixel& px, int method, Direction dir, int maxComponent) { //TODO: implement direction here too - for (int iComp = 0; iComp < 3; ++iComp) + for (int iComp = 0 ; iComp < 3 ; ++iComp) { // Obtain weight data block. Weights w; - int polynomeOrder=-1; + int polynomeOrder = -1; switch (method) { @@ -279,46 +282,47 @@ //} // Calculate weighted pixel sum. - for (int y = 0; y= DBL_MIN) { - component=(int) (v/sum_weight); + component = (int) (v / sum_weight); //Clamp value - if (component<0) + if (component < 0) { - component=0; + component = 0; } - if (component>maxComponent) + if (component > maxComponent) { - component=maxComponent; + component = maxComponent; } } else if (v >= 0.0) { - component=maxComponent; + component = maxComponent; } else { - component=0; + component = 0; } - if (iComp==0) + if (iComp == 0) { color.setRed(component); } - else if (iComp==1) + else if (iComp == 1) { color.setGreen(component); } else { color.setBlue(component); } - img.setPixelColor(px.x()+x,px.y()+y,color); + img.setPixelColor(px.x() + x, px.y() + y,color); } } } diff --git a/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelstool.cpp b/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelstool.cpp --- a/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelstool.cpp +++ b/core/utilities/imageeditor/tools/enhance/hotpixels/hotpixelstool.cpp @@ -61,8 +61,8 @@ { public: - explicit Private() : - blackFrameButton(0), + explicit Private() + : blackFrameButton(0), progressBar(0), filterMethodCombo(0), blackFrameListView(0), @@ -94,11 +94,6 @@ // -------------------------------------------------------- -void HotPixelsTool::registerFilter() -{ - Digikam::DImgFilterManager::instance()->addGenerator(new Digikam::BasicDImgFilterGenerator()); -} - HotPixelsTool::HotPixelsTool(QObject* const parent) : EditorToolThreaded(parent), d(new Private) @@ -169,6 +164,11 @@ delete d; } +void HotPixelsTool::registerFilter() +{ + DImgFilterManager::instance()->addGenerator(new BasicDImgFilterGenerator()); +} + void HotPixelsTool::readSettings() { KSharedConfig::Ptr config = KSharedConfig::openConfig(); diff --git a/core/utilities/imageeditor/tools/enhance/hotpixels/weights.cpp b/core/utilities/imageeditor/tools/enhance/hotpixels/weights.cpp --- a/core/utilities/imageeditor/tools/enhance/hotpixels/weights.cpp +++ b/core/utilities/imageeditor/tools/enhance/hotpixels/weights.cpp @@ -35,8 +35,8 @@ namespace Digikam { -Weights::Weights() : - mHeight(0), +Weights::Weights() + : mHeight(0), mWidth(0), mCoefficientNumber(0), mTwoDim(false), @@ -46,8 +46,8 @@ { } -Weights::Weights(const Weights& w) : - mHeight(0), +Weights::Weights(const Weights& w) + : mHeight(0), mWidth(0), mCoefficientNumber(0), mTwoDim(false), @@ -86,17 +86,17 @@ // Allocate mPositions.count() matrices mWeightMatrices = new double** [mPositions.count()]; - for (int i=0 ; i < mPositions.count() ; ++i) + for (int i = 0 ; i < mPositions.count() ; ++i) { // Allocate mHeight rows on each position mWeightMatrices[i] = new double*[mHeight]; - for (uint j=0 ; j < mHeight ; ++j) + for (uint j = 0 ; j < mHeight ; ++j) { // Allocate mWidth columns on each row mWeightMatrices[i][j] = new double[mWidth]; - for (uint k=0 ; k < mWidth ; ++k) + for (uint k = 0 ; k < mWidth ; ++k) { mWeightMatrices[i][j][k] = origMatrices[i][j][k]; } @@ -127,12 +127,12 @@ { for (x = -iPolynomeOrder ; x < iWidth + iPolynomeOrder ; ++x) { - if ((x < 0 && y < 0 && -x - y < iPolynomeOrder + 2) || - (x < 0 && y >= iHeight && -x + y - iHeight < iPolynomeOrder + 1) || - (x >= iWidth && y < 0 && x - y - iWidth < iPolynomeOrder + 1) || - (x >= iWidth && y >= iHeight && x + y - iWidth - iHeight < iPolynomeOrder) || - (x < 0 && y >= 0 && y < iHeight) || (x >= iWidth && y >= 0 && y < iHeight) || - (y < 0 && x >= 0 && x < iWidth ) || (y >= iHeight && x >= 0 && x < iWidth)) + if ((x < 0 && y < 0 && (-x - y < iPolynomeOrder + 2)) || + (x < 0 && y >= iHeight && (-x + y - iHeight < iPolynomeOrder + 1)) || + (x >= iWidth && y < 0 && ( x - y - iWidth < iPolynomeOrder + 1)) || + (x >= iWidth && y >= iHeight && ( x + y - iWidth - iHeight < iPolynomeOrder)) || + (x < 0 && y >= 0 && y < iHeight) || (x >= iWidth && y >= 0 && y < iHeight) || + (y < 0 && x >= 0 && x < iWidth ) || (y >= iHeight && x >= 0 && x < iWidth)) { QPoint position(x,y); mPositions.append(position); @@ -144,15 +144,15 @@ { // In the one-dimensional case, only the y coordinate and y size is used. */ - for (y = (-1)*mPolynomeOrder ; y < 0 ; ++y) + for (y = -mPolynomeOrder ; y < 0 ; ++y) { - QPoint position(0,y); + QPoint position(0, y); mPositions.append(position); } for (y = (int) height() ; y < (int) height() + (int) mPolynomeOrder ; ++y) { - QPoint position(0,y); + QPoint position(0, y); mPositions.append(position); } } diff --git a/core/utilities/imageeditor/widgets/imagebrushguidewidget.cpp b/core/utilities/imageeditor/widgets/imagebrushguidewidget.cpp --- a/core/utilities/imageeditor/widgets/imagebrushguidewidget.cpp +++ b/core/utilities/imageeditor/widgets/imagebrushguidewidget.cpp @@ -24,14 +24,18 @@ #include "imagebrushguidewidget.h" +// Local includes + +#include "digikam_debug.h" + namespace Digikam { void ImageBrushGuideWidget::mouseMoveEvent(QMouseEvent* e) { if ((e->buttons() & Qt::LeftButton) && !srcSet) { - qDebug() << "MOOOOOVE The location is: " << e->x() << ", "<< e->y(); + qCDebug(DIGIKAM_GENERAL_LOG) << "Move The location is: " << e->x() << ", "<< e->y(); QPoint currentDst = QPoint(e->x(), e->y()); diff --git a/core/utilities/maintenance/databasetask.h b/core/utilities/maintenance/databasetask.h --- a/core/utilities/maintenance/databasetask.h +++ b/core/utilities/maintenance/databasetask.h @@ -64,7 +64,6 @@ void computeDatabaseJunk(bool thumbsDb=false, bool facesDb=false, bool similarityDb=false); - Q_SIGNALS: void signalFinished(); diff --git a/core/utilities/maintenance/databasetask.cpp b/core/utilities/maintenance/databasetask.cpp --- a/core/utilities/maintenance/databasetask.cpp +++ b/core/utilities/maintenance/databasetask.cpp @@ -113,6 +113,7 @@ if (d->mode == Mode::ShrinkDatabases) { qCDebug(DIGIKAM_GENERAL_LOG) << "Shrinking databases"; + if (CoreDbAccess().db()->integrityCheck()) { CoreDbAccess().db()->vacuum(); @@ -241,16 +242,16 @@ } else if (d->mode == Mode::ComputeDatabaseJunk) { - QList staleImageIds; - QList staleThumbIds; - QList staleIdentities; - QList staleSimilarityImageIds; + QList staleImageIds; + QList staleThumbIds; + QList staleIdentities; + QList staleSimilarityImageIds; int additionalItemsToProcess = 0; QList coredbItems = CoreDbAccess().db()->getAllItems(); // Get the count of image entries in DB to delete. - staleImageIds = CoreDbAccess().db()->getImageIds(DatabaseItem::Status::Obsolete); + staleImageIds = CoreDbAccess().db()->getImageIds(DatabaseItem::Status::Obsolete); // get the count of items to process for thumbnails cleanup it enabled. if (d->scanThumbsDb && ThumbsDbAccess::isInitialized()) @@ -287,11 +288,11 @@ // OR // The thumbnail is stale, i.e. no thumbs db table references it. - QSet thumbIds = ThumbsDbAccess().db()->findAll().toSet(); + QSet thumbIds = ThumbsDbAccess().db()->findAll().toSet(); FaceTagsEditor editor; - foreach(const qlonglong& item, coredbItems) + foreach (const qlonglong& item, coredbItems) { if (m_cancel) { @@ -304,10 +305,9 @@ { QString hash = CoreDbAccess().db()->getImagesFields(item,DatabaseFields::ImagesField::UniqueHash).first().toString(); qlonglong fileSize = info.fileSize(); - bool removed = false; // Remove the id that is found by the file path. Finding the id -1 does no harm - removed = thumbIds.remove(ThumbsDbAccess().db()->findByFilePath(info.filePath()).id); + bool removed = thumbIds.remove(ThumbsDbAccess().db()->findByFilePath(info.filePath()).id); if (!removed) { @@ -362,7 +362,7 @@ QList properties = CoreDbAccess().db()->getTagProperties(TagPropertyName::faceEngineUuid()); QSet uuidSet; - foreach(TagProperty prop, properties) + foreach (TagProperty prop, properties) { uuidSet << prop.value; } @@ -399,7 +399,7 @@ QSet similarityDbItems = SimilarityDbAccess().db()->registeredImageIds(); // Remove all image ids that are existent in the core db - foreach(const qlonglong& imageId, coredbItems) + foreach (const qlonglong& imageId, coredbItems) { similarityDbItems.remove(imageId); diff --git a/core/utilities/maintenance/dbcleaner.h b/core/utilities/maintenance/dbcleaner.h --- a/core/utilities/maintenance/dbcleaner.h +++ b/core/utilities/maintenance/dbcleaner.h @@ -27,9 +27,7 @@ // Qt includes #include -#include #include -#include #include // Local includes @@ -114,11 +112,8 @@ private: - int active; - DWorkingPixmap progressPix; - QTimer* progressTimer; - int progressIndex; - QListWidget* statusList; + class Private; + Private* const d; }; } // namespace Digikam diff --git a/core/utilities/maintenance/dbcleaner.cpp b/core/utilities/maintenance/dbcleaner.cpp --- a/core/utilities/maintenance/dbcleaner.cpp +++ b/core/utilities/maintenance/dbcleaner.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include // KDE includes @@ -60,11 +62,6 @@ { } - ~Private() - { - delete shrinkDlg; - } - MaintenanceThread* thread; bool cleanThumbsDb; bool cleanFacesDb; @@ -130,6 +127,7 @@ DbCleaner::~DbCleaner() { + delete d->shrinkDlg; delete d; } @@ -443,107 +441,128 @@ //---------------------------------------------------------------------------- +class DbShrinkDialog::Private +{ +public: + + explicit Private() + : active(-1), + progressTimer(0), + progressIndex(1), + statusList(0) + { + } + + int active; + DWorkingPixmap progressPix; + QTimer* progressTimer; + int progressIndex; + QListWidget* statusList; +}; + DbShrinkDialog::DbShrinkDialog(QWidget* const parent) : QDialog(parent), - active(-1), - progressPix(DWorkingPixmap()), - progressTimer(new QTimer(parent)), - progressIndex(1), - statusList(new QListWidget(this)) + d(new Private) { - QVBoxLayout* statusLayout = new QVBoxLayout(this); - - QLabel* infos = new QLabel(i18n("

Database shrinking in progress.

" - "

Currently, your databases are being shrunk. " - "This will take some time - depending on " - "your databases size.

" - "

We have to freeze digiKam in order to " - "prevent database corruption. This info box " - "will vanish when the shrinking process is " - "finished.

" - "Current Status:"), - this); + d->progressPix = DWorkingPixmap(); + d->progressTimer = new QTimer(parent); + d->statusList = new QListWidget(this); + + QVBoxLayout* const statusLayout = new QVBoxLayout(this); + + QLabel* const infos = new QLabel(i18n("

Database shrinking in progress.

" + "

Currently, your databases are being shrunk. " + "This will take some time - depending on " + "your databases size.

" + "

We have to freeze digiKam in order to " + "prevent database corruption. This info box " + "will vanish when the shrinking process is " + "finished.

" + "Current Status:"), + this); infos->setWordWrap(true); statusLayout->addWidget(infos); - statusList->addItem(i18n("Core DB")); - statusList->addItem(i18n("Thumbnails DB")); - statusList->addItem(i18n("Face Recognition DB")); - statusList->addItem(i18n("Similarity DB")); + d->statusList->addItem(i18n("Core DB")); + d->statusList->addItem(i18n("Thumbnails DB")); + d->statusList->addItem(i18n("Face Recognition DB")); + d->statusList->addItem(i18n("Similarity DB")); for (int i = 0 ; i < 4 ; ++i) { - statusList->item(i)->setIcon(QIcon::fromTheme(QLatin1String("system-run"))); + d->statusList->item(i)->setIcon(QIcon::fromTheme(QLatin1String("system-run"))); } -// statusList->setMinimumSize(0, 0); -// statusList->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); -// statusList->adjustSize(); - statusList->setMaximumHeight(4 * statusList->sizeHintForRow(0) - + 2 * statusList->frameWidth()); - statusLayout->addWidget(statusList); - - connect(progressTimer, SIGNAL(timeout()), +// d->statusList->setMinimumSize(0, 0); +// d->statusList->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); +// d->statusList->adjustSize(); + d->statusList->setMaximumHeight(4 * d->statusList->sizeHintForRow(0) + + 2 * d->statusList->frameWidth()); + statusLayout->addWidget(d->statusList); + + connect(d->progressTimer, SIGNAL(timeout()), this, SLOT(slotProgressTimerDone())); } DbShrinkDialog::~DbShrinkDialog() { - progressTimer->stop(); + d->progressTimer->stop(); + delete d; } void DbShrinkDialog::setActive(const int pos) { - active = pos; + d->active = pos; - if (progressTimer->isActive()) + if (d->progressTimer->isActive()) { - if (active < 0) + if (d->active < 0) { - progressTimer->stop(); + d->progressTimer->stop(); } } else { - if (active >= 0) + if (d->active >= 0) { - statusList->item(active)->setIcon(progressPix.frameAt(0)); - progressTimer->start(300); - progressIndex = 1; + d->statusList->item(d->active)->setIcon(d->progressPix.frameAt(0)); + d->progressTimer->start(300); + d->progressIndex = 1; } } } void DbShrinkDialog::setIcon(const int pos, const QIcon& icon) { - if (active == pos) + if (d->active == pos) { - active = -1; + d->active = -1; } - statusList->item(pos)->setIcon(icon); + d->statusList->item(pos)->setIcon(icon); } int DbShrinkDialog::exec() { - active = 0; - progressTimer->start(300); + d->active = 0; + d->progressTimer->start(300); + return QDialog::exec(); } void DbShrinkDialog::slotProgressTimerDone() { - if (active < 0) + if (d->active < 0) { return; } - if (progressIndex == progressPix.frameCount()) + if (d->progressIndex == d->progressPix.frameCount()) { - progressIndex = 0; + d->progressIndex = 0; } - statusList->item(active)->setIcon(progressPix.frameAt(progressIndex)); - ++progressIndex; + d->statusList->item(d->active)->setIcon(d->progressPix.frameAt(d->progressIndex)); + ++d->progressIndex; } } // namespace Digikam diff --git a/core/utilities/maintenance/duplicatesfinder.cpp b/core/utilities/maintenance/duplicatesfinder.cpp --- a/core/utilities/maintenance/duplicatesfinder.cpp +++ b/core/utilities/maintenance/duplicatesfinder.cpp @@ -52,8 +52,8 @@ { public: - explicit Private() : - minSimilarity(90), + explicit Private() + : minSimilarity(90), maxSimilarity(100), albumTagRelation(0), searchResultRestriction(0), @@ -73,7 +73,8 @@ SearchesDBJobsThread* job; }; -DuplicatesFinder::DuplicatesFinder(const QList& imageIds, int minSimilarity, int maxSimilarity, int searchResultRestriction, ProgressItem* const parent) +DuplicatesFinder::DuplicatesFinder(const QList& imageIds, int minSimilarity, int maxSimilarity, + int searchResultRestriction, ProgressItem* const parent) : MaintenanceTool(QLatin1String("DuplicatesFinder"), parent), d(new Private) { @@ -85,7 +86,8 @@ d->searchResultRestriction = searchResultRestriction; } -DuplicatesFinder::DuplicatesFinder(const AlbumList& albums, const AlbumList& tags, int albumTagRelation,int minSimilarity, int maxSimilarity, int searchResultRestriction, ProgressItem* const parent) +DuplicatesFinder::DuplicatesFinder(const AlbumList& albums, const AlbumList& tags, int albumTagRelation,int minSimilarity, + int maxSimilarity, int searchResultRestriction, ProgressItem* const parent) : MaintenanceTool(QLatin1String("DuplicatesFinder"), parent), d(new Private) { @@ -101,7 +103,8 @@ d->tagsIdList << a->id(); } -DuplicatesFinder::DuplicatesFinder(const int minSimilarity, int maxSimilarity, int searchResultRestriction, ProgressItem* const parent) +DuplicatesFinder::DuplicatesFinder(const int minSimilarity, int maxSimilarity, + int searchResultRestriction, ProgressItem* const parent) : MaintenanceTool(QLatin1String("DuplicatesFinder"), parent), d(new Private) { diff --git a/core/utilities/maintenance/maintenancedata.cpp b/core/utilities/maintenance/maintenancedata.cpp --- a/core/utilities/maintenance/maintenancedata.cpp +++ b/core/utilities/maintenance/maintenancedata.cpp @@ -49,7 +49,7 @@ QList identitiesList; QList similarityImageIdList; - QMutex lock; + QMutex mutex; }; MaintenanceData::MaintenanceData() @@ -94,85 +94,85 @@ qlonglong MaintenanceData::getImageId() const { - d->lock.lock(); + d->mutex.lock(); qlonglong id = -1; if (!d->imageIdList.isEmpty()) { id = d->imageIdList.takeFirst(); } - d->lock.unlock(); + d->mutex.unlock(); return id; } int MaintenanceData::getThumbnailId() const { - d->lock.lock(); + d->mutex.lock(); int id = -1; if (!d->thumbnailIdList.isEmpty()) { id = d->thumbnailIdList.takeFirst(); } - d->lock.unlock(); + d->mutex.unlock(); return id; } QString MaintenanceData::getImagePath() const { - d->lock.lock(); + d->mutex.lock(); QString path; if (!d->imagePathList.isEmpty()) { path = d->imagePathList.takeFirst(); } - d->lock.unlock(); + d->mutex.unlock(); return path; } ImageInfo MaintenanceData::getImageInfo() const { - d->lock.lock(); + d->mutex.lock(); ImageInfo info; if (!d->imageInfoList.isEmpty()) { info = d->imageInfoList.takeFirst(); } - d->lock.unlock(); + d->mutex.unlock(); return info; } Identity MaintenanceData::getIdentity() const { - d->lock.lock(); + d->mutex.lock(); Identity identity; if (!d->identitiesList.isEmpty()) { identity = d->identitiesList.takeFirst(); } - d->lock.unlock(); + d->mutex.unlock(); return identity; } qlonglong MaintenanceData::getSimilarityImageId() const { - d->lock.lock(); + d->mutex.lock(); qlonglong id = -1; if (!d->similarityImageIdList.isEmpty()) { id = d->similarityImageIdList.takeFirst(); } - d->lock.unlock(); + d->mutex.unlock(); return id; } diff --git a/core/utilities/mediaserver/dlnaserverdelegate.cpp b/core/utilities/mediaserver/dlnaserverdelegate.cpp --- a/core/utilities/mediaserver/dlnaserverdelegate.cpp +++ b/core/utilities/mediaserver/dlnaserverdelegate.cpp @@ -82,9 +82,8 @@ bool use_cache) : d(new Private) { - d->urlRoot = url_root; - d->filterUnknownOut = false; - d->useCache = use_cache; + d->urlRoot = url_root; + d->useCache = use_cache; } DLNAMediaServerDelegate::~DLNAMediaServerDelegate() @@ -121,9 +120,11 @@ NPT_CHECK_WARNING(ServeFile(request, context, response, NPT_FilePath::Create(d->fileRoot, file_path))); return NPT_SUCCESS; +// cppcheck-suppress unusedLabel failure: response.SetStatus(404, "File Not Found"); + return NPT_SUCCESS; } @@ -163,7 +164,9 @@ (NPT_String(filter).Find("ALLIP") != -1)); if (item.IsNull()) + { return NPT_FAILURE; + } NPT_String tmp; NPT_CHECK_SEVERE(PLT_Didl::ToDidl(*item.AsPointer(), filter, tmp)); @@ -284,7 +287,9 @@ // verify we want to process this file first if (!ProcessFile(filepath, filter)) + { continue; + } qCDebug(DIGIKAM_MEDIASRV_LOG) << "OnBrowseDirectChildren()" << ":: Process item" << filepath.GetChars(); @@ -375,7 +380,9 @@ } if (object->m_Title.GetLength() == 0) + { goto failure; + } // make sure we return something with a valid mimetype @@ -394,7 +401,9 @@ resource.m_ProtocolInfo = PLT_ProtocolInfo::GetProtocolInfo(filepath, true, &context); if (!resource.m_ProtocolInfo.IsValid()) + { goto failure; + } // format the resource URI @@ -445,7 +454,9 @@ // if we only want the one resource reachable by client if (!allip) + { break; + } } } else @@ -525,14 +536,17 @@ << filepath.GetChars() << "\""; delete object; + return NULL; } NPT_Result DLNAMediaServerDelegate::GetFilePath(const char* object_id, NPT_String& filepath) { if (!object_id) + { return NPT_ERROR_INVALID_PARAMETERS; + } filepath = "/"; // krazy:exclude=doublequote_chars @@ -543,9 +557,13 @@ int index = 0; if (object_id[0] == '0' && object_id[1] == '/') + { index = 2; + } else if (object_id[0] == '0') + { index = 1; + } filepath += (object_id + index); } @@ -621,12 +639,16 @@ NPT_HttpUrl uri = base_uri; if (host) + { uri.SetHost(host); + } NPT_String uri_path = uri.GetPath(); if (!uri_path.EndsWith("/")) + { uri_path += "/"; // krazy:exclude=doublequote_chars + } // some controllers (like WMP) will call us with an already urldecoded version. // We're intentionally prepending a known urlencoded string @@ -683,7 +705,9 @@ // remove our prepended string we used to detect urldecoded version if (file_path.StartsWith("%25/")) + { file_path.Erase(0, 4); + } // ok to urldecode diff --git a/core/utilities/mediaserver/dmediaserver.h b/core/utilities/mediaserver/dmediaserver.h --- a/core/utilities/mediaserver/dmediaserver.h +++ b/core/utilities/mediaserver/dmediaserver.h @@ -46,12 +46,14 @@ explicit DMediaServer(QObject* const parent = 0); virtual ~DMediaServer(); - /** Initialize the internal server instance and return true if all is ready to host contents. - * If port = 0, the server will select one automatically, else it will use the specified one. + /** + * Initialize the internal server instance and return true if all is ready to host contents. + * If port = 0, the server will select one automatically, else it will use the specified one. */ bool init(int port = 0); - /** To share a list of albums with dedicated urls list for each one. + /** + * To share a list of albums with dedicated urls list for each one. */ void addAlbumsOnServer(const MediaServerMap& map); diff --git a/core/utilities/mediaserver/dmediaserver.cpp b/core/utilities/mediaserver/dmediaserver.cpp --- a/core/utilities/mediaserver/dmediaserver.cpp +++ b/core/utilities/mediaserver/dmediaserver.cpp @@ -94,7 +94,7 @@ explicit Private() : upnp(0), logHandler(NULL), - serverHolder(new CDeviceHostReferenceHolder()) + serverHolder(NULL) { NPT_LogManager::GetDefault().Configure("plist:.level=INFO;.handlers=CustomHandler;"); NPT_LogHandler::Create("digiKam", "CustomHandler", logHandler); @@ -110,37 +110,11 @@ : QObject(parent), d(new Private) { - d->upnp = new PLT_UPnP(); + d->serverHolder = new CDeviceHostReferenceHolder(); + d->upnp = new PLT_UPnP(); d->upnp->Start(); } -bool DMediaServer::init(int port) -{ - QString devDesc = i18n("%1 Media Server", qApp->applicationName()); - - DLNAMediaServer* const device = new DLNAMediaServer( - devDesc.toUtf8().data(), - false, - NULL, - port); - - device->m_ModelName = "digiKam"; - device->m_ModelNumber = digikam_version; - device->m_ModelDescription = DAboutData::digiKamSlogan().toUtf8().data(); - device->m_ModelURL = DAboutData::webProjectUrl().toString().toUtf8().data(); - device->m_Manufacturer = "digiKam.org"; - device->m_ManufacturerURL = DAboutData::webProjectUrl().toString().toUtf8().data(); - device->SetDelegate(device); - - d->serverHolder->m_device = device; - - NPT_Result res = d->upnp->AddDevice(d->serverHolder->m_device); - - qCDebug(DIGIKAM_MEDIASRV_LOG) << "Upnp device created:" << res; - - return true; -} - DMediaServer::~DMediaServer() { d->upnp->Stop(); @@ -152,6 +126,32 @@ delete d; } +bool DMediaServer::init(int port) +{ + QString devDesc = i18n("%1 Media Server", qApp->applicationName()); + + DLNAMediaServer* const device = new DLNAMediaServer(devDesc.toUtf8().data(), + false, + NULL, + port); + + device->m_ModelName = "digiKam"; + device->m_ModelNumber = digikam_version; + device->m_ModelDescription = DAboutData::digiKamSlogan().toUtf8().data(); + device->m_ModelURL = DAboutData::webProjectUrl().toString().toUtf8().data(); + device->m_Manufacturer = "digiKam.org"; + device->m_ManufacturerURL = DAboutData::webProjectUrl().toString().toUtf8().data(); + device->SetDelegate(device); + + d->serverHolder->m_device = device; + + NPT_Result res = d->upnp->AddDevice(d->serverHolder->m_device); + + qCDebug(DIGIKAM_MEDIASRV_LOG) << "Upnp device created:" << res; + + return true; +} + void DMediaServer::addAlbumsOnServer(const MediaServerMap& map) { static_cast(d->serverHolder->m_device.AsPointer())->addAlbumsOnServer(map); diff --git a/core/utilities/queuemanager/manager/task.h b/core/utilities/queuemanager/manager/task.h --- a/core/utilities/queuemanager/manager/task.h +++ b/core/utilities/queuemanager/manager/task.h @@ -66,6 +66,7 @@ private: + void removeTempFiles(const QList& tmpList); void emitActionData(ActionData::ActionStatus st, const QString& mess=QString(), const QUrl& dest=QUrl()); diff --git a/core/utilities/queuemanager/manager/task.cpp b/core/utilities/queuemanager/manager/task.cpp --- a/core/utilities/queuemanager/manager/task.cpp +++ b/core/utilities/queuemanager/manager/task.cpp @@ -96,6 +96,20 @@ d->cancel = true; } +void Task::removeTempFiles(const QList& tmpList) +{ + foreach (const QUrl& url, tmpList) + { + QString tmpPath(url.toLocalFile()); + QFile::remove(tmpPath); + + tmpPath = DMetadata::sidecarPath(tmpPath); + + if (QFile::exists(tmpPath)) + QFile::remove(tmpPath); + } +} + void Task::emitActionData(ActionData::ActionStatus st, const QString& mess, const QUrl& dest) { ActionData ad; @@ -177,39 +191,29 @@ errMsg = d->tool->errorDescription(); tmp2del.append(outUrl); + delete d->tool; + d->tool = 0; + if (d->cancel) { emitActionData(ActionData::BatchCanceled); + removeTempFiles(tmp2del); emit signalDone(); - delete d->tool; - d->tool = 0; return; } else if (!success) { emitActionData(ActionData::BatchFailed, errMsg); break; } - - delete d->tool; - d->tool = 0; } // Clean up all tmp url. // We don't remove last output tmp url. tmp2del.removeAll(outUrl); - foreach (const QUrl& url, tmp2del) - { - QString tmpPath(url.toLocalFile()); - QFile::remove(tmpPath); - - tmpPath = DMetadata::sidecarPath(tmpPath); - - if (QFile::exists(tmpPath)) - QFile::remove(tmpPath); - } + removeTempFiles(tmp2del); // Move processed temp file to target diff --git a/project/bundles/macports/04-build-installer.sh b/project/bundles/macports/04-build-installer.sh --- a/project/bundles/macports/04-build-installer.sh +++ b/project/bundles/macports/04-build-installer.sh @@ -101,6 +101,7 @@ Applications/KF5/showfoto.app/Contents/MacOS/showfoto \ lib/plugins/imageformats/*.so \ lib/sane/*.so \ +lib/mariadb \ bin/kbuildsycoca5 \ libexec/qt5/plugins/imageformats/*.dylib \ libexec/qt5/plugins/sqldrivers/*.dylib \ diff --git a/project/reports/clangscan.sh b/project/reports/clangscan.sh --- a/project/reports/clangscan.sh +++ b/project/reports/clangscan.sh @@ -98,7 +98,7 @@ ORG_STR="class=\"Q\">$STAT_VAL<\/td>" STAT_VAL=$((STAT_VAL-1)) - if (( $STAT_VAL == 0 )); then + if (( $STAT_VAL == 0 )); then # if counter is zero, the line can be removed from HTML report. sed -i '/$ORG_STAT_LINE/d' $SCANBUILD_DIR/index.html else @@ -110,7 +110,7 @@ TOTAL_COUNT=$((TOTAL_COUNT+1)) done - # decrease total statistics with current TOTOAL_COUNT + # decrease total statistics with current TOTAL_COUNT TOTAL_ORG_STAT_LINE=$(grep "CopyCheckedStateToCheckButtons(this)" $SCANBUILD_DIR/index.html | grep "AllBugsCheck") TOTAL_STAT_VAL=$(echo $TOTAL_ORG_STAT_LINE | grep -o -P '(?<=class=\"Q\">).*(?=<\/td>)') diff --git a/project/reports/cppcheck.sh b/project/reports/cppcheck.sh --- a/project/reports/cppcheck.sh +++ b/project/reports/cppcheck.sh @@ -31,28 +31,34 @@ IGNORE_DIRS="" for DROP_ITEM in $KRAZY_FILTERS ; do - IGNORE_DIRS+="-i../../$DROP_ITEM/ " + IGNORE_DIRS+="-i../../$DROP_ITEM/ " done cppcheck -j$CPU_CORES \ + -DQ_OS_LINUX \ --verbose \ - --xml \ + --inline-suppr \ + --xml-version=2 \ --platform=unix64 \ --enable=all \ --report-progress \ --suppress=*:*CImg.h* \ --suppress=variableScope \ --suppress=purgedConfiguration \ --suppress=toomanyconfigs \ + --suppress=unreadVariable \ + --suppress=class_X_Y \ + --suppress=ConfigurationNotChecked \ + --suppress=unmatchedSuppression \ $IGNORE_DIRS \ ../../core \ 2> report.cppcheck.xml cppcheck-htmlreport --file=report.cppcheck.xml \ --report-dir=$REPORT_DIR \ --source-dir=. \ --title=$TITLE - +exit # update www.digikam.org report section. updateReportToWebsite "cppcheck" $REPORT_DIR $TITLE $(parseGitBranch)